Sfoglia il codice sorgente

期台账历史调整

MaiXinRong 2 anni fa
parent
commit
3986908ee8
2 ha cambiato i file con 7 aggiunte e 14 eliminazioni
  1. 5 0
      app/service/ledger_history.js
  2. 2 14
      app/service/stage_audit.js

+ 5 - 0
app/service/ledger_history.js

@@ -71,6 +71,11 @@ module.exports = app => {
          * @private
          */
         async backupStageLedgerHistory(stage) {
+            const sbCount = await this.ctx.service.ledger.count({ tender_id: this.ctx.stage.tid });
+            const spCount = await this.ctx.service.pos.count({ tid: this.ctx.stage.tid });
+            const ledgerHis = await this.ctx.service.ledgerHistory.getLatestHistory(this.ctx.tender.id);
+            if (sbCount === ledgerHis.bills_count || spCount === ledgerHis.pos_count) return ledgerHis.id;
+
             const now = new Date();
             const timestamp = (now).getTime();
 

+ 2 - 14
app/service/stage_audit.js

@@ -470,20 +470,8 @@ module.exports = app => {
                     await this.ctx.helper.sendWechat(nextAudit.aid, smsTypeConst.const.JL, smsTypeConst.judge.approval.toString(), wxConst.template.stage, wechatData);
                 } else {
                     await this.ctx.service.tenderTag.saveTenderTag(this.ctx.tender.id, {stage_time: new Date()}, transaction);
-                    let his_id;
-                    if (this.ctx.tender.measureType === measureType.tz.value) {
-                        const ledgerHis = await this.ctx.service.ledgerHistory.getLatestHistory(this.ctx.tender.id);
-                        his_id = ledgerHis.id;
-                    } else {
-                        const sbCount = await this.ctx.service.ledger.count({ tender_id: this.ctx.stage.tid });
-                        const spCount = await this.ctx.service.pos.count({ tid: this.ctx.stage.tid });
-                        const ledgerHis = await this.ctx.service.ledgerHistory.getLatestHistory(this.ctx.tender.id);
-                        if (sbCount > ledgerHis.bills_count || spCount > ledgerHis.pos_count) {
-                            his_id = await this.ctx.service.ledgerHistory.backupStageLedgerHistory(this.ctx.stage);
-                        } else {
-                            his_id = ledgerHis.id;
-                        }
-                    }
+                    const his_id = await this.ctx.service.ledgerHistory.backupStageLedgerHistory(this.ctx.stage);
+
                     // 本期结束
                     // 生成截止本期数据 final数据
                     await this.ctx.service.stageBillsFinal.generateFinalData(transaction, this.ctx.tender, this.ctx.stage);