浏览代码

保留撤回的合同支付数据

laiguoran 2 年之前
父节点
当前提交
e4826f1fd7
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 5 2
      app/service/stage_audit.js
  2. 2 2
      app/service/stage_pay.js

+ 5 - 2
app/service/stage_audit.js

@@ -1032,6 +1032,9 @@ module.exports = app => {
                     // 计算该审批人最终数据
                     await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                     // 复制一份最新数据给下一人
+                    // 保留审批人数据,覆盖到原报中并删除该审批人合同支付数据
+                    await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 0, transaction);
+                    await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, 0, transaction, this.ctx.stage.times, 1);
                     await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 1, transaction);
                     await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
                     await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction);
@@ -1260,9 +1263,9 @@ module.exports = app => {
                     // 计算该审批人最终数据
                     await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                     // 复制一份最新数据给下一人
+                    await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 1, transaction, this.ctx.stage.times, 0);
+                    await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 2, transaction, this.ctx.stage.times, 0);
                     await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 0, transaction);
-                    await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 1, transaction);
-                    await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 2, transaction);
                     await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
                     await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction);
                     await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction);

+ 2 - 2
app/service/stage_pay.js

@@ -293,7 +293,7 @@ module.exports = app => {
          * @param transaction - 事务
          * @returns {Promise<*>}
          */
-        async copyAuditStagePays(stage, times, order, transaction) {
+        async copyAuditStagePays(stage, times, order, transaction, curTimes = stage.curTimes, curOrder = stage.curOrder) {
             if (!stage || !transaction || !times || order === undefined) {
                 throw '数据错误';
             }
@@ -303,7 +303,7 @@ module.exports = app => {
                         '     SP.`pre_tp`, SP.`end_tp`, SP.`pre_used`, SP.`pre_finish`, SP.`start_stage_order`, SP.`postil` ' +
                         '  FROM ?? As SP' +
                         '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ?';
-            const sqlParam = [this.tableName, times, order, this.tableName, stage.id, stage.curTimes, stage.curOrder];
+            const sqlParam = [this.tableName, times, order, this.tableName, stage.id, curTimes, curOrder];
             return await transaction.query(sql, sqlParam);
         }