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
98ffcca1
Commit
98ffcca1
authored
Apr 21, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
14cbd8b4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
159 additions
and
30 deletions
+159
-30
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
+139
-17
xgg-saas-merchant/app/base/controller/impl/uc/userCtl.js
+3
-3
xgg-saas-merchant/app/base/service/impl/saas/invoiceSve.js
+5
-0
xgg-saas-merchant/app/base/system.js
+9
-2
xgg-saas-merchant/app/config/settings.js
+3
-8
No files found.
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
View file @
98ffcca1
var
system
=
require
(
"../../../system"
)
const
system
=
require
(
"../../../system"
)
const
settings
=
require
(
"../../../../config/settings"
)
const
CtlBase
=
require
(
"../../ctlms.base"
);
const
CtlBase
=
require
(
"../../ctlms.base"
);
const
validation
=
system
.
getObject
(
"util.validation"
);
const
validation
=
system
.
getObject
(
"util.validation"
);
const
moment
=
require
(
"moment"
);
const
axios
=
require
(
"axios"
);
class
InvoiceCtl
extends
CtlBase
{
class
InvoiceCtl
extends
CtlBase
{
constructor
()
{
constructor
()
{
...
@@ -166,6 +169,111 @@ class InvoiceCtl extends CtlBase {
...
@@ -166,6 +169,111 @@ class InvoiceCtl extends CtlBase {
return
system
.
getResultSuccess
(
data
);
return
system
.
getResultSuccess
(
data
);
}
}
async
apply20
(
params
,
pobj2
,
req
)
{
try
{
// 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
,
"invoiceList"
,
{
name
:
"开票信息"
,
arr_require
:
true
});
let
title
=
await
this
.
merchantSve
.
title
(
params
)
||
{};
title
=
title
.
data
||
{};
if
(
!
title
.
merchant_name
||
!
title
.
merchant_credit_code
||
!
title
.
merchant_addr
||
!
title
.
merchant_mobile
||
!
title
.
merchant_bank
||
!
title
.
merchant_account
)
{
return
system
.
getResult
(
null
,
"开票抬头不完整,请联系平台"
);
}
let
addr
=
await
this
.
merchantSve
.
addr
(
params
)
||
{};
addr
=
addr
.
data
||
{};
if
(
!
addr
||
!
addr
.
mail_to
||
!
addr
.
mail_addr
||
!
addr
.
mail_mobile
)
{
return
system
.
getResult
(
null
,
"开票邮寄不完整"
);
}
let
info
=
await
this
.
merchantSve
.
signInfo
({
id
:
params
.
saas_merchant_id
})
||
{};
info
=
info
.
data
||
{};
// TODO WK
if
(
!
info
.
main_trade
)
{
return
system
.
getResult
(
null
,
"商户未设置转账交易主体,请联系平台进行设置、"
);
}
let
main
=
info
.
main_trade
;
let
invoiceList
=
params
.
invoiceList
;
let
creditCodes
=
[];
for
(
let
invoice
of
invoiceList
)
{
creditCodes
.
push
(
invoice
.
credit_code
);
}
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
,
saas_merchant_id
:
params
.
saas_merchant_id
});
for
(
let
invoice
of
invoiceList
)
{
validation
.
check
(
businessmenMap
,
invoice
.
credit_code
,
{
name
:
`个体户[
${
invoice
.
credit_code
}
]`
,
is_require
:
true
});
}
let
applyList
=
[];
let
batch_no
=
await
this
.
redisClient
.
genrateId
(
"invoice_batch_no"
);
for
(
let
invoice
of
invoiceList
)
{
let
bussinessmen
=
businessmenMap
[
invoice
.
credit_code
];
let
apply_no
=
await
this
.
redisClient
.
genrateId
(
"invoice_apply_no"
);
let
data
=
{
saas_id
:
params
.
saas_id
,
saas_merchant_id
:
params
.
saas_merchant_id
,
parent_id
:
""
,
owner_type
:
"00"
,
status
:
"1000"
,
batch_no
:
batch_no
,
apply_no
:
apply_no
,
fee_type
:
params
.
fee_type
,
invoice_amount
:
system
.
y2f
(
invoice
.
invoice_amount
),
invoice_type
:
this
.
trim
(
params
.
invoice_type
),
from_name
:
bussinessmen
.
name
,
from_credit_code
:
bussinessmen
.
credit_code
,
from_mobile
:
bussinessmen
.
legal_mobile
,
from_addr
:
bussinessmen
.
business_place
,
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
),
mail_addr
:
this
.
trim
(
addr
.
mail_addr
),
mail_mobile
:
this
.
trim
(
addr
.
mail_mobile
),
mail_to
:
this
.
trim
(
addr
.
mail_to
),
personal_invoice_tax
:
system
.
y2f
(
invoice
.
personal_invoice_tax
),
additional_tax
:
system
.
y2f
(
invoice
.
additional_tax
),
service_tax
:
system
.
y2f
(
invoice
.
service_tax
),
value_added_tax
:
system
.
y2f
(
invoice
.
value_added_tax
),
unit
:
this
.
trim
(
invoice
.
unit
),
quantity
:
this
.
trim
(
invoice
.
quantity
),
price
:
this
.
trim
(
invoice
.
price
),
remark
:
this
.
trim
(
invoice
.
remark
),
};
applyList
.
push
(
data
);
}
let
rs
=
await
this
.
invoiceSve
.
applyBulkSave
({
fee_type
:
params
.
fee_type
,
dataList
:
applyList
,
parent_id
:
""
,
updateStatus
:
{
id
:
apply
.
id
,
preStatus
:
"1040"
,
status
:
"1060"
,
}
});
return
system
.
getResultSuccess
(
rs
);
}
catch
(
error
)
{
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
// 功能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
});
...
@@ -277,16 +385,15 @@ class InvoiceCtl extends CtlBase {
...
@@ -277,16 +385,15 @@ class InvoiceCtl extends CtlBase {
// 功能1 确定个体户开票
// 功能1 确定个体户开票
async
confirmInvoice
(
params
,
pobj2
,
req
)
{
async
confirmInvoice
(
params
,
pobj2
,
req
)
{
let
invoice_type
=
params
.
invoice_type
;
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
try
{
try
{
return
await
this
.
invoiceSve
.
invoiceOrder
(
params
);
let
invoiceData
=
await
this
.
buildTradeInvoice
(
params
);
return
invoiceData
;
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误`
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
}
}
...
@@ -298,6 +405,7 @@ class InvoiceCtl extends CtlBase {
...
@@ -298,6 +405,7 @@ class InvoiceCtl extends CtlBase {
let
items
=
await
this
.
tradeSve
.
byIds
({
let
items
=
await
this
.
tradeSve
.
byIds
({
ids
:
params
.
data_ids
,
ids
:
params
.
data_ids
,
saas_merchant_id
:
params
.
saas_merchant_id
,
saas_merchant_id
:
params
.
saas_merchant_id
,
order_type
:
params
.
fee_type
,
trade_statuses
:
[
'00'
],
trade_statuses
:
[
'00'
],
unInvoice
:
true
,
unInvoice
:
true
,
})
||
[];
})
||
[];
...
@@ -305,6 +413,19 @@ class InvoiceCtl extends CtlBase {
...
@@ -305,6 +413,19 @@ class InvoiceCtl extends CtlBase {
if
(
!
items
||
items
.
length
==
0
)
{
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
)
{
return
system
.
getResult
(
null
,
"商户签约信息不存在,请先做签约配置"
);
}
// TODO WK 改成开票签约主体
let
main
=
signInfo
.
data
.
main_trade
;
if
(
!
main
)
{
return
system
.
getResult
(
null
,
"开票签约主体未设置,请联系平台配置"
);
}
let
invoice_service_rate
=
signInfo
.
data
.
invoice_service_rate
||
0
;
let
bmMap
=
{};
let
bmMap
=
{};
let
creditCodes
=
[];
let
creditCodes
=
[];
for
(
let
item
of
items
)
{
for
(
let
item
of
items
)
{
...
@@ -314,8 +435,7 @@ class InvoiceCtl extends CtlBase {
...
@@ -314,8 +435,7 @@ class InvoiceCtl extends CtlBase {
bmMap
[
creditCode
]
=
list
;
bmMap
[
creditCode
]
=
list
;
creditCodes
.
push
(
creditCode
);
creditCodes
.
push
(
creditCode
);
}
}
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
});
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
,
saas_merchant_id
:
params
.
saas_merchant_id
});
businessmenMap
=
businessmenMap
.
data
;
let
invoiceList
=
[];
let
invoiceList
=
[];
let
calcParams
=
[];
let
calcParams
=
[];
...
@@ -327,6 +447,7 @@ class InvoiceCtl extends CtlBase {
...
@@ -327,6 +447,7 @@ class InvoiceCtl extends CtlBase {
for
(
let
item
of
itemList
)
{
for
(
let
item
of
itemList
)
{
amount
=
amount
+
Number
(
item
.
amt
||
0
);
amount
=
amount
+
Number
(
item
.
amt
||
0
);
}
}
let
service_tax
=
parseFloat
((
Number
(
amount
)
*
Number
(
invoice_service_rate
)
/
100
).
toFixed
(
2
));
calcParams
.
push
({
calcParams
.
push
({
"credit_code"
:
creditCode
,
"credit_code"
:
creditCode
,
"invoiced_time"
:
moment
().
format
(
"YYYY-MM-DD hh:mm:ss"
),
"invoiced_time"
:
moment
().
format
(
"YYYY-MM-DD hh:mm:ss"
),
...
@@ -340,10 +461,10 @@ class InvoiceCtl extends CtlBase {
...
@@ -340,10 +461,10 @@ class InvoiceCtl extends CtlBase {
"credit_code"
:
creditCode
,
"credit_code"
:
creditCode
,
"is_bank"
:
businessmen
.
isBank
,
"is_bank"
:
businessmen
.
isBank
,
"is_bank_name"
:
businessmen
.
isBank
?
"已开户"
:
"未开户"
,
"is_bank_name"
:
businessmen
.
isBank
?
"已开户"
:
"未开户"
,
"invoice_amount"
:
system
.
y2f
(
amount
),
"invoice_amount"
:
system
.
f2y
(
amount
),
"personal_invoice_tax"
:
0
,
"personal_invoice_tax"
:
0
,
"additional_tax"
:
0
,
"additional_tax"
:
0
,
"service_tax"
:
0
,
"service_tax"
:
system
.
f2y
(
service_tax
)
,
"value_added_tax"
:
0
,
"value_added_tax"
:
0
,
"unit"
:
""
,
"unit"
:
""
,
"quantity"
:
""
,
"quantity"
:
""
,
...
@@ -366,8 +487,8 @@ class InvoiceCtl extends CtlBase {
...
@@ -366,8 +487,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
;
...
@@ -389,11 +510,11 @@ class InvoiceCtl extends CtlBase {
...
@@ -389,11 +510,11 @@ class InvoiceCtl extends CtlBase {
additional_tax_total
=
additional_tax_total
+
Number
(
invoiceCalc
.
additional_tax
);
additional_tax_total
=
additional_tax_total
+
Number
(
invoiceCalc
.
additional_tax
);
personal_invoice_tax_total
=
personal_invoice_tax_total
+
Number
(
invoiceCalc
.
personal_invoice_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
);
value_added_tax_total
=
value_added_tax_total
+
Number
(
invoiceCalc
.
value_added_tax
);
service_tax_total
=
service_tax_total
+
Number
(
invoiceCalc
.
service_amount
);
service_tax_total
=
service_tax_total
+
Number
(
invoice
.
service_tax
);
invoice
.
personal_invoice_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
personal_invoice_tax
));
invoice
.
personal_invoice_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
personal_invoice_tax
));
invoice
.
additional_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
additional_tax
));
invoice
.
additional_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
additional_tax
));
invoice
.
service_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
service_amount
));
invoice
.
value_added_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
value_added_tax
));
invoice
.
value_added_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
value_added_tax
));
}
}
...
@@ -404,11 +525,12 @@ class InvoiceCtl extends CtlBase {
...
@@ -404,11 +525,12 @@ class InvoiceCtl extends CtlBase {
value_added_tax_total
:
system
.
toFloat
(
value_added_tax_total
),
value_added_tax_total
:
system
.
toFloat
(
value_added_tax_total
),
service_tax_total
:
system
.
toFloat
(
service_tax_total
),
service_tax_total
:
system
.
toFloat
(
service_tax_total
),
},
},
main
:
main
,
invoiceList
:
invoiceList
invoiceList
:
invoiceList
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
}
}
}
}
...
...
xgg-saas-merchant/app/base/controller/impl/uc/userCtl.js
View file @
98ffcca1
...
@@ -43,9 +43,9 @@ class UserCtl extends CtlBase {
...
@@ -43,9 +43,9 @@ class UserCtl extends CtlBase {
async
setLogin
(
user
)
{
async
setLogin
(
user
)
{
let
loginsid
=
"saasmcth_"
+
uuidv4
();
let
loginsid
=
"saasmcth_"
+
uuidv4
();
if
(
settings
.
env
=
"dev"
)
{
//
if (settings.env = "dev") {
loginsid
=
"saasmcth_"
+
"2cb49932-fa02-44f0-90db-9f06fe02e5c7"
;
//
loginsid = "saasmcth_" + "2cb49932-fa02-44f0-90db-9f06fe02e5c7";
}
//
}
await
this
.
redisClient
.
setWithEx
(
loginsid
,
JSON
.
stringify
(
user
),
60
*
60
*
5
);
await
this
.
redisClient
.
setWithEx
(
loginsid
,
JSON
.
stringify
(
user
),
60
*
60
*
5
);
return
loginsid
;
return
loginsid
;
}
}
...
...
xgg-saas-merchant/app/base/service/impl/saas/invoiceSve.js
View file @
98ffcca1
...
@@ -31,6 +31,11 @@ class InvoiceService extends ServiceBase {
...
@@ -31,6 +31,11 @@ class InvoiceService extends ServiceBase {
return
rs
;
return
rs
;
}
}
async
applyBulkSave
(
params
)
{
let
rs
=
await
this
.
callms
(
"invoice"
,
"invoiceapplyBulkSave"
,
params
);
return
rs
;
}
transOrderField
(
rows
)
{
transOrderField
(
rows
)
{
if
(
!
rows
||
rows
.
length
==
0
)
{
if
(
!
rows
||
rows
.
length
==
0
)
{
return
;
return
;
...
...
xgg-saas-merchant/app/base/system.js
View file @
98ffcca1
...
@@ -121,6 +121,13 @@ class System {
...
@@ -121,6 +121,13 @@ class System {
}
}
return
(
Number
(
y
)
*
100
).
toFixed
(
0
);
return
(
Number
(
y
)
*
100
).
toFixed
(
0
);
}
}
static
toFloat
(
f
,
digits
)
{
digits
=
digits
||
2
;
if
(
!
f
)
{
return
0
;
}
return
parseFloat
((
Number
(
f
)).
toFixed
(
digits
));
}
static
f2y
(
f
)
{
static
f2y
(
f
)
{
if
(
!
f
)
{
if
(
!
f
)
{
...
@@ -187,10 +194,10 @@ class System {
...
@@ -187,10 +194,10 @@ class System {
merchant
:
dev
+
":3101"
+
path
,
merchant
:
dev
+
":3101"
+
path
,
// 订单服务
// 订单服务
order
:
local
+
":3103"
+
path
,
order
:
dev
+
":3103"
+
path
,
// 发票服务
// 发票服务
invoice
:
local
+
":3105"
+
path
,
invoice
:
dev
+
":3105"
+
path
,
// 用户服务
// 用户服务
uc
:
dev
+
":3106"
+
path
,
uc
:
dev
+
":3106"
+
path
,
...
...
xgg-saas-merchant/app/config/settings.js
View file @
98ffcca1
...
@@ -128,18 +128,13 @@ var settings = {
...
@@ -128,18 +128,13 @@ var settings = {
deliverSysApi
:
function
()
{
deliverSysApi
:
function
()
{
let
domain
=
""
;
let
domain
=
""
;
if
(
this
.
env
==
"dev"
)
{
if
(
this
.
env
==
"dev"
)
{
// domain = "http://39.107.234.14:3002";
domain
=
"http://39.107.234.14:3002"
;
domain
=
"http://127.0.0.1:3002"
;
}
else
{
}
else
{
domain
=
"https://xggadmin.gongsibao.com"
;
domain
=
"https://xggadmin.gongsibao.com"
;
}
}
return
{
return
{
// 推送订单s
//发票是试算
orderPushApi
:
domain
+
"/web/order/orderCtl/addSourceOrder"
,
calcInvoice
:
domain
+
"/web/invoice/invoiceCtl/calcInvoice"
,
// 获取个体工商户信息
info
:
domain
+
"/web/business/businessmenCtl/info"
,
//获取工商户列表
businessmenPage
:
"/web/business/businessmenCtl/businessmenPage"
,
}
}
},
},
redis
:
function
()
{
redis
:
function
()
{
...
...
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