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
7f1277c0
Commit
7f1277c0
authored
Apr 10, 2020
by
zhaoxiqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
276fd0e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
446 additions
and
2 deletions
+446
-2
bpo-web/app/base/api/impl/yzcontractApi.js
+82
-0
bpo-web/app/base/service/impl/entcontractSve.js
+364
-2
No files found.
bpo-web/app/base/api/impl/yzcontractApi.js
View file @
7f1277c0
...
...
@@ -104,6 +104,88 @@ class YZContractApi {
}
}
async
merchantSigns
(
pobj
)
{
// 处理参数
var
param
=
{
ecid
:
this
.
trim
(
pobj
.
ecid
),
appId
:
this
.
trim
(
pobj
.
appId
),
merchantId
:
this
.
trim
(
pobj
.
merchantId
),
merchantName
:
this
.
trim
(
pobj
.
merchantName
),
//甲方 必填
merchantAddr
:
this
.
trim
(
pobj
.
merchantAddr
),
//甲方地址
merchantLegal
:
this
.
trim
(
pobj
.
merchantLegal
),
//甲方法定代表人
idName
:
this
.
trim
(
pobj
.
idName
),
// 代理人姓名
mobile
:
this
.
trim
(
pobj
.
mobile
),
// 代理人手机号
idNo
:
this
.
trim
(
pobj
.
idNo
),
// 代理人身份证
nonceStr
:
this
.
trim
(
pobj
.
nonceStr
),
//随机码
sign
:
this
.
trim
(
pobj
.
sign
)
};
if
(
!
param
.
ecid
)
{
return
this
.
returnjson
(
-
1
,
"请传入薪必果提供的ecid"
)
}
if
(
!
param
.
appId
)
{
return
this
.
returnjson
(
-
1
,
"请传入薪必果提供的appId"
)
}
if
(
!
param
.
idName
)
{
return
this
.
returnjson
(
-
1
,
"请提供代理人姓名"
)
}
if
(
!
param
.
idNo
)
{
return
this
.
returnjson
(
-
1
,
"请提供代理人身份证号"
)
}
if
(
!
await
this
.
idcardClient
.
checkIDCard
(
param
.
idNo
))
{
return
this
.
returnjson
(
-
1
,
"代理人身份证格式不正确"
);
}
let
card
=
await
this
.
idcardClient
.
cardInfo
(
param
.
idNo
);
let
age
=
card
.
age
||
0
;
if
(
!
age
)
{
return
this
.
returnjson
(
-
1
,
"代理人身份证号格式错误, 只支持18位身份证号码"
);
}
if
(
card
.
sex
==
'male'
)
{
if
(
age
<
18
||
age
>
60
)
{
return
this
.
returnjson
(
-
1
,
"签约失败,男性代理人限制18-60岁之间"
)
}
}
else
{
if
(
age
<
18
||
age
>
55
)
{
return
this
.
returnjson
(
-
1
,
"签约失败,女性代理人限制18-55岁之间"
)
}
}
if
(
!
param
.
nonceStr
)
{
return
this
.
returnjson
(
-
1
,
"请提供随机码"
)
}
var
enttemplate
=
await
this
.
enttemplateSve
.
findById
(
param
.
ecid
);
if
(
!
enttemplate
||
!
enttemplate
.
key
)
{
return
this
.
returnjson
(
1001003
,
"配置信息错误,请联系薪必果人员进行配置"
);
}
// 签名
var
signArr
=
[];
var
keys
=
Object
.
keys
(
param
).
sort
();
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
var
k
=
keys
[
i
];
var
v
=
param
[
k
];
if
(
!
k
||
!
v
||
k
==
'sign'
)
{
continue
;
}
signArr
.
push
(
k
+
"="
+
v
);
}
var
signStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
enttemplate
.
key
;
var
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
sign
);
if
(
param
.
sign
!=
sign
)
{
return
this
.
returnjson
(
1001001
,
"签名错误"
);
}
try
{
var
result
=
await
this
.
entcontractSve
.
yzMerchantAutoSigns
(
param
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
async
autoSign
(
pobj
)
{
// 处理参数
var
param
=
{
...
...
bpo-web/app/base/service/impl/entcontractSve.js
View file @
7f1277c0
...
...
@@ -236,7 +236,7 @@ class EntcontractService extends ServiceBase {
type
:
"0"
,
// 类型 0 一般纳税人 1 小规模纳税人
companyName
:
params
.
merchantName
,
//商户名称
mobile
:
params
.
mobile
,
//手机号
mainId
:
"67731
101
"
,
//代征主体 67731101 测试 67731504
mainId
:
"67731
504
"
,
//代征主体 67731101 测试 67731504
signedName
:
params
.
merchantName
,
//合同名称 使用商户名称
beginTime
:
moment
().
format
(
"YYYY-MM-DD"
),
//当前时间, // 签约开始时间
invalidTime
:
moment
().
add
(
2
,
'y'
).
format
(
"YYYY-MM-DD"
),
// 签约失效时间
...
...
@@ -399,6 +399,179 @@ class EntcontractService extends ServiceBase {
}
async
createYzMerchant_1
(
params
)
{
var
data
=
{
// appId: "1202849621743763458",
// mchtId: "1202848945651318786",
appId
:
params
.
toAppId
,
mchtId
:
params
.
toMcthid
,
ageFlag
:
0
,
type
:
"0"
,
// 类型 0 一般纳税人 1 小规模纳税人
companyName
:
params
.
merchantName
,
//商户名称
mobile
:
params
.
mobile
,
//手机号
mainId
:
"67731504"
,
//代征主体 67731101 测试 67731504
signedName
:
params
.
merchantName
,
//合同名称 使用商户名称
beginTime
:
moment
().
format
(
"YYYY-MM-DD"
),
//当前时间, // 签约开始时间
invalidTime
:
moment
().
add
(
2
,
'y'
).
format
(
"YYYY-MM-DD"
),
// 签约失效时间
completeTime
:
moment
().
format
(
"YYYY-MM-DD"
),
// 签约完成时间 取当前时间
incomeCompany
:
"0"
,
// 个税来源 0 个税向个人收 1 个税向企业收
addedCollectType
:
"0"
,
// 服务费PLUS收取类型, 0 个人收 1 企业收
addedValueRate
:
"0.0"
,
// 服务费PLUS费率(%)
serviceCollectType
:
"0"
,
// 服务费收取类型, 0 个人收 1 企业收
serviceRate
:
"10.0"
,
//服务费率(%)
operatingCost
:
'0.0'
,
// 核定成本费用率(%)
taxChargeMode
:
"0"
,
// 个税计费模式 0 按月,1 按年
signType
:
'MD5'
,
nonceStr
:
await
this
.
getUidStr
(
16
,
36
)
};
console
.
log
(
"有赞商户创建data:"
,
data
);
var
signArr
=
[];
var
keys
=
Object
.
keys
(
data
).
sort
();
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
var
k
=
keys
[
i
];
var
v
=
data
[
k
];
signArr
.
push
(
k
+
"="
+
v
);
}
var
signStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
params
.
key
;
console
.
log
(
"有赞商户创建signStr:"
,
signStr
);
data
.
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
"有赞商户创建sign:"
,
data
.
sign
);
data
.
bizContent
=
[
{
"quickDeductionFactor"
:
0
,
"minValue"
:
0
,
"rate"
:
0
,
"maxValue"
:
3000000
},
{
"quickDeductionFactor"
:
0
,
"minValue"
:
3000001
,
"rate"
:
1.5
,
"maxValue"
:
10000000
},
{
"quickDeductionFactor"
:
0
,
"minValue"
:
10000001
,
"rate"
:
4.86
,
"maxValue"
:
214748364700
}
];
var
rtn
=
null
;
try
{
let
url
=
settings
.
apiconfig
.
settleApiConfig
().
createMerchantApi
;
console
.
log
(
"有赞商户创建url:"
,
url
);
let
rs
=
await
axios
({
method
:
'post'
,
url
:
url
,
data
:
data
,
});
console
.
log
(
"段经理接口返回==============="
,
rs
);
console
.
log
(
"有赞商户创建result:"
,
rs
.
data
);
var
reso
=
rs
.
data
;
var
erchants
=
await
this
.
yzmerchantsignedDao
.
findOne
({
companyName
:
params
.
merchantName
,
});
if
(
!
erchants
)
{
erchants
=
await
this
.
yzmerchantsignedDao
.
create
({
companyName
:
params
.
merchantName
,
appId
:
reso
.
data
.
appId
,
mchtId
:
reso
.
data
.
mchtId
,
mainId
:
reso
.
data
.
mainId
,
secret
:
reso
.
data
.
secret
,
entcontract_id
:
params
.
entcontract_id
,
});
}
let
ecompany
=
await
this
.
ecompanyDao
.
findOne
({
"name"
:
params
.
merchantName
,
})
if
(
!
ecompany
)
{
// 创建ecompany
ecompany
=
await
this
.
ecompanyDao
.
create
({
"name"
:
params
.
merchantName
,
"nameA"
:
''
,
"isEnabled"
:
true
,
"isQuiet"
:
true
,
"sealurl"
:
""
,
"encryptkey"
:
""
,
"posturl"
:
""
});
}
let
temp
=
await
this
.
etemplateDao
.
findById
(
10287
);
let
template
=
await
this
.
etemplateDao
.
findOne
({
ecompany_id
:
ecompany
.
id
,
});
if
(
!
template
)
{
template
=
await
this
.
etemplateDao
.
create
({
ecompany_id
:
ecompany
.
id
,
name
:
ecompany
.
name
,
templateid
:
temp
.
templateid
,
ecompanyMainId
:
temp
.
ecompanyMainId
,
nameA
:
temp
.
nameA
,
filekey
:
temp
.
filekey
,
//e签宝返回文件key
filepath
:
temp
.
filepath
,
//需要在后台补充
placeholderkey
:
temp
.
placeholderkey
,
//模板占位信息
isEnabled
:
true
,
});
}
reso
.
data
.
ecid
=
template
.
id
;
if
(
!
erchants
.
ecid
)
{
erchants
.
ecid
=
template
.
id
;
await
erchants
.
save
();
}
var
etemplatebusi
=
await
this
.
etemplatebusiDao
.
findOne
({
template_id
:
erchants
.
ecid
,
busi_id
:
erchants
.
mchtId
,
});
if
(
!
etemplatebusi
)
{
this
.
etemplatebusiDao
.
create
({
template_type
:
1
,
template_id
:
10287
,
busi_id
:
erchants
.
mchtId
,
busi_company_name
:
erchants
.
companyName
,
});
}
// let busi = await this.ecompanybusiDao.findOne({
// ecompany_id: ecompany.id,
// etemplate_id: template.id,
// });
// if (!busi) {
// await this.ecompanybusiDao.create({
// ecompany_id: ecompany.id,
// etemplate_id: template.id,
// postwxurl: "",
// postsignurl: "",
// appId: reso.data.appId,
// mchtId: reso.data.mchtId,
// mainId: reso.data.mainId,
// key: reso.data.secret,
// });
// } else {
// busi.appId = reso.data.appId;
// busi.mchtId = reso.data.mchtId;
// busi.mainId = reso.data.mainId;
// busi.key = reso.data.secret;
// await busi.save();
// }
return
reso
;
}
catch
(
e
)
{
console
.
log
(
e
.
stack
);
let
result
=
{};
result
.
code
=
-
1
;
result
.
message
=
"操作异常"
;
return
result
;
}
}
async
syncSign
(
contractId
)
{
var
contract
=
await
this
.
dao
.
findById
(
contractId
);
if
(
!
contract
)
{
...
...
@@ -588,7 +761,7 @@ class EntcontractService extends ServiceBase {
entcontract_id
:
entcontract
.
id
,
});
if
(
!
merchantSign
)
{
return
this
.
returnjson
(
500
,
"数据错误"
);
return
this
.
returnjson
(
-
1
,
"数据错误"
);
}
let
res
=
{
...
...
@@ -728,6 +901,195 @@ class EntcontractService extends ServiceBase {
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
async
yzMerchantAutoSigns
(
params
)
{
var
ecid
=
params
.
ecid
;
var
unionId
=
params
.
appId
+
"_"
+
params
.
merchantId
+
"_"
+
params
.
idNo
;
// enttemplate 模板查询
var
enttemplate
=
await
this
.
enttemplateSve
.
findById
(
ecid
);
// entcompany
var
entcompany
=
await
this
.
entcompanyDao
.
findById
(
enttemplate
.
entcompany_id
);
// p_user
var
user
=
await
this
.
userDao
.
findOne
({
unionId
:
unionId
,
});
if
(
!
user
)
{
user
=
await
this
.
userDao
.
create
({
appkey
:
params
.
appId
,
unionId
:
unionId
,
userId3rd
:
params
.
merchantId
,
userName
:
params
.
idName
,
mobile
:
params
.
mobile
,
utype
:
0
,
});
}
// p_user_eaccount
var
eaccount
=
await
this
.
usereaccountDao
.
findOne
({
user_id
:
user
.
id
,
personsSign
:
params
.
idNo
,
})
||
{};
var
isNeedCreate
=
!
eaccount
.
eaccountid
||
eaccount
.
userName
!=
params
.
idName
||
eaccount
.
mobile
!=
params
.
mobile
;
eaccount
.
user_id
=
user
.
id
;
eaccount
.
userName
=
params
.
idName
;
eaccount
.
mobile
=
params
.
mobile
;
eaccount
.
bankno
=
""
;
eaccount
.
personsSign
=
params
.
idNo
;
if
(
eaccount
.
id
)
{
await
eaccount
.
save
();
}
else
{
eaccount
=
await
this
.
usereaccountDao
.
create
(
eaccount
);
}
// c_entcontract
var
entcontract
=
await
this
.
dao
.
findOne
({
eflowstatus
:
'2'
,
usereaccount_id
:
eaccount
.
id
,
enttemplate_id
:
ecid
,
});
if
(
entcontract
)
{
// return this.returnjson(0, "该商户已签约");
let
merchantSign
=
await
this
.
yzmerchantsignedDao
.
findOne
({
entcontract_id
:
entcontract
.
id
,
});
if
(
!
merchantSign
)
{
return
this
.
returnjson
(
-
1
,
"数据错误"
);
}
let
res
=
{
code
:
0
,
msg
:
"执行成功"
,
data
:
{
ecid
:
merchantSign
.
ecid
,
appId
:
merchantSign
.
appId
,
mchtId
:
merchantSign
.
mchtId
,
mainId
:
merchantSign
.
mainId
,
secret
:
merchantSign
.
secret
,
},
};
return
res
;
}
// e签宝流程
if
(
isNeedCreate
)
{
// 任博说有赞商户不验证银行卡三要素
// var bankthreeParams = {
// name: eaccount.userName,
// idno: eaccount.personsSign,
// cardno: eaccount.bankno
// };
// var threeResult = await this.utilesignbaoSve.bankthree(bankthreeParams, "bankinfoAuth");
// console.log("threeResult-----------------------------", threeResult);
// if (!threeResult || threeResult.code == -120) {
// return this.returnjson(-1, "银行三要素(姓名、身份证、银行卡号)验证失败");
// }
// if (threeResult.code == -110) {
// return this.returnjson(-1, "银行三要素验证失败");
// }
var
uidStr
=
await
this
.
getUidStr
(
8
,
36
);
var
thirdId
=
enttemplate
.
id
+
"_"
+
eaccount
.
id
+
uidStr
;
//2.创建e签宝account 5.2.1 , 创建后save()
let
createParams
=
{
thirdId
:
thirdId
,
name
:
eaccount
.
userName
,
idNo
:
eaccount
.
personsSign
,
idType
:
19
,
mobile
:
eaccount
.
mobile
};
var
getAccount
=
await
this
.
utilesignbaoSve
.
createAccountId
(
createParams
,
"econtractSve"
);
if
(
getAccount
&&
getAccount
.
code
==
1
&&
getAccount
.
data
)
{
eaccount
.
eaccountid
=
getAccount
.
data
.
accountId
;
await
eaccount
.
save
();
}
else
{
return
this
.
returnjson
(
-
1
,
"账户创建失败"
);
}
}
// 3.设置静默签署授权 5.2.5
if
(
!
eaccount
.
isGrantAuto
)
{
var
paramsGrant
=
{
grantAccountId
:
eaccount
.
eaccountid
};
var
grantAuto
=
await
this
.
utilesignbaoSve
.
grantAuthorization
(
paramsGrant
,
"econtractSve"
);
if
(
grantAuto
.
code
!=
1
)
{
return
this
.
returnjson
(
-
1
,
"静默签署设置失败"
);
}
eaccount
.
isGrantAuto
=
true
;
await
eaccount
.
save
();
}
// 创建合同
entcontract
=
{
name
:
entcompany
.
name
,
eflowstatusname
:
"签约中"
,
eflowstatus
:
"1"
,
user_id
:
eaccount
.
user_id
,
usereaccount_id
:
eaccount
.
id
,
enttemplate_id
:
enttemplate
.
id
,
entcompany_id
:
entcompany
.
id
,
};
entcontract
=
await
this
.
create
(
entcontract
);
var
sealId
=
entcompany
.
sealId
;
let
today
=
new
Date
().
Format
(
"yyyy"
)
+
"年"
+
new
Date
().
Format
(
"MM"
)
+
"月"
+
new
Date
().
Format
(
"dd"
)
+
"日"
;
var
signParams
=
{
templateId
:
enttemplate
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
enttemplate
.
name
,
//合同模板名称 必填
simpleFormFields
:
{
nameA
:
params
.
merchantName
,
//甲方 必填
addressA
:
params
.
merchantAddr
,
//甲方地址
representA
:
params
.
merchantLegal
,
//甲方法定代表人
agentA
:
params
.
idName
,
//甲方联系人
agentMobileA
:
params
.
mobile
,
//甲方 联系电话
nameB
:
entcompany
.
name
,
//乙方 必填
addressB
:
entcompany
.
addr
,
//乙方 地址
representB
:
entcompany
.
legal
,
//乙方 法定代表人
agentB
:
entcompany
.
contactName
,
//乙方 联系人
agentMobileB
:
entcompany
.
contactMobile
,
//乙方 联系电话
signDate
:
today
,
//签约时间
signDateA
:
today
,
//甲方签约日期 必填
signDateB
:
today
//乙方签约日期 必填
}
};
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
entcontract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
""
;
var
tt
=
await
this
.
utilesignbaoSve
.
userAutoSignContractNoTemplaterEversalSeal
(
signParams
,
ebaoAccountId
,
thirdOrderNo
,
eBaoRedirectBossUrl
,
"econtractSve"
,
sealId
);
if
(
tt
&&
tt
.
data
&&
tt
.
code
==
1
)
{
entcontract
.
eflowid
=
tt
.
data
.
flowId
;
entcontract
.
edocid
=
tt
.
data
.
docId
;
entcontract
.
eflowstatus
=
'2'
;
entcontract
.
eflowstatusname
=
"已完成"
;
var
signTime
=
new
Date
();
entcontract
.
completed_at
=
signTime
;
entcontract
.
begin_at
=
signTime
;
var
end_at
=
new
Date
();
end_at
.
setFullYear
(
end_at
.
getFullYear
()
+
1
);
entcontract
.
end_at
=
end_at
;
await
entcontract
.
save
();
params
.
entcontract_id
=
entcontract
.
id
;
params
.
toAppId
=
enttemplate
.
appid
;
params
.
toMcthid
=
enttemplate
.
mcthid
;
params
.
key
=
enttemplate
.
key
;
// 合同下载任务
this
.
redisClient
.
rpushBCD
({
id
:
entcontract
.
id
,
sve
:
"ent"
});
return
await
this
.
createYzMerchant_1
(
params
);
}
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
returnjson
(
code
,
msg
,
data
)
{
return
{
code
:
code
,
...
...
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