Commit 7b8ecb53 by zhaoxiqing

gsb

parent ba1c5de8
......@@ -118,6 +118,7 @@ class YZContractApi {
mobile: this.trim(pobj.mobile),// 代理人手机号
idNo: this.trim(pobj.idNo),// 代理人身份证
nonceStr: this.trim(pobj.nonceStr),//随机码
idType : this.trim(pobj.idType),
sign: this.trim(pobj.sign)
};
console.log("有赞商户签约接口===========", param);
......@@ -133,24 +134,41 @@ class YZContractApi {
if (!param.idNo) {
return this.returnjson(-1, "请提供代理人身份证号");
}
if (!await this.idcardClient.checkIDCard(param.idNo)) {
return this.returnjson(-1, "代理人身份证格式不正确");
var cludes = ["13","17","19"];
if(!cludes.includes(param.idType)){
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岁之间");
if(param.idType == 19){
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位身份证号码");
}
} else {
if (age < 18 || age > 55) {
return this.returnjson(-1, "签约失败,女性代理人限制18-55岁之间");
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.idType == 13){
if (!await this.idcardClient.isPassPortCard(param.idNo)) {
return this.returnjson(-1, "护照号码不合规");
}
}
if(param.idType == 17){
if (!await this.idcardClient.isHKCard(param.idNo)) {
return this.returnjson(-1, "港澳居民来往内地通行证号码不合规");
}
}
if (!param.nonceStr) {
return this.returnjson(-1, "请提供随机码");
}
......
......@@ -665,7 +665,7 @@ class EntcontractService extends ServiceBase {
thirdId: thirdId,
name: eaccount.userName,
idNo: eaccount.personsSign,
idType: 19,
idType: params.idType,
mobile: eaccount.mobile
};
var getAccount = await this.utilesignbaoSve.createAccountId(createParams, "econtractSve");
......
......@@ -157,6 +157,33 @@ class IdcardClient {
}
}
async isHKCard(card) {
// 港澳居民来往内地通行证
// 规则: H/M + 10位或6位数字
// 样本: H1234567890
var reg = /^([A-Z]\d{6,10}(\(\w{1}\))?)$/;
if (reg.test(card) === false) {
return false;
} else {
return true;
}
}
async isPassPortCard(card) {
// 护照
// 规则: 14/15开头 + 7位数字, G + 8位数字, P + 7位数字, S/D + 7或8位数字,等
// 样本: 141234567, G12345678, P1234567
var reg = /^([a-zA-z]|[0-9]){5,17}$/;
if (reg.test(card) === false) {
return false;
} else {
return true;
}
}
}
module.exports = IdcardClient;
......
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