Commit cf0a880e by 王昆

gsb

parent ea4cbcdc
......@@ -33,6 +33,10 @@ module.exports = (db, DataTypes) => {
begin_at: DataTypes.DATE,
end_at: DataTypes.DATE,
isPush: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
}, {
paranoid: true, //假的删除
underscored: true,
......
......@@ -29,6 +29,13 @@ class EntcontractService extends ServiceBase {
this.YZKEY = "4a112ce87c38464d8d454caf23b7b31f"
}
async getAppConfig() {
return {
appId : "1201869719607517185",
key : "bee7870e008ab144bf518b70ef91f8ac",
}
}
async autoSign(params) {
var ecid = params.ecid;
var unionId = params.appId + "_" + params.userId;
......@@ -705,13 +712,15 @@ class EntcontractService extends ServiceBase {
let fileRs = await this.utilesignbaoSve.downloadUserContractFile(contract.eflowid, "econtractSve");
if (fileRs.code == 1 && fileRs.data.selfossUrl) {
contract.fileurl = fileRs.data.selfossUrl;
contract.save();
await contract.save();
this.syncYzSign();
} else {
await this.utilesignbaoSve.archiveProcess({flowId: contract.eflowid}, "econtractSve");
let fileRs = await this.utilesignbaoSve.downloadUserContractFile(contract.eflowid, "econtractSve");
if (fileRs.code == 1 && fileRs.data.selfossUrl) {
contract.fileurl = fileRs.data.selfossUrl;
contract.save();
await contract.save();
this.syncYzSign();
}
}
}
......@@ -732,6 +741,67 @@ class EntcontractService extends ServiceBase {
}
}
}
async syncYzSign(contractId) {
// 查询合同
var contract = await this.dao.findById(contractId);
if (!contract) {
return null;
}
// 查代理人
var account = await this.usereaccountDao.findById(contract.usereaccount_id);
if (!account) {
return null;
}
// 查用户
var user = await this.userDao.findById(account.user_id);
// 查商户签约返回值
let signInfo = this.yzmerchantsignedDao.findOne({entcontract_id: contractId});
// 获取yz配置
let conf = this.getAppConfig();
// 推送数据
var param = {
"appId": conf.appId, // appId
"merchantName": signInfo.companyName, // 有赞商户名称
"merchantId": user.userId3rd, // 有赞商户id
"fileUrl": contract.fileurl, // 签约合同pdf文件
"idName": account.userName, // 代理人姓名
"idNo": account.personsSign, // 代理人身份证
"nonceStr": await this.getUidStr(16), // 随机码
"beginDate": await this.formateTime(contract.begin_at), // 合同开始时间
"endDate": await this.formateTime(contract.end_at), // 合同结束时间
}
// 签名
var signArr = [];
signArr.push("appId=" + param.appId);
// ...补全签名信息
signArr.push("nonceStr=" + param.nonceStr);
signArr.push("key=" + busi.key);
param.sign = md5(signArr.join("&")).toUpperCase();
console.log(JSON.stringify(param));
var rs = "";
try {
var rs = await this.restClient.execPost(param, "有赞给出的回调地址");
if (rs.stdout) {
let rsData = JSON.parse(rs.stdout);
if (rsData.code == "0" || rsData.code == "0000") {
account.isPush = true;
account.save();
}
}
return rs.stdout;
} catch (error) {
console.log(rs, "push sign url " + busi.postsignurl, "rs = " + rs);
console.log(error);
return "error";
}
}
}
module.exports = EntcontractService;
\ 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