Browse Source

多期审批通过,缓存问题

MaiXinRong 1 year ago
parent
commit
1bf7741372
2 changed files with 37 additions and 3 deletions
  1. 3 1
      app/service/stage_audit.js
  2. 34 2
      app/service/tender_cache.js

+ 3 - 1
app/service/stage_audit.js

@@ -567,7 +567,6 @@ module.exports = app => {
                             his_id,
                         });
 
-                        await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, checkData.checkType, nextAudits, flowAudits, ledgerTp, stageTp);
                         await this.ctx.service.stagePay.cacheOrder(this.ctx.stage, transaction);
                         // 当前期不是最新一起时
                         if (this.ctx.stage.highOrder !== this.ctx.stage.order) {
@@ -588,6 +587,9 @@ module.exports = app => {
                                 pre_sf_tp: this.ctx.helper.add(this.ctx.stage.pre_sf_tp, stageTp.sf_tp),
                             };
                             await transaction.updateRows(this.ctx.service.stage.tableName, nextStages.map(x => { return { id: x.id, ...preStageTp }; }));
+                            await this.ctx.service.tenderCache.updateStageCache4MultiChecked(transaction, this.ctx.stage, flowAudits, ledgerTp, stageTp, nextStages[0], preStageTp);
+                        } else {
+                            await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, checkData.checkType, nextAudits, flowAudits, ledgerTp, stageTp);
                         }
 
                         // 添加短信通知-审批通过提醒功能

+ 34 - 2
app/service/tender_cache.js

@@ -63,7 +63,6 @@ module.exports = app => {
                         status_class: auditConst.stage.tiStatusStringClass[cache.stage_status],
                     };
                 } catch (err) {
-                    console.log(tender.id);
                     tender.progress = {
                         title: `第${tender.stage_count}期`,
                         status: auditConst.stage.tiStatusString[cache.stage_status],
@@ -85,7 +84,6 @@ module.exports = app => {
                         status_class: auditConst.stage.tiStatusStringClass[auditConst.stage.status.checked],
                     };
                 } catch(err) {
-                    console.log(tender.id);
                     tender.progress = {
                         title: `第${tender.stage_count}期`,
                         status: auditConst.stage.tiStatusString[auditConst.stage.status.checked],
@@ -299,6 +297,40 @@ module.exports = app => {
             await transaction.update(this.tableName, data);
         }
 
+        async updateStageCache4MultiChecked(transaction, stage, auditors, ledgerTp, stageTp, nextStage, nextStageTp) {
+            if (!stage.isCheckFirst) return;
+
+            const orgCache = await this.getDataById(stage.tid);
+
+            const data = { id: stage.tid, stage_status: auditConst.stage.status.uncheck, stage_complete_count: stage.order };
+            if (ledgerTp) data.ledger_tp = JSON.stringify(ledgerTp);
+            const tp = orgCache.stage_flow_cur_tp ? JSON.parse(orgCache.stage_flow_cur_tp) : (orgCache.stage_flow_pre_tp ? JSON.parse(orgCache.stage_flow_pre_tp) : {});
+            if (stageTp) this._.assign(tp, stageTp);
+
+            if (auditors && auditors.length > 0) {
+                const auditorIds = auditors.map(x => { return x.aid; });
+                data.stage_flow_pre_uid = auditorIds.join(',');
+                const info = await this.ctx.service.projectAccount.getAccountCacheDatas(auditorIds, { order: stage.order,
+                    audit_type: auditors[0].audit_type, status: auditConst.stage.status.checked, audit_order: auditors[0].audit_order });
+                data.stage_flow_pre_info = info.length > 0 ? JSON.stringify(info) : '';
+            }
+            data.stage_flow_pre_tp = JSON.stringify(tp);
+
+            data.stage_flow_cur_uid = nextStage.user_id;
+            const cur_flow_info = await this.ctx.service.projectAccount.getAccountCacheData(nextStage.user_id);
+            cur_flow_info.order = nextStage.order;
+            cur_flow_info.status = auditConst.stage.status.uncheck;
+            data.stage_flow_cur_info = JSON.stringify(cur_flow_info);
+            const cur_flow_tp = {
+                contract_tp: 0, qc_tp: 0,
+                positive_qc_tp: 0, negative_qc_tp: 0,
+                yf_tp: 0, sf_tp: 0,
+                ...nextStageTp,
+            };
+            data.stage_flow_cur_tp = JSON.stringify(cur_flow_tp);
+            await transaction.update(this.tableName, data);
+        }
+
         async updateStageCache4Revise(transaction, tid, ledgerTp, pcTp) {
             const orgCache = await this.getDataById(tid);
             const data = { id: tid };