Commit 5e759c43 by 王昆

gsb

parent b2cba881
...@@ -119,6 +119,33 @@ class XbgApi extends apiBase{ ...@@ -119,6 +119,33 @@ class XbgApi extends apiBase{
} }
} }
async validLwbSign(obj, req) {
let idNo = this.trim(obj.idNo);
let ecid = Number(obj.ecid || 0);
try {
let rs = await this.econtractSve.validLwbSign(idNo, ecid);
return system.getResult2(rs);
}catch (e) {
console.log(e);
return system.getErrResult2("接口异常");
}
}
async lwbContractUrl(obj, req) {
let idNo = this.trim(obj.idNo);
let ecid = Number(obj.ecid || 0);
try {
let rs = await this.econtractSve.lwbContractUrl(idNo, ecid);
if (rs == -1) {
return system.getErrResult2("用户未签约");
}
return system.getResult2(rs);
}catch (e) {
console.log(e);
return system.getErrResult2("接口异常");
}
}
} }
module.exports = XbgApi; module.exports = XbgApi;
\ No newline at end of file
const system=require("../../system"); const system = require("../../system");
const Dao=require("../dao.base"); const Dao = require("../dao.base");
class EcontractDao extends Dao{
constructor(){ class EcontractDao extends Dao {
constructor() {
super(Dao.getModelName(EcontractDao)); super(Dao.getModelName(EcontractDao));
} }
extraModelFilter(qobj) { extraModelFilter(qobj) {
var usereaccountWhere = {}; var usereaccountWhere = {};
if(qobj.accountMobile) { if (qobj.accountMobile) {
usereaccountWhere.mobile = qobj.accountMobile; usereaccountWhere.mobile = qobj.accountMobile;
} }
if(qobj.accountName) { if (qobj.accountName) {
usereaccountWhere.userName = qobj.accountName; usereaccountWhere.userName = qobj.accountName;
} }
if(qobj.accountIdno) { if (qobj.accountIdno) {
usereaccountWhere.personsSign = qobj.accountIdno; usereaccountWhere.personsSign = qobj.accountIdno;
} }
let v = [ let v = [
{model:this.db.models.ecompany,attributes:["id","name"]}, {model: this.db.models.ecompany, attributes: ["id", "name"]},
{model:this.db.models.usereaccount,attributes:["id","userName","mobile", "personsSign", "email"], where:usereaccountWhere}, {
{model:this.db.models.etemplate,attributes:["id","name"]} model: this.db.models.usereaccount,
attributes: ["id", "userName", "mobile", "personsSign", "email"],
where: usereaccountWhere
},
{model: this.db.models.etemplate, attributes: ["id", "name"]}
]; ];
//return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]}; //return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return {"key":"include","value": v}; return {"key": "include", "value": v};
} }
async findUserSinedCompanyIds(usereaccount_id) { async findUserSinedCompanyIds(usereaccount_id) {
let sql = "SELECT ecompany_id FROM `c_econtract` WHERE usereaccount_id = :usereaccount_id AND begin_at < NOW() AND end_at > NOW() AND eflowstatus = '2' GROUP BY ecompany_id"; let sql = "SELECT ecompany_id FROM `c_econtract` WHERE usereaccount_id = :usereaccount_id AND begin_at < NOW() AND end_at > NOW() AND eflowstatus = '2' GROUP BY ecompany_id";
let tmpParas = {usereaccount_id : usereaccount_id} let tmpParas = {usereaccount_id: usereaccount_id}
let rs = await this.customQuery(sql, tmpParas); let rs = await this.customQuery(sql, tmpParas);
let list = []; let list = [];
if(rs && rs.length > 0) { if (rs && rs.length > 0) {
for(let r of rs) { for (let r of rs) {
list.push(r.ecompany_id); list.push(r.ecompany_id);
} }
} }
...@@ -46,16 +51,31 @@ class EcontractDao extends Dao{ ...@@ -46,16 +51,31 @@ class EcontractDao extends Dao{
async findUserSinedTemplateIds(usereaccount_id) { async findUserSinedTemplateIds(usereaccount_id) {
let sql = "SELECT etemplate_id FROM `c_econtract` WHERE usereaccount_id = :usereaccount_id AND begin_at < NOW() AND end_at > NOW() AND eflowstatus = '2' GROUP BY etemplate_id"; let sql = "SELECT etemplate_id FROM `c_econtract` WHERE usereaccount_id = :usereaccount_id AND begin_at < NOW() AND end_at > NOW() AND eflowstatus = '2' GROUP BY etemplate_id";
let tmpParas = {usereaccount_id : usereaccount_id} let tmpParas = {usereaccount_id: usereaccount_id}
let rs = await this.customQuery(sql, tmpParas); let rs = await this.customQuery(sql, tmpParas);
let list = []; let list = [];
if(rs && rs.length > 0) { if (rs && rs.length > 0) {
for(let r of rs) { for (let r of rs) {
list.push(r.ecompany_id); list.push(r.ecompany_id);
} }
} }
return list; return list;
} }
async getFlowIdsAccountIds(accountIds, etemplate_id) {
if (!accountIds || accountIds.length == 0) {
return [];
}
let sql = "SELECT id, fileurl FROM `c_econtract` WHERE usereaccount_id IN (:accountIds) AND eflowstatus = '2' AND etemplate_id = :etemplate_id ORDER BY id DESC";
let tmpParas = {etemplate_id: etemplate_id, accountIds: accountIds};
let rs = await this.customQuery(sql, tmpParas);
if (!rs || rs.length === 0) {
return [];
}
return rs;
}
} }
module.exports=EcontractDao;
module.exports = EcontractDao;
...@@ -1599,6 +1599,50 @@ class EcontractService extends ServiceBase { ...@@ -1599,6 +1599,50 @@ class EcontractService extends ServiceBase {
data: data || null data: data || null
} }
} }
async validLwbSign(idNo, ecid) {
if(!idNo || !ecid) {
return false;
}
let ids = await this.usereaccountDao.idsByCondition({personsSign: idNo});
if (!ids || ids.length == 0) {
return false;
}
let list = await this.dao.getFlowIdsAccountIds(ids, ecid);
return list && list.length > 0;
}
async lwbContractUrl(idNo, ecid) {
try {
let ids = await this.usereaccountDao.idsByCondition({personsSign: idNo});
if (!ids || ids.length == 0) {
return "-1";
}
let list = await this.dao.getFlowIdsAccountIds(ids, ecid);
if(!list || list.length == 0) {
return "-1";
}
for(var item of list) {
if (item.fileurl) {
return item.fileurl;
}
}
let contract = await this.dao.findById(list[0].id);
let fileRs = await this.utilesignbaoSve.downloadUserContractFile(contract.eflowid, "econtractSve");
if (fileRs.code == 1 && fileRs.data.selfossUrl) {
contract.fileurl = fileRs.data.selfossUrl;
contract.save();
return contract.fileurl;
}
return "";
}catch (e) {
console.log(e);
return system.getErrResult2("接口异常");
}
}
} }
module.exports = EcontractService; module.exports = EcontractService;
\ 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