Commit 83396dbe by 赵庆

gsb

parent 9aaef0f0
......@@ -770,6 +770,7 @@ class EcontractApi {
}
var signStr = signArr.join("&") + "&key=" + busi.key;
var sign = md5(signStr).toUpperCase();
console.log(sign);
if (param.sign != sign) {
return this.returnjson(1001001, "签名错误");
}
......@@ -1234,9 +1235,11 @@ class EcontractApi {
msg: "请更新电子签企业"
};
}
// 3 查签约模板
var templateIds = await this.etemplateSve.findIdsByCompanyIdAndMainId(companybpo.ecompany_id, companybpo.mainId);
if (!templateIds || templateIds.length == 0) {
// 3 查签约模板(c_etemplate_busi)
var templateIds = await this.etemplateSve.findIdsByCompanyIdAndMainId(companybpo.mtchId);
if (templateIds.idsO.length == 0 && templateIds.idsT.length == 0) {
return {
code: 1,
msg: "电子签模板签约主体设置错误,请到bpo后台重新设置"
......@@ -1245,13 +1248,23 @@ class EcontractApi {
var signList = [];
var unSignList = [];
// 4 查签约用户
var accounts = await this.usereaccountSve.getSignAccounts(templateIds, idNoList, idNameList);
var accountMap = {};
for (var signer of accounts) {
accountMap[signer.userName + "_" + signer.personsSign] = 1;
// 4 查签约用户
if (templateIds.idsO.length > 0) {
var idsOCOunt = await this.usereaccountSve.getSignAccounts(templateIds.idsO, idNoList, idNameList);
for (var idO of idsOCOunt) {
accountMap[idO.userName + "_" + idO.personsSign] = 1;
}
}
if (templateIds.idsT.length > 0) {
var idsTCount = await this.usereaccountSve.getSignAccounts_dk(templateIds.idsT, idNoList, idNameList);
for (var idT of idsTCount) {
accountMap[idT.userName + "_" + idT.personsSign] = 1;
}
}
// 5 比对用户是否签约
for (var u of userList) {
if (accountMap[u.idName + "_" + u.idNo]) {
......@@ -1260,6 +1273,18 @@ class EcontractApi {
unSignList.push(u);
}
}
var hash = {};
signList = signList.reduce(function(item, next) {
hash[next.idNo] ? '' : hash[next.idNo] = true && item.push(next);
return item
}, []);
unSignList = unSignList.reduce(function(item, next) {
hash[next.idNo] ? '' : hash[next.idNo] = true && item.push(next);
return item
}, []);
return {
code: 0,
msg: "",
......@@ -1273,7 +1298,7 @@ class EcontractApi {
code: 1,
msg: "接口异常"
};
console.log(e.stack);
console.log(error);
//日志记录
logCtl.error({
optitle: "校验签约error",
......@@ -1284,6 +1309,7 @@ class EcontractApi {
return result;
}
}
}
module.exports = EcontractApi;
\ No newline at end of file
......@@ -114,14 +114,21 @@ class EtemplateService extends ServiceBase{
return list;
}
async findIdsByCompanyIdAndMainId(ecompanyId, mainId) {
var sql = "SELECT id FROM `c_etemplate` WHERE ecompany_id = :ecompanyId AND mainId = :mainId";
var list = await this.dao.customQuery(sql, {ecompanyId: ecompanyId, mainId: mainId});
var ids = [];
async findIdsByCompanyIdAndMainId(mtchId) {
var sql = "SELECT template_id,template_type FROM `c_etemplate_busi` WHERE busi_id = :busiId";
var list = await this.dao.customQuery(sql, {busiId: mtchId});
var ids = {
idsO:[],
idsT:[],
};
if(list) {
for(var item of list) {
ids.push(item.id);
if(item.template_type == 1){
ids.idsO.push(item.template_id)
}else if(item.template_type == 2){
ids.idsT.push(item.template_id)
}
}
}
return ids;
......
......@@ -160,6 +160,24 @@ class UsereaccountService extends ServiceBase{
});
return list || [];
}
async getSignAccounts_dk(etemplateIds, idNoList, idNameList) {
var sql = [];
sql.push("SELECT ");
sql.push("t2.userName, t2.personsSign");
sql.push("FROM c_dkcontract t1");
sql.push("INNER JOIN p_user_eaccount t2 ON t1.usereaccount_id = t2.id");
sql.push("WHERE t1.dktemplate_id IN (:etemplateIds) AND t1.`eflowstatus` = '2'");
sql.push("AND t2.`userName` IN (:idNameList)");
sql.push("AND t2.`personsSign` IN (:idNoList)");
var list = await this.dao.customQuery(sql.join(" "), {
etemplateIds: etemplateIds,
idNameList: idNameList,
idNoList: idNoList,
});
return list || [];
}
}
module.exports=UsereaccountService;
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