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
ab7fb774
Commit
ab7fb774
authored
Jun 16, 2020
by
zhaoxiqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
a69054e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
600 additions
and
1 deletions
+600
-1
bpo-web/app/base/api/impl/econtractApi.js
+212
-0
bpo-web/app/base/service/impl/econtractSve.js
+388
-1
No files found.
bpo-web/app/base/api/impl/econtractApi.js
View file @
ab7fb774
...
@@ -1091,6 +1091,218 @@ class EcontractApi {
...
@@ -1091,6 +1091,218 @@ class EcontractApi {
}
}
}
}
//三要素验证
async
autoSigntoLbw
(
pobj
)
{
// 处理参数
var
param
=
{
ecid
:
this
.
trim
(
pobj
.
ecid
),
appId
:
this
.
trim
(
pobj
.
appId
),
userId
:
this
.
trim
(
pobj
.
userId
),
idName
:
this
.
trim
(
pobj
.
idName
),
mobile
:
this
.
trim
(
pobj
.
mobile
),
idNo
:
this
.
trim
(
pobj
.
idNo
),
bankno
:
this
.
trim
(
pobj
.
bankno
),
nonceStr
:
this
.
trim
(
pobj
.
nonceStr
),
userCode
:
this
.
trim
(
pobj
.
userCode
),
//用户code-韵达
branchCode
:
this
.
trim
(
pobj
.
branchCode
),
//韵达分公司ID
sign
:
this
.
trim
(
pobj
.
sign
)
};
if
(
!
param
.
ecid
)
{
return
this
.
returnjson
(
-
1
,
"请传入薪必果提供的ecid"
)
}
if
(
!
param
.
appId
)
{
return
this
.
returnjson
(
-
1
,
"请传入薪必果提供的appId"
)
}
if
(
!
param
.
userId
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户的userId"
)
}
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
busiIds
=
await
this
.
etemplatebusiSve
.
busiIdsByTemplateId
(
param
.
ecid
);
let
num
=
await
this
.
esettleSve
.
isValidAge
(
busiIds
);
if
(
num
)
{
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
.
bankno
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户银行卡号"
)
}
if
(
!
param
.
nonceStr
)
{
return
this
.
returnjson
(
-
1
,
"请提供随机码"
)
}
// 查appId关联key
var
busi
=
await
this
.
ecompanybusiSve
.
findOne
({
appId
:
param
.
appId
});
if
(
!
busi
||
!
busi
.
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="
+
busi
.
key
;
var
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
signStr
,
sign
);
if
(
param
.
sign
!=
sign
)
{
return
this
.
returnjson
(
1001001
,
"签名错误"
);
}
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
econtractSve
.
autoSigntoLbw
(
param
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
//四要素验证
async
autoSign4toLbw
(
pobj
)
{
// 处理参数
var
param
=
{
ecid
:
this
.
trim
(
pobj
.
ecid
),
appId
:
this
.
trim
(
pobj
.
appId
),
userId
:
this
.
trim
(
pobj
.
userId
),
idName
:
this
.
trim
(
pobj
.
idName
),
mobile
:
this
.
trim
(
pobj
.
mobile
),
idNo
:
this
.
trim
(
pobj
.
idNo
),
bankno
:
this
.
trim
(
pobj
.
bankno
),
nonceStr
:
this
.
trim
(
pobj
.
nonceStr
),
userCode
:
this
.
trim
(
pobj
.
userCode
),
//用户code-韵达
branchCode
:
this
.
trim
(
pobj
.
branchCode
),
//韵达分公司ID
sign
:
this
.
trim
(
pobj
.
sign
)
};
if
(
!
param
.
ecid
)
{
return
this
.
returnjson
(
-
1
,
"请传入薪必果提供的ecid"
)
}
if
(
!
param
.
appId
)
{
return
this
.
returnjson
(
-
1
,
"请传入薪必果提供的appId"
)
}
if
(
!
param
.
userId
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户的userId"
)
}
if
(
!
param
.
idName
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户姓名"
)
}
if
(
!
param
.
idNo
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户身份证号"
)
}
if
(
!
param
.
mobile
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户手机号"
)
}
if
(
!
await
this
.
idcardClient
.
checkIDCard
(
param
.
idNo
))
{
return
this
.
returnjson
(
-
1
,
"身份证格式不正确"
);
}
let
busiIds
=
await
this
.
etemplatebusiSve
.
busiIdsByTemplateId
(
param
.
ecid
);
let
num
=
await
this
.
esettleSve
.
isValidAge
(
busiIds
);
if
(
num
)
{
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
.
bankno
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户银行卡号"
)
}
if
(
!
param
.
nonceStr
)
{
return
this
.
returnjson
(
-
1
,
"请提供随机码"
)
}
// 查appId关联key
var
busi
=
await
this
.
ecompanybusiSve
.
findOne
({
appId
:
param
.
appId
});
if
(
!
busi
||
!
busi
.
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="
+
busi
.
key
;
var
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
signStr
,
sign
);
if
(
param
.
sign
!=
sign
)
{
return
this
.
returnjson
(
1001001
,
"签名错误"
);
}
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
econtractSve
.
autoSign4toLbw
(
param
);
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
//不带三要素验证
//不带三要素验证
async
autoSignNo3rd
(
pobj
)
{
async
autoSignNo3rd
(
pobj
)
{
// 处理参数
// 处理参数
...
...
bpo-web/app/base/service/impl/econtractSve.js
View file @
ab7fb774
...
@@ -1483,6 +1483,198 @@ class EcontractService extends ServiceBase {
...
@@ -1483,6 +1483,198 @@ class EcontractService extends ServiceBase {
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
}
async
autoSigntoLbw
(
params
)
{
let
ecid
=
params
.
ecid
;
// 验证身份证是否签约过
let
todays
=
moment
().
format
(
"YYYY-MM-DD"
)
+
" 00:00:00"
;
let
contractId
=
await
this
.
dao
.
findSignedContractId
({
idno
:
params
.
idNo
,
ecid
:
ecid
,
today
:
todays
})
||
0
;
if
(
contractId
)
{
return
this
.
returnjson
(
0
,
"用户已经签约"
,
{
contractId
:
contractId
});
}
let
banklog
=
await
this
.
bankthreelogDao
.
findOne
({
userName
:
params
.
idName
,
userIdNo
:
params
.
idNo
,
userBankNo
:
params
.
bankno
,
result
:
1
,
});
if
(
!
banklog
)
{
var
bankthreeParams
=
{
name
:
params
.
idName
,
idno
:
params
.
idNo
,
cardno
:
params
.
bankno
};
var
threeResult
=
await
this
.
utillbwSve
.
bankthree
(
bankthreeParams
,
"bankinfoAuth"
);
// {"code":-110,"message":"手机号格式错误","data":{}}
//1成功,-110提示验证信息有误,-120亲,提供的信息不正确,请验证后再试!
console
.
log
(
"threeResult-----------------------------"
,
threeResult
);
if
(
!
threeResult
||
threeResult
.
code
==
-
120
)
{
return
this
.
returnjson
(
-
1
,
"银行三要素(姓名、身份证、银行卡号)验证失败"
);
}
if
(
threeResult
.
code
==
-
110
)
{
return
this
.
returnjson
(
-
1
,
"银行三要素验证失败"
);
}
}
// ecid etemplate
var
etemplate
=
await
this
.
etemplateSve
.
findById
(
ecid
);
// ecompany
var
ecompany
=
await
this
.
ecompanyDao
.
findById
(
etemplate
.
ecompany_id
);
// p_user
var
unionId
=
params
.
appId
+
"_"
+
params
.
userId
+
params
.
userCode
+
params
.
branchCode
;
var
user
=
await
this
.
userDao
.
findOne
({
unionId
:
unionId
,
});
if
(
!
user
)
{
user
=
await
this
.
userDao
.
create
({
appkey
:
params
.
appId
,
unionId
:
unionId
,
userId3rd
:
params
.
userId
,
userCode3rd
:
params
.
userCode
,
branchCode3rd
:
params
.
branchCode
,
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
.
bankno
!=
params
.
bankno
;
eaccount
.
user_id
=
user
.
id
;
eaccount
.
userName
=
params
.
idName
;
eaccount
.
mobile
=
params
.
mobile
;
eaccount
.
bankno
=
params
.
bankno
;
eaccount
.
personsSign
=
params
.
idNo
;
if
(
eaccount
.
id
)
{
await
eaccount
.
save
();
}
else
{
eaccount
=
await
this
.
usereaccountDao
.
create
(
eaccount
);
}
// e签宝流程
if
(
isNeedCreate
)
{
var
uidStr
=
await
this
.
getUidStr
(
8
,
36
);
var
thirdId
=
etemplate
.
id
+
"_"
+
eaccount
.
id
+
uidStr
;
//2.创建e签宝account 5.2.1 , 创建后save()
var
params
=
{
thirdId
:
thirdId
,
name
:
eaccount
.
userName
,
idNo
:
eaccount
.
personsSign
,
idType
:
19
,
mobile
:
eaccount
.
mobile
};
var
getAccount
=
await
this
.
utilesignbaoSve
.
createAccountId
(
params
,
"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
();
}
// 创建合同 fileurl、esignUrl 怎么赋值????????????
let
econtract
=
{
name
:
ecompany
.
name
,
eflowstatusname
:
"签约中"
,
eflowstatus
:
"1"
,
// begin_at: now,
// completed_at: now,
user_id
:
eaccount
.
user_id
,
usereaccount_id
:
eaccount
.
id
,
etemplate_id
:
etemplate
.
id
,
ecompany_id
:
ecompany
.
id
,
// end_at: end,
};
econtract
=
await
this
.
create
(
econtract
);
// 创建印章id
var
sealId
=
""
;
var
eseal
=
await
this
.
esealSve
.
findOne
({
nameA
:
etemplate
.
nameA
});
// 生产环境需要打开
if
(
!
eseal
)
{
var
rs
=
await
this
.
utilesignbaoSve
.
creatEntSignet
(
settings
.
apiconfig
.
companyAccountId
(),
etemplate
.
nameA
+
"alias"
,
etemplate
.
nameA
,
""
,
""
,
"econtractSve"
);
// var rs = await this.utilesignbaoSve.creatEntSignet("740b19e0799a4d7abacfa1a31fb72b1e", etemplate.nameA + "alias", etemplate.nameA, "", "", "econtractSve");
if
(
rs
&&
rs
.
code
==
1
)
{
sealId
=
rs
.
data
.
sealId
;
await
this
.
esealSve
.
create
({
nameA
:
etemplate
.
nameA
,
sealId
:
sealId
,
});
}
else
{
return
this
.
returnjson
(
-
1
,
"生成印章错误"
);
}
}
else
{
sealId
=
eseal
.
sealId
;
}
let
today
=
new
Date
().
Format
(
"yyyy-MM-dd"
);
var
signParams
=
{
templateId
:
etemplate
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
ecompany
.
name
,
//合同模板名称 必填
simpleFormFields
:
{
nameA
:
etemplate
.
nameA
,
//甲方 必填
nameB
:
eaccount
.
userName
,
//乙方 必填
unit
:
ecompany
.
name
,
//合作单位(国美) 必填---------------------------超出长度风险---目前不知多少长度
signDateA
:
today
,
//甲方签约日期 必填
signDateB
:
today
//乙方签约日期 必填
}
};
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
econtract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
""
;
var
tt
=
await
this
.
utilesignbaoSve
.
userAutoSignContractNoTemplate
(
signParams
,
ebaoAccountId
,
thirdOrderNo
,
eBaoRedirectBossUrl
,
"econtractSve"
,
sealId
);
if
(
tt
&&
tt
.
data
&&
tt
.
code
==
1
)
{
econtract
.
eflowid
=
tt
.
data
.
flowId
;
econtract
.
edocid
=
tt
.
data
.
docId
;
econtract
.
eflowstatus
=
'2'
;
econtract
.
eflowstatusname
=
"已完成"
;
var
signTime
=
new
Date
();
econtract
.
completed_at
=
signTime
;
econtract
.
begin_at
=
signTime
;
var
end_at
=
new
Date
();
end_at
.
setFullYear
(
end_at
.
getFullYear
()
+
1
);
econtract
.
end_at
=
end_at
;
await
econtract
.
save
();
this
.
syncSign
(
econtract
.
id
);
// TODO DOWNLOAD OK
this
.
redisClient
.
rpushBCD
({
id
:
econtract
.
id
,
sve
:
"e"
});
return
this
.
returnjson
(
0
,
"success"
,
{
contractId
:
econtract
.
id
});
}
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
/**
/**
* 静默签 四要素验证
* 静默签 四要素验证
* @param {ecid, appId, userId, idName, mobile, idNo, bankno, nonceStr, sign} params
* @param {ecid, appId, userId, idName, mobile, idNo, bankno, nonceStr, sign} params
...
@@ -1681,6 +1873,201 @@ class EcontractService extends ServiceBase {
...
@@ -1681,6 +1873,201 @@ class EcontractService extends ServiceBase {
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
}
async
autoSign4toLbw
(
params
)
{
var
ecid
=
params
.
ecid
;
// 验证身份证是否签约过
let
todays
=
moment
().
format
(
"YYYY-MM-DD"
)
+
" 00:00:00"
;
let
contractId
=
await
this
.
dao
.
findSignedContractId
({
idno
:
params
.
idNo
,
ecid
:
ecid
,
today
:
todays
})
||
0
;
if
(
contractId
)
{
return
this
.
returnjson
(
0
,
"用户已经签约"
,
{
contractId
:
contractId
});
}
let
banklog
=
await
this
.
bankthreelogDao
.
findOne
({
userName
:
params
.
idName
,
userIdNo
:
params
.
idNo
,
userBankNo
:
params
.
bankno
,
userMobile
:
params
.
mobile
,
result
:
1
,
});
if
(
!
banklog
)
{
var
bankthreeParams
=
{
name
:
params
.
idName
,
idno
:
params
.
idNo
,
cardno
:
params
.
bankno
,
mobile
:
params
.
mobile
};
var
threeResult
=
await
this
.
utillbwSve
.
bankfour
(
bankthreeParams
,
"bankinfoAuth"
);
// {"code":-110,"message":"手机号格式错误","data":{}}
//1成功,-110提示验证信息有误,-120亲,提供的信息不正确,请验证后再试!
console
.
log
(
"threeResult-----------------------------"
,
threeResult
);
if
(
!
threeResult
||
threeResult
.
code
==
-
120
)
{
return
this
.
returnjson
(
-
1
,
"银行四要素(姓名、身份证、银行卡号、手机号)验证失败"
);
}
if
(
threeResult
.
code
==
-
110
)
{
return
this
.
returnjson
(
-
1
,
"银行四要素验证失败"
);
}
}
// ecid etemplate
var
etemplate
=
await
this
.
etemplateSve
.
findById
(
ecid
);
// ecompany
var
ecompany
=
await
this
.
ecompanyDao
.
findById
(
etemplate
.
ecompany_id
);
// p_user
var
unionId
=
params
.
appId
+
"_"
+
params
.
userId
+
params
.
userCode
+
params
.
branchCode
;
var
user
=
await
this
.
userDao
.
findOne
({
unionId
:
unionId
,
});
if
(
!
user
)
{
user
=
await
this
.
userDao
.
create
({
appkey
:
params
.
appId
,
unionId
:
unionId
,
userId3rd
:
params
.
userId
,
userCode3rd
:
params
.
userCode
,
branchCode3rd
:
params
.
branchCode
,
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
.
bankno
!=
params
.
bankno
;
eaccount
.
user_id
=
user
.
id
;
eaccount
.
userName
=
params
.
idName
;
eaccount
.
mobile
=
params
.
mobile
;
eaccount
.
bankno
=
params
.
bankno
;
eaccount
.
personsSign
=
params
.
idNo
;
if
(
eaccount
.
id
)
{
await
eaccount
.
save
();
}
else
{
eaccount
=
await
this
.
usereaccountDao
.
create
(
eaccount
);
}
// e签宝流程
if
(
isNeedCreate
)
{
var
uidStr
=
await
this
.
getUidStr
(
8
,
36
);
var
thirdId
=
etemplate
.
id
+
"_"
+
eaccount
.
id
+
uidStr
;
//2.创建e签宝account 5.2.1 , 创建后save()
var
params
=
{
thirdId
:
thirdId
,
name
:
eaccount
.
userName
,
idNo
:
eaccount
.
personsSign
,
idType
:
19
,
mobile
:
eaccount
.
mobile
};
var
getAccount
=
await
this
.
utilesignbaoSve
.
createAccountId
(
params
,
"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
();
}
// 创建合同 fileurl、esignUrl 怎么赋值????????????
let
econtract
=
{
name
:
ecompany
.
name
,
eflowstatusname
:
"签约中"
,
eflowstatus
:
"1"
,
// begin_at: now,
// completed_at: now,
user_id
:
eaccount
.
user_id
,
usereaccount_id
:
eaccount
.
id
,
etemplate_id
:
etemplate
.
id
,
ecompany_id
:
ecompany
.
id
,
// end_at: end,
};
econtract
=
await
this
.
create
(
econtract
);
// 创建印章id
var
sealId
=
""
;
var
eseal
=
await
this
.
esealSve
.
findOne
({
nameA
:
etemplate
.
nameA
});
// 生产环境需要打开
if
(
!
eseal
)
{
// var accountId = ""; // 测试
var
rs
=
await
this
.
utilesignbaoSve
.
creatEntSignet
(
settings
.
apiconfig
.
companyAccountId
(),
etemplate
.
nameA
+
"alias"
,
etemplate
.
nameA
,
""
,
""
,
"econtractSve"
);
// var rs = await this.utilesignbaoSve.creatEntSignet("740b19e0799a4d7abacfa1a31fb72b1e", etemplate.nameA + "alias", etemplate.nameA, "", "", "econtractSve");
if
(
rs
&&
rs
.
code
==
1
)
{
sealId
=
rs
.
data
.
sealId
;
await
this
.
esealSve
.
create
({
nameA
:
etemplate
.
nameA
,
sealId
:
sealId
,
});
}
else
{
return
this
.
returnjson
(
-
1
,
"生成印章错误"
);
}
}
else
{
sealId
=
eseal
.
sealId
;
}
let
today
=
new
Date
().
Format
(
"yyyy-MM-dd"
);
var
signParams
=
{
templateId
:
etemplate
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
ecompany
.
name
,
//合同模板名称 必填
simpleFormFields
:
{
nameA
:
etemplate
.
nameA
,
//甲方 必填
nameB
:
eaccount
.
userName
,
//乙方 必填
unit
:
ecompany
.
name
,
//合作单位(国美) 必填---------------------------超出长度风险---目前不知多少长度
signDateA
:
today
,
//甲方签约日期 必填
signDateB
:
today
//乙方签约日期 必填
}
};
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
econtract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
""
;
var
tt
=
await
this
.
utilesignbaoSve
.
userAutoSignContractNoTemplate
(
signParams
,
ebaoAccountId
,
thirdOrderNo
,
eBaoRedirectBossUrl
,
"econtractSve"
,
sealId
);
if
(
tt
&&
tt
.
data
&&
tt
.
code
==
1
)
{
econtract
.
eflowid
=
tt
.
data
.
flowId
;
econtract
.
edocid
=
tt
.
data
.
docId
;
econtract
.
eflowstatus
=
'2'
;
econtract
.
eflowstatusname
=
"已完成"
;
var
signTime
=
new
Date
();
econtract
.
completed_at
=
signTime
;
econtract
.
begin_at
=
signTime
;
var
end_at
=
new
Date
();
end_at
.
setFullYear
(
end_at
.
getFullYear
()
+
1
);
econtract
.
end_at
=
end_at
;
await
econtract
.
save
();
this
.
syncSign
(
econtract
.
id
);
// TODO DOWNLOAD OK
this
.
redisClient
.
rpushBCD
({
id
:
econtract
.
id
,
sve
:
"e"
});
return
this
.
returnjson
(
0
,
"success"
,
{
contractId
:
econtract
.
id
});
}
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
/**
/**
* 静默签 不带三要素验证
* 静默签 不带三要素验证
* @param {ecid, appId, userId, idName, mobile, idNo, bankno, nonceStr, sign} params
* @param {ecid, appId, userId, idName, mobile, idNo, bankno, nonceStr, sign} params
...
@@ -2468,7 +2855,7 @@ class EcontractService extends ServiceBase {
...
@@ -2468,7 +2855,7 @@ class EcontractService extends ServiceBase {
idno
:
eaccount
.
personsSign
,
idno
:
eaccount
.
personsSign
,
};
};
var
threeResult
=
await
this
.
util
lbwSve
.
bank
Two
(
vparam
,
"autoSignPT"
);
var
threeResult
=
await
this
.
util
esignbaoSve
.
person
Two
(
vparam
,
"autoSignPT"
);
console
.
log
(
"threeResult-----------------------------"
,
threeResult
);
console
.
log
(
"threeResult-----------------------------"
,
threeResult
);
if
(
!
threeResult
||
threeResult
.
code
==
-
120
)
{
if
(
!
threeResult
||
threeResult
.
code
==
-
120
)
{
return
this
.
returnjson
(
-
1
,
"银行儿要素(姓名、身份证)验证失败"
);
return
this
.
returnjson
(
-
1
,
"银行儿要素(姓名、身份证)验证失败"
);
...
...
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