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
b9209ea6
Commit
b9209ea6
authored
Dec 03, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'测试代码提交'
parent
5e07bf8e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
368 additions
and
6 deletions
+368
-6
bpo-web/app/base/api/impl/econtractApi.js
+1
-0
bpo-web/app/base/api/impl/signContractApi.js
+169
-0
bpo-web/app/base/controller/impl/dksignCtl.js
+22
-1
bpo-web/app/base/controller/impl/econtractCtl.js
+12
-1
bpo-web/app/base/db/models/dktemplate.js
+1
-0
bpo-web/app/base/db/models/etemplate.js
+1
-1
bpo-web/app/base/service/impl/dkcontractSve.js
+162
-3
bpo-web/app/base/service/impl/econtractSve.js
+0
-0
No files found.
bpo-web/app/base/api/impl/econtractApi.js
View file @
b9209ea6
...
...
@@ -295,6 +295,7 @@ class EcontractApi {
userId3rd
:
userId
,
userCode3rd
:
userCode
,
branchCode3rd
:
branchCode
,
etemplate_id
:
busi
.
etemplate_id
,
};
try
{
...
...
bpo-web/app/base/api/impl/signContractApi.js
0 → 100644
View file @
b9209ea6
var
system
=
require
(
"../../system"
)
const
md5
=
require
(
"MD5"
);
const
uuidv1
=
require
(
'uuid/v1'
);
class
SignContractApi
{
constructor
()
{
this
.
redisLock
=
system
.
getObject
(
"util.redisLock"
);
this
.
dkcontractSve
=
system
.
getObject
(
"service.dkcontractSve"
);
this
.
idcardClient
=
system
.
getObject
(
"util.idcardClient"
);
this
.
esettleSve
=
system
.
getObject
(
"service.esettleSve"
);
this
.
etemplatebusiSve
=
system
.
getObject
(
"service.etemplatebusiSve"
);
this
.
ecompanybusiSve
=
system
.
getObject
(
"service.ecompanybusiSve"
);
}
//签约完成参数:
//专票(三要素)
//普票(二要素)
async
signParams
(
pobj
)
{
// 处理参数
var
param
=
{
ecid
:
this
.
trim
(
pobj
.
ecid
),
appId
:
this
.
trim
(
pobj
.
appId
),
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
),
userId
:
this
.
trim
(
pobj
.
userId
),
sign
:
this
.
trim
(
pobj
.
sign
),
fileurl
:
this
.
trim
(
pobj
.
fileurl
)
};
// 查appId关联key
var
busi
=
await
this
.
ecompanybusiSve
.
findOne
({
appId
:
param
.
appId
,
etemplate_id
:
param
.
ecid
});
if
(
!
busi
||
!
busi
.
key
)
{
return
this
.
returnjson
(
1001003
,
"配置信息错误,请联系薪必果人员进行配置"
);
}
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
,
"身份证格式不正确"
);
}
if
(
!
param
.
nonceStr
)
{
return
this
.
returnjson
(
-
1
,
"请提供随机码"
)
}
if
(
!
param
.
fileurl
)
{
return
this
.
returnjson
(
-
1
,
"请提供签约合同地址"
)
}
// 签名
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
(
'dkcontractApi---autoSign--签名'
,
param
.
sign
,
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
.
dkcontractSve
.
signParams
(
param
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
async
signingQuerytoPer
(
obj
,
req
)
{
let
appId
=
obj
.
appId
;
let
ecid
=
obj
.
ecid
;
let
nonceStr
=
obj
.
nonceStr
;
let
userName
=
obj
.
userName
;
let
idNo
=
obj
.
idNo
;
let
busi
=
await
this
.
ecompanybusiSve
.
findOne
({
appId
:
appId
,
etemplate_id
:
ecid
});
if
(
!
busi
)
{
return
{
code
:
1001003
,
msg
:
"配置信息错误,请联系薪必果人员进行配置"
};
}
let
signArr
=
[];
signArr
.
push
(
"appId="
+
appId
);
signArr
.
push
(
"ecid="
+
ecid
);
signArr
.
push
(
"idNo="
+
idNo
);
signArr
.
push
(
"nonceStr="
+
nonceStr
);
if
(
userName
){
signArr
.
push
(
"userName="
+
userName
);
}
signArr
.
push
(
"key="
+
busi
.
key
);
let
signStr
=
signArr
.
join
(
"&"
)
let
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
signStr
,
sign
);
if
(
sign
!=
obj
.
sign
)
{
return
{
code
:
1001001
,
msg
:
"签名失败"
};
}
try
{
let
user
=
await
this
.
dkcontractSve
.
signingQuerytoPer
({
ecid
:
ecid
,
userName
:
userName
,
idNo
:
idNo
});
let
result
=
{
code
:
0
,
msg
:
"success"
,
data
:
user
};
return
result
;
}
catch
(
e
)
{
let
result
=
{
code
:
500
,
msg
:
"接口异常"
};
console
.
log
(
e
.
stack
);
return
result
;
}
}
returnjson
(
code
,
msg
,
data
)
{
return
{
code
:
code
,
msg
:
msg
,
data
:
data
||
null
}
}
trim
(
o
)
{
if
(
!
o
)
{
return
""
;
}
return
o
.
toString
().
trim
();
}
}
module
.
exports
=
SignContractApi
;
bpo-web/app/base/controller/impl/dksignCtl.js
View file @
b9209ea6
...
...
@@ -37,7 +37,7 @@ class DKSignCtl {
var
dktemplate
=
await
this
.
dktemplateSve
.
getInfo
(
tid
);
var
domain
=
"http://bpohhr.gongsibao.com"
;
// var domain = "http://192.168.18.125:3000
";
//var domain = "127.0.0.1:3001
";
if
(
!
dktemplate
||
!
dktemplate
.
dkaggreement
)
{
return
domain
+
"/errpage?errmsg="
+
encodeURIComponent
(
encodeURIComponent
(
"参数错误"
));
}
...
...
@@ -286,6 +286,7 @@ class DKSignCtl {
"usereaccount_id"
:
eaccount_id
,
"eflowstatus"
:
"1"
});
if
(
!
contract
)
{
contract
=
{
name
:
dkcompany
.
name
,
...
...
@@ -302,6 +303,9 @@ class DKSignCtl {
}
else
{
}
var
signdate
=
moment
().
format
(
"YYYY/MM/DD"
);
if
(
dktemplate
.
isnew
==
1
){
var
params
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
...
...
@@ -322,6 +326,23 @@ class DKSignCtl {
signdate
:
signdate
,
// 签约日期
}
};
}
else
{
var
params
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
simpleFormFields
:
{
nameA
:
dkcompany
.
name
,
//甲方 必填
nameB
:
eaccount
.
userName
,
//乙方姓名 必填
iphone
:
eaccount
.
mobile
,
// 乙方电话
idNo
:
eaccount
.
personsSign
,
// 乙方身份证
signDateA
:
signdate
,
signDateB
:
signdate
,
// 签约日期
}
};
}
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
"dk_"
+
contract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
"https://bpohhr.gongsibao.com/tsign?ecid="
+
dktemplate
.
id
+
"&cb=1#/ecompany/tsigned"
;
...
...
bpo-web/app/base/controller/impl/econtractCtl.js
View file @
b9209ea6
...
...
@@ -323,11 +323,22 @@ class EcontractCtl extends CtlBase {
simpleFormFields
:
{
nameA
:
nameA
,
//甲方 必填
nameB
:
eaccount
.
userName
,
//乙方 必填
unit
:
company
.
name
,
//合作单位(国美) 必填---------------------------超出长度风险---目前不知多少长度
signDateA
:
today
,
//甲方签约日期 必填
signDateB
:
today
//乙方签约日期 必填
}
};
if
(
etemplate
.
isnew
==
1
){
params
.
simpleFormFields
.
unit
=
company
.
name
;
//合作单位(国美) 必填---------------------------超出长度风险---目前不知多少长度
}
if
(
etemplate
.
isnew
!=
1
){
console
.
log
(
"==============================================新合同"
,
eaccount
)
params
.
simpleFormFields
.
iphone
=
eaccount
.
mobile
;
params
.
simpleFormFields
.
idNo
=
eaccount
.
personsSign
;
}
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
contract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
this
.
eSignBaoRedirectBossUrl
+
"?ecid="
+
etemplate
.
id
+
"&cb=1#/ecompany/signed"
;
...
...
bpo-web/app/base/db/models/dktemplate.js
View file @
b9209ea6
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"dktemplate"
,
{
isnew
:
DataTypes
.
INTEGER
,
dkaggreement_id
:
DataTypes
.
INTEGER
,
dkcompany_id
:
DataTypes
.
INTEGER
,
name
:
DataTypes
.
STRING
(
50
),
...
...
bpo-web/app/base/db/models/etemplate.js
View file @
b9209ea6
...
...
@@ -8,7 +8,7 @@ module.exports = (db, DataTypes) => {
ecompanyMainId
:
DataTypes
.
INTEGER
,
mainId
:
DataTypes
.
STRING
(
64
),
nameA
:
DataTypes
.
STRING
(
50
),
isnew
:
DataTypes
.
INTEGER
,
templateid
:
{
type
:
DataTypes
.
STRING
,
// e签宝模板id
defaultValue
:
""
...
...
bpo-web/app/base/service/impl/dkcontractSve.js
View file @
b9209ea6
...
...
@@ -559,7 +559,9 @@ class DKcontractService extends ServiceBase {
dkecontract
=
await
this
.
create
(
dkecontract
);
var
dkaggreement
=
await
this
.
dkaggreementDao
.
findById
(
etemplate
.
dkaggreement_id
);
var
params
=
{
if
(
etemplate
.
isnew
==
1
){
var
signParams
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
...
...
@@ -579,12 +581,27 @@ class DKcontractService extends ServiceBase {
signdate
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
}
};
}
else
{
var
signParams
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
simpleFormFields
:
{
nameA
:
dkcompany
.
name
,
//甲方 必填
nameB
:
params
.
idName
,
//乙方姓名 必填
idNo
:
params
.
idNo
,
// 乙方身份证
signDateA
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
signDateB
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
}
};
}
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
"dk_"
+
dkecontract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
""
;
var
sealId
=
dkcompany
.
sealId
;
let
tt
=
await
this
.
utilesignbaoSve
.
userAutoSignContractNoTemplate
(
p
arams
,
ebaoAccountId
,
thirdOrderNo
,
eBaoRedirectBossUrl
,
"econtractSve"
,
sealId
);
let
tt
=
await
this
.
utilesignbaoSve
.
userAutoSignContractNoTemplate
(
signP
arams
,
ebaoAccountId
,
thirdOrderNo
,
eBaoRedirectBossUrl
,
"econtractSve"
,
sealId
);
console
.
log
(
"-============= result ==========================="
,
tt
);
if
(
tt
&&
tt
.
data
&&
tt
.
code
==
1
)
{
dkecontract
.
eflowid
=
tt
.
data
.
flowId
;
...
...
@@ -610,12 +627,113 @@ class DKcontractService extends ServiceBase {
return
this
.
returnjson
(
-
1
,
tt
.
message
||
"签约失败"
,
tt
.
code
);
}
async
signParams
(
params
)
{
var
ecid
=
params
.
ecid
;
var
unionId
=
params
.
appId
+
"_"
+
params
.
ecid
+
"_"
+
params
.
idNo
;
// ecid dketemplate
var
etemplate
=
await
this
.
dktemplateSve
.
findById
(
ecid
);
// dkecompany
var
dkcompany
=
await
this
.
dkcompanyDao
.
findById
(
etemplate
.
dkcompany_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
,
})
||
{};
eaccount
.
user_id
=
user
.
id
;
eaccount
.
userName
=
params
.
idName
;
eaccount
.
mobile
=
params
.
mobile
;
eaccount
.
bankno
=
params
.
bankno
;
eaccount
.
personsSign
=
params
.
idNo
;
eaccount
.
isGrantAuto
=
true
;
if
(
eaccount
.
id
)
{
await
eaccount
.
save
();
}
else
{
eaccount
=
await
this
.
usereaccountDao
.
create
(
eaccount
);
}
// c_dkecontract
var
dkecontract
=
await
this
.
dao
.
findOne
({
eflowstatus
:
'2'
,
usereaccount_id
:
eaccount
.
id
,
dktemplate_id
:
ecid
,
});
if
(
dkecontract
)
{
return
this
.
returnjson
(
0
,
"用户签约信息已添加"
,
{
contractId
:
dkecontract
.
id
});
}
var
signTime
=
new
Date
();
var
end_at
=
new
Date
();
end_at
.
setFullYear
(
end_at
.
getFullYear
()
+
1
);
dkecontract
=
{
name
:
dkcompany
.
name
,
dktemplate_id
:
ecid
,
user_id
:
user
.
id
,
usereaccount_id
:
eaccount
.
id
,
dkcompany_id
:
dkcompany
.
id
,
eflowstatus
:
"2"
,
fileurl
:
params
.
fileurl
,
completed_at
:
signTime
,
begin_at
:
signTime
,
end_at
:
end_at
}
dkecontract
=
await
this
.
create
(
dkecontract
);
return
this
.
returnjson
(
0
,
"success"
,
{
contractId
:
dkecontract
.
id
});
}
async
signingQuerytoPer
(
params
)
{
let
sql
=
[];
sql
.
push
(
"SELECT t1.id,t1.begin_at AS beginDate,t1.end_at AS endDate,t2.userName AS idName,t2.mobile,t2.`personsSign` AS idNo,t1.completed_at AS signTime,t2.bankno AS bankNo,t1.fileurl AS fileUrl "
)
sql
.
push
(
"FROM c_dkcontract t1 INNER JOIN p_user_eaccount t2 ON t1.`usereaccount_id` = t2.`id` "
)
sql
.
push
(
"WHERE t1.`dktemplate_id` = :ecid AND t1.`eflowstatus` = '2' AND t1.`end_at` >= NOW() AND t2.`personsSign` = :idNo "
)
if
(
params
.
userName
)
{
sql
.
push
(
"AND t2.userName = :userName"
);
}
let
list
=
await
this
.
dao
.
customQuery
(
sql
.
join
(
" "
),
params
);
if
(
!
list
||
list
.
length
==
0
)
{
return
null
;
}
for
(
var
item
of
list
)
{
item
.
signTime
=
await
this
.
formateTime
(
item
.
signTime
);
item
.
beginDate
=
await
this
.
formateTime
(
item
.
beginDate
);
item
.
endDate
=
await
this
.
formateTime
(
item
.
endDate
);
}
return
list
[
0
];
}
async
autoSignNew
(
params
)
{
let
ecid
=
params
.
ecid
;
let
unionId
=
params
.
appId
+
"_"
+
params
.
idNo
;
let
todays
=
moment
().
format
(
"YYYY-MM-DD"
)
+
" 00:00:00"
;
let
contractId
=
await
this
.
dao
.
findSignedContractId
({
idno
:
params
.
idNo
,
ecid
:
ecid
,
today
:
todays
})
||
0
;
let
contractId
=
await
this
.
dao
.
findSignedContractId
({
idno
:
params
.
idNo
,
ecid
:
ecid
,
today
:
todays
})
||
0
;
if
(
contractId
)
{
return
this
.
returnjson
(
0
,
"用户已经签约"
,
{
contractId
:
contractId
...
...
@@ -709,6 +827,8 @@ class DKcontractService extends ServiceBase {
dkecontract
=
await
this
.
create
(
dkecontract
);
var
dkaggreement
=
await
this
.
dkaggreementDao
.
findById
(
etemplate
.
dkaggreement_id
);
if
(
etemplate
.
isnew
==
1
){
var
contractParams
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
...
...
@@ -729,6 +849,24 @@ class DKcontractService extends ServiceBase {
signdate
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
}
};
}
else
{
var
contractParams
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
simpleFormFields
:
{
nameA
:
dkcompany
.
name
,
//甲方 必填
nameB
:
eaccount
.
userName
,
//乙方姓名 必填
iphone
:
eaccount
.
mobile
,
//乙方电话 必填
idNo
:
eaccount
.
personsSign
,
// 乙方身份证
signDateA
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
signDateB
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
}
};
}
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
"dk_"
+
dkecontract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
""
;
...
...
@@ -807,6 +945,10 @@ class DKcontractService extends ServiceBase {
dkecontract
=
await
this
.
create
(
dkecontract
);
var
dkaggreement
=
await
this
.
dkaggreementDao
.
findById
(
etemplate
.
dkaggreement_id
);
if
(
etemplate
.
isnew
==
1
){
var
contractParams
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
...
...
@@ -827,6 +969,23 @@ class DKcontractService extends ServiceBase {
signdate
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
}
};
}
else
{
var
contractParams
=
{
templateId
:
dkaggreement
.
templateid
,
//模板id,由创建模板接口调用返回的templateId 必填
name
:
dkcompany
.
name
,
//合同模板名称 必填
simpleFormFields
:
{
nameA
:
dkcompany
.
name
,
//甲方 必填
nameB
:
eaccount
.
userName
,
//乙方姓名 必填
iphone
:
eaccount
.
mobile
,
//乙方电话 必填
idNo
:
eaccount
.
personsSign
,
// 乙方身份证
signDateA
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
signDateB
:
moment
().
format
(
"YYYY/MM/DD"
),
// 签约日期
}
};
}
var
ebaoAccountId
=
eaccount
.
eaccountid
;
//签署人账户id-- 必填
var
thirdOrderNo
=
"dk_"
+
dkecontract
.
id
;
//第三方流水号,通知回调使用---选填
var
eBaoRedirectBossUrl
=
""
;
...
...
bpo-web/app/base/service/impl/econtractSve.js
View file @
b9209ea6
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