Commit 937a74c9 by 王昆

gsb

parent b5128458
......@@ -18,7 +18,7 @@ class TestApi {
async testAddDL(obj) {
let contracts = obj.contracts || [];
for(let p of contracts) {
await this.redisClient.rpush("bpo:contract:download", JSON.stringify(p));
await this.downcontractClient.download(p);
}
return {msg: "success"}
}
......
......@@ -16,6 +16,8 @@ class DKcontractService extends ServiceBase {
this.userDao = system.getObject("db.userDao");
this.restClient = system.getObject("util.restClient");
this.redisClient = system.getObject("util.redisClient");
}
async getInfo(id) {
......@@ -235,6 +237,8 @@ class DKcontractService extends ServiceBase {
end_at.setFullYear(end_at.getFullYear() + 1);
contract.end_at = end_at;
// 合同下载任务
this.redisClient.rpushBCD({id: contract.id, sve: "dk"});
await contract.save();
} catch (e) {
logCtl.error({
......
......@@ -32,6 +32,8 @@ class EcontractService extends ServiceBase {
this.eSignBaoRedirectBossUrl = settings.apiconfig.eSignBaoRedirectBossUrl();
this.redisClient = system.getObject("util.redisClient");
this.ydCompanyIds = [
10173,
10174,
......@@ -271,6 +273,10 @@ class EcontractService extends ServiceBase {
contract.end_at = end_at;
contract.save();
// TODO DOWNLOAD OK
this.redisClient.rpushBCD({id: contract.id, sve: "e"});
// }
}
} catch (error) {
......@@ -518,13 +524,9 @@ class EcontractService extends ServiceBase {
}
if (signResult == "2") {
// TODO WANGKUN 改定时任务获取
// let fileRs = await this.utilesignbaoSve.downloadUserContractFile(contract.eflowid, "econtractSve");
// console.log(fileRs, "---------------------------------------------------");
// if(fileRs.code == 1 && fileRs.data.selfossUrl) {
// contract.fileurl = fileRs.data.selfossUrl;
// contract.save();
// }
// TODO DOWNLOAD OK
this.redisClient.rpushBCD({id: contract.id, sve: "e"});
try {
this.updateApply(contract.id);
} catch (error) {
......@@ -1453,6 +1455,8 @@ class EcontractService extends ServiceBase {
await econtract.save();
this.syncSign(econtract.id);
// TODO DOWNLOAD OK
this.redisClient.rpushBCD({id: econtract.id, sve: "e"});
return this.returnjson(0, "success", {
contractId: econtract.id
});
......@@ -1638,6 +1642,8 @@ class EcontractService extends ServiceBase {
econtract.end_at = end_at;
await econtract.save();
// TODO DOWNLOAD OK
this.redisClient.rpushBCD({id: econtract.id, sve: "e"});
return this.returnjson(0, "success", {
contractId: econtract.id
});
......@@ -1810,6 +1816,9 @@ class EcontractService extends ServiceBase {
await econtract.save();
this.syncSign(econtract.id);
// TODO DOWNLOAD OK
this.redisClient.rpushBCD({id: econtract.id, sve: "e"});
return this.returnjson(0, "success", {
contractId: econtract.id
});
......@@ -2015,6 +2024,9 @@ class EcontractService extends ServiceBase {
await econtract.save();
this.syncSign(econtract.id);
// TODO DOWNLOAD
this.redisClient.rpushBCD({id: econtract.id, sve: "e"});
return this.returnjson(0, "success", {
contractId: econtract.id
});
......
......@@ -29,6 +29,8 @@ class EntcontractService extends ServiceBase {
this.YZKEY = "4a112ce87c38464d8d454caf23b7b31f";
this.YZHDURL = "http://bifrost-youzan-gateway.qa.s.qima-inc.com/api/auth_exempt/youzan.pay.finance.tax.sign.merchant.gsb.notify/1.0.0";
this.redisClient = system.getObject("util.redisClient");
}
async getAppConfig() {
......@@ -196,6 +198,9 @@ class EntcontractService extends ServiceBase {
entcontract.end_at = end_at;
await entcontract.save();
// 合同下载任务
this.redisClient.rpushBCD({id: entcontract.id, sve: "ent"});
// this.syncSign(entcontract.id);
// return await this.createMerchant(params); 暂时先不用了
// return this.returnjson(0, "success", {
......@@ -682,6 +687,10 @@ class EntcontractService extends ServiceBase {
params.toAppId = enttemplate.appid;
params.toMcthid = enttemplate.mcthid;
params.key = enttemplate.key;
// 合同下载任务
this.redisClient.rpushBCD({id: entcontract.id, sve: "ent"});
return await this.createYzMerchant(params);
// return this.returnjson(0, "success", {
// contractId: entcontract.id
......
......@@ -8,6 +8,7 @@ const redisClient = system.getObject("util.redisClient");
// const logCtl=system.getObject("web.oplogCtl");
class DownContractClient {
constructor() {
this.DOWNLOAD_KEY = "bpo:contract:download";
this.KEY = "DOWN_LOAD_CONTRACT_KEY";
this.sve = {
e: system.getObject("service.econtractSve"),
......@@ -33,13 +34,13 @@ class DownContractClient {
}
async doDownLoad() {
let len = await redisClient.llen("bpo:contract:download") || 0;
let len = await redisClient.llen(this.DOWNLOAD_KEY) || 0;
if (!len) {
redisClient.delete(this.KEY);
return;
}
for (let i = 0; i < len; i++) {
let item = await redisClient.rpop("bpo:contract:download");
let item = await redisClient.rpop(this.DOWNLOAD_KEY);
console.log(item);
item = JSON.parse(item);
try {
......
......@@ -216,6 +216,10 @@ class RedisClient{
return await this.client.blpopAsync(key, d);
}
async rpushBCD(v) {
this.rpush("bpo:contract:download", JSON.stringify(v));
}
}
module.exports=RedisClient;
// var client=new RedisClient();
......
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