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
89c19867
Commit
89c19867
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
ad60605d
8f12e877
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
68 deletions
+189
-68
tx-fi-tax/app/base/controller/impl/bizchance/deliverybillCtl.js
+101
-42
tx-fi-tax/app/base/system.js
+53
-0
tx-fi-tax/app/base/utils/toFtClient.js
+34
-25
tx-fi-tax/app/config/settings.js
+1
-1
No files found.
tx-fi-tax/app/base/controller/impl/bizchance/deliverybillCtl.js
View file @
89c19867
...
...
@@ -6,7 +6,10 @@ var settings = require("../../../../config/settings");
const
CtlBase
=
require
(
"../../ctl.base"
);
const
moment
=
require
(
'moment'
);
const
System
=
require
(
"../../../system"
);
const
toFtClient
=
require
(
"../../../utils/toFtClient"
);
const
appconfig
=
system
.
getSysConfig
();
const
sha235
=
require
(
"sha256"
);
const
{
getResult
}
=
require
(
"../../../system"
);
class
DeliverybillCtl
extends
CtlBase
{
constructor
()
{
super
(
"bizchance"
,
CtlBase
.
getServiceName
(
DeliverybillCtl
));
...
...
@@ -119,6 +122,9 @@ class DeliverybillCtl extends CtlBase {
/**
* 分配人
* @param {*} pobj
* @param {*} qobj
* @param {*} req
*/
async
distributionPerson
(
pobj
,
qobj
,
req
)
{
try
{
...
...
@@ -144,9 +150,29 @@ class DeliverybillCtl extends CtlBase {
}
}
/**
* 获取交付商信息
* @param {*} pobj
* @param {*} qobj
* @param {*} req
*/
async
getChannelCompany
(
pobj
,
qobj
,
req
)
{
try
{
const
rs
=
await
toFtClient
.
getChannelCompany
();
return
system
.
getResult
(
rs
.
map
(
item
=>
{
return
{
id
:
item
.
id
,
name
:
item
.
name
}
}));
}
catch
(
err
)
{
return
system
.
getResult
(
null
,
err
.
message
)
}
}
// 创建融易算服务实例
async
insertInfo
(
mobj
,
qobj
,
req
)
{
console
.
log
(
'mobj--------------------------------'
,
mobj
);
console
.
log
(
'mobj--------------------------------'
,
mobj
);
try
{
var
pobj
=
mobj
.
actionBody
;
var
cachestr
=
sha235
(
JSON
.
stringify
(
pobj
));
...
...
@@ -267,6 +293,8 @@ class DeliverybillCtl extends CtlBase {
}
}
//根据bizId查询deliverybill表中的所有信息
async
getInfo
(
pobj
,
qobj
,
req
)
{
try
{
...
...
@@ -281,55 +309,86 @@ class DeliverybillCtl extends CtlBase {
}
}
async
portog
(){
console
.
log
(
settings
.
port
);
//服务状态变更通知
async
notifyServiceStatusChange
(
pobj
,
qobj
,
req
)
{
let
ab
=
pobj
.
actionBody
;
if
(
!
ab
.
requestId
||
ab
.
requestId
==
"undefined"
)
{
return
system
.
getResultFail
(
-
1
,
"请求id不能为空"
);
}
if
(
!
ab
.
bizId
||
ab
.
bizId
==
"undefined"
)
{
return
system
.
getResultFail
(
-
1
,
"服务实例编号不能为空"
);
}
if
(
!
ab
.
status
||
ab
.
status
==
"undefined"
)
{
return
system
.
getResultFail
(
-
1
,
"服务状态不能为空"
);
}
try
{
let
cacheStr
=
sha235
(
JSON
.
stringify
(
ab
));
let
cacheInfo
=
await
this
.
cacheManager
[
"TxCache"
].
getCache
(
cacheStr
);
if
(
cacheInfo
&&
cacheInfo
!==
"undefined"
)
{
return
{
"status"
:
1
,
"msg"
:
"已处理成功"
,
"data"
:
cacheInfo
,
"requestId"
:
ab
.
requestId
,
};
}
else
{
// 变更服务状态
let
whereObj
=
{
biz_id
:
ab
.
bizId
};
let
rtn
=
await
this
.
service
.
findOne
(
whereObj
);
if
(
!
rtn
)
{
return
system
.
getResultFail
(
-
1
,
"未知服务信息"
);
}
let
deliveryInfo
=
{};
Object
.
assign
(
deliveryInfo
,
rtn
.
delivery_info
,
{
"serviceStartTime"
:
ab
.
serviceStartTime
,
"serviceEndTime"
:
ab
.
serviceEndTime
,
});
let
upObj
=
{
delivery_status
:
ab
.
status
,
delivery_info
:
deliveryInfo
,
};
await
rtn
.
update
(
upObj
,
{
where
:
whereObj
});
// 将变更结果插入到redis中
await
this
.
cacheManager
[
"TxCache"
].
cache
(
cachestr
,
JSON
.
stringify
({
cachestr
:
cachestr
}),
180
);
return
{
"status"
:
1
,
"msg"
:
"处理成功"
,
"data"
:
rtn
,
"requestId"
:
ab
.
requestId
};
}
}
catch
(
err
)
{
return
system
.
getResultError
(
err
);
}
}
}
module
.
exports
=
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"
}
}
"requestId"
:
"1111111"
,
"bizId"
:
2592748677
,
"status"
:
"inservice"
,
"serviceStartTime"
:
"today"
,
"serviceEndTime"
:
"tomorrow"
,
}
task
.
portog
(
).
then
(
d
=>
{
task
.
notifyServiceStatusChange
({
actionBody
:
obj
},
{},
{}
).
then
(
d
=>
{
console
.
log
(
JSON
.
stringify
(
d
));
})
// (async () => {
// 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",
// "orderId": "235184456620496",
// "companyName": "北京融易算",
// "contactName": "JAMES7",
// "taxpayerType": 5,
// "contactMobile": "18510669367",
// "companyBizType": 1,
// "uscc": "911101053516460817K"
// }
// }
// }
// task.updateServer(obj, {}, {}).then(d => {
// console.log(JSON.stringify(d));
// })
// "deliverId":"1111111",
// "company1": "华为技术有限公司",
// "company2": "中兴通讯股份有限公司",
// "keyword1":"用户设备,通信领域,通信技术,设备发送,指示信息,通信系统,通信方法,设备接收,对应关系,基站发送,终端发送,用户体验,配置信息,请求消息,数据传输方法,用户终端,网络侧,移动终端,通信设备,传输方法",
// "keyword2":"用户体验,移动终端,用户设备,相关技术,网络侧,终端发送,用户终端,配置信息,指示信息,请求消息,对应关系,传输方法,基站发送,通信系统,数据传输方法,通信领域,通信技术,设备发送,响应消息,发送方法"
// };
// var d = await task.deliverInfo(obj,{},{})
// console.log("dddddd---------" + JSON.stringify(d));
// })()
tx-fi-tax/app/base/system.js
View file @
89c19867
...
...
@@ -367,6 +367,59 @@ class System {
}
return
svrSign
;
}
/**
* 队列操作
* @param {json}
pushUrl string 推送URL地址
actionType string 推送地址接收时的功能名称
notifyUrl string 推送成功后通知的Url
messageBody json 推送的业务消息,必须有一项对象属性值
headData json 请求头信息
requestId string 请求id
*/
static
queueOper
(
obj
)
{
if
(
obj
.
pushUrl
&&
obj
.
actionType
&&
obj
.
messageBody
)
{
try
{
var
exec
=
this
.
getObject
(
"util.execClient"
);
var
reqUrl
=
settings
.
queueUrl
;
var
param
=
{
actionType
:
"produceData"
,
actionBody
:
{
pushUrl
:
obj
.
pushUrl
,
actionType
:
obj
.
actionType
,
identifyCode
:
"book-manage"
,
messageBody
:
obj
.
messageBody
}
}
if
(
obj
.
notifyUrl
)
{
param
.
actionBody
.
notifyUrl
=
obj
.
notifyUrl
;
}
if
(
obj
.
headData
)
{
param
.
actionBody
.
headData
;
}
if
(
obj
.
requestId
)
{
param
.
requestId
=
obj
.
requestId
;
}
var
result
=
await
exec
.
execPost
(
param
,
reqUrl
);
var
j
=
JSON
.
parse
(
result
.
stdout
);
if
(
j
.
status
==
1
){
return
this
.
getResult
(
j
);
}
else
{
return
this
.
getResultError
(
"队列返回失败"
);
}
}
catch
(
error
)
{
return
this
.
getResultError
(
error
);
}
}
else
{
return
this
.
getResultError
(
"参数错误"
);
}
}
}
Date
.
prototype
.
Format
=
function
(
fmt
)
{
//author: meizz
...
...
tx-fi-tax/app/base/utils/toFtClient.js
View file @
89c19867
const
axios
=
require
(
"axios"
);
const
settings
=
require
(
"../../config/settings"
);
const
system
=
require
(
"../system"
);
const
moment
=
require
(
'moment'
);
const
ftConfig
=
settings
.
ftConfig
();
let
ftTenantInfo
;
// 财税中心 缓存
const
_
=
require
(
"lodash"
)
/**
* 发送 post 请求
...
...
@@ -12,7 +13,7 @@ let ftTenantInfo; // 财税中心 缓存
*/
const
postRequest
=
async
(
url
,
data
,
headers
=
{})
=>
{
try
{
console
.
log
(
`
${
url
}
:
推送财税中心
数据 ------- `
);
console
.
log
(
`
${
url
}
:
请求
数据 ------- `
);
console
.
log
(
JSON
.
stringify
(
data
))
let
result
=
await
axios
.
post
(
url
,
data
,
{
headers
:
{
...
...
@@ -22,7 +23,7 @@ const postRequest = async (url, data, headers = {}) => {
timeout
:
5000
,
});
result
=
result
.
data
;
console
.
log
(
"
推送财税中心
返回数据 ------- "
);
console
.
log
(
"
${url} :
返回数据 ------- "
);
console
.
log
(
JSON
.
stringify
(
result
));
if
(
result
.
code
==
1
)
{
return
result
.
data
...
...
@@ -62,47 +63,55 @@ const postToFtBySign = async (url, data, headers = {}) => {
/**
* 财税 获取 租户信息
*/
const
getChannelCompany
=
async
()
=>
{
// 内存 缓存
if
(
ftTenantInfo
)
{
return
ftTenantInfo
}
const
getChannelCompany
=
async
(
id
)
=>
{
let
reqData
=
{
channelCode
:
ftConfig
.
channelCode
,
}
let
sign
=
system
.
signValid
(
reqData
,
ftConfig
.
secret
);
cons
t
companyData
=
await
postToFt
(
"/company/getChannelCompany"
,
{
le
t
companyData
=
await
postToFt
(
"/company/getChannelCompany"
,
{
...
reqData
,
sign
});
if
(
companyData
.
datas
&&
companyData
.
datas
.
length
>
0
)
{
ftTenantInfo
=
companyData
.
datas
[
0
]
return
ftTenantInfo
;
}
else
{
throw
(
"渠道码信息获取错误"
);
companyData
=
companyData
.
datas
;
if
(
id
)
{
// TODO: 获取单个信息
}
return
companyData
;
}
/**
* 建账
* @param {*} deliverData
* @param {*} pobj
*/
const
addCusAccApplyInfo
=
async
()
=>
{
const
addCusAccApplyInfo
=
async
(
deliverData
,
pobj
)
=>
{
const
accountStandard
=
{
"小企业会计准则"
:
1
,
"企业会计准则"
:
2
}
const
valueAddedTax
=
{
"小规模纳税人"
:
0
,
"一般纳税人"
:
1
,
"个体工商户"
:
2
}
let
reqData
=
{
accountStandard
:
1
,
applyDate
:
"2020-09-10"
,
contact
:
"JAMES7"
,
creditCode
:
"911101053516460817K"
,
customerName
:
"北京融易算"
,
phoneNumber
:
"18510669367"
,
valueAddedTax
:
1
,
serviceTime
:
"5"
,
initPeriod
:
202009
,
accountStandard
:
accountStandard
[
pobj
.
accountingType
]
,
applyDate
:
pobj
.
time
,
contact
:
deliverData
.
delivery_info
.
contactsName
,
creditCode
:
deliverData
.
delivery_info
.
creditCode
,
customerName
:
deliverData
.
delivery_info
.
companyName
,
phoneNumber
:
deliverData
.
delivery_info
.
contactsPhone
,
valueAddedTax
:
valueAddedTax
[
pobj
.
taxpayerType
]
,
serviceTime
:
moment
(
deliverData
.
delivery_info
.
serviceEndTime
).
diff
(
moment
(
deliverData
.
delivery_info
.
serviceStartTime
),
'months'
).
toString
()
,
initPeriod
:
parseInt
(
moment
(
deliverData
.
delivery_info
.
serviceStartTime
).
format
(
'YYYYMMDD'
))
,
}
const
data
=
await
postToFtBySign
(
'/cusAccApplyInfo/addCusAccApplyInfo'
,
reqData
);
console
.
log
(
data
);
}
// console.log(moment("2021-05-31").diff(moment("2020-06-01"), 'months', true).toString())
module
.
exports
=
{
postToFtBySign
,
addCusAccApplyInfo
addCusAccApplyInfo
,
getChannelCompany
}
tx-fi-tax/app/config/settings.js
View file @
89c19867
...
...
@@ -40,7 +40,7 @@ var settings = {
},
queueUrl
:
function
()
{
if
(
this
.
env
==
"localhost"
)
{
return
"http://192.168.1.
128
:4018/api/queueAction/producer/springBoard"
;
return
"http://192.168.1.
9
:4018/api/queueAction/producer/springBoard"
;
}
else
{
return
"http://sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
}
...
...
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