MaiXinRong 2 éve
szülő
commit
bdd9b97e9c
2 módosított fájl, 20 hozzáadás és 10 törlés
  1. 8 4
      app/service/stage_audit.js
  2. 12 6
      app/service/tender_cache.js

+ 8 - 4
app/service/stage_audit.js

@@ -1004,7 +1004,10 @@ module.exports = app => {
                         cache_time_r: this.ctx.stage.cache_time_l,
                         status: times === 1 ? auditConst.status.uncheck : auditConst.status.checkNo,
                     });
-                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, times === 1 ? auditConst.status.uncheck : auditConst.status.checkNo, { id: this.ctx.stage.user_id }, { id: this.ctx.stage.user_id }, ledgerTp, stageTp);
+                    const preFlow = times > 1 ? await this.getLastestAuditor(stageId, times, auditConst.status.checkNo): null;
+                    const curFlow = { aid: this.ctx.stage.user_id, order: 1, status: auditConst.status.uncheck};
+                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, times === 1 ? auditConst.status.uncheck : auditConst.status.checkNo,
+                        curFlow, preFlow, ledgerTp, stageTp);
                     // 计算该审批人最终数据
                     await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                     // 复制一份最新数据给下一人
@@ -1077,7 +1080,7 @@ module.exports = app => {
                         tp_history: JSON.stringify(this.ctx.stage.tp_history),
                         cache_time_r: this.ctx.stage.cache_time_l,
                     });
-                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage.status, preAudit, preAudit, ledgerTp, stageTp);
+                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, this.ctx.stage.status, newAuditors[1], newAuditors[0], ledgerTp, stageTp);
 
                     // 计算该审批人最终数据
                     await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
@@ -1143,7 +1146,8 @@ module.exports = app => {
                         tp_history: JSON.stringify(this.ctx.stage.tp_history),
                         cache_time_r: this.ctx.stage.cache_time_l,
                     });
-                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage.status, preAudit, preAudit, ledgerTp, stageTp);
+                    const cur = {tid: curAudit.tid, sid: curAudit.sid, aid: preAudit.aid, times: curAudit.times, order: curAudit.order + 1, status: auditConst.status.checking};
+                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, this.ctx.stage.status, cur, newAuditors[0], ledgerTp, stageTp);
 
                     // 计算该审批人最终数据
                     await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
@@ -1215,7 +1219,7 @@ module.exports = app => {
                         cache_time_r: this.ctx.stage.cache_time_l,
                         status: auditConst.status.checking,
                     });
-                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage.status, curAudit, curAudit, ledgerTp, stageTp);
+                    await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, auditConst.status.checking, newAuditors[1], newAuditors[0], ledgerTp, stageTp);
                     // 计算该审批人最终数据
                     await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                     // 复制一份最新数据给下一人

+ 12 - 6
app/service/tender_cache.js

@@ -208,16 +208,22 @@ module.exports = app => {
             if (stageTp) this._.assign(tp, stageTp);
             if (pcTp) this._.assign(tp, pcTp);
             if (preAuditor) {
-                data.stage_flow_pre_uid = preAuditor.id;
-                const info = await this.ctx.service.projectAccount.getAccountCacheData(preAuditor.id);
+                data.stage_flow_pre_uid = preAuditor.aid;
+                const info = await this.ctx.service.projectAccount.getAccountCacheData(preAuditor.aid);
+                info.order = preAuditor.order;
+                info.status = preAuditor.status;
+                info.time = new Date();
                 data.stage_flow_pre_info = JSON.stringify(info);
+            } else {
+                data.stage_flow_pre_uid = orgCache.stage_flow_cur_uid;
+                data.stage_flow_pre_info = orgCache.stage_flow_cur_info;
             }
-            data.stage_flow_pre_uid = orgCache.stage_flow_cur_uid;
-            data.stage_flow_pre_info = orgCache.stage_flow_cur_info;
             data.stage_flow_pre_tp = JSON.stringify(tp);
             if (auditor) {
-                data.stage_flow_cur_uid = auditor.id;
-                const info = await this.ctx.service.projectAccount.getAccountCacheData(auditor.id);
+                data.stage_flow_cur_uid = auditor.aid;
+                const info = await this.ctx.service.projectAccount.getAccountCacheData(auditor.aid);
+                info.order = auditor.order;
+                info.status = status;
                 data.stage_flow_cur_info = JSON.stringify(info);
             }
             data.stage_flow_cur_tp = JSON.stringify(tp);