فهرست منبع

合同支付,记录往期排序

MaiXinRong 2 سال پیش
والد
کامیت
1b3cd7b43c
3فایلهای تغییر یافته به همراه21 افزوده شده و 3 حذف شده
  1. 1 0
      app/service/stage_audit.js
  2. 15 2
      app/service/stage_pay.js
  3. 5 1
      sql/update.sql

+ 1 - 0
app/service/stage_audit.js

@@ -489,6 +489,7 @@ module.exports = app => {
                         cache_time_r: this.ctx.stage.cache_time_l,
                         his_id,
                     });
+                    await this.ctx.service.stagePay.cacheOrder(this.ctx.stage, transaction);
 
                     // 添加短信通知-审批通过提醒功能
                     const stageInfo = await this.ctx.service.stage.getDataById(stageId);

+ 15 - 2
app/service/stage_pay.js

@@ -138,6 +138,11 @@ module.exports = app => {
             return await this.getAuditorStagePay(pid, stage.id, stage.curTimes, stage.curOrder);
         }
 
+        async resortStagePays(stage, stagePays) {
+            if (stage.status !== auditConst.stage.status.checked) return;
+            stagePays.sort((x, y) => { return x.porder - y.porder; });
+        }
+
         /**
          * 获取某期合同支付数据
          *
@@ -145,7 +150,9 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getStagePays(stage) {
-            return await this.getAuditorStageData(stage.id, stage.curTimes, stage.curOrder);
+            const result = await this.getAuditorStageData(stage.id, stage.curTimes, stage.curOrder);
+            this.resortStagePays(stage, result);
+            return result;
         }
 
         /**
@@ -166,7 +173,8 @@ module.exports = app => {
                 '  WHERE SP.`sid` = ? AND P.`valid` = true' +
                 '  ORDER BY P.`order`';
             const sqlParam = [sid, sid];
-            return await this.db.query(sql, sqlParam);
+            const result = await this.db.query(sql, sqlParam);
+            return result;
         }
 
         /**
@@ -485,6 +493,11 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        async cacheOrder(stage, transaction) {
+            const sql = `UPDATE ${this.tableName} sp LEFT JOIN ${this.ctx.service.pay.tableName} p ON sp.pid = p.id SET sp.porder = p.\`order\` Where sp.sid = ?`;
+            await transaction.query(sql, [stage.id]);
+        }
     }
 
     return StagePay;

+ 5 - 1
sql/update.sql

@@ -175,4 +175,8 @@ ADD COLUMN `ccid`  varchar(36) NULL DEFAULT '' COMMENT 'create_change_id(uuid)'
 ALTER TABLE `zh_revise_pos_18`
 ADD COLUMN `ccid`  varchar(36) NULL DEFAULT '' COMMENT 'create_change_id(uuid)' AFTER `crid`;
 ALTER TABLE `zh_revise_pos_19`
-ADD COLUMN `ccid`  varchar(36) NULL DEFAULT '' COMMENT 'create_change_id(uuid)' AFTER `crid`;
+ADD COLUMN `ccid`  varchar(36) NULL DEFAULT '' COMMENT 'create_change_id(uuid)' AFTER `crid`;
+
+ALTER TABLE `zh_stage_pay`
+ADD COLUMN `porder` tinyint(4) NOT NULL DEFAULT '0' COMMENT '排序' AFTER `sorder`;
+UPDATE zh_stage_pay sp LEFT JOIN zh_pay p ON sp.pid = p.id SET sp.porder = p.`order`;