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
004c016a
Commit
004c016a
authored
Aug 27, 2020
by
王勇飞
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tx-fi-tax' of gitlab.gongsibao.com:jiangyong/zhichan into tx-fi-tax
parents
0fa5190b
d7ea23a4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
330 additions
and
376 deletions
+330
-376
tx-fi-tax/app/base/api/impl/common/apps.js
+2
-2
tx-fi-tax/app/base/controller/impl/bizchance/deliverybillCtl.js
+94
-65
tx-fi-tax/app/base/db/impl/bizchance/deliverybillDao.js
+41
-120
tx-fi-tax/app/base/db/models/delivery/delivery_bill.js
+10
-2
tx-fi-tax/app/base/service/impl/bizchance/deliverybillSve.js
+56
-178
tx-fi-tax/app/base/system.js
+4
-9
tx-fi-tax/app/base/utils/toFtClient.js
+108
-0
tx-fi-tax/app/config/settings.js
+15
-0
No files found.
tx-fi-tax/app/base/api/impl/common/apps.js
View file @
004c016a
...
@@ -7,8 +7,8 @@ class AppAPI extends APIBase {
...
@@ -7,8 +7,8 @@ class AppAPI extends APIBase {
this
.
appS
=
system
.
getObject
(
"service.common.appSve"
);
this
.
appS
=
system
.
getObject
(
"service.common.appSve"
);
}
}
async
create
(
pobj
,
q
,
req
){
async
create
(
pobj
,
q
,
req
){
//
console.log("oooooooooooooooooooooooooooooooooooooooooooooooo")
console
.
log
(
"oooooooooooooooooooooooooooooooooooooooooooooooo"
)
//
console.log(req.xctx)
console
.
log
(
req
.
xctx
)
let
rtn
=
this
.
appS
.
create
(
pobj
,
q
,
req
);
let
rtn
=
this
.
appS
.
create
(
pobj
,
q
,
req
);
return
system
.
getResult
(
rtn
);
return
system
.
getResult
(
rtn
);
}
}
...
...
tx-fi-tax/app/base/controller/impl/bizchance/deliverybillCtl.js
View file @
004c016a
...
@@ -145,10 +145,10 @@ class DeliverybillCtl extends CtlBase {
...
@@ -145,10 +145,10 @@ class DeliverybillCtl extends CtlBase {
}
}
// 创建融易算服务实例
// 创建融易算服务实例
async
insertInfo
(
obj
,
qobj
,
req
)
{
async
insertInfo
(
m
obj
,
qobj
,
req
)
{
console
.
log
(
"GGGGGGG----------------------------------------------"
+
JSON
.
stringify
(
obj
)
);
console
.
log
(
'mobj--------------------------------'
,
mobj
);
try
{
try
{
var
pobj
=
obj
.
actionBody
.
message
Body
;
var
pobj
=
mobj
.
action
Body
;
var
cachestr
=
sha235
(
JSON
.
stringify
(
pobj
));
var
cachestr
=
sha235
(
JSON
.
stringify
(
pobj
));
var
cacheInfo
=
await
this
.
cacheManager
[
"TxCache"
].
getCache
(
cachestr
);
var
cacheInfo
=
await
this
.
cacheManager
[
"TxCache"
].
getCache
(
cachestr
);
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
...
@@ -158,31 +158,39 @@ class DeliverybillCtl extends CtlBase {
...
@@ -158,31 +158,39 @@ class DeliverybillCtl extends CtlBase {
"data"
:
""
,
"data"
:
""
,
"requestId"
:
""
"requestId"
:
""
}
}
}
}
else
{
else
{
pobj
.
orderId
=
pobj
.
orderId
+
"_book"
;
var
obj
=
{};
pobj
.
contactsPhone
=
pobj
.
contactsMobile
;
obj
.
delivery_code
=
pobj
.
orderId
+
"_book"
;
pobj
.
product_code
=
"bookkeeping"
;
obj
.
source_number
=
"tx"
;
pobj
.
product_name
=
"代帐服务"
;
if
(
pobj
.
solutionBizId
)
{
pobj
.
delivery_status
=
"received"
;
obj
.
scheme_number
=
pobj
.
solutionBizId
;
pobj
.
facilitator_id
=
"10"
;
var
scheme
=
await
this
.
fitaxschemeService
.
findInfoByBizid
({
"bizId"
:
pobj
.
solutionBizId
});
pobj
.
facilitator_name
=
"公司宝"
;
if
(
scheme
)
{
pobj
.
source_number
=
"tx"
;
pobj
.
demand_code
=
scheme
.
demand_code
;
pobj
.
source_name
=
"tencentCloud"
;
}
pobj
.
taxpayerName
=
pobj
.
taxpayerType
;
}
if
(
pobj
.
taxpayerType
==
1
){
obj
.
product_code
=
"bookkeeping"
;
obj
.
product_name
=
"代帐服务"
;
obj
.
service_address
=
pobj
.
area
;
obj
.
delivery_status
=
"received"
;
obj
.
facilitator_id
=
"10"
;
obj
.
facilitator_name
=
"公司宝"
;
obj
.
source_name
=
"tencentCloud"
;
pobj
.
contactsPhone
=
pobj
.
contactMobile
;
delete
pobj
.
contactMobile
;
if
(
pobj
.
taxpayerType
==
1
)
{
pobj
.
taxpayerType
=
"generalTaxpayer"
;
pobj
.
taxpayerType
=
"generalTaxpayer"
;
pobj
.
taxpayerName
=
"一般纳税人"
;
}
}
else
if
(
pobj
.
taxpayerType
==
2
)
{
else
if
(
pobj
.
taxpayerType
==
2
)
{
pobj
.
taxpayerType
=
"smallScaleTaxpayer"
;
pobj
.
taxpayerType
=
"smallScaleTaxpayer"
;
pobj
.
taxpayerName
=
"小规模纳税人"
;
}
}
if
(
pobj
.
solutionBizId
){
obj
.
delivery_info
=
pobj
;
var
scheme
=
await
this
.
fitaxschemeService
.
findInfoByBizid
({
"bizId"
:
pobj
.
solutionBizId
});
obj
.
biz_id
=
pobj
.
bizId
;
if
(
scheme
){
var
buInfo
=
await
this
.
service
.
insertInfo
(
obj
);
pobj
.
demand_code
=
scheme
.
demand_code
;
}
}
var
buInfo
=
await
this
.
service
.
insertInfo
(
pobj
);
if
(
buInfo
)
{
if
(
buInfo
)
{
await
this
.
cacheManager
[
"TxCache"
].
cache
(
cachestr
,
JSON
.
stringify
({
cachestr
:
cachestr
}),
180
);
//插入redis缓存
await
this
.
cacheManager
[
"TxCache"
].
cache
(
cachestr
,
JSON
.
stringify
({
cachestr
:
cachestr
}),
180
);
//插入redis缓存
return
{
return
{
...
@@ -191,7 +199,7 @@ class DeliverybillCtl extends CtlBase {
...
@@ -191,7 +199,7 @@ class DeliverybillCtl extends CtlBase {
"data"
:
buInfo
,
"data"
:
buInfo
,
"requestId"
:
""
"requestId"
:
""
}
}
}
}
else
{
else
{
return
system
.
getResultFail
(
buInfo
);
return
system
.
getResultFail
(
buInfo
);
}
}
...
@@ -203,12 +211,11 @@ class DeliverybillCtl extends CtlBase {
...
@@ -203,12 +211,11 @@ class DeliverybillCtl extends CtlBase {
}
}
//更新融易算服务实例
//更新融易算服务实例
async
updateServer
(
obj
,
qobj
,
req
)
{
async
updateServer
(
m
obj
,
qobj
,
req
)
{
try
{
try
{
var
pobj
=
obj
.
actionBody
.
message
Body
;
var
pobj
=
mobj
.
action
Body
;
var
cachestr
=
sha235
(
JSON
.
stringify
(
pobj
));
var
cachestr
=
sha235
(
JSON
.
stringify
(
pobj
));
var
cacheInfo
=
await
this
.
cacheManager
[
"TxCache"
].
getCache
(
cachestr
);
var
cacheInfo
=
await
this
.
cacheManager
[
"TxCache"
].
getCache
(
cachestr
);
var
cacheInfo
;
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
return
{
return
{
"status"
:
1
,
//1代表成功,否则失败
"status"
:
1
,
//1代表成功,否则失败
...
@@ -217,31 +224,31 @@ class DeliverybillCtl extends CtlBase {
...
@@ -217,31 +224,31 @@ class DeliverybillCtl extends CtlBase {
"requestId"
:
""
"requestId"
:
""
}
}
}
else
{
}
else
{
if
(
!
pobj
.
requestId
||
pobj
.
requestId
==
'undefined'
)
{
if
(
pobj
.
contactMobile
&&
pobj
.
contactMobile
!=
'undefined'
)
{
throw
new
Error
(
"requestId 不能为空"
);
pobj
.
contactsPhone
=
pobj
.
contactMobile
;
}
delete
pobj
.
contactMobile
;
if
(
!
pobj
.
bizId
||
pobj
.
bizId
==
'undefined'
)
{
throw
new
Error
(
"bizId 不能为空"
);
}
if
(
!
pobj
.
orderId
||
pobj
.
orderId
==
'undefined'
)
{
throw
new
Error
(
"orderId 不能为空"
);
}
if
(
!
pobj
.
topOrgCode
||
pobj
.
topOrgCode
==
'undefined'
)
{
throw
new
Error
(
"topOrgCode 不能为空"
);
}
}
if
(
!
pobj
.
companyName
||
pobj
.
companyName
==
'undefined'
)
{
pobj
.
contactsName
=
pobj
.
contactName
;
throw
new
Error
(
"companyName 不能为空"
);
delete
pobj
.
contactName
;
}
pobj
.
companyType
=
pobj
.
companyBizType
;
if
(
!
pobj
.
contactName
||
pobj
.
contactName
==
'undefined'
)
{
delete
pobj
.
companyBizType
;
throw
new
Error
(
"contactName 不能为空"
);
pobj
.
creditCode
=
pobj
.
uscc
;
}
delete
pobj
.
uscc
;
if
(
!
pobj
.
companyBizType
||
pobj
.
companyBizType
==
'undefined'
)
{
if
(
pobj
.
taxpayerType
==
1
)
{
throw
new
Error
(
"companyBizType 不能为空"
);
pobj
.
taxpayerType
=
"generalTaxpayer"
;
pobj
.
taxpayerName
=
"一般纳税人"
;
}
}
if
(
!
pobj
.
uscc
||
pobj
.
uscc
==
'undefined'
)
{
else
if
(
pobj
.
taxpayerType
==
2
)
{
throw
new
Error
(
"uscc 不能为空"
);
pobj
.
taxpayerType
=
"smallScaleTaxpayer"
;
pobj
.
taxpayerName
=
"小规模纳税人"
;
}
}
const
rs
=
await
this
.
service
.
updateServer
(
pobj
);
obj
=
{
"delivery_code"
:
pobj
.
orderId
+
"_book"
,
"delivery_info"
:
pobj
,
"biz_id"
:
pobj
.
bizId
};
const
rs
=
await
this
.
service
.
updateServer
(
obj
);
if
(
rs
)
{
if
(
rs
)
{
await
this
.
cacheManager
[
"TxCache"
].
cache
(
cachestr
,
JSON
.
stringify
({
cachestr
:
cachestr
}),
180
);
//插入redis缓存
await
this
.
cacheManager
[
"TxCache"
].
cache
(
cachestr
,
JSON
.
stringify
({
cachestr
:
cachestr
}),
180
);
//插入redis缓存
return
{
return
{
...
@@ -273,10 +280,37 @@ class DeliverybillCtl extends CtlBase {
...
@@ -273,10 +280,37 @@ class DeliverybillCtl extends CtlBase {
return
system
.
getResult
(
null
,
err
.
message
)
return
system
.
getResult
(
null
,
err
.
message
)
}
}
}
}
async
portog
(){
console
.
log
(
settings
.
port
);
}
}
}
module
.
exports
=
DeliverybillCtl
;
module
.
exports
=
DeliverybillCtl
;
// var task = new DeliverybillCtl();
var
task
=
new
DeliverybillCtl
();
var
obj
=
{
"actionType"
:
"produceData"
,
"actionBody"
:
{
"pushUrl"
:
"http://ic.com:8000/web/bizchance/deliverybillCtl"
,
"actionType"
:
"insertInfo"
,
"identifyCode"
:
"book-manage"
,
"messageBody"
:
{
"requestId"
:
"825da0a74432-738f-4bed-468d-d51aa880"
,
"bizId"
:
"2292748809"
,
"userId"
:
"24173452443103825"
,
"orderId"
:
"235184456620496"
,
"areatype"
:
"city"
,
"area"
:
"100010"
,
"topOrgCode"
:
"rong_yi_suan"
,
"taxpayerType"
:
1
,
"contactMobile"
:
"18510669321"
}
}
}
task
.
portog
().
then
(
d
=>
{
console
.
log
(
JSON
.
stringify
(
d
));
})
// var obj = {
// var obj = {
// "actionType": "produceData",
// "actionType": "produceData",
// "actionBody": {
// "actionBody": {
...
@@ -284,23 +318,18 @@ module.exports = DeliverybillCtl;
...
@@ -284,23 +318,18 @@ module.exports = DeliverybillCtl;
// "actionType": "insertInfo",
// "actionType": "insertInfo",
// "identifyCode": "book-manage",
// "identifyCode": "book-manage",
// "messageBody": {
// "messageBody": {
// "requestId": "825da0a74432-738f-4bed-b48d-d51aa808",
// "requestId": "825da0a74432-738f-4bed-468d-d51aa880",
// "bizId": "5892748825",
// "bizId": "2292748809",
// "contactsPhone": "18510669321",
// "orderId": "235184456620496",
// "userId": "10973452443103825",
// "companyName": "北京融易算",
// "orderId": "341184456620496_book",
// "contactName": "JAMES7",
// "areatype": "city",
// "taxpayerType": 5,
// "area": "100010",
// "contactMobile": "18510669367",
// "topOrgCode": "rong_yi_suan",
// "companyBizType": 1,
// "taxpayerType": 1,
// "uscc": "911101053516460817K"
// "product_code": "bookkeeping",
// "product_name": "代账服务",
// "service_address": "110100",
// "delivery_status": "waituserconfirm",
// "facilitator_id": "10"
// }
// }
// }
// }
// }
// }
// task.
insertInfo
(obj, {}, {}).then(d => {
// task.
updateServer
(obj, {}, {}).then(d => {
// console.log(JSON.stringify(d));
// console.log(JSON.stringify(d));
// })
// })
tx-fi-tax/app/base/db/impl/bizchance/deliverybillDao.js
View file @
004c016a
...
@@ -40,7 +40,7 @@ class DeliverybillDao extends Dao {
...
@@ -40,7 +40,7 @@ class DeliverybillDao extends Dao {
})
})
// 根据 页面 过滤 交付状态
// 根据 页面 过滤 交付状态
switch
(
qobj
.
bizpath
)
{
switch
(
qobj
.
bizpath
)
{
case
"/
configManageMent
/deliveryRecord"
:
// 交付单记录
case
"/
deliveryManage
/deliveryRecord"
:
// 交付单记录
filters
.
push
({
filters
.
push
({
delivery_status
:
{
delivery_status
:
{
$in
:
[
$in
:
[
...
@@ -49,7 +49,7 @@ class DeliverybillDao extends Dao {
...
@@ -49,7 +49,7 @@ class DeliverybillDao extends Dao {
}
}
});
});
break
break
case
"/
configManageMent/deliveryManage
"
:
//交付单处理
case
"/
deliveryManage/deliveryDealWith
"
:
//交付单处理
filters
.
push
({
filters
.
push
({
delivery_status
:
{
delivery_status
:
{
$in
:
[
$in
:
[
...
@@ -90,139 +90,60 @@ class DeliverybillDao extends Dao {
...
@@ -90,139 +90,60 @@ class DeliverybillDao extends Dao {
delete
qc
.
where
.
deliveryNumber
;
delete
qc
.
where
.
deliveryNumber
;
}
}
if
(
qc
.
where
.
deliveryStatus
)
{
filters
.
push
({
delivery_status
:
qc
.
where
.
deliveryStatus
});
delete
qc
.
where
.
deliveryStatus
;
}
if
(
qc
.
where
.
setupStatus
)
{
if
(
qobj
&&
qobj
.
search
&&
qobj
.
search
.
setupStatus
&&
qobj
.
search
.
setupStatus
===
system
.
SERVERSESTATUS
.
SETUP
)
{
filters
.
push
({
v_setup_status
:
qc
.
where
.
setupStatus
});
}
else
{
filters
.
push
({
$or
:
[
{
v_setup_status
:
qc
.
where
.
setupStatus
},
{
v_setup_status
:
{
$eq
:
null
}
}
]
});
}
delete
qc
.
where
.
setupStatus
;
}
qc
.
where
[
"$and"
]
=
filters
;
qc
.
where
[
"$and"
]
=
filters
;
return
qw
;
return
qw
;
}
}
async
insertInfo
(
qobj
,
t
)
{
async
insertInfo
(
qobj
,
t
)
{
var
obj
=
{
return
await
this
.
create
(
qobj
,
t
);
"delivery_code"
:
qobj
.
orderId
,
"product_code"
:
qobj
.
product_code
,
"product_name"
:
qobj
.
product_name
,
"service_address"
:
qobj
.
area
,
"delivery_status"
:
qobj
.
delivery_status
,
"facilitator_id"
:
qobj
.
facilitator_id
,
"biz_id"
:
qobj
.
bizId
};
// source_number
if
(
qobj
.
source_number
&&
qobj
.
source_number
!=
'undefined'
)
{
obj
.
source_number
=
qobj
.
source_number
;
delete
qobj
.
source_number
;
}
// demand_code
if
(
qobj
.
demand_code
&&
qobj
.
demand_code
!=
'undefined'
)
{
obj
.
demand_code
=
qobj
.
demand_code
;
delete
qobj
.
demand_code
;
}
// sku_code
if
(
qobj
.
sku_code
&&
qobj
.
sku_code
!=
'undefined'
)
{
obj
.
sku_code
=
qobj
.
sku_code
;
delete
qobj
.
sku_code
;
}
// scheme_number
if
(
qobj
.
solutionBizId
&&
qobj
.
solutionBizId
!=
'undefined'
)
{
obj
.
scheme_number
=
qobj
.
solutionBizId
;
delete
qobj
.
solutionBizId
;
}
// selling_price
if
(
qobj
.
selling_price
&&
qobj
.
selling_price
!=
'undefined'
)
{
obj
.
selling_price
=
qobj
.
selling_price
;
delete
qobj
.
selling_price
;
}
// cost_price
if
(
qobj
.
cost_price
&&
qobj
.
cost_price
!=
'undefined'
)
{
obj
.
cost_price
=
qobj
.
cost_price
;
delete
qobj
.
cost_price
;
}
// close_reason
if
(
qobj
.
close_reason
&&
qobj
.
close_reason
!=
'undefined'
)
{
obj
.
close_reason
=
qobj
.
close_reason
;
delete
qobj
.
close_reason
;
}
// facilitator_name
if
(
qobj
.
facilitator_name
&&
qobj
.
facilitator_name
!=
'undefined'
)
{
obj
.
facilitator_name
=
qobj
.
facilitator_name
;
delete
qobj
.
facilitator_name
;
}
// salesman_opcode
if
(
qobj
.
salesman_opcode
&&
qobj
.
salesman_opcode
!=
'undefined'
)
{
obj
.
salesman_opcode
=
qobj
.
salesman_opcode
;
delete
qobj
.
salesman_opcode
;
}
// salesman_id
if
(
qobj
.
salesman_id
&&
qobj
.
salesman_id
!=
'undefined'
)
{
obj
.
salesman_id
=
qobj
.
salesman_id
;
delete
qobj
.
salesman_id
;
}
// salesman_name
if
(
qobj
.
salesman_name
&&
qobj
.
salesman_name
!=
'undefined'
)
{
obj
.
salesman_name
=
qobj
.
salesman_name
;
delete
qobj
.
salesman_name
;
}
// salesman_phone
if
(
qobj
.
salesman_phone
&&
qobj
.
salesman_phone
!=
'undefined'
)
{
obj
.
salesman_phone
=
qobj
.
salesman_phone
;
delete
qobj
.
salesman_phone
;
}
// source_name
if
(
qobj
.
source_name
&&
qobj
.
source_name
!=
'undefined'
)
{
obj
.
source_name
=
qobj
.
source_name
;
delete
qobj
.
source_name
;
}
// master_source_number
if
(
qobj
.
master_source_number
&&
qobj
.
master_source_number
!=
'undefined'
)
{
obj
.
master_source_number
=
qobj
.
master_source_number
;
delete
qobj
.
master_source_number
;
}
// settle_status
if
(
qobj
.
settle_status
&&
qobj
.
settle_status
!=
'undefined'
)
{
obj
.
settle_status
=
qobj
.
settle_status
;
delete
qobj
.
settle_status
;
}
// settlebill_id
if
(
qobj
.
settlebill_id
&&
qobj
.
settlebill_id
!=
'undefined'
)
{
obj
.
settlebill_id
=
qobj
.
settlebill_id
;
delete
qobj
.
settlebill_id
;
}
// delivery_man_id
if
(
qobj
.
delivery_man_id
&&
qobj
.
delivery_man_id
!=
'undefined'
)
{
obj
.
delivery_man_id
=
qobj
.
delivery_man_id
;
delete
qobj
.
delivery_man_id
;
}
// delivery_man_name
if
(
qobj
.
delivery_man_name
&&
qobj
.
delivery_man_name
!=
'undefined'
)
{
obj
.
delivery_man_name
=
qobj
.
delivery_man_name
;
delete
qobj
.
delivery_man_name
;
}
// delivery_man_opcode
if
(
qobj
.
delivery_man_opcode
&&
qobj
.
delivery_man_opcode
!=
'undefined'
)
{
obj
.
delivery_man_opcode
=
qobj
.
delivery_man_opcode
;
delete
qobj
.
delivery_man_opcode
;
}
delete
qobj
.
orderId
;
delete
qobj
.
product_code
;
delete
qobj
.
product_name
;
delete
qobj
.
service_address
;
delete
qobj
.
delivery_status
;
delete
qobj
.
facilitator_id
;
obj
.
delivery_info
=
qobj
;
return
await
this
.
create
(
obj
,
t
);
}
}
async
updateServer
(
qobj
,
whereobj
,
t
)
{
async
updateServer
(
qobj
,
t
)
{
return
await
this
.
updateByWhere
(
qobj
,
whereobj
,
t
);
var
setobj
=
{
"delivery_info"
:
qobj
.
delivery_info
};
var
whereobj
=
{
"delivery_code"
:
qobj
.
delivery_code
,
"biz_id"
:
qobj
.
biz_id
};
return
await
this
.
updateByWhere
(
setobj
,
whereobj
,
t
);
}
}
async
findOneByDeliveryCodeAndBizId
(
qobj
)
{
async
findOneByDeliveryCodeAndBizId
(
qobj
)
{
var
qcwhere
=
{
"delivery_code"
:
qobj
.
orderId
,
"biz_id"
:
qobj
.
bizI
d
};
var
qcwhere
=
{
"delivery_code"
:
qobj
.
delivery_code
,
"biz_id"
:
qobj
.
biz_i
d
};
return
await
this
.
findOne
(
qcwhere
);
return
await
this
.
findOne
(
qcwhere
);
}
}
/**
/**
* 根据服务实例id查找服务所有信息
* 根据服务实例id查找服务所有信息
*/
*/
async
findByBizId
(
pobj
){
async
findByBizId
(
pobj
)
{
var
oid
=
pobj
.
bizId
;
var
oid
=
pobj
.
bizId
;
return
await
this
.
findOne
({
biz_id
:
oid
});
return
await
this
.
findOne
({
biz_id
:
oid
});
}
}
}
}
module
.
exports
=
DeliverybillDao
;
module
.
exports
=
DeliverybillDao
;
tx-fi-tax/app/base/db/models/delivery/delivery_bill.js
View file @
004c016a
...
@@ -22,6 +22,10 @@ module.exports = (db, DataTypes) => {
...
@@ -22,6 +22,10 @@ module.exports = (db, DataTypes) => {
allowNull
:
true
,
allowNull
:
true
,
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
},
},
company_name
:
{
// 公司名称-虚拟字段
allowNull
:
true
,
type
:
DataTypes
.
STRING
},
v_coname
:
{
// 联系人-虚拟字段
v_coname
:
{
// 联系人-虚拟字段
allowNull
:
true
,
allowNull
:
true
,
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
...
@@ -30,6 +34,10 @@ module.exports = (db, DataTypes) => {
...
@@ -30,6 +34,10 @@ module.exports = (db, DataTypes) => {
allowNull
:
true
,
allowNull
:
true
,
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
},
},
v_setup_status
:
{
// 公司名称-建账状态
allowNull
:
true
,
type
:
DataTypes
.
STRING
},
demand_code
:
{
// 商机编号
demand_code
:
{
// 商机编号
allowNull
:
true
,
allowNull
:
true
,
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
...
@@ -62,14 +70,14 @@ module.exports = (db, DataTypes) => {
...
@@ -62,14 +70,14 @@ module.exports = (db, DataTypes) => {
allowNull
:
false
,
allowNull
:
false
,
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
},
},
master_source_number
:{
//主订单号
master_source_number
:
{
//主订单号
allowNull
:
true
,
allowNull
:
true
,
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
},
},
settle_status
:
{
// 服务单流转状态
settle_status
:
{
// 服务单流转状态
allowNull
:
false
,
allowNull
:
false
,
type
:
DataTypes
.
STRING
,
type
:
DataTypes
.
STRING
,
defaultValue
:
'waittosettle'
defaultValue
:
'waittosettle'
},
},
selling_price
:
{
//售价
selling_price
:
{
//售价
allowNull
:
true
,
allowNull
:
true
,
...
...
tx-fi-tax/app/base/service/impl/bizchance/deliverybillSve.js
View file @
004c016a
...
@@ -27,7 +27,7 @@ class DeliverybillService extends ServiceBase {
...
@@ -27,7 +27,7 @@ class DeliverybillService extends ServiceBase {
if
(
pobj
.
orderStaus
===
true
)
{
if
(
pobj
.
orderStaus
===
true
)
{
updateResult
=
{
updateResult
=
{
delivery_info
:
{
delivery_info
:
{
delivery_info
,
...
delivery_info
,
setupAt
:
pobj
.
setupAt
//建账时间
setupAt
:
pobj
.
setupAt
//建账时间
},
},
delivery_status
:
system
.
SERVERSESTATUS
.
WAITUSERCONFIRM
delivery_status
:
system
.
SERVERSESTATUS
.
WAITUSERCONFIRM
...
@@ -62,6 +62,9 @@ class DeliverybillService extends ServiceBase {
...
@@ -62,6 +62,9 @@ class DeliverybillService extends ServiceBase {
if
(
deliverData
.
delivery_status
!==
system
.
SERVERSESTATUS
.
INSERVICE
)
{
if
(
deliverData
.
delivery_status
!==
system
.
SERVERSESTATUS
.
INSERVICE
)
{
throw
new
Error
(
"该状态下不可建账"
);
throw
new
Error
(
"该状态下不可建账"
);
}
}
if
(
deliverData
.
delivery_info
.
setupStatus
&&
deliverData
.
delivery_info
.
setupStatus
===
system
.
SERVERSESTATUS
.
SETUP
)
{
throw
new
Error
(
"已建账"
);
}
await
this
.
dao
.
updateByWhere
({
await
this
.
dao
.
updateByWhere
({
delivery_info
:
{
delivery_info
:
{
...
delivery_info
,
...
delivery_info
,
...
@@ -92,19 +95,19 @@ class DeliverybillService extends ServiceBase {
...
@@ -92,19 +95,19 @@ class DeliverybillService extends ServiceBase {
deliveryId
:
deliverData
.
id
,
// id
deliveryId
:
deliverData
.
id
,
// id
deliveryNumber
:
deliverData
.
delivery_code
,
// 交付单编号
deliveryNumber
:
deliverData
.
delivery_code
,
// 交付单编号
companyName
:
deliverData
.
delivery_info
.
companyName
,
// 企业名称
companyName
:
deliverData
.
delivery_info
.
companyName
,
// 企业名称
uscc
:
deliverData
.
delivery_info
.
uscc
,
//统一信用代码
uscc
:
deliverData
.
delivery_info
.
creditCode
,
//统一信用代码
taxpayerType
:
delivery_info
.
taxpayerType
,
//纳税人类型 1 一般;2 小规模
taxpayerType
:
deliver
Data
.
deliver
y_info
.
taxpayerType
,
//纳税人类型 1 一般;2 小规模
//会计准侧
//会计准侧
companyBizType
:
delivery_info
.
companyBizType
,
// 公司类型 1-商贸型;2-服务型;3-特殊行业;4-其他
companyBizType
:
deliver
Data
.
deliver
y_info
.
companyBizType
,
// 公司类型 1-商贸型;2-服务型;3-特殊行业;4-其他
areaType
:
delivery_info
.
areaType
,
//区域类型 city-城市
areaType
:
deliver
Data
.
deliver
y_info
.
areaType
,
//区域类型 city-城市
area
:
service_address
,
// 服务 地区 编码
area
:
deliverData
.
service_address
,
// 服务 地区 编码
contactsName
:
delivery_info
.
contactsName
,
// 联系人
contactsName
:
deliver
Data
.
deliver
y_info
.
contactsName
,
// 联系人
contactsPhone
:
delivery_info
.
contactsPhone
,
// 联系电话
contactsPhone
:
deliver
Data
.
deliver
y_info
.
contactsPhone
,
// 联系电话
owner
:
salesman_name
,
//所属人
owner
:
deliverData
.
salesman_name
,
//所属人
deliveryStatus
:
delivery_status
,
// 交付单状态
deliveryStatus
:
deliver
Data
.
deliver
y_status
,
// 交付单状态
setupStatus
:
delivery_info
.
setupStatus
||
System
.
SERVERSESTATUS
.
NOTSETUP
,
//建账状态 notsetup | setup
setupStatus
:
deliver
Data
.
deliver
y_info
.
setupStatus
||
System
.
SERVERSESTATUS
.
NOTSETUP
,
//建账状态 notsetup | setup
createdAt
:
created_at
,
createdAt
:
deliverData
.
created_at
,
updatedAt
:
updated_at
,
updatedAt
:
deliverData
.
updated_at
,
}
}
if
(
deliverData
.
scheme_number
)
{
if
(
deliverData
.
scheme_number
)
{
let
schemeData
=
await
this
.
fitaxschemeDao
.
findOne
({
let
schemeData
=
await
this
.
fitaxschemeDao
.
findOne
({
...
@@ -245,180 +248,55 @@ class DeliverybillService extends ServiceBase {
...
@@ -245,180 +248,55 @@ class DeliverybillService extends ServiceBase {
async
updateServer
(
qobj
)
{
async
updateServer
(
qobj
)
{
var
self
=
this
;
var
self
=
this
;
var
bill
=
await
self
.
dao
.
findOneByDeliveryCodeAndBizId
(
qobj
);
var
bill
=
await
self
.
dao
.
findOneByDeliveryCodeAndBizId
(
qobj
);
var
obj
=
{};
qobj
.
delivery_info
=
JSON
.
parse
((
JSON
.
stringify
(
bill
.
delivery_info
)
+
JSON
.
stringify
(
qobj
.
delivery_info
)).
replace
(
/}{/
,
','
));
var
whereobj
=
{
"delivery_code"
:
qobj
.
orderId
,
"biz_id"
:
qobj
.
bizId
};
// source_number
if
(
qobj
.
source_number
&&
qobj
.
source_number
!=
'undefined'
)
{
obj
.
source_number
=
qobj
.
source_number
;
delete
qobj
.
source_number
;
}
// demand_code
if
(
qobj
.
demand_code
&&
qobj
.
demand_code
!=
'undefined'
)
{
obj
.
demand_code
=
qobj
.
demand_code
;
delete
qobj
.
demand_code
;
}
// sku_code
if
(
qobj
.
sku_code
&&
qobj
.
sku_code
!=
'undefined'
)
{
obj
.
sku_code
=
qobj
.
sku_code
;
delete
qobj
.
sku_code
;
}
// scheme_number
if
(
qobj
.
solutionBizId
&&
qobj
.
solutionBizId
!=
'undefined'
)
{
obj
.
scheme_number
=
qobj
.
solutionBizId
;
delete
qobj
.
solutionBizId
;
}
// product_code
if
(
qobj
.
product_code
&&
qobj
.
product_code
!=
'undefined'
)
{
obj
.
product_code
=
qobj
.
product_code
;
delete
qobj
.
product_code
;
}
// product_name
if
(
qobj
.
product_name
&&
qobj
.
product_name
!=
'undefined'
)
{
obj
.
product_name
=
qobj
.
product_name
;
delete
qobj
.
product_name
;
}
// service_address
if
(
qobj
.
service_address
&&
qobj
.
service_address
!=
'undefined'
)
{
obj
.
service_address
=
qobj
.
service_address
;
delete
qobj
.
service_address
;
}
// delivery_status
if
(
qobj
.
delivery_status
&&
qobj
.
delivery_status
!=
'undefined'
)
{
obj
.
delivery_status
=
qobj
.
delivery_status
;
delete
qobj
.
delivery_status
;
}
// selling_price
if
(
qobj
.
selling_price
&&
qobj
.
selling_price
!=
'undefined'
)
{
obj
.
selling_price
=
qobj
.
selling_price
;
delete
qobj
.
selling_price
;
}
// cost_price
if
(
qobj
.
cost_price
&&
qobj
.
cost_price
!=
'undefined'
)
{
obj
.
cost_price
=
qobj
.
cost_price
;
delete
qobj
.
cost_price
;
}
// close_reason
if
(
qobj
.
close_reason
&&
qobj
.
close_reason
!=
'undefined'
)
{
obj
.
close_reason
=
qobj
.
close_reason
;
delete
qobj
.
close_reason
;
}
// facilitator_id
if
(
qobj
.
facilitator_id
&&
qobj
.
facilitator_id
!=
'undefined'
)
{
obj
.
facilitator_id
=
qobj
.
facilitator_id
;
delete
qobj
.
facilitator_id
;
}
// facilitator_name
if
(
qobj
.
facilitator_name
&&
qobj
.
facilitator_name
!=
'undefined'
)
{
obj
.
facilitator_name
=
qobj
.
facilitator_name
;
delete
qobj
.
facilitator_name
;
}
// salesman_opcode
if
(
qobj
.
salesman_opcode
&&
qobj
.
salesman_opcode
!=
'undefined'
)
{
obj
.
salesman_opcode
=
qobj
.
salesman_opcode
;
delete
qobj
.
salesman_opcode
;
}
// salesman_id
if
(
qobj
.
salesman_id
&&
qobj
.
salesman_id
!=
'undefined'
)
{
obj
.
salesman_id
=
qobj
.
salesman_id
;
delete
qobj
.
salesman_id
;
}
// salesman_name
if
(
qobj
.
salesman_name
&&
qobj
.
salesman_name
!=
'undefined'
)
{
obj
.
salesman_name
=
qobj
.
salesman_name
;
delete
qobj
.
salesman_name
;
}
// salesman_phone
if
(
qobj
.
salesman_phone
&&
qobj
.
salesman_phone
!=
'undefined'
)
{
obj
.
salesman_phone
=
qobj
.
salesman_phone
;
delete
qobj
.
salesman_phone
;
}
// source_name
if
(
qobj
.
source_name
&&
qobj
.
source_name
!=
'undefined'
)
{
obj
.
source_name
=
qobj
.
source_name
;
delete
qobj
.
source_name
;
}
// master_source_number
if
(
qobj
.
master_source_number
&&
qobj
.
master_source_number
!=
'undefined'
)
{
obj
.
master_source_number
=
qobj
.
master_source_number
;
delete
qobj
.
master_source_number
;
}
// settle_status
if
(
qobj
.
settle_status
&&
qobj
.
settle_status
!=
'undefined'
)
{
obj
.
settle_status
=
qobj
.
settle_status
;
delete
qobj
.
settle_status
;
}
// settlebill_id
if
(
qobj
.
settlebill_id
&&
qobj
.
settlebill_id
!=
'undefined'
)
{
obj
.
settlebill_id
=
qobj
.
settlebill_id
;
delete
qobj
.
settlebill_id
;
}
// delivery_man_id
if
(
qobj
.
delivery_man_id
&&
qobj
.
delivery_man_id
!=
'undefined'
)
{
obj
.
delivery_man_id
=
qobj
.
delivery_man_id
;
delete
qobj
.
delivery_man_id
;
}
// delivery_man_name
if
(
qobj
.
delivery_man_name
&&
qobj
.
delivery_man_name
!=
'undefined'
)
{
obj
.
delivery_man_name
=
qobj
.
delivery_man_name
;
delete
qobj
.
delivery_man_name
;
}
// delivery_man_opcode
if
(
qobj
.
delivery_man_opcode
&&
qobj
.
delivery_man_opcode
!=
'undefined'
)
{
obj
.
delivery_man_opcode
=
qobj
.
delivery_man_opcode
;
delete
qobj
.
delivery_man_opcode
;
}
delete
qobj
.
orderId
;
obj
.
delivery_info
=
JSON
.
parse
((
JSON
.
stringify
(
bill
.
delivery_info
)
+
JSON
.
stringify
(
qobj
)).
replace
(
/}{/
,
','
));
return
self
.
db
.
transaction
(
async
function
(
t
)
{
return
self
.
db
.
transaction
(
async
function
(
t
)
{
return
await
self
.
dao
.
updateServer
(
obj
,
where
obj
,
t
);
return
await
self
.
dao
.
updateServer
(
q
obj
,
t
);
});
});
}
}
//根据bizId查询deliverybill表中的所有信息
//根据bizId查询deliverybill表中的所有信息
async
getInfo
(
pobj
){
async
getInfo
(
pobj
)
{
let
result
=
{};
let
result
=
{};
let
deliveryBillInfo
=
await
this
.
dao
.
findByBizId
(
pobj
);
let
deliveryBillInfo
=
await
this
.
dao
.
findByBizId
(
pobj
);
// console.log("gggg"+deliveryBillInfo+pobj.bizId)
// console.log("gggg"+deliveryBillInfo+pobj.bizId)
if
(
!
deliveryBillInfo
)
{
if
(
!
deliveryBillInfo
)
{
throw
new
Error
(
"没有服务信息"
);
throw
new
Error
(
"没有服务信息"
);
}
}
//封装deliverybill表数据
//封装deliverybill表数据
result
.
deliveryBillInfo
=
{
result
.
deliveryBillInfo
=
{
deliveryCode
:
deliveryBillInfo
.
delivery_code
,
//交付单编号
deliveryCode
:
deliveryBillInfo
.
delivery_code
,
//交付单编号
sourceNumber
:
deliveryBillInfo
.
source_number
,
//渠道来源编号
sourceNumber
:
deliveryBillInfo
.
source_number
,
//渠道来源编号
demandCode
:
deliveryBillInfo
.
demand_code
,
//商机编号
demandCode
:
deliveryBillInfo
.
demand_code
,
//商机编号
skuCode
:
deliveryBillInfo
.
sku_code
,
//sku编号
skuCode
:
deliveryBillInfo
.
sku_code
,
//sku编号
schemeNumber
:
deliveryBillInfo
.
scheme_number
,
//方案编号
schemeNumber
:
deliveryBillInfo
.
scheme_number
,
//方案编号
productCode
:
deliveryBillInfo
.
product_code
,
//产品编码
productCode
:
deliveryBillInfo
.
product_code
,
//产品编码
productName
:
deliveryBillInfo
.
product_name
,
//产品名称
productName
:
deliveryBillInfo
.
product_name
,
//产品名称
serviceAddress
:
deliveryBillInfo
.
service_address
,
//服务地区
serviceAddress
:
deliveryBillInfo
.
service_address
,
//服务地区
deliveryInfo
:
deliveryBillInfo
.
delivery_info
,
//交付单详情
deliveryInfo
:
deliveryBillInfo
.
delivery_info
,
//交付单详情
payStatus
:
deliveryBillInfo
.
pay_status
,
//交付状态-虚拟字段
payStatus
:
deliveryBillInfo
.
pay_status
,
//交付状态-虚拟字段
vConame
:
deliveryBillInfo
.
v_coname
,
//联系人-虚拟字段
vConame
:
deliveryBillInfo
.
v_coname
,
//联系人-虚拟字段
vCophone
:
deliveryBillInfo
.
v_cophone
,
//联系电话-虚拟字段
vCophone
:
deliveryBillInfo
.
v_cophone
,
//联系电话-虚拟字段
delivery_status
:
deliveryBillInfo
.
delivery_status
,
//交付单状态
delivery_status
:
deliveryBillInfo
.
delivery_status
,
//交付单状态
sellingPrice
:
deliveryBillInfo
.
selling_price
,
//交付单价格
sellingPrice
:
deliveryBillInfo
.
selling_price
,
//交付单价格
costPrice
:
deliveryBillInfo
.
cost_price
,
//成本价
costPrice
:
deliveryBillInfo
.
cost_price
,
//成本价
closeReason
:
deliveryBillInfo
.
close_reason
,
//状态为关闭原因
closeReason
:
deliveryBillInfo
.
close_reason
,
//状态为关闭原因
facilitatorId
:
deliveryBillInfo
.
facilitator_id
,
//服务商id
facilitatorId
:
deliveryBillInfo
.
facilitator_id
,
//服务商id
facilitatorName
:
deliveryBillInfo
.
facilitator_name
,
//服务商名称
facilitatorName
:
deliveryBillInfo
.
facilitator_name
,
//服务商名称
salesmanOpcode
:
deliveryBillInfo
.
salesman_opcode
,
//业务员opcode
salesmanOpcode
:
deliveryBillInfo
.
salesman_opcode
,
//业务员opcode
salesmanId
:
deliveryBillInfo
.
salesman_id
,
//业务员id
salesmanId
:
deliveryBillInfo
.
salesman_id
,
//业务员id
salesmanName
:
deliveryBillInfo
.
salesman_name
,
//业务员名称
salesmanName
:
deliveryBillInfo
.
salesman_name
,
//业务员名称
salesmanPhone
:
deliveryBillInfo
.
salesman_phone
,
//业务员联系方式
salesmanPhone
:
deliveryBillInfo
.
salesman_phone
,
//业务员联系方式
sourceName
:
deliveryBillInfo
.
source_name
,
//渠道名称
sourceName
:
deliveryBillInfo
.
source_name
,
//渠道名称
createdAt
:
deliveryBillInfo
.
created_at
,
//创建时间
createdAt
:
deliveryBillInfo
.
created_at
,
//创建时间
updatedAt
:
deliveryBillInfo
.
updated_at
,
//更新时间
updatedAt
:
deliveryBillInfo
.
updated_at
,
//更新时间
version
:
deliveryBillInfo
.
version
,
//o
version
:
deliveryBillInfo
.
version
,
//o
masterSourceNumber
:
deliveryBillInfo
.
master_source_number
,
//主来源单
masterSourceNumber
:
deliveryBillInfo
.
master_source_number
,
//主来源单
settleStatus
:
deliveryBillInfo
.
settle_status
,
//结算状态
settleStatus
:
deliveryBillInfo
.
settle_status
,
//结算状态
settlebillId
:
deliveryBillInfo
.
settlebill_id
,
//结算单id
settlebillId
:
deliveryBillInfo
.
settlebill_id
,
//结算单id
deliveryManId
:
deliveryBillInfo
.
delivery_man_id
,
//销售员id
deliveryManId
:
deliveryBillInfo
.
delivery_man_id
,
//销售员id
deliveryManName
:
deliveryBillInfo
.
delivery_man_name
,
//销售员姓名
deliveryManName
:
deliveryBillInfo
.
delivery_man_name
,
//销售员姓名
deliveryManOpcode
:
deliveryBillInfo
.
delivery_man_opcode
,
//销售员opcode
deliveryManOpcode
:
deliveryBillInfo
.
delivery_man_opcode
,
//销售员opcode
bizId
:
pobj
.
bizId
//融易算-服务实例id
bizId
:
pobj
.
bizId
//融易算-服务实例id
}
}
return
result
;
return
result
;
}
}
...
...
tx-fi-tax/app/base/system.js
View file @
004c016a
...
@@ -354,23 +354,18 @@ class System {
...
@@ -354,23 +354,18 @@ class System {
for
(
var
i
in
arr
)
{
for
(
var
i
in
arr
)
{
if
(
arr
[
i
]
!=
"sign"
&&
arr
[
i
]
!=
"ip"
&&
if
(
arr
[
i
]
!=
"sign"
&&
arr
[
i
]
!=
"ip"
&&
(
!
(
Object
.
prototype
.
toString
.
call
(
obj
[
arr
[
i
]])
==
'[object Object]'
||
Object
.
prototype
.
toString
.
call
(
obj
[
arr
[
i
]])
==
'[object Array]'
)
(
!
(
Object
.
prototype
.
toString
.
call
(
obj
[
arr
[
i
]])
==
'[object Object]'
||
Object
.
prototype
.
toString
.
call
(
obj
[
arr
[
i
]])
==
'[object Array]'
)
&&
(
obj
[
arr
[
i
]]
&&
obj
[
arr
[
i
]]
!=
'undefined'
)))
{
&&
(
(
obj
[
arr
[
i
]]
||
obj
[
arr
[
i
]]
===
0
||
obj
[
arr
[
i
]]
===
false
)
&&
obj
[
arr
[
i
]]
!=
'undefined'
)))
{
str
+=
arr
[
i
]
+
"="
+
obj
[
arr
[
i
]]
+
"&"
;
str
+=
arr
[
i
]
+
"="
+
obj
[
arr
[
i
]]
+
"&"
;
}
}
}
}
var
toSignStr
=
str
.
substr
(
0
,
str
.
length
-
1
);
var
toSignStr
=
str
.
substr
(
0
,
str
.
length
-
1
);
var
sb
=
toSignStr
+
secret
;
var
sb
=
toSignStr
+
secret
;
console
.
log
(
"cmd=ApiSignUtils:toSign msg=original Sign:"
+
sb
.
toString
()
+
" req param:"
+
obj
);
console
.
log
(
"cmd=ApiSignUtils:toSign msg=original Sign:"
+
sb
.
toString
());
// 对sb进行md5加密后得到svrSign
// 对sb进行md5加密后得到svrSign
svrSign
=
md5
(
sb
);
svrSign
=
md5
(
sb
);
console
.
log
(
"svrSign===>"
+
svrSign
);
console
.
log
(
"svrSign===>"
+
svrSign
);
}
}
if
(
svrSign
.
toLowerCase
()
==
obj
[
"sign"
].
toLowerCase
())
{
return
svrSign
;
console
.
log
(
"cmd=ApiSignUtils:SignValid msg=original Sign:"
+
svrSign
)
return
true
;
}
console
.
error
(
"cmd=ApiSignUtils:SignValid msg=Sign validtate fail! svrSign:"
+
svrSign
+
" reqSign:"
+
obj
[
"sign"
]);
return
false
;
}
}
}
}
...
@@ -415,7 +410,7 @@ System.SERVERSESTATUS = {
...
@@ -415,7 +410,7 @@ System.SERVERSESTATUS = {
INSERVICE
:
"inservice"
,
//服务中
INSERVICE
:
"inservice"
,
//服务中
CLOSED
:
"closed"
,
//已关闭 、已终止
CLOSED
:
"closed"
,
//已关闭 、已终止
NOTSETUP
:
"notsetup"
,
//未建账
NOTSETUP
:
"notsetup"
,
//未建账
SETUP
:
"setup"
//
未
建账
SETUP
:
"setup"
//建账
}
}
/*
/*
...
...
tx-fi-tax/app/base/utils/toFtClient.js
0 → 100644
View file @
004c016a
const
axios
=
require
(
"axios"
);
const
settings
=
require
(
"../../config/settings"
);
const
system
=
require
(
"../system"
);
const
ftConfig
=
settings
.
ftConfig
();
let
ftTenantInfo
;
// 财税中心 缓存
/**
* 发送 post 请求
* @param {*} url
* @param {*} data
* @param {*} headers
*/
const
postRequest
=
async
(
url
,
data
,
headers
=
{})
=>
{
try
{
console
.
log
(
`
${
url
}
: 推送财税中心数据 ------- `
);
console
.
log
(
JSON
.
stringify
(
data
))
let
result
=
await
axios
.
post
(
url
,
data
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
...
headers
},
timeout
:
5000
,
});
result
=
result
.
data
;
console
.
log
(
"推送财税中心返回数据 ------- "
);
console
.
log
(
JSON
.
stringify
(
result
));
if
(
result
.
code
==
1
)
{
return
result
.
data
}
else
{
throw
new
Error
(
result
.
errMsg
);
}
}
catch
(
err
)
{
console
.
log
(
"------ 财税中心err -----"
);
console
.
log
(
err
)
throw
(
err
)
}
}
/**
* 向财税 项目 发送消息 (不带签名)
* @param {*} url
* @param {*} data
* @param {*} headers
*/
const
postToFt
=
(
url
,
data
,
headers
=
{})
=>
{
return
postRequest
(
`
${
ftConfig
.
url
}${
url
}
`
,
data
,
headers
=
{})
}
/**
* 租户 向财税 项目 发送消息 带签名
* @param {*} url
* @param {*} data
* @param {*} headers
*/
const
postToFtBySign
=
async
(
url
,
data
,
headers
=
{})
=>
{
let
tenantInfo
=
await
getChannelCompany
();
data
.
companyId
=
tenantInfo
.
id
;
let
sign
=
system
.
signValid
(
data
,
tenantInfo
.
signSecret
);
return
postRequest
(
`
${
ftConfig
.
url
}${
url
}
`
,
{
...
data
,
sign
},
headers
=
{})
}
/**
* 财税 获取 租户信息
*/
const
getChannelCompany
=
async
()
=>
{
// 内存 缓存
if
(
ftTenantInfo
)
{
return
ftTenantInfo
}
let
reqData
=
{
channelCode
:
ftConfig
.
channelCode
,
}
let
sign
=
system
.
signValid
(
reqData
,
ftConfig
.
secret
);
const
companyData
=
await
postToFt
(
"/company/getChannelCompany"
,
{
...
reqData
,
sign
});
if
(
companyData
.
datas
&&
companyData
.
datas
.
length
>
0
)
{
ftTenantInfo
=
companyData
.
datas
[
0
]
return
ftTenantInfo
;
}
else
{
throw
(
"渠道码信息获取错误"
);
}
}
/**
* 建账
*/
const
addCusAccApplyInfo
=
async
()
=>
{
let
reqData
=
{
accountStandard
:
1
,
applyDate
:
"2020-09-10"
,
contact
:
"JAMES7"
,
creditCode
:
"911101053516460817K"
,
customerName
:
"北京融易算"
,
phoneNumber
:
"18510669367"
,
valueAddedTax
:
1
,
serviceTime
:
"5"
,
initPeriod
:
202009
,
}
const
data
=
await
postToFtBySign
(
'/cusAccApplyInfo/addCusAccApplyInfo'
,
reqData
);
console
.
log
(
data
);
}
module
.
exports
=
{
postToFtBySign
,
addCusAccApplyInfo
}
tx-fi-tax/app/config/settings.js
View file @
004c016a
...
@@ -59,6 +59,21 @@ var settings = {
...
@@ -59,6 +59,21 @@ var settings = {
return
"http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
return
"http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
}
}
},
},
ftConfig
:
function
()
{
if
(
this
.
env
==
"localhost"
)
{
return
{
channelCode
:
"e0kj8ehs"
,
secret
:
"92a15b9b4c5a9ea708bb5583408e1441"
,
url
:
"https://nt-api.gongsibao.com/nga-api"
};
}
else
{
return
{
channelCode
:
"e0kj8ehs"
,
secret
:
"92a15b9b4c5a9ea708bb5583408e1441"
,
url
:
"https://nt-api.gongsibao.com/nga-api"
};
}
},
pmappid
:
1
,
pmappid
:
1
,
pmcompanyid
:
1
,
pmcompanyid
:
1
,
pmroleid
:
{
"ta"
:
1
,
"pr"
:
2
},
pmroleid
:
{
"ta"
:
1
,
"pr"
:
2
},
...
...
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