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
dbeebcd6
Commit
dbeebcd6
authored
Aug 28, 2020
by
DESKTOP-7Q3CA17\86137
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
58aeeaa5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
266 additions
and
3 deletions
+266
-3
bpo-web/app/base/api/impl/gemaApi.js
+96
-2
bpo-web/app/base/db/models/qbgconfig.js
+2
-0
bpo-web/app/base/service/impl/qbgconfigSve.js
+168
-1
No files found.
bpo-web/app/base/api/impl/gemaApi.js
View file @
dbeebcd6
...
@@ -13,6 +13,101 @@ class GemaApi {
...
@@ -13,6 +13,101 @@ class GemaApi {
}
}
// //三要素验证
// async autoSign(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 (!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.bankno) {
// return this.returnjson(-1, "请提供该用户银行卡号")
// }
// if (!param.nonceStr) {
// return this.returnjson(-1, "请提供随机码")
// }
//
// // 查appId关联key
// var qbg = await this.qbgconfigSve.findOne({
// appId: param.appId
// });
// if (!qbg || !qbg.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=" + qbg.key;
// var sign = md5(signStr).toUpperCase();
// console.log("---autoSign---签名---", signStr, sign);
// if (param.sign != sign) {
// return this.returnjson(1001001, `签名错误`);
// }
//
// try {
// param.idNo = param.idNo.toUpperCase();
// param.bankno = param.bankno.replace(/\s*/g, "");
// var key = param.idNo + "_" + param.ecid
// const id = uuidv1();
// await this.redisLock.lock(key, id, 20);
// var result = await this.qbgconfigSve.autoSign(param,qbg);
// await this.redisLock.unLock(key, id);
// return result;
// } catch (error) {
// console.log(error);
// }
// }
//三要素验证
//三要素验证
async
autoSign
(
pobj
)
{
async
autoSign
(
pobj
)
{
// 处理参数
// 处理参数
...
@@ -94,14 +189,13 @@ class GemaApi {
...
@@ -94,14 +189,13 @@ class GemaApi {
if
(
param
.
sign
!=
sign
)
{
if
(
param
.
sign
!=
sign
)
{
return
this
.
returnjson
(
1001001
,
`签名错误`
);
return
this
.
returnjson
(
1001001
,
`签名错误`
);
}
}
try
{
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
param
.
bankno
=
param
.
bankno
.
replace
(
/
\s
*/g
,
""
);
param
.
bankno
=
param
.
bankno
.
replace
(
/
\s
*/g
,
""
);
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
qbgconfigSve
.
autoSign
(
param
,
qbg
);
var
result
=
await
this
.
qbgconfigSve
.
autoSign
s
(
param
,
qbg
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
return
result
;
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
bpo-web/app/base/db/models/qbgconfig.js
View file @
dbeebcd6
...
@@ -8,6 +8,8 @@ module.exports = (db, DataTypes) => {
...
@@ -8,6 +8,8 @@ module.exports = (db, DataTypes) => {
initiator_account
:
DataTypes
.
STRING
,
initiator_account
:
DataTypes
.
STRING
,
merchant_name
:
DataTypes
.
STRING
,
merchant_name
:
DataTypes
.
STRING
,
ecompany_name
:
DataTypes
.
STRING
,
ecompany_name
:
DataTypes
.
STRING
,
phoneA
:
DataTypes
.
STRING
,
addressA
:
DataTypes
.
STRING
,
ecompany_id
:
DataTypes
.
INTEGER
,
ecompany_id
:
DataTypes
.
INTEGER
,
},{
},{
paranoid
:
true
,
//假的删除
paranoid
:
true
,
//假的删除
...
...
bpo-web/app/base/service/impl/qbgconfigSve.js
View file @
dbeebcd6
...
@@ -9,6 +9,7 @@ class QbgconfigService extends ServiceBase {
...
@@ -9,6 +9,7 @@ class QbgconfigService extends ServiceBase {
constructor
()
{
constructor
()
{
super
(
ServiceBase
.
getDaoName
(
QbgconfigService
));
super
(
ServiceBase
.
getDaoName
(
QbgconfigService
));
this
.
econtractDao
=
system
.
getObject
(
"db.econtractDao"
)
this
.
econtractDao
=
system
.
getObject
(
"db.econtractDao"
)
this
.
dkcontractDao
=
system
.
getObject
(
"db.dkcontractDao"
)
this
.
userDao
=
system
.
getObject
(
"db.userDao"
)
this
.
userDao
=
system
.
getObject
(
"db.userDao"
)
this
.
usereaccountDao
=
system
.
getObject
(
"db.usereaccountDao"
)
this
.
usereaccountDao
=
system
.
getObject
(
"db.usereaccountDao"
)
this
.
API
=
settings
.
signApi
();
this
.
API
=
settings
.
signApi
();
...
@@ -19,7 +20,7 @@ class QbgconfigService extends ServiceBase {
...
@@ -19,7 +20,7 @@ class QbgconfigService extends ServiceBase {
/**
/**
* 静默签
带三要素验证
* 静默签
普票
* @param {ecid, appId, userId, idName, mobile, idNo, bankno, nonceStr, sign} params
* @param {ecid, appId, userId, idName, mobile, idNo, bankno, nonceStr, sign} params
*/
*/
async
autoSign
(
params
,
qbg
)
{
async
autoSign
(
params
,
qbg
)
{
...
@@ -182,6 +183,172 @@ class QbgconfigService extends ServiceBase {
...
@@ -182,6 +183,172 @@ class QbgconfigService extends ServiceBase {
}
}
return
this
.
returnjson
(
-
1
,
econtr
.
data
.
msg
||
"签约失败"
,
econtr
.
data
.
status
);
return
this
.
returnjson
(
-
1
,
econtr
.
data
.
msg
||
"签约失败"
,
econtr
.
data
.
status
);
}
}
async
autoSigns
(
params
,
qbg
)
{
let
ecid
=
params
.
ecid
;
// 验证身份证是否签约过
let
todays
=
moment
().
format
(
"YYYY-MM-DD"
)
+
" 00:00:00"
;
let
contractId
=
await
this
.
dkcontractDao
.
findSignedContractId
({
idno
:
params
.
idNo
,
ecid
:
ecid
,
today
:
todays
})
||
0
;
if
(
contractId
)
{
return
this
.
returnjson
(
0
,
"用户已经签约"
,
{
contractId
:
contractId
});
}
//1、三要素验证
var
bankthreeParamss
=
{
appId
:
params
.
appId
,
timestamp
:
new
Date
().
getTime
(),
nonceStr
:
params
.
nonceStr
,
idName
:
params
.
idName
,
idNo
:
params
.
idNo
,
bankNo
:
params
.
bankno
}
bankthreeParamss
.
sign
=
await
this
.
getsign
(
bankthreeParamss
,
qbg
.
key
);
let
bankthrees
=
await
axios
({
method
:
'post'
,
url
:
this
.
API
.
bankThree
,
data
:
bankthreeParamss
,
});
console
.
log
(
"三要素收费三要素请求返回==================================================="
,
bankthrees
);
if
(
bankthrees
.
data
.
status
==
0
&&
!
bankthrees
.
data
.
data
.
pass
)
{
return
this
.
returnjson
(
-
1
,
bankthrees
.
data
.
msg
);
}
//2、 创建账户--p_user
var
unionId
=
params
.
appId
+
"_"
+
params
.
ecid
+
"_"
+
params
.
userId
;
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
;
if
(
eaccount
.
id
)
{
await
eaccount
.
save
();
}
else
{
eaccount
=
await
this
.
usereaccountDao
.
create
(
eaccount
);
}
//创建账户
if
(
eaccount
.
id
&&
!
eaccount
.
eaccountid
)
{
var
createAccount
=
{
appId
:
params
.
appId
,
timestamp
:
new
Date
().
getTime
(),
nonceStr
:
params
.
nonceStr
,
idName
:
params
.
idName
,
idNo
:
params
.
idNo
,
mobile
:
params
.
mobile
}
createAccount
.
sign
=
await
this
.
getsign
(
createAccount
,
qbg
.
key
);
let
qbgaccount
=
await
axios
({
method
:
'post'
,
url
:
this
.
API
.
createAccount
,
data
:
createAccount
,
});
console
.
log
(
qbgaccount
)
if
(
qbgaccount
.
data
.
status
==
0
&&
!
qbgaccount
.
data
.
data
.
accountId
)
{
return
this
.
returnjson
(
-
1
,
bankthrees
.
data
.
msg
);
}
eaccount
.
eaccountid
=
qbgaccount
.
data
.
data
.
accountId
;
eaccount
.
save
();
}
var
today
=
moment
().
format
(
"YYYY-MM-DD"
)
//发起签署
var
toecontract
=
{
appId
:
params
.
appId
,
nonceStr
:
params
.
nonceStr
,
timestamp
:
new
Date
().
getTime
(),
initiatorAccountId
:
qbg
.
initiator_account
,
accountId
:
eaccount
.
eaccountid
,
channel
:
1
,
entSealId
:
qbg
.
seal_id
,
contractName
:
qbg
.
merchant_name
,
simpleFormFields
:
{
nameA
:
qbg
.
merchant_name
,
addressA
:
qbg
.
addressA
,
phoneA
:
qbg
.
phoneA
,
nameB
:
params
.
idName
,
phoneB
:
params
.
mobile
,
nameC
:
params
.
idName
,
banknoC
:
params
.
bankno
,
phoneC
:
params
.
mobile
,
idcardC
:
params
.
idNo
,
signdate
:
today
,
},
templateId
:
params
.
ecid
}
var
sign
=
await
this
.
getsign
(
toecontract
,
qbg
.
key
)
toecontract
.
sign
=
sign
;
console
.
log
(
toecontract
)
let
econtr
=
await
axios
({
method
:
'post'
,
url
:
this
.
API
.
autoSign
,
data
:
toecontract
,
});
console
.
log
(
econtr
)
// 创建合同
let
dkecontract
=
{
name
:
qbg
.
merchant_name
,
dktemplate_id
:
qbg
.
template_id
,
user_id
:
eaccount
.
user_id
,
usereaccount_id
:
eaccount
.
id
,
dkcompany_id
:
qbg
.
ecompany_id
,
edocid
:
""
,
eflowid
:
""
,
esignUrl
:
""
,
eflowstatus
:
"1"
,
}
dkecontract
=
await
this
.
dkcontractDao
.
create
(
dkecontract
);
if
(
econtr
&&
econtr
.
data
&&
econtr
.
data
.
status
==
0
)
{
dkecontract
.
eflowid
=
econtr
.
data
.
data
.
flowId
;
dkecontract
.
edocid
=
econtr
.
data
.
data
.
docId
;
dkecontract
.
eflowstatus
=
'2'
;
dkecontract
.
eflowstatusname
=
"已完成"
;
var
signTime
=
new
Date
();
dkecontract
.
completed_at
=
signTime
;
dkecontract
.
begin_at
=
signTime
;
var
end_at
=
new
Date
();
end_at
.
setFullYear
(
end_at
.
getFullYear
()
+
1
);
dkecontract
.
end_at
=
end_at
;
await
dkecontract
.
save
();
this
.
redisClient
.
rpushBCD
({
id
:
dkecontract
.
id
,
sve
:
"e"
});
return
this
.
returnjson
(
0
,
"success"
,
{
contractId
:
dkecontract
.
id
});
}
return
this
.
returnjson
(
-
1
,
econtr
.
data
.
msg
||
"签约失败"
,
econtr
.
data
.
status
);
}
async
getsign
(
params
,
secret
)
{
async
getsign
(
params
,
secret
)
{
...
...
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