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
251f885f
Commit
251f885f
authored
Feb 14, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
c1215861
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
246 additions
and
186 deletions
+246
-186
bpo-web/app/base/api/impl/yzcontractApi.js
+14
-3
bpo-web/app/base/db/models/ecompanybusi.js
+1
-0
bpo-web/app/base/service/impl/econtractSve.js
+172
-0
bpo-web/app/base/service/impl/entcontractSve.js
+59
-183
No files found.
bpo-web/app/base/api/impl/yzcontractApi.js
View file @
251f885f
...
...
@@ -6,6 +6,9 @@ class YZContractApi {
this
.
entcontractSve
=
system
.
getObject
(
"service.entcontractSve"
);
this
.
idcardClient
=
system
.
getObject
(
"util.idcardClient"
);
this
.
utilesignbaoSve
=
system
.
getObject
(
"service.utilesignbaoSve"
);
this
.
ecompanybusiSve
=
system
.
getObject
(
"service.ecompanybusiSve"
);
this
.
econtractSve
=
system
.
getObject
(
"service.econtractSve"
);
this
.
appId
=
"1201869719607517185"
;
this
.
key
=
"bee7870e008ab144bf518b70ef91f8ac"
;
...
...
@@ -138,6 +141,14 @@ class YZContractApi {
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
();
...
...
@@ -149,15 +160,15 @@ class YZContractApi {
}
signArr
.
push
(
k
+
"="
+
v
);
}
var
signStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
this
.
key
;
var
signStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
busi
.
key
;
var
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
sign
)
console
.
log
(
sign
Str
,
sign
)
if
(
param
.
sign
!=
sign
)
{
return
this
.
returnjson
(
1001001
,
"签名错误"
);
}
try
{
var
result
=
await
this
.
e
ntcontractSve
.
yzPersonAutoSign
(
param
);
var
result
=
await
this
.
e
contractSve
.
autoSignNoBank
(
param
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
bpo-web/app/base/db/models/ecompanybusi.js
View file @
251f885f
...
...
@@ -4,6 +4,7 @@ const uiconfig = system.getUiConfig2(settings.wxconfig.appId);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"ecompanybusi"
,
{
ecompany_id
:
DataTypes
.
INTEGER
,
etemplate_id
:
DataTypes
.
INTEGER
,
appId
:
DataTypes
.
STRING
(
64
),
mainId
:
DataTypes
.
STRING
(
64
),
mchtId
:
DataTypes
.
STRING
(
64
),
...
...
bpo-web/app/base/service/impl/econtractSve.js
View file @
251f885f
...
...
@@ -1613,6 +1613,178 @@ class EcontractService extends ServiceBase {
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
/**
* 静默签 暂时提供给有赞使用
* @param {ecid, appId, userId, idName, mobile, idNo, nonceStr, sign} params
*/
async
autoSignNoBank
(
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
.
user_id
=
user
.
id
;
eaccount
.
userName
=
params
.
idName
;
eaccount
.
mobile
=
params
.
mobile
;
eaccount
.
personsSign
=
params
.
idNo
;
if
(
eaccount
.
id
)
{
await
eaccount
.
save
();
}
else
{
eaccount
=
await
this
.
usereaccountDao
.
create
(
eaccount
);
}
// c_econtract
var
econtract
=
await
this
.
dao
.
findOne
({
eflowstatus
:
'2'
,
usereaccount_id
:
eaccount
.
id
,
etemplate_id
:
ecid
,
});
if
(
econtract
)
{
return
this
.
returnjson
(
0
,
"用户已经签约"
,
{
contractId
:
econtract
.
id
});
}
// 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 怎么赋值????????????
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
);
return
this
.
returnjson
(
0
,
"success"
,
{
contractId
:
econtract
.
id
});
}
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
returnjson
(
code
,
msg
,
data
)
{
return
{
code
:
code
,
...
...
bpo-web/app/base/service/impl/entcontractSve.js
View file @
251f885f
This diff is collapsed.
Click to expand it.
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