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
fb718cff
Commit
fb718cff
authored
Nov 28, 2019
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
013e66d0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
327 additions
and
2 deletions
+327
-2
bpo-web/app/base/api/impl/econtractApi.js
+144
-1
bpo-web/app/base/service/impl/econtractSve.js
+183
-1
No files found.
bpo-web/app/base/api/impl/econtractApi.js
View file @
fb718cff
...
@@ -26,6 +26,11 @@ class EcontractApi {
...
@@ -26,6 +26,11 @@ class EcontractApi {
this
.
smsS
=
system
.
getObject
(
"util.smsClient"
);
this
.
smsS
=
system
.
getObject
(
"util.smsClient"
);
}
}
async
syncSignedFile
()
{
this
.
econtractSve
.
downloadCompleteUrl
();
return
"start success"
}
async
importECompany
(
obj
)
{
async
importECompany
(
obj
)
{
console
.
log
(
obj
,
"===================>>>>>>>>>>>>>>>>>>>>>"
);
console
.
log
(
obj
,
"===================>>>>>>>>>>>>>>>>>>>>>"
);
var
names
=
obj
.
companyNames
;
var
names
=
obj
.
companyNames
;
...
@@ -504,7 +509,7 @@ class EcontractApi {
...
@@ -504,7 +509,7 @@ class EcontractApi {
var
userName
=
obj
.
userName
||
""
;
var
userName
=
obj
.
userName
||
""
;
var
userIdNo
=
obj
.
userIdNo
||
""
;
var
userIdNo
=
obj
.
userIdNo
||
""
;
var
userBankNo
=
obj
.
userBankNo
||
""
;
var
userBankNo
=
obj
.
userBankNo
||
""
;
var
userMobile
=
obj
.
userMobile
||
""
;
var
userMobile
=
obj
.
userMobile
||
""
;
var
nonceStr
=
obj
.
nonceStr
||
""
;
var
nonceStr
=
obj
.
nonceStr
||
""
;
var
sign
=
obj
.
sign
||
""
;
var
sign
=
obj
.
sign
||
""
;
...
@@ -588,6 +593,75 @@ class EcontractApi {
...
@@ -588,6 +593,75 @@ class EcontractApi {
}
}
}
}
async
bankfourTest
(
obj
,
req
)
{
try
{
var
appId
=
obj
.
appId
;
var
userName
=
obj
.
userName
||
""
;
var
userIdNo
=
obj
.
userIdNo
||
""
;
var
userBankNo
=
obj
.
userBankNo
||
""
;
var
userMobile
=
obj
.
userMobile
||
""
;
var
nonceStr
=
obj
.
nonceStr
||
""
;
var
sign
=
obj
.
sign
||
""
;
var
btl
=
await
this
.
bankthreelogSve
.
create
({
appId
:
appId
,
userName
:
userName
,
userIdNo
:
userIdNo
,
userBankNo
:
userBankNo
,
userMobile
:
userMobile
,
nonceStr
:
nonceStr
,
sign
:
sign
,
use_esign
:
false
,
result
:
false
,
});
var
busi
=
await
this
.
ecompanybusiSve
.
findOne
({
appId
:
appId
});
if
(
!
busi
)
{
return
{
code
:
1001003
,
msg
:
"配置信息错误,请联系薪必果人员进行配置"
};
}
var
signArr
=
[];
signArr
.
push
(
"appId="
+
appId
);
signArr
.
push
(
"nonceStr="
+
nonceStr
);
signArr
.
push
(
"userBankNo="
+
userBankNo
);
signArr
.
push
(
"userIdNo="
+
userIdNo
);
signArr
.
push
(
"userMobile="
+
userMobile
);
signArr
.
push
(
"userName="
+
userName
);
signArr
.
push
(
"key="
+
busi
.
key
);
var
calcSign
=
md5
(
signArr
.
join
(
"&"
)).
toUpperCase
();
if
(
sign
!=
calcSign
)
{
return
{
code
:
1
,
msg
:
"签名失败"
};
}
var
bankParams
=
{
name
:
userName
,
//姓名 必填
idno
:
userIdNo
,
//身份证 必填
cardno
:
userBankNo
,
//银行卡 必填
mobile
:
userMobile
,
};
// var tt = await this.utilesignbaoSve.bankfour(bankParams, "econtractapi.bankthree") || {};
var
tt
=
{
code
:
1
};
return
{
code
:
0
,
msg
:
"success"
};
}
catch
(
error
)
{
return
{
code
:
500
,
msg
:
"接口异常"
};
}
}
async
dosync
(
obj
,
req
)
{
async
dosync
(
obj
,
req
)
{
// TODO 需要验证一下合法
// TODO 需要验证一下合法
this
.
econtractSve
.
syncAllSigners
();
this
.
econtractSve
.
syncAllSigners
();
...
@@ -685,6 +759,75 @@ class EcontractApi {
...
@@ -685,6 +759,75 @@ class EcontractApi {
}
}
}
}
async
autoSignTest
(
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
),
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
.
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
();
if
(
param
.
sign
!=
sign
)
{
return
this
.
returnjson
(
1001001
,
"签名错误"
);
}
try
{
var
result
=
await
this
.
econtractSve
.
autoSignTest
(
param
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
async
formateTime
(
inputTime
)
{
async
formateTime
(
inputTime
)
{
if
(
!
inputTime
)
{
if
(
!
inputTime
)
{
return
''
;
return
''
;
...
...
bpo-web/app/base/service/impl/econtractSve.js
View file @
fb718cff
...
@@ -830,7 +830,6 @@ class EcontractService extends ServiceBase {
...
@@ -830,7 +830,6 @@ class EcontractService extends ServiceBase {
var
sql
=
[];
var
sql
=
[];
sql
.
push
(
"SELECT t1.id,t1.begin_at as beginDate,t1.end_at as endDate,"
);
sql
.
push
(
"SELECT t1.id,t1.begin_at as beginDate,t1.end_at as endDate,"
);
sql
.
push
(
"t2.userName AS idName, t2.mobile ,t2.`personsSign` AS idNo, t1.completed_at AS signTime, t2.bankno AS bankNo,"
);
sql
.
push
(
"t2.userName AS idName, t2.mobile ,t2.`personsSign` AS idNo, t1.completed_at AS signTime, t2.bankno AS bankNo,"
);
// sql.push("t3.userId3rd, t3.userCode3rd, t3.branchCode3rd");
sql
.
push
(
"t3.userId3rd, t3.userCode3rd, t3.branchCode3rd, t1.fileurl AS fileUrl"
);
sql
.
push
(
"t3.userId3rd, t3.userCode3rd, t3.branchCode3rd, t1.fileurl AS fileUrl"
);
sql
.
push
(
"FROM c_econtract t1"
);
sql
.
push
(
"FROM c_econtract t1"
);
sql
.
push
(
"INNER JOIN p_user_eaccount t2 ON t1.`usereaccount_id` = t2.`id`"
);
sql
.
push
(
"INNER JOIN p_user_eaccount t2 ON t1.`usereaccount_id` = t2.`id`"
);
...
@@ -1362,12 +1361,195 @@ class EcontractService extends ServiceBase {
...
@@ -1362,12 +1361,195 @@ class EcontractService extends ServiceBase {
econtract
.
end_at
=
end_at
;
econtract
.
end_at
=
end_at
;
await
econtract
.
save
();
await
econtract
.
save
();
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
*/
async
autoSignTest
(
params
)
{
var
ecid
=
params
.
ecid
;
var
unionId
=
params
.
appId
+
"_"
+
params
.
userId
;
// ecid etemplate
var
etemplate
=
await
this
.
etemplateSve
.
findById
(
ecid
);
// ecompany
var
ecompany
=
await
this
.
ecompanyDao
.
findById
(
etemplate
.
ecompany_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
.
userId
,
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
);
}
}
var
econtract
;
// c_econtract
// econtract = await this.dao.findOne({
// eflowstatus: '2',
// usereaccount_id: eaccount.id,
// etemplate_id: ecid,
// });
// e签宝流程
if
(
isNeedCreate
)
{
// var bankthreeParams = {
// name: eaccount.userName,
// idno: eaccount.personsSign,
// cardno: eaccount.bankno
// };
// var threeResult = await this.utilesignbaoSve.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, "银行三要素验证失败");
// }
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 怎么赋值????????????
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
(
"f50d8f8cdd8d4bcda6b1aaad1d4b14bf"
,
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
();
return
this
.
returnjson
(
0
,
"success"
,
{
contractId
:
econtract
.
id
});
}
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
}
returnjson
(
code
,
msg
,
data
)
{
returnjson
(
code
,
msg
,
data
)
{
...
...
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