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
fce83d88
Commit
fce83d88
authored
Jun 22, 2020
by
zhaoxiqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
8f8aaa8a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
199 additions
and
230 deletions
+199
-230
bpo-web/app/base/api/impl/econtractApi.js
+0
-212
bpo-web/app/base/service/impl/econtractSve.js
+0
-0
bpo-web/app/base/service/impl/utilesignbaoSve.js
+179
-18
bpo-web/app/base/service/impl/utillbwSve.js
+20
-0
No files found.
bpo-web/app/base/api/impl/econtractApi.js
View file @
fce83d88
...
...
@@ -1147,218 +1147,6 @@ 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
)
{
// 处理参数
...
...
bpo-web/app/base/service/impl/econtractSve.js
View file @
fce83d88
This diff is collapsed.
Click to expand it.
bpo-web/app/base/service/impl/utilesignbaoSve.js
View file @
fce83d88
...
...
@@ -2,11 +2,13 @@ var System = require("../../system");
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../config/settings"
);
const
logCtl
=
System
.
getObject
(
"web.oplogCtl"
);
const
crypto
=
require
(
'crypto'
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
fs
=
require
(
"fs"
);
const
axios
=
require
(
'axios'
);
const
moment
=
require
(
"moment"
);
const
md5
=
require
(
"MD5"
);
const
crypto
=
require
(
'crypto'
);
const
Qs
=
require
(
'qs'
);
//工商查询操作
...
...
@@ -16,6 +18,11 @@ class UtilESignBaoService {
this
.
eSignBaoBankVerifyUrl
=
settings
.
apiconfig
.
eSignBaoBankVerifyUrl
();
this
.
restClient
=
System
.
getObject
(
"util.restClient"
);
this
.
ossClient
=
System
.
getObject
(
"util.ossClient"
);
this
.
lbwConfig
=
settings
.
apiconfig
.
lbwConfig
();
this
.
restClient
=
System
.
getObject
(
"util.restClient"
);
this
.
merchantId
=
"131032002020009"
;
//商户ID
this
.
idauthlogDao
=
System
.
getObject
(
"db.idauthlogDao"
)
}
//-------------------------------------------------------------------------e签宝银行四要素、三要素验证---开始----------------
...
...
@@ -48,6 +55,71 @@ class UtilESignBaoService {
}
async
bankthree
(
params
,
opName
)
{
//三要素验证
// console.log(opName, "兰铂旺三要素验证");
// var result = {
// code: 1,
// message: "success",
// data: {}
// };
// var merchantTraceNo = await this.getRandomCode(32);
// var merchantRequestTime = moment().format("YYYY-MM-DD HH:mm:ss");
// var bizType = "010102"; //业务类型,010112(精准)010102(非精准)
//
// var encrypt = {
// "idType": "01",
// "pan": params.cardno,//卡号,
// "idNum": params.idno,//证件号,
// "chName": params.name,//姓名
// };
// var encryptStr = JSON.stringify(encrypt);
// var str = crypto.privateEncrypt(this.lbwConfig.pik, Buffer.from(encryptStr)).toString('base64');
// var paramMap = {};
// paramMap.merchantId = this.merchantId;
// paramMap.bizType = bizType;
// paramMap.merchantTraceNo = merchantTraceNo;
// paramMap.merchantRequestTime = merchantRequestTime;
// paramMap.encrypt = str;
//
// var signStr = await this.sortParam(paramMap);
// var sign = md5(signStr);
//
// var list = {
// "merchantId": this.merchantId,
// "bizType": bizType,
// "merchantTraceNo": merchantTraceNo,
// "merchantRequestTime": merchantRequestTime,
// "encrypt": str,
// "sign": sign
// }
// console.log("请求参数=", list);
// let rs = await axios({
// url: this.lbwConfig.validate_bank,
// method: 'post',
// data: list,
// transformRequest: [function (data) {
// data = Qs.stringify(data);
// return data;
// }],
// headers: {"Content-Type": "application/x-www-form-urlencoded"},
// });
// console.log("返回状态===", rs.status);
// console.log("返回参数===", rs.data);
// this.idauthlogDao.create({
// userName: params.name,
// userIdNo: params.idno,
// userBankNo: params.cardno,
// result: result.code
// });
// if (rs.status === 200 && rs.data) {
// if (rs.data.respCode != '00000000') { //验证通过
// result.code = -120;
// }
// return result;
// }
// result.code = -110;
// return result;
var
result
=
{
code
:
1
,
message
:
"success"
,
...
...
@@ -73,32 +145,97 @@ class UtilESignBaoService {
result
.
data
=
tResult
.
data
;
return
result
;
}
//
async
bankfour
(
params
,
opName
)
{
//四要素验证
console
.
log
(
opName
,
"兰铂旺四要素验证"
);
var
result
=
{
code
:
1
,
message
:
"success"
,
data
:
{}
};
var
reqUrl
=
this
.
eSignBaoBankVerifyUrl
+
"/infoauth/psn/bankfour"
;
var
tResult
=
await
this
.
returnResult
(
params
,
reqUrl
,
opName
,
"createAccountId"
,
result
);
if
(
tResult
.
errCode
!=
0
)
{
result
.
code
=
-
110
;
if
(
tResult
.
message
&&
tResult
.
message
.
indexOf
(
":"
)
>
0
)
{
var
tmpListStr
=
tResult
.
message
.
split
(
':'
);
result
.
message
=
tmpListStr
[
1
]
?
tmpListStr
[
1
]
:
tmpListStr
[
0
];
}
else
{
result
.
message
=
"接口请求错误"
;
var
merchantTraceNo
=
await
this
.
getRandomCode
(
32
);
var
merchantRequestTime
=
moment
().
format
(
"YYYY-MM-DD HH:mm:ss"
);
var
bizType
=
"010103"
;
//业务类型,010113(精准)010103(非精准)
var
encrypt
=
{
"idType"
:
"01"
,
"pan"
:
params
.
cardno
,
//卡号,
"idNum"
:
params
.
idno
,
//证件号,
"chName"
:
params
.
name
,
//姓名
"chTel"
:
params
.
mobile
,
//手机号
};
var
encryptStr
=
JSON
.
stringify
(
encrypt
);
var
str
=
crypto
.
privateEncrypt
(
this
.
lbwConfig
.
pik
,
Buffer
.
from
(
encryptStr
)).
toString
(
'base64'
);
var
paramMap
=
{};
paramMap
.
merchantId
=
this
.
merchantId
;
paramMap
.
bizType
=
bizType
;
paramMap
.
merchantTraceNo
=
merchantTraceNo
;
paramMap
.
merchantRequestTime
=
merchantRequestTime
;
paramMap
.
encrypt
=
str
;
var
signStr
=
await
this
.
sortParam
(
paramMap
);
var
sign
=
md5
(
signStr
);
var
list
=
{
"merchantId"
:
this
.
merchantId
,
"bizType"
:
bizType
,
"merchantTraceNo"
:
merchantTraceNo
,
"merchantRequestTime"
:
merchantRequestTime
,
"encrypt"
:
str
,
"sign"
:
sign
}
console
.
log
(
"请求参数="
,
list
);
let
rs
=
await
axios
({
url
:
this
.
lbwConfig
.
validate_bank
,
method
:
'post'
,
data
:
list
,
transformRequest
:
[
function
(
data
)
{
data
=
Qs
.
stringify
(
data
);
return
data
;
}],
headers
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
},
});
console
.
log
(
"返回状态==="
,
rs
.
status
);
console
.
log
(
"返回参数==="
,
rs
.
data
);
this
.
idauthlogDao
.
create
({
userName
:
params
.
name
,
userIdNo
:
params
.
idno
,
userBankNo
:
params
.
cardno
,
userMobile
:
params
.
mobile
,
result
:
result
.
code
});
if
(
rs
.
status
===
200
&&
rs
.
data
)
{
if
(
rs
.
data
.
respCode
!=
'00000000'
)
{
//验证通过
result
.
code
=
-
120
;
}
return
result
;
}
if
(
tResult
.
errCode
==
0
&&
tResult
.
data
&&
!
tResult
.
data
.
pass
)
{
result
.
code
=
-
120
;
result
.
message
=
"亲,提供的信息不正确,请验证后再试!"
;
return
result
;
}
result
.
data
=
tResult
.
data
;
result
.
code
=
-
110
;
return
result
;
// var result = {
// code: 1,
// message: "success",
// data: {}
// };
// var reqUrl = this.eSignBaoBankVerifyUrl + "/infoauth/psn/bankfour";
// var tResult = await this.returnResult(params, reqUrl, opName, "createAccountId", result);
// if (tResult.errCode != 0) {
// result.code = -110;
// if (tResult.message && tResult.message.indexOf(":") > 0) {
// var tmpListStr = tResult.message.split(':');
// result.message = tmpListStr[1] ? tmpListStr[1] : tmpListStr[0];
// } else {
// result.message = "接口请求错误";
// }
// return result;
// }
// if (tResult.errCode == 0 && tResult.data && !tResult.data.pass) {
// result.code = -120;
// result.message = "亲,提供的信息不正确,请验证后再试!";
// return result;
// }
// result.data = tResult.data;
// return result;
}
//-------------------------------------------------------------------------e签宝银行四要素、三要素验证---结束----------------
...
...
@@ -1191,5 +1328,29 @@ class UtilESignBaoService {
return
result
;
}
}
async
sortParam
(
paramMap
)
{
var
signArr
=
[];
var
keys
=
Object
.
keys
(
paramMap
).
sort
();
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
var
k
=
keys
[
i
];
var
v
=
paramMap
[
k
];
if
(
!
k
||
!
v
||
k
==
'sign'
)
{
continue
;
}
signArr
.
push
(
k
+
"="
+
v
);
}
var
signStr
=
signArr
.
join
(
","
);
return
signStr
;
}
async
getRandomCode
(
iun
)
{
var
randStr
=
""
;
for
(
var
i
=
0
;
i
<
iun
;
i
++
)
{
//此处的12为生成12位数字,可随即更改
var
randItem
=
Math
.
floor
(
Math
.
random
()
*
10
);
randStr
+=
randItem
;
}
return
randStr
;
}
}
module
.
exports
=
UtilESignBaoService
;
bpo-web/app/base/service/impl/utillbwSve.js
View file @
fce83d88
...
...
@@ -16,6 +16,7 @@ class UitlLBWService {
this
.
lbwConfig
=
settings
.
apiconfig
.
lbwConfig
();
this
.
restClient
=
System
.
getObject
(
"util.restClient"
);
this
.
merchantId
=
"131032002020009"
;
//商户ID
this
.
idauthlogDao
=
System
.
getObject
(
"db.idauthlogDao"
)
}
async
bankTwo
(
params
,
opName
){
//二要素(姓名、银行卡号)
...
...
@@ -64,6 +65,7 @@ class UitlLBWService {
}],
headers
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
},
});
console
.
log
(
"返回状态==="
,
rs
.
status
);
console
.
log
(
"返回参数==="
,
rs
.
data
);
if
(
rs
.
status
===
200
&&
rs
.
data
)
{
...
...
@@ -73,6 +75,11 @@ class UitlLBWService {
return
result
;
}
result
.
code
=
-
110
;
this
.
idauthlogDao
.
create
({
userName
:
params
.
name
,
userBankNo
:
params
.
cardno
,
result
:
result
.
code
});
return
result
;
}
...
...
@@ -134,6 +141,12 @@ class UitlLBWService {
return
result
;
}
result
.
code
=
-
110
;
this
.
idauthlogDao
.
create
({
userName
:
params
.
idName
,
userIdNo
:
params
.
idNo
,
userBankNo
:
params
.
bankno
,
result
:
result
.
code
});
return
result
;
}
...
...
@@ -194,6 +207,13 @@ class UitlLBWService {
return
result
;
}
result
.
code
=
-
110
;
this
.
idauthlogDao
.
create
({
userName
:
params
.
idName
,
userIdNo
:
params
.
idNo
,
userBankNo
:
params
.
bankno
,
userMobile
:
params
.
mobile
,
result
:
result
.
code
});
return
result
;
}
...
...
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