Commit 074a39de by 王昆

gsb

parent 77358bd1
......@@ -77,24 +77,24 @@ class EcontractDao extends Dao {
return rs;
}
async countSignTimes(params) {
async findSignedContractId(params) {
// idno, begin, end
let sql = [];
sql.push("SELECT COUNT(1) AS num FROM `c_econtract` t1");
sql.push("SELECT t1.id FROM `c_econtract` t1");
sql.push("INNER JOIN `p_user_eaccount` t2 ON t1.`usereaccount_id` = t2.`id`");
sql.push("WHERE t2.`personsSign` = :idno");
if (params.begin) {
sql.push("AND t1.`created_at` >= :begin");
sql.push("WHERE t2.`personsSign` = :idno AND t1.eflowstatus = '2'");
if (params.ecid) {
sql.push("AND t1.`etemplate_id` = :ecid");
}
if (params.end) {
sql.push("AND t1.`created_at` <= :begin");
if (params.today) {
sql.push("AND t1.`end_at` >= :today AND t1.`begin_at` <= :today");
}
let list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return 0;
}
return list[0].num || 0;
return list[0].id || 0;
}
}
......
......@@ -1357,25 +1357,23 @@ class EcontractService extends ServiceBase {
}
// c_econtract
var econtract = await this.dao.findOne({
eflowstatus: '2',
usereaccount_id: eaccount.id,
etemplate_id: ecid,
});
if (econtract) {
// var econtract = await this.dao.findOne({
// eflowstatus: '2',
// usereaccount_id: eaccount.id,
// etemplate_id: ecid,
// });
let contractId = await this.dao.findSignedContractId({idno: eaccount.personsSign, ecid: ecid}) || 0;
if (contractId) {
return this.returnjson(0, "用户已经签约", {
contractId: econtract.id
contractId: contractId
});
}
let begin = moment().subtract(30, "days").format("YYYY-MM-DD HH:mm:ss");
let times = await this.dao.countSignTimes({idno: eaccount.personsSign, begin: begin}) || 0;
if (times > 5) {
let timesMsg = `该用户[${eaccount.personsSign}]签约次数过多,30天内已经签约${times}次`;
console.log(timesMsg);
return this.returnjson(-1, timesMsg);
}
// let begin = moment().subtract(30, "days").format("YYYY-MM-DD HH:mm:ss");
// if (times > 5) {
// let timesMsg = `该用户[${eaccount.personsSign}]签约次数过多,30天内已经签约${times}次`;
// console.log(timesMsg);
// return this.returnjson(-1, timesMsg);
// }
// e签宝流程
if (isNeedCreate) {
......@@ -1413,7 +1411,7 @@ class EcontractService extends ServiceBase {
}
// 创建合同 fileurl、esignUrl 怎么赋值????????????
econtract = {
let econtract = {
name: ecompany.name,
eflowstatusname: "签约中",
eflowstatus: "1",
......
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