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
af823eb9
Commit
af823eb9
authored
Apr 22, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
f1de0ed6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
232 additions
and
56 deletions
+232
-56
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
+96
-45
xgg-saas-merchant/app/base/service/impl/trade/tradeSve.js
+18
-7
xgg-saas-merchant/app/base/system.js
+1
-1
xgg-saas-merchant/app/front/entry/public/apidoc/saas/invoice.md
+117
-3
No files found.
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
View file @
af823eb9
...
...
@@ -174,8 +174,8 @@ class InvoiceCtl extends CtlBase {
// 功能1开票(商户交易 也是线下交易)
async
apply20
(
params
,
pobj2
,
req
)
{
try
{
// TODO 方法未测试
validation
.
check
(
params
,
"invoice_type"
,
{
name
:
"发票类型"
,
is_require
:
true
,
dics
:
[
'00'
,
"10"
,
"20"
]});
validation
.
check
(
params
,
"pay_voucher"
,
{
name
:
"支付凭证"
,
is_require
:
true
});
validation
.
check
(
params
,
"invoiceList"
,
{
name
:
"开票信息"
,
arr_require
:
true
});
let
title
=
await
this
.
merchantSve
.
title
(
params
)
||
{};
...
...
@@ -214,10 +214,11 @@ class InvoiceCtl extends CtlBase {
}
let
applyList
=
[];
let
pay_amount
=
0
;
let
batch_no
=
await
this
.
redisClient
.
genrateId
(
"invoice_batch_no"
);
for
(
let
invoice
of
invoiceList
)
{
if
(
!
invoice
.
data_ids
)
{
return
system
.
getResult
(
null
,
"数据
错误
,请刷新重试"
);
return
system
.
getResult
(
null
,
"数据
异常
,请刷新重试"
);
}
let
bussinessmen
=
businessmenMap
[
invoice
.
credit_code
];
...
...
@@ -241,12 +242,12 @@ class InvoiceCtl extends CtlBase {
from_bank
:
bussinessmen
.
bank_name
,
from_account
:
bussinessmen
.
bank_no
,
to_name
:
this
.
trim
(
main
.
from_
name
),
to_credit_code
:
this
.
trim
(
main
.
from_
credit_code
),
to_mobile
:
this
.
trim
(
main
.
from_
mobile
),
to_addr
:
this
.
trim
(
main
.
from_
addr
),
to_bank
:
this
.
trim
(
main
.
from_bank
),
to_account
:
this
.
trim
(
main
.
from_account
),
to_name
:
this
.
trim
(
main
.
name
),
to_credit_code
:
this
.
trim
(
main
.
credit_code
),
to_mobile
:
this
.
trim
(
main
.
mobile
),
to_addr
:
this
.
trim
(
main
.
addr
),
to_bank
:
this
.
trim
(
main
.
bank_name
),
to_account
:
this
.
trim
(
main
.
bank_no
),
mail_addr
:
this
.
trim
(
addr
.
mail_addr
),
mail_mobile
:
this
.
trim
(
addr
.
mail_mobile
),
...
...
@@ -260,16 +261,56 @@ class InvoiceCtl extends CtlBase {
quantity
:
this
.
trim
(
invoice
.
quantity
),
price
:
this
.
trim
(
invoice
.
price
),
remark
:
this
.
trim
(
invoice
.
remark
),
pay_voucher
:
this
.
trim
(
params
.
pay_voucher
),
data_ids
:
invoice
.
data_ids
,
};
pay_amount
=
pay_amount
+
Number
(
data
.
personal_invoice_tax
||
0
)
+
Number
(
data
.
additional_tax
||
0
)
+
Number
(
data
.
value_added_tax
||
0
)
+
Number
(
data
.
service_tax
||
0
);
applyList
.
push
(
data
);
}
let
signInfo
=
await
this
.
merchantSve
.
signInfo
({
id
:
params
.
saas_merchant_id
});
if
(
!
signInfo
||
!
signInfo
.
data
)
{
return
system
.
getResult
(
null
,
"商户签约信息不存在,请先做签约配置"
);
}
let
accountInfo
=
JSON
.
stringify
({
name
:
this
.
trim
(
main
.
name
),
credit_code
:
this
.
trim
(
main
.
credit_code
),
bank_account
:
this
.
trim
(
main
.
bank_account
),
bank_name
:
this
.
trim
(
main
.
bank_name
),
bank_no
:
this
.
trim
(
main
.
bank_no
),
addr
:
this
.
trim
(
main
.
addr
),
mobile
:
this
.
trim
(
main
.
mobile
)
});
// 支付信息
let
pay
=
await
this
.
tradeSve
.
saveStPay
({
saas_id
:
params
.
saas_id
,
saas_merchant_id
:
params
.
saas_merchant_id
,
pay_voucher_img
:
params
.
pay_voucher
,
trade_no
:
batch_no
,
busi_name
:
"saas_invoice_apply.batch_no"
,
busi_id
:
batch_no
,
amount
:
pay_amount
,
pay_type
:
"1"
,
pay_status
:
"10"
,
account_info
:
accountInfo
,
});
// 判断支付是否插入
if
(
!
pay
||
pay
.
status
!=
0
||
!
pay
.
data
)
{
return
system
.
getResult
(
null
,
""
);
}
let
rs
=
await
this
.
invoiceSve
.
applyBulkSave
({
fee_type
:
params
.
fee_type
,
dataList
:
applyList
,
parent_id
:
""
});
if
(
rs
&&
rs
.
data
&&
rs
.
data
.
length
>
0
)
{
// 更改支付状态
await
this
.
tradeSve
.
updatePayStatus
({
id
:
pay
.
data
.
id
,
pay_status
:
"20"
,
});
for
(
let
d
of
rs
.
data
)
{
console
.
log
(
d
.
id
,
d
.
data_ids
);
if
(
!
d
.
data_ids
)
{
...
...
@@ -437,7 +478,7 @@ class InvoiceCtl extends CtlBase {
})
||
[];
items
=
items
.
data
;
if
(
!
items
||
items
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"
注册订单
信息有误,请刷新重新选择"
);
return
system
.
getResult
(
null
,
"
交易
信息有误,请刷新重新选择"
);
}
let
signInfo
=
await
this
.
merchantSve
.
signInfo
({
id
:
params
.
saas_merchant_id
});
if
(
!
signInfo
||
!
signInfo
.
data
)
{
...
...
@@ -479,24 +520,26 @@ class InvoiceCtl extends CtlBase {
data_ids
.
push
(
item
.
id
);
}
let
service_tax
=
parseFloat
((
Number
(
amount
)
*
Number
(
invoice_service_rate
)
/
100
).
toFixed
(
2
));
calcParams
.
push
({
"credit_code"
:
creditCode
,
"invoiced_time"
:
moment
().
format
(
"YYYY-MM-DD hh:mm:ss"
),
"invoice_type"
:
invoice_type
,
"invoice_amount"
:
amount
});
if
(
!
businessmen
.
is_bank
)
{
calcParams
.
push
({
"credit_code"
:
creditCode
,
"invoiced_time"
:
moment
().
format
(
"YYYY-MM-DD hh:mm:ss"
),
"invoice_type"
:
invoice_type
,
"invoice_amount"
:
amount
});
}
// TODO 总统计算 end
invoiceList
.
push
({
"name"
:
businessmen
.
name
,
"credit_code"
:
creditCode
,
"is_bank"
:
businessmen
.
is
Bank
,
"is_bank_name"
:
businessmen
.
is
B
ank
?
"已开户"
:
"未开户"
,
"is_bank"
:
businessmen
.
is
_bank
?
1
:
0
,
"is_bank_name"
:
businessmen
.
is
_b
ank
?
"已开户"
:
"未开户"
,
"invoice_amount"
:
system
.
f2y
(
amount
),
"personal_invoice_tax"
:
0
,
"additional_tax"
:
0
,
"service_tax"
:
system
.
f2y
(
service_tax
),
"value_added_tax"
:
0
,
"service_tax"
:
system
.
f2y
(
service_tax
),
"unit"
:
""
,
"quantity"
:
""
,
"price"
:
""
,
...
...
@@ -509,45 +552,52 @@ class InvoiceCtl extends CtlBase {
let
personal_invoice_tax_total
=
0
;
let
value_added_tax_total
=
0
;
let
service_tax_total
=
0
;
let
pay_total
=
0
;
// TODO 总统计算 begin
// 计算税金
try
{
let
url
=
settings
.
deliverSysApi
().
calcInvoice
;
let
res
=
await
axios
({
method
:
'post'
,
url
:
url
,
data
:
calcParams
});
if
(
!
res
||
!
res
.
data
||
res
.
data
.
status
!=
0
||
res
.
data
.
data
.
length
==
0
)
{
return
system
.
getResult
(
null
,
`试算错误`
);
}
let
calcList
=
res
.
data
.
data
;
let
calcMap
=
{};
let
errors
=
[];
for
(
let
c
of
calcList
)
{
calcMap
[
c
.
credit_code
]
=
c
;
if
(
c
.
error
)
{
errors
.
push
(
`
${
c
.
msg
}
【
${
c
.
credit_code
}
】`
);
if
(
calcParams
.
length
>
0
)
{
let
url
=
settings
.
deliverSysApi
().
calcInvoice
;
let
res
=
await
axios
({
method
:
'post'
,
url
:
url
,
data
:
calcParams
});
if
(
!
res
||
!
res
.
data
||
res
.
data
.
status
!=
0
||
res
.
data
.
data
.
length
==
0
)
{
return
system
.
getResult
(
null
,
`试算错误`
);
}
}
if
(
errors
.
length
>
0
)
{
return
system
.
getResult
(
null
,
errors
.
join
(
"、"
));
let
calcList
=
res
.
data
.
data
;
let
errors
=
[];
for
(
let
c
of
calcList
)
{
calcMap
[
c
.
credit_code
]
=
c
;
if
(
c
.
error
)
{
errors
.
push
(
`
${
c
.
msg
}
【
${
c
.
credit_code
}
】`
);
}
}
if
(
errors
.
length
>
0
)
{
return
system
.
getResult
(
null
,
errors
.
join
(
"、"
));
}
}
for
(
let
invoice
of
invoiceList
)
{
let
invoiceCalc
=
calcMap
[
invoice
.
credit_code
];
additional_tax_total
=
additional_tax_total
+
Number
(
invoiceCalc
.
additional_tax
);
personal_invoice_tax_total
=
personal_invoice_tax_total
+
Number
(
invoiceCalc
.
personal_invoice_tax
);
value_added_tax_total
=
value_added_tax_total
+
Number
(
invoiceCalc
.
value_added_tax
);
let
businessmen
=
businessmenMap
[
invoice
.
credit_code
];
if
(
!
businessmen
.
is_bank
)
{
let
invoiceCalc
=
calcMap
[
invoice
.
credit_code
];
additional_tax_total
=
additional_tax_total
+
Number
(
invoiceCalc
.
additional_tax
);
personal_invoice_tax_total
=
personal_invoice_tax_total
+
Number
(
invoiceCalc
.
personal_invoice_tax
);
value_added_tax_total
=
value_added_tax_total
+
Number
(
invoiceCalc
.
value_added_tax
);
invoice
.
personal_invoice_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
personal_invoice_tax
));
invoice
.
additional_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
additional_tax
));
invoice
.
value_added_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
value_added_tax
));
}
pay_total
=
pay_total
+
system
.
toFloat
(
Number
(
invoice
.
personal_invoice_tax
||
0
)
+
Number
(
invoice
.
additional_tax
||
0
)
+
Number
(
invoice
.
value_added_tax
||
0
)
+
Number
(
invoice
.
service_tax
||
0
));
service_tax_total
=
service_tax_total
+
Number
(
invoice
.
service_tax
);
invoice
.
personal_invoice_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
personal_invoice_tax
));
invoice
.
additional_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
additional_tax
));
invoice
.
value_added_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
value_added_tax
));
}
return
system
.
getResultSuccess
({
...
...
@@ -556,6 +606,7 @@ class InvoiceCtl extends CtlBase {
personal_invoice_tax_total
:
system
.
toFloat
(
personal_invoice_tax_total
),
value_added_tax_total
:
system
.
toFloat
(
value_added_tax_total
),
service_tax_total
:
system
.
toFloat
(
service_tax_total
),
pay_total
:
system
.
toFloat
(
pay_total
),
},
main
:
main
,
invoiceList
:
invoiceList
...
...
xgg-saas-merchant/app/base/service/impl/trade/tradeSve.js
View file @
af823eb9
...
...
@@ -17,7 +17,7 @@ class TradeService extends ServiceBase {
params
.
currentPage
=
Number
(
params
.
currentPage
||
1
);
params
.
pageSize
=
Number
(
params
.
pageSize
||
10
);
let
rs
=
await
this
.
callms
(
"trade"
,
"orderPage"
,
params
)
||
{};
if
(
rs
.
data
&&
rs
.
data
.
rows
)
{
if
(
rs
.
data
&&
rs
.
data
.
rows
)
{
this
.
transFields
(
rs
.
data
.
rows
);
}
return
rs
;
...
...
@@ -26,7 +26,7 @@ class TradeService extends ServiceBase {
async
orderInfo
(
params
)
{
let
rs
=
await
this
.
callms
(
"trade"
,
"orderInfo"
,
params
)
||
{};
let
order
=
rs
.
data
;
if
(
order
)
{
if
(
order
)
{
this
.
transFields
([
order
]);
let
merchant
=
await
this
.
merchantSve
.
info
({
id
:
params
.
saas_merchant_id
})
||
{};
merchant
=
merchant
.
data
||
{};
...
...
@@ -39,7 +39,7 @@ class TradeService extends ServiceBase {
params
.
currentPage
=
Number
(
params
.
currentPage
||
1
);
params
.
pageSize
=
Number
(
params
.
pageSize
||
10
);
let
rs
=
await
this
.
callms
(
"trade"
,
"itemPage"
,
params
)
||
{};
if
(
rs
.
data
&&
rs
.
data
.
rows
)
{
if
(
rs
.
data
&&
rs
.
data
.
rows
)
{
this
.
transFields
(
rs
.
data
.
rows
);
}
return
rs
;
...
...
@@ -146,7 +146,7 @@ class TradeService extends ServiceBase {
// 获取商户签约信息
let
info
=
await
this
.
merchantSve
.
signInfo
({
id
:
params
.
saas_merchant_id
})
||
{};
info
=
info
.
data
||
{};
if
(
!
info
.
main_trade
||
!
info
.
main_trade
.
id
)
{
if
(
!
info
.
main_trade
||
!
info
.
main_trade
.
id
)
{
return
system
.
getResult
(
null
,
"签约时未设置转账交易签约主体,请联系平台进行设置"
);
}
...
...
@@ -164,7 +164,7 @@ class TradeService extends ServiceBase {
result
.
error
=
error
;
if
(
result
.
error
)
{
// 处理错误信息
for
(
let
idx
=
0
;
idx
<
itemList
.
length
;
idx
++
)
{
for
(
let
idx
=
0
;
idx
<
itemList
.
length
;
idx
++
)
{
let
item
=
itemList
[
idx
];
if
(
item
.
errors
&&
item
.
errors
.
length
>
0
)
{
let
len
=
Number
(
idx
)
+
7
;
...
...
@@ -309,6 +309,16 @@ class TradeService extends ServiceBase {
return
rs
;
}
async
saveStPay
(
params
)
{
let
rs
=
await
this
.
callms
(
"trade"
,
"saveStPay"
,
params
);
return
rs
;
}
async
updatePayStatus
(
params
)
{
let
rs
=
await
this
.
callms
(
"trade"
,
"updateStatus"
,
params
);
return
rs
;
}
checkField
(
data
,
field
,
rule
)
{
if
(
!
data
||
!
field
)
{
return
;
...
...
@@ -333,11 +343,11 @@ class TradeService extends ServiceBase {
}
transFields
(
rows
)
{
if
(
!
rows
||
rows
.
length
==
0
)
{
if
(
!
rows
||
rows
.
length
==
0
)
{
return
;
}
for
(
let
row
of
rows
)
{
for
(
let
row
of
rows
)
{
row
.
amt
=
system
.
f2y
(
row
.
amt
);
row
.
actual_amt
=
system
.
f2y
(
row
.
actual_amt
);
row
.
deduct_amt
=
system
.
f2y
(
row
.
deduct_amt
);
...
...
@@ -345,6 +355,7 @@ class TradeService extends ServiceBase {
row
.
service_rate
=
system
.
f2y
(
row
.
service_rate
);
}
}
async
invoiceTrade
(
params
)
{
let
rs
=
await
this
.
callms
(
"trade"
,
"invoiceTrade"
,
params
)
||
{};
return
rs
;
...
...
xgg-saas-merchant/app/base/system.js
View file @
af823eb9
...
...
@@ -197,7 +197,7 @@ class System {
order
:
dev
+
":3103"
+
path
,
// 发票服务
invoice
:
local
+
":3105"
+
path
,
invoice
:
dev
+
":3105"
+
path
,
// 用户服务
uc
:
dev
+
":3106"
+
path
,
...
...
xgg-saas-merchant/app/front/entry/public/apidoc/saas/invoice.md
View file @
af823eb9
...
...
@@ -8,6 +8,8 @@
1.
[
发票申请列表
](
#merchantinvoiceapplyPage
)
1.
[
发票列表
](
#invoicePage
)
1.
[
平台查询发票详情
](
#invoiceOrder
)
1.
[
发票申请-功能1-确定个体户开票
](
#confirmInvoice
)
1.
[
发票申请-功能1-提交申请
](
#apply1
)
## **<a name="feeTypeDic"> 费用记录类型</a>**
...
...
@@ -166,7 +168,6 @@ fee_type == "00"
##### URL
[
/web/saas/merchantCtl/addr
]
<a
href=
"/doc/saas/merchant.md#saveAddr"
>
【 去接口详情 】
</a>
## **<a name="apply2"> 发票申请-功能2</a>**
[
返回到目录
](
#menu
)
##### URL
...
...
@@ -511,4 +512,118 @@ fee_type == "00"
},
"bizmsg"
:
"empty"
}
```
\ No newline at end of file
```
## **<a name="confirmInvoice"> 发票申请-功能1-确定个体户开票</a>**
[
返回到目录
](
#menu
)
##### URL
[
/web/saas/invoiceCtl/confirmInvoice
]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
```
javascript
{
"fee_type"
:
"10"
,
// 费用类型 00注册订单费用 10平台转账费用 20商户转账费用
"invoice_type"
:
"10"
,
// 发票类型 10 增值税专用发票 20 增值税普通发票 30 普通发票
"data_ids"
:
[
// 所选交易列表
"1"
,
"2"
],
}
```
#### 返回结果
```
javascript
{
"status"
:
0
,
"msg"
:
"success"
,
"data"
:
{
// 金额总计,第三页显示
"tax"
:
{
"additional_tax_total"
:
1294.37
,
// 附加税
"personal_invoice_tax_total"
:
733.92
,
// 个税
"value_added_tax_total"
:
10786.46
,
// 增值税
"service_tax_total"
:
1561.48
,
// 服务费
"pay_total"
:
14376.23
// 总付款金额(付款信息处使用)
},
// 付款账户信息
"main"
:
{
"bank_account"
:
"bank_account"
,
// 账户名称
"bank_name"
:
"bank_name"
,
// 开户行
"bank_no"
:
"bank_no"
,
// 银行卡号
},
// 第二页使用,确定个体户开票信息
"invoiceList"
:
[
{
"name"
:
"name4"
,
// 个体户名称
"credit_code"
:
"ZJFMC1231231231231"
,
// 统一社会信用代码
"is_bank"
:
1
,
"is_bank_name"
:
"已开户"
,
// 开户状态
"invoice_amount"
:
17436.58
,
// 开票金额
"personal_invoice_tax"
:
0
,
// 个税
"additional_tax"
:
0
,
// 附加税
"value_added_tax"
:
0
,
// 增值税
"service_tax"
:
174.37
,
// 服务费
"unit"
:
""
,
// 单位
"quantity"
:
""
,
// 数量
"price"
:
""
,
// 单价
"remark"
:
""
,
// 备注
"data_ids"
:
"1001579,1001582"
// 不用管,但是后面要带着这个
},
]
}
}
```
1.
[
发票申请-功能1-提交申请
](
#apply1
)
## **<a name="#apply1"> 发票申请-功能2</a>**
[
返回到目录
](
#menu
)
##### URL
[
/web/saas/invoiceCtl/apply
]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
```
javascript
{
"fee_type"
:
"10"
,
// 费用类型 00注册订单费用 10平台转账费用 20商户转账费用
"invoice_type"
:
"10"
,
// 发票类型 10 增值税专用发票 20 增值税普通发票 30 普通发票
"pay_voucher"
:
"https//1112321"
,
// 付款凭证 第三页上传的
// 发票信息,确定个体户开票结果中的invoiceList,其中unit, quantity, price, remark跟随页面联动
"invoiceList"
:
[
{
"name"
:
"name4"
,
"credit_code"
:
"ZJFMC1231231231231"
,
"is_bank_name"
:
"未开户"
,
"invoice_amount"
:
17436.58
,
"service_tax"
:
174.37
,
"personal_invoice_tax"
:
0
,
"additional_tax"
:
0
,
"value_added_tax"
:
0
,
"unit"
:
"11"
,
"quantity"
:
"12"
,
"price"
:
"13"
,
"remark"
:
"14"
,
"data_ids"
:
"1001579,1001582"
},
]
}
```
#### 返回结果
```
javascript
{
"status"
:
0
,
"msg"
:
"success"
,
"data"
:
null
,
"requestid"
:
"00521a0a0f094c8d982bf4375fbe91b1"
}
```
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