Commit 6a5e8621 by DESKTOP-7Q3CA17\86137

gsb

parent 0c6000be
...@@ -794,6 +794,7 @@ class EcontractApi { ...@@ -794,6 +794,7 @@ class EcontractApi {
signArr.push("userName=" + userName); signArr.push("userName=" + userName);
signArr.push("key=" + busi.key); signArr.push("key=" + busi.key);
var calcSign = md5(signArr.join("&")).toUpperCase(); var calcSign = md5(signArr.join("&")).toUpperCase();
console.log("银行卡四要素验证密钥++++++++++++++++++++++++++++++》",calcSign);
if (sign != calcSign) { if (sign != calcSign) {
return { return {
code: 1, code: 1,
......
...@@ -76,7 +76,8 @@ class GemaApi { ...@@ -76,7 +76,8 @@ class GemaApi {
// 查appId关联key // 查appId关联key
var qbg = await this.qbgconfigSve.findOne({ var qbg = await this.qbgconfigSve.findOne({
appId: param.appId appId: param.appId,
xbg_ecid: param.ecid
}); });
if (!qbg || !qbg.key) { if (!qbg || !qbg.key) {
return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置"); return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置");
......
...@@ -14,108 +14,106 @@ class QbgecontractApi { ...@@ -14,108 +14,106 @@ class QbgecontractApi {
} }
// /** /**
// * 两方电子签 * 三方电子签(二要素)
// * @param pobj */
// * @returns {Promise<{msg: *, code: *, data: (*|null)}|{msg: *, code: *, data}|*|{msg: *, code: *, data}>} async signToTwoElement(pobj) {
// */ // 处理参数
// async autoSign(pobj) { var param = {
// // 处理参数 ecid: this.trim(pobj.ecid),
// var param = { appId: this.trim(pobj.appId),
// ecid: this.trim(pobj.ecid), userId: this.trim(pobj.userId),
// appId: this.trim(pobj.appId), idName: this.trim(pobj.idName),
// userId: this.trim(pobj.userId), idNo: this.trim(pobj.idNo),
// idName: this.trim(pobj.idName), nonceStr: this.trim(pobj.nonceStr),
// mobile: this.trim(pobj.mobile), sign: this.trim(pobj.sign)
// idNo: this.trim(pobj.idNo), };
// bankno: this.trim(pobj.bankno),
// nonceStr: this.trim(pobj.nonceStr), if (!param.ecid) {
// sign: this.trim(pobj.sign) return this.returnjson(-1, "请传入薪必果提供的ecid")
// }; }
// if (!param.appId) {
// if (!param.ecid) { return this.returnjson(-1, "请传入薪必果提供的appId")
// return this.returnjson(-1, "请传入薪必果提供的ecid") }
// } if (!param.userId) {
// if (!param.appId) { return this.returnjson(-1, "请提供该用户的userId")
// return this.returnjson(-1, "请传入薪必果提供的appId") }
// } if (!param.idName) {
// if (!param.userId) { return this.returnjson(-1, "请提供该用户姓名")
// return this.returnjson(-1, "请提供该用户的userId") }
// } if (!param.idNo) {
// if (!param.idName) { return this.returnjson(-1, "请提供该用户身份证号")
// return this.returnjson(-1, "请提供该用户姓名") }
// } if (!await this.idcardClient.checkIDCard(param.idNo)) {
// if (!param.idNo) { return this.returnjson(-1, "身份证格式不正确");
// return this.returnjson(-1, "请提供该用户身份证号") }
// }
// if (!await this.idcardClient.checkIDCard(param.idNo)) { let card = await this.idcardClient.cardInfo(param.idNo);
// return this.returnjson(-1, "身份证格式不正确"); let age = card.age || 0;
// } if (!age) {
// return this.returnjson(-1, "身份证号格式错误, 只支持18位身份证号码");
// let card = await this.idcardClient.cardInfo(param.idNo); }
// let age = card.age || 0; if (card.sex == 'male') {
// if (!age) { if (age < 18 || age > 60) {
// return this.returnjson(-1, "身份证号格式错误, 只支持18位身份证号码"); return this.returnjson(-1, "签约失败,男限制18-60岁之间")
// } }
// if (card.sex == 'male') { } else {
// if (age < 18 || age > 60) { if (age < 18 || age > 55) {
// return this.returnjson(-1, "签约失败,男限制18-60岁之间") return this.returnjson(-1, "签约失败,女限制18-55岁之间")
// } }
// } else { }
// if (age < 18 || age > 55) {
// return this.returnjson(-1, "签约失败,女限制18-55岁之间") if (!param.bankno) {
// } return this.returnjson(-1, "请提供该用户银行卡号")
// } }
// if (!param.nonceStr) {
// if (!param.bankno) { return this.returnjson(-1, "请提供随机码")
// return this.returnjson(-1, "请提供该用户银行卡号") }
// }
// if (!param.nonceStr) { // 查appId关联key
// return this.returnjson(-1, "请提供随机码") var qbg = await this.qbgconfigSve.findOne({
// } appId: param.appId,
// xbg_ecid: param.ecid
// // 查appId关联key });
// var qbg = await this.qbgconfigSve.findOne({ if (!qbg || !qbg.key) {
// appId: param.appId return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置");
// }); }
// 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 signArr = []; var k = keys[i];
// var keys = Object.keys(param).sort(); var v = param[k];
// for (var i = 0; i < keys.length; i++) { if (!k || !v || k == 'sign') {
// var k = keys[i]; continue;
// var v = param[k]; }
// if (!k || !v || k == 'sign') { signArr.push(k + "=" + v);
// continue; }
// } var signStr = signArr.join("&") + "&key=" + qbg.key;
// signArr.push(k + "=" + v); var sign = md5(signStr).toUpperCase();
// } console.log("---autoSign---签名---", signStr, sign);
// var signStr = signArr.join("&") + "&key=" + qbg.key; if (param.sign != sign) {
// var sign = md5(signStr).toUpperCase(); return this.returnjson(1001001, `签名错误`);
// console.log("---autoSign---签名---", signStr, sign); }
// if (param.sign != sign) {
// return this.returnjson(1001001, `签名错误`); try {
// } param.idNo = param.idNo.toUpperCase();
// try { param.bankno = param.bankno.replace(/\s*/g, "");
// param.idNo = param.idNo.toUpperCase(); var key = param.idNo + "_" + param.ecid
// param.bankno = param.bankno.replace(/\s*/g, ""); const id = uuidv1();
// var key = param.idNo + "_" + param.ecid await this.redisLock.lock(key, id, 20);
// const id = uuidv1(); var result = await this.qbgconfigSve.autoSign(param, qbg);
// await this.redisLock.lock(key, id, 20); await this.redisLock.unLock(key, id);
// var result = await this.qbgconfigSve.autoSigns(param, qbg); return result;
// await this.redisLock.unLock(key, id); } catch (error) {
// return result; console.log(error);
// } catch (error) { }
// console.log(error); }
// }
// }
/** /**
* 三方电子签 * 三方电子签(三要素)
*/ */
async autoSign(pobj) { async autoSign(pobj) {
// 处理参数 // 处理参数
...@@ -174,7 +172,8 @@ class QbgecontractApi { ...@@ -174,7 +172,8 @@ class QbgecontractApi {
// 查appId关联key // 查appId关联key
var qbg = await this.qbgconfigSve.findOne({ var qbg = await this.qbgconfigSve.findOne({
appId: param.appId appId: param.appId,
xbg_ecid: param.ecid
}); });
if (!qbg || !qbg.key) { if (!qbg || !qbg.key) {
return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置"); return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置");
...@@ -204,7 +203,105 @@ class QbgecontractApi { ...@@ -204,7 +203,105 @@ class QbgecontractApi {
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(param, qbg);
await this.redisLock.unLock(key, id);
return result;
} catch (error) {
console.log(error);
}
}
/**
* 三方电子签(四要素)
*/
async signToFourElement(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,
xbg_ecid: param.ecid
});
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); await this.redisLock.unLock(key, id);
return result; return result;
} catch (error) { } catch (error) {
...@@ -213,6 +310,8 @@ class QbgecontractApi { ...@@ -213,6 +310,8 @@ class QbgecontractApi {
} }
async sinedUser(obj, req) { async sinedUser(obj, req) {
// 验证合法性 // 验证合法性
let appId = obj.appId; let appId = obj.appId;
...@@ -269,6 +368,105 @@ class QbgecontractApi { ...@@ -269,6 +368,105 @@ class QbgecontractApi {
} }
} }
// /**
// * 两方电子签
// * @param pobj
// * @returns {Promise<{msg: *, code: *, data: (*|null)}|{msg: *, code: *, data}|*|{msg: *, code: *, data}>}
// */
// 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.autoSigns(param, qbg);
// await this.redisLock.unLock(key, id);
// return result;
// } catch (error) {
// console.log(error);
// }
// }
trim(o) { trim(o) {
if (!o) { if (!o) {
......
...@@ -8,8 +8,7 @@ module.exports = (db, DataTypes) => { ...@@ -8,8 +8,7 @@ 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, xbg_ecid: DataTypes.INTEGER,
addressA: DataTypes.STRING,
ecompany_id: DataTypes.INTEGER, ecompany_id: DataTypes.INTEGER,
},{ },{
paranoid: true,//假的删除 paranoid: true,//假的删除
......
...@@ -26,6 +26,8 @@ class QbgconfigService extends ServiceBase { ...@@ -26,6 +26,8 @@ class QbgconfigService extends ServiceBase {
let ecid = params.ecid; let ecid = params.ecid;
// 验证身份证是否签约过 // 验证身份证是否签约过
let todays = moment().format("YYYY-MM-DD") + " 00:00:00"; let todays = moment().format("YYYY-MM-DD") + " 00:00:00";
// dkecompany
var dkcompany = await this.dkcompanyDao.findById(qbg.ecompany_id);
let contractId = await this.dkcontractDao.findSignedContractId({ let contractId = await this.dkcontractDao.findSignedContractId({
idno: params.idNo, idno: params.idNo,
...@@ -124,27 +126,27 @@ class QbgconfigService extends ServiceBase { ...@@ -124,27 +126,27 @@ class QbgconfigService extends ServiceBase {
appId: params.appId, appId: params.appId,
nonceStr: params.nonceStr, nonceStr: params.nonceStr,
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
initiatorAccountId: qbg.initiator_account, initiatorAccountId: qbg.initiator_account, //企业账号(E签宝)
accountId: eaccount.eaccountid, accountId: eaccount.eaccountid, //个人账号(E签宝)
channel: 1, channel: 1,
entSealId: qbg.seal_id, entSealId: qbg.seal_id,
contractName: qbg.merchant_name, contractName: dkcompany.name, //合同名称
simpleFormFields: { simpleFormFields: {
nameA: qbg.merchant_name, nameA: dkcompany.name, //甲方 必填
addressA: qbg.addressA, addressA: dkcompany.addr, // 甲方地址
phoneA: qbg.phoneA, phoneA: dkcompany.phone, // 甲方电话
nameB: params.idName, nameB: params.idName, //乙方姓名 必填
phoneB: params.mobile, phoneB: params.mobile, //乙方电话 必填
nameC: params.idName, nameC: params.idName, // 乙方姓名
banknoC: params.bankno, banknoC: params.bankno, // 乙方电话
phoneC: params.mobile, phoneC: params.mobile, // 乙方身份证
idcardC: params.idNo, idcardC: params.idNo, // 乙方银行卡号
signdate: today, signdate: today, // 签约日期
}, },
templateId: params.ecid templateId: qbg.template_id //ecid(E签宝)
} }
var sign = await this.getsign(toecontract, qbg.key) var sign = await this.getsign(toecontract, qbg.key)
...@@ -156,12 +158,11 @@ class QbgconfigService extends ServiceBase { ...@@ -156,12 +158,11 @@ class QbgconfigService extends ServiceBase {
data: toecontract, data: toecontract,
}); });
console.log(econtr) console.log(econtr)
// 创建合同 // 创建合同
let dkecontract = { let dkecontract = {
name: qbg.merchant_name, name: qbg.merchant_name,
dktemplate_id: qbg.template_id, dktemplate_id: ecid,
user_id: eaccount.user_id, user_id: eaccount.user_id,
usereaccount_id: eaccount.id, usereaccount_id: eaccount.id,
dkcompany_id: qbg.ecompany_id, dkcompany_id: qbg.ecompany_id,
...@@ -311,7 +312,7 @@ class QbgconfigService extends ServiceBase { ...@@ -311,7 +312,7 @@ class QbgconfigService extends ServiceBase {
signDateA: today, signDateA: today,
signDateB: today signDateB: today
}, },
templateId: params.ecid templateId: qbg.template_id
} }
var sign = await this.getsign(toecontract, qbg.key) var sign = await this.getsign(toecontract, qbg.key)
...@@ -322,8 +323,6 @@ class QbgconfigService extends ServiceBase { ...@@ -322,8 +323,6 @@ class QbgconfigService extends ServiceBase {
url: this.API.autoSign, url: this.API.autoSign,
data: toecontract, data: toecontract,
}); });
console.log(econtr) console.log(econtr)
// 创建合同 // 创建合同
let econtract = { let econtract = {
...@@ -332,7 +331,7 @@ class QbgconfigService extends ServiceBase { ...@@ -332,7 +331,7 @@ class QbgconfigService extends ServiceBase {
eflowstatus: "1", eflowstatus: "1",
user_id: eaccount.user_id, user_id: eaccount.user_id,
usereaccount_id: eaccount.id, usereaccount_id: eaccount.id,
etemplate_id: qbg.template_id, etemplate_id: ecid,
ecompany_id: qbg.ecompany_id, ecompany_id: qbg.ecompany_id,
}; };
econtract = await this.econtractDao.create(econtract); econtract = await this.econtractDao.create(econtract);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment