Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
9bd9ef2b
Commit
9bd9ef2b
authored
Apr 22, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
991b6dca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
27 deletions
+47
-27
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
+46
-26
xgg-saas-merchant/app/base/system.js
+1
-1
No files found.
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
View file @
9bd9ef2b
...
@@ -70,6 +70,7 @@ class InvoiceCtl extends CtlBase {
...
@@ -70,6 +70,7 @@ class InvoiceCtl extends CtlBase {
// 发票申请
// 发票申请
async
apply
(
params
,
pobj2
,
req
)
{
async
apply
(
params
,
pobj2
,
req
)
{
try
{
try
{
validation
.
check
(
params
,
"fee_type"
,
{
name
:
"费用记录类型"
,
is_require
:
true
,
dics
:
[
'00'
,
"10"
,
"20"
]});
let
fee_type
=
this
.
trim
(
params
.
fee_type
);
let
fee_type
=
this
.
trim
(
params
.
fee_type
);
if
(
fee_type
==
"00"
)
{
if
(
fee_type
==
"00"
)
{
return
await
this
.
apply00
(
params
,
pobj2
,
req
);
return
await
this
.
apply00
(
params
,
pobj2
,
req
);
...
@@ -153,6 +154,7 @@ class InvoiceCtl extends CtlBase {
...
@@ -153,6 +154,7 @@ class InvoiceCtl extends CtlBase {
mail_addr
:
this
.
trim
(
addr
.
mail_addr
),
mail_addr
:
this
.
trim
(
addr
.
mail_addr
),
mail_mobile
:
this
.
trim
(
addr
.
mail_mobile
),
mail_mobile
:
this
.
trim
(
addr
.
mail_mobile
),
mail_to
:
this
.
trim
(
addr
.
mail_to
),
mail_to
:
this
.
trim
(
addr
.
mail_to
),
data_ids
:
params
.
data_ids
.
join
(
","
),
};
};
data
=
await
this
.
invoiceSve
.
applySave
(
data
);
data
=
await
this
.
invoiceSve
.
applySave
(
data
);
...
@@ -171,11 +173,9 @@ class InvoiceCtl extends CtlBase {
...
@@ -171,11 +173,9 @@ class InvoiceCtl extends CtlBase {
// 功能3开票
// 功能3开票
async
apply20
(
params
,
pobj2
,
req
)
{
async
apply20
(
params
,
pobj2
,
req
)
{
try
{
try
{
// TODO 方法未测试
// TODO 方法未测试
validation
.
check
(
params
,
"fee_type"
,
{
name
:
"费用记录类型"
,
is_require
:
true
,
dics
:
[
'00'
,
"10"
,
"20"
]});
validation
.
check
(
params
,
"invoice_type"
,
{
name
:
"发票类型"
,
is_require
:
true
,
dics
:
[
'00'
,
"10"
,
"20"
]});
validation
.
check
(
params
,
"invoice_type"
,
{
name
:
"发票类型"
,
is_require
:
true
,
dics
:
[
'00'
,
"10"
,
"20"
]});
validation
.
check
(
params
,
"invoiceList"
,
{
name
:
"开票信息"
,
arr_require
:
true
});
validation
.
check
(
params
,
"invoiceList"
,
{
name
:
"开票信息"
,
arr_require
:
true
});
...
@@ -205,7 +205,10 @@ class InvoiceCtl extends CtlBase {
...
@@ -205,7 +205,10 @@ class InvoiceCtl extends CtlBase {
for
(
let
invoice
of
invoiceList
)
{
for
(
let
invoice
of
invoiceList
)
{
creditCodes
.
push
(
invoice
.
credit_code
);
creditCodes
.
push
(
invoice
.
credit_code
);
}
}
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
,
saas_merchant_id
:
params
.
saas_merchant_id
});
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
,
saas_merchant_id
:
params
.
saas_merchant_id
});
for
(
let
invoice
of
invoiceList
)
{
for
(
let
invoice
of
invoiceList
)
{
validation
.
check
(
businessmenMap
,
invoice
.
credit_code
,
{
name
:
`个体户[
${
invoice
.
credit_code
}
]`
,
is_require
:
true
});
validation
.
check
(
businessmenMap
,
invoice
.
credit_code
,
{
name
:
`个体户[
${
invoice
.
credit_code
}
]`
,
is_require
:
true
});
...
@@ -214,13 +217,17 @@ class InvoiceCtl extends CtlBase {
...
@@ -214,13 +217,17 @@ class InvoiceCtl extends CtlBase {
let
applyList
=
[];
let
applyList
=
[];
let
batch_no
=
await
this
.
redisClient
.
genrateId
(
"invoice_batch_no"
);
let
batch_no
=
await
this
.
redisClient
.
genrateId
(
"invoice_batch_no"
);
for
(
let
invoice
of
invoiceList
)
{
for
(
let
invoice
of
invoiceList
)
{
if
(
!
invoice
.
data_ids
)
{
return
system
.
getResult
(
null
,
"数据错误,请刷新重试"
);
}
let
bussinessmen
=
businessmenMap
[
invoice
.
credit_code
];
let
bussinessmen
=
businessmenMap
[
invoice
.
credit_code
];
let
apply_no
=
await
this
.
redisClient
.
genrateId
(
"invoice_apply_no"
);
let
apply_no
=
await
this
.
redisClient
.
genrateId
(
"invoice_apply_no"
);
let
data
=
{
let
data
=
{
saas_id
:
params
.
saas_id
,
saas_id
:
params
.
saas_id
,
saas_merchant_id
:
params
.
saas_merchant_id
,
saas_merchant_id
:
params
.
saas_merchant_id
,
parent_id
:
""
,
parent_id
:
""
,
owner_type
:
"00"
,
owner_type
:
"00"
,
status
:
"1000"
,
status
:
"1000"
,
batch_no
:
batch_no
,
batch_no
:
batch_no
,
apply_no
:
apply_no
,
apply_no
:
apply_no
,
...
@@ -254,19 +261,25 @@ class InvoiceCtl extends CtlBase {
...
@@ -254,19 +261,25 @@ class InvoiceCtl extends CtlBase {
quantity
:
this
.
trim
(
invoice
.
quantity
),
quantity
:
this
.
trim
(
invoice
.
quantity
),
price
:
this
.
trim
(
invoice
.
price
),
price
:
this
.
trim
(
invoice
.
price
),
remark
:
this
.
trim
(
invoice
.
remark
),
remark
:
this
.
trim
(
invoice
.
remark
),
data_ids
:
invoice
.
data_ids
,
};
};
applyList
.
push
(
data
);
applyList
.
push
(
data
);
}
}
let
rs
=
await
this
.
invoiceSve
.
applyBulkSave
({
let
rs
=
await
this
.
invoiceSve
.
applyBulkSave
({
fee_type
:
params
.
fee_type
,
fee_type
:
params
.
fee_type
,
dataList
:
applyList
,
dataList
:
applyList
,
parent_id
:
""
,
parent_id
:
""
updateStatus
:
{
id
:
apply
.
id
,
preStatus
:
"1040"
,
status
:
"1060"
,
}
});
});
if
(
rs
&&
rs
.
data
&&
rs
.
data
.
length
>
0
)
{
for
(
let
d
of
rs
.
data
)
{
console
.
log
(
d
.
id
,
d
.
data_ids
);
if
(
!
d
.
data_ids
)
{
continue
;
}
let
tradeIds
=
d
.
data_ids
.
split
(
","
);
await
this
.
tradeSve
.
updateInvoice
({
ids
:
tradeIds
,
saas_invoice_id
:
d
.
id
});
}
}
return
system
.
getResultSuccess
(
rs
);
return
system
.
getResultSuccess
(
rs
);
}
catch
(
error
)
{
}
catch
(
error
)
{
let
msg
=
error
.
message
;
let
msg
=
error
.
message
;
...
@@ -279,12 +292,12 @@ class InvoiceCtl extends CtlBase {
...
@@ -279,12 +292,12 @@ class InvoiceCtl extends CtlBase {
// 功能1开票
// 功能1开票
async
apply00
(
params
,
pobj2
,
req
)
{
async
apply00
(
params
,
pobj2
,
req
)
{
validation
.
check
(
params
,
'data_ids'
,
{
name
:
"
提示
信息"
,
arr_require
:
true
});
validation
.
check
(
params
,
'data_ids'
,
{
name
:
"
订单
信息"
,
arr_require
:
true
});
let
title
=
await
this
.
merchantSve
.
title
(
params
)
||
{};
let
title
=
await
this
.
merchantSve
.
title
(
params
)
||
{};
title
=
title
.
data
||
{};
title
=
title
.
data
||
{};
if
(
!
title
.
merchant_name
||
!
title
.
merchant_credit_code
||
!
title
.
merchant_addr
if
(
!
title
.
merchant_name
||
!
title
.
merchant_credit_code
||
!
title
.
merchant_addr
||
!
title
.
merchant_mobile
||
!
title
.
merchant_bank
||
!
title
.
merchant_account
)
{
||
!
title
.
merchant_mobile
||
!
title
.
merchant_bank
||
!
title
.
merchant_account
)
{
return
system
.
getResult
(
null
,
"开票抬头不完整,请联系平台"
);
return
system
.
getResult
(
null
,
"开票抬头不完整,请联系平台"
);
}
}
...
@@ -295,17 +308,17 @@ class InvoiceCtl extends CtlBase {
...
@@ -295,17 +308,17 @@ class InvoiceCtl extends CtlBase {
}
}
let
orders
=
await
this
.
orderSve
.
byIds
({
let
orders
=
await
this
.
orderSve
.
byIds
({
ids
:
params
.
data_ids
,
ids
:
params
.
data_ids
,
saas_merchant_id
:
params
.
saas_merchant_id
,
saas_merchant_id
:
params
.
saas_merchant_id
,
attrs
:
"id,price"
,
attrs
:
"id,price"
,
handle_status
:
[
'20'
,
'30'
],
handle_status
:
[
'20'
,
'30'
],
unInvoice
:
true
,
unInvoice
:
true
,
})
||
[];
})
||
[];
if
(
orders
.
data
.
length
!=
params
.
data_ids
.
length
)
{
if
(
orders
.
data
.
length
!=
params
.
data_ids
.
length
)
{
return
system
.
getResult
(
null
,
"订单数据选择有误,请重新搜索后选择"
);
return
system
.
getResult
(
null
,
"订单数据选择有误,请重新搜索后选择"
);
}
}
let
invoice_amount
=
0
;
let
invoice_amount
=
0
;
for
(
let
item
of
orders
.
data
)
{
for
(
let
item
of
orders
.
data
)
{
invoice_amount
=
invoice_amount
+
Number
(
item
.
price
||
0
);
invoice_amount
=
invoice_amount
+
Number
(
item
.
price
||
0
);
}
}
...
@@ -348,9 +361,9 @@ class InvoiceCtl extends CtlBase {
...
@@ -348,9 +361,9 @@ class InvoiceCtl extends CtlBase {
mail_mobile
:
this
.
trim
(
addr
.
mail_mobile
),
mail_mobile
:
this
.
trim
(
addr
.
mail_mobile
),
mail_to
:
this
.
trim
(
addr
.
mail_to
),
mail_to
:
this
.
trim
(
addr
.
mail_to
),
invoice_amount
:
invoice_amount
,
invoice_amount
:
invoice_amount
,
service_tax
:
service_tax
,
service_tax
:
service_tax
,
data_ids
:
params
.
data_ids
.
join
(
","
),
};
};
data
=
await
this
.
invoiceSve
.
applySave
(
data
);
data
=
await
this
.
invoiceSve
.
applySave
(
data
);
...
@@ -366,6 +379,7 @@ class InvoiceCtl extends CtlBase {
...
@@ -366,6 +379,7 @@ class InvoiceCtl extends CtlBase {
console
.
log
(
data
);
console
.
log
(
data
);
return
system
.
getResultSuccess
(
data
);
return
system
.
getResultSuccess
(
data
);
}
}
//发票申请列表
//发票申请列表
async
merchantinvoiceapplyPage
(
params
,
pobj2
,
req
)
{
async
merchantinvoiceapplyPage
(
params
,
pobj2
,
req
)
{
try
{
try
{
...
@@ -448,7 +462,10 @@ class InvoiceCtl extends CtlBase {
...
@@ -448,7 +462,10 @@ class InvoiceCtl extends CtlBase {
bmMap
[
creditCode
]
=
list
;
bmMap
[
creditCode
]
=
list
;
creditCodes
.
push
(
creditCode
);
creditCodes
.
push
(
creditCode
);
}
}
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
,
saas_merchant_id
:
params
.
saas_merchant_id
});
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
,
saas_merchant_id
:
params
.
saas_merchant_id
});
let
invoiceList
=
[];
let
invoiceList
=
[];
let
calcParams
=
[];
let
calcParams
=
[];
...
@@ -457,8 +474,10 @@ class InvoiceCtl extends CtlBase {
...
@@ -457,8 +474,10 @@ class InvoiceCtl extends CtlBase {
let
businessmen
=
businessmenMap
[
creditCode
];
let
businessmen
=
businessmenMap
[
creditCode
];
let
itemList
=
bmMap
[
creditCode
];
let
itemList
=
bmMap
[
creditCode
];
let
amount
=
0
;
let
amount
=
0
;
let
data_ids
=
[];
for
(
let
item
of
itemList
)
{
for
(
let
item
of
itemList
)
{
amount
=
amount
+
Number
(
item
.
amt
||
0
);
amount
=
amount
+
Number
(
item
.
amt
||
0
);
data_ids
.
push
(
item
.
id
);
}
}
let
service_tax
=
parseFloat
((
Number
(
amount
)
*
Number
(
invoice_service_rate
)
/
100
).
toFixed
(
2
));
let
service_tax
=
parseFloat
((
Number
(
amount
)
*
Number
(
invoice_service_rate
)
/
100
).
toFixed
(
2
));
calcParams
.
push
({
calcParams
.
push
({
...
@@ -482,7 +501,8 @@ class InvoiceCtl extends CtlBase {
...
@@ -482,7 +501,8 @@ class InvoiceCtl extends CtlBase {
"unit"
:
""
,
"unit"
:
""
,
"quantity"
:
""
,
"quantity"
:
""
,
"price"
:
""
,
"price"
:
""
,
"remark"
:
""
"remark"
:
""
,
"data_ids"
:
data_ids
.
join
(
","
),
});
});
}
}
...
@@ -500,8 +520,8 @@ class InvoiceCtl extends CtlBase {
...
@@ -500,8 +520,8 @@ class InvoiceCtl extends CtlBase {
url
:
url
,
url
:
url
,
data
:
calcParams
data
:
calcParams
});
});
if
(
!
res
||
!
res
.
data
||
res
.
data
.
status
!=
0
||
res
.
data
.
data
.
length
==
0
)
{
if
(
!
res
||
!
res
.
data
||
res
.
data
.
status
!=
0
||
res
.
data
.
data
.
length
==
0
)
{
return
system
.
getResult
(
null
,
`试算错误`
);
return
system
.
getResult
(
null
,
`试算错误`
);
}
}
let
calcList
=
res
.
data
.
data
;
let
calcList
=
res
.
data
.
data
;
...
@@ -543,7 +563,7 @@ class InvoiceCtl extends CtlBase {
...
@@ -543,7 +563,7 @@ class InvoiceCtl extends CtlBase {
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
}
}
}
}
...
...
xgg-saas-merchant/app/base/system.js
View file @
9bd9ef2b
...
@@ -197,7 +197,7 @@ class System {
...
@@ -197,7 +197,7 @@ class System {
order
:
dev
+
":3103"
+
path
,
order
:
dev
+
":3103"
+
path
,
// 发票服务
// 发票服务
invoice
:
dev
+
":3105"
+
path
,
invoice
:
local
+
":3105"
+
path
,
// 用户服务
// 用户服务
uc
:
dev
+
":3106"
+
path
,
uc
:
dev
+
":3106"
+
path
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment