Commit 72608629 by zhaoxiqing

gsb

parent 206d65a0
...@@ -5,14 +5,121 @@ const moment = require("moment"); ...@@ -5,14 +5,121 @@ const moment = require("moment");
class DKcontractApi { class DKcontractApi {
constructor() { constructor() {
this.dkcompanySve = system.getObject("service.dkcompanySve");
this.idcardClient = system.getObject("util.idcardClient");
this.esettleSve = system.getObject("service.esettleSve");
this.dkcontractSve = system.getObject("service.dkcontractSve"); this.dkcontractSve = system.getObject("service.dkcontractSve");
this.etemplatebusiSve = system.getObject("service.etemplatebusiSve");
} }
async syncSignedFile() { async syncSignedFile() {
this.dkcontractSve.downloadCompleteUrl(); this.dkcontractSve.downloadCompleteUrl();
return "start success" return "start success"
} }
async autoSign(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)
};
if (!param.ecid) {
return this.returnjson(-1, "请传入薪必果提供的ecid")
}
if (!param.appId) {
return this.returnjson(-1, "请传入薪必果提供的appId")
}
if (!param.userId) {
return this.returnjson(-1, "请提供该用户ID")
}
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 busi = await this.etemplatebusiSve.busiByTemplate(param.ecid);
let num = await this.esettleSve.isValidAge(busi[0].busi_id);
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, "请提供随机码")
}
if (!busi[0] ||!busi[0].app_id || !busi[0].key || busi[0].app_id != param.appId) {
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[0].key;
var sign = md5(signStr).toUpperCase();
console.log(signStr, sign);
if (param.sign != sign) {
return this.returnjson(1001001, "签名错误");
}
try {
var result = await this.dkcontractSve.autoSign(param);
return result;
} catch (error) {
console.log(error);
}
}
returnjson(code, msg, data) {
return {
code: code,
msg: msg,
data: data || null
}
}
trim(o) {
if (!o) {
return "";
}
return o.toString().trim();
}
} }
module.exports = DKcontractApi; module.exports = DKcontractApi;
\ No newline at end of file
...@@ -54,7 +54,7 @@ class YZContractApi { ...@@ -54,7 +54,7 @@ class YZContractApi {
} }
if (!await this.idcardClient.checkIDCard(param.idNo)) { if (!await this.idcardClient.checkIDCard(param.idNo)) {
return this.returnjson(-1, "代理人身份证格式不正确"); return this.returnjson(-1, "代理人身份证格式不正确");
} }
let card = await this.idcardClient.cardInfo(param.idNo); let card = await this.idcardClient.cardInfo(param.idNo);
let age = card.age || 0; let age = card.age || 0;
if (!age) { if (!age) {
...@@ -105,7 +105,6 @@ class YZContractApi { ...@@ -105,7 +105,6 @@ class YZContractApi {
} }
async merchantSigns(pobj) { async merchantSigns(pobj) {
// 处理参数 // 处理参数
var param = { var param = {
...@@ -121,18 +120,18 @@ class YZContractApi { ...@@ -121,18 +120,18 @@ class YZContractApi {
nonceStr: this.trim(pobj.nonceStr),//随机码 nonceStr: this.trim(pobj.nonceStr),//随机码
sign: this.trim(pobj.sign) sign: this.trim(pobj.sign)
}; };
console.log("有赞商户签约接口===========", param);
if (!param.ecid) { if (!param.ecid) {
return this.returnjson(-1, "请传入薪必果提供的ecid") return this.returnjson(-1, "请传入薪必果提供的ecid");
} }
if (!param.appId) { if (!param.appId) {
return this.returnjson(-1, "请传入薪必果提供的appId") return this.returnjson(-1, "请传入薪必果提供的appId");
} }
if (!param.idName) { if (!param.idName) {
return this.returnjson(-1, "请提供代理人姓名") return this.returnjson(-1, "请提供代理人姓名");
} }
if (!param.idNo) { if (!param.idNo) {
return this.returnjson(-1, "请提供代理人身份证号") return this.returnjson(-1, "请提供代理人身份证号");
} }
if (!await this.idcardClient.checkIDCard(param.idNo)) { if (!await this.idcardClient.checkIDCard(param.idNo)) {
return this.returnjson(-1, "代理人身份证格式不正确"); return this.returnjson(-1, "代理人身份证格式不正确");
...@@ -144,16 +143,16 @@ class YZContractApi { ...@@ -144,16 +143,16 @@ class YZContractApi {
} }
if (card.sex == 'male') { if (card.sex == 'male') {
if (age < 18 || age > 60) { if (age < 18 || age > 60) {
return this.returnjson(-1, "签约失败,男性代理人限制18-60岁之间") return this.returnjson(-1, "签约失败,男性代理人限制18-60岁之间");
} }
} else { } else {
if (age < 18 || age > 55) { if (age < 18 || age > 55) {
return this.returnjson(-1, "签约失败,女性代理人限制18-55岁之间") return this.returnjson(-1, "签约失败,女性代理人限制18-55岁之间");
} }
} }
if (!param.nonceStr) { if (!param.nonceStr) {
return this.returnjson(-1, "请提供随机码") return this.returnjson(-1, "请提供随机码");
} }
var enttemplate = await this.enttemplateSve.findById(param.ecid); var enttemplate = await this.enttemplateSve.findById(param.ecid);
...@@ -179,7 +178,7 @@ class YZContractApi { ...@@ -179,7 +178,7 @@ class YZContractApi {
return this.returnjson(1001001, "签名错误"); return this.returnjson(1001001, "签名错误");
} }
try { try {
var result = await this.entcontractSve.yzMerchantAutoSigns(param); var result = await this.entcontractSve.yzMerchantAutoSigns(param,enttemplate);
return result; return result;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
...@@ -217,13 +216,13 @@ class YZContractApi { ...@@ -217,13 +216,13 @@ class YZContractApi {
let busiIds = await this.etemplatebusiSve.busiIdsByTemplateId(param.ecid); let busiIds = await this.etemplatebusiSve.busiIdsByTemplateId(param.ecid);
let num = await this.esettleSve.isValidAge(busiIds); let num = await this.esettleSve.isValidAge(busiIds);
if(num) { if (num) {
let card = await this.idcardClient.cardInfo(param.idNo); let card = await this.idcardClient.cardInfo(param.idNo);
let age = card.age || 0; let age = card.age || 0;
if(!age) { if (!age) {
return this.returnjson(-1, "身份证号格式错误, 只支持18位身份证号码"); return this.returnjson(-1, "身份证号格式错误, 只支持18位身份证号码");
} }
if(card.sex == 'male') { if (card.sex == 'male') {
if (age < 18 || age > 60) { if (age < 18 || age > 60) {
return this.returnjson(-1, "签约失败,男限制18-60岁之间") return this.returnjson(-1, "签约失败,男限制18-60岁之间")
} }
...@@ -353,7 +352,7 @@ class YZContractApi { ...@@ -353,7 +352,7 @@ class YZContractApi {
if (!obj.appId) { if (!obj.appId) {
return this.returnjson(-1, "请传入appId") return this.returnjson(-1, "请传入appId")
} }
var enttemplate = await this.enttemplateSve.findOne({appid : obj.appId}); var enttemplate = await this.enttemplateSve.findOne({appid: obj.appId});
if (!enttemplate || !enttemplate.key) { if (!enttemplate || !enttemplate.key) {
return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置"); return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置");
...@@ -367,7 +366,7 @@ class YZContractApi { ...@@ -367,7 +366,7 @@ class YZContractApi {
signArr.push("startId=" + startId); signArr.push("startId=" + startId);
signArr.push("key=" + enttemplate.key); signArr.push("key=" + enttemplate.key);
var sign = md5(signArr.join("&")).toUpperCase(); var sign = md5(signArr.join("&")).toUpperCase();
console.log(signArr.join("&"),sign); console.log(signArr.join("&"), sign);
if (sign != obj.sign) { if (sign != obj.sign) {
return { return {
code: 1001001, code: 1001001,
......
...@@ -445,4 +445,4 @@ class DKSignCtl { ...@@ -445,4 +445,4 @@ class DKSignCtl {
} }
} }
} }
module.exports = DKSignCtl; module.exports = DKSignCtl;
\ No newline at end of file
const Dao = require("../dao.base");
class DktemplatebusiDao extends Dao {
constructor() {
super(Dao.getModelName(DktemplatebusiDao));
}
}
module.exports = DktemplatebusiDao;
module.exports = (db, DataTypes) => {
return db.define("dktemplatebusi", {
template_type:DataTypes.BIGINT,
template_id:DataTypes.BIGINT,
busi_id:DataTypes.STRING,
busi_company_name:DataTypes.STRING,
app_id : DataTypes.STRING,
key : DataTypes.STRING,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_dktemplate_busi',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
...@@ -4,6 +4,7 @@ const uiconfig = system.getUiConfig2(settings.wxconfig.appId); ...@@ -4,6 +4,7 @@ const uiconfig = system.getUiConfig2(settings.wxconfig.appId);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("entcontract", { return db.define("entcontract", {
name: DataTypes.STRING, name: DataTypes.STRING,
tenant_name: DataTypes.STRING,
edocid: DataTypes.STRING, // 合同id edocid: DataTypes.STRING, // 合同id
eflowid: DataTypes.STRING, // 合同流程id eflowid: DataTypes.STRING, // 合同流程id
esignUrl: DataTypes.STRING, // 合同签署链接 esignUrl: DataTypes.STRING, // 合同签署链接
......
...@@ -2,8 +2,8 @@ module.exports = (db, DataTypes) => { ...@@ -2,8 +2,8 @@ module.exports = (db, DataTypes) => {
return db.define("etemplatebusi", { return db.define("etemplatebusi", {
template_type:DataTypes.BIGINT, template_type:DataTypes.BIGINT,
template_id:DataTypes.BIGINT, template_id:DataTypes.BIGINT,
busi_id:DataTypes.BIGINT, busi_id:DataTypes.STRING,
busi_company_name:DataTypes.BIGINT, busi_company_name:DataTypes.STRING,
},{ },{
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
const ServiceBase = require("../sve.base");
class DktemplatebusiService extends ServiceBase {
constructor() {
super(ServiceBase.getDaoName(DktemplatebusiService));
}
async getlist(id) {
var sql = "SELECT * FROM c_dktemplate_busi WHERE template_id = :template_id";
var page = await this.customQuery(sql,{template_id:id});
return page;
}
async busiIdsByTemplateId(template_id) {
var sql = "SELECT busi_id FROM c_dktemplate_busi WHERE template_id = :template_id";
var list = await this.customQuery(sql, {template_id: template_id});
let rs = [];
if (!list || list.length == 0) {
return rs;
}
for (let item of list) {
rs.push(item.busi_id);
}
return rs;
}
async getinfo(qobj) {
var sql = "SELECT * FROM c_dktemplate_busi WHERE template_id = " + qobj.template_id + " AND busi_id = " + qobj.company_id;
var page = await this.customQuery(sql);
return page;
}
async deleteTetId(qobj) {
let sql = "DELETE FROM c_dktemplate_busi WHERE id = " + qobj.id;
await this.customExecAddOrPutSql(sql);
return 1;
}
async suggest(name, ownerIds) {
return await this.dao.suggest(name, ownerIds);
}
async saveto(etebusi) {
return await this.create(etebusi);
}
}
module.exports = DktemplatebusiService;
...@@ -1295,6 +1295,7 @@ class EcontractService extends ServiceBase { ...@@ -1295,6 +1295,7 @@ class EcontractService extends ServiceBase {
var ecompany = await this.ecompanyDao.findById(etemplate.ecompany_id); var ecompany = await this.ecompanyDao.findById(etemplate.ecompany_id);
// p_user // p_user
var user = await this.userDao.findOne({ var user = await this.userDao.findOne({
unionId: unionId, unionId: unionId,
}); });
......
...@@ -23,6 +23,11 @@ class EtemplatebusiService extends ServiceBase { ...@@ -23,6 +23,11 @@ class EtemplatebusiService extends ServiceBase {
return rs; return rs;
} }
async busiByTemplate(template_id) {
var sql = "SELECT * FROM c_etemplate_busi WHERE template_type = 2 AND template_id = :template_id";
return await this.customQuery(sql, {template_id: template_id});
}
async getinfo(qobj) { async getinfo(qobj) {
var sql = "SELECT * FROM c_etemplate_busi WHERE template_id = " + qobj.template_id + " AND busi_id = " + qobj.company_id; var sql = "SELECT * FROM c_etemplate_busi WHERE template_id = " + qobj.template_id + " AND busi_id = " + qobj.company_id;
var page = await this.customQuery(sql); var page = await this.customQuery(sql);
...@@ -45,4 +50,4 @@ class EtemplatebusiService extends ServiceBase { ...@@ -45,4 +50,4 @@ class EtemplatebusiService extends ServiceBase {
} }
} }
module.exports = EtemplatebusiService; module.exports = EtemplatebusiService;
\ No newline at end of file
...@@ -85,6 +85,16 @@ var settings = { ...@@ -85,6 +85,16 @@ var settings = {
return "5111588557" return "5111588557"
} }
}, },
//有赞商户创建 代征主体 //代征主体 67731101 测试 67731504
getmainId : function(){
if (settings.env == "dev") {
return "67731504";
} else {
return "67731101"
}
},
//e签宝appKey //e签宝appKey
eSignBaoAppKey: function () { eSignBaoAppKey: function () {
if (settings.env == "dev") { if (settings.env == "dev") {
...@@ -185,4 +195,4 @@ var settings = { ...@@ -185,4 +195,4 @@ var settings = {
} }
}; };
settings.ENVINPUT = ENVINPUT; settings.ENVINPUT = ENVINPUT;
module.exports = settings; module.exports = settings;
\ No newline at end of file
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