Browse Source

删除本次审批,删除合同支付调整

MaiXinRong 5 years ago
parent
commit
d5fab79fc8
2 changed files with 22 additions and 3 deletions
  1. 2 3
      app/service/stage_audit.js
  2. 20 0
      app/service/stage_pay.js

+ 2 - 3
app/service/stage_audit.js

@@ -1042,13 +1042,12 @@ module.exports = app => {
                 await transaction.insert(this.tableName, auditors);
                 await transaction.insert(this.tableName, auditors);
 
 
                 // 计算缓存
                 // 计算缓存
-                this.ctx.stage.curTimes = this.ctx.stage.nowTimes;
-                this.ctx.stage.curOrder = 0;
                 const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
                 const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
                 // 计算并合同支付最终数据
                 // 计算并合同支付最终数据
                 const lastAudit = await this.getDataByCondition({sid: this.ctx.stage.id, times: nowTimes - 1, status: auditConst.status.checkNo});
                 const lastAudit = await this.getDataByCondition({sid: this.ctx.stage.id, times: nowTimes - 1, status: auditConst.status.checkNo});
                 if (!lastAudit) throw '审批数据错误';
                 if (!lastAudit) throw '审批数据错误';
-                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, lastAudit.times, lastAudit.order, transaction);
+
+                await this.ctx.service.stagePay.copyStagePays4DeleteTimes(this.ctx.stage, nowTimes, 0, lastAudit.times, lastAudit.order, transaction);
                 const stagePay = await this.ctx.service.stagePay.getAuditorStageData(this.ctx.stage.id, lastAudit.times, lastAudit.order);
                 const stagePay = await this.ctx.service.stagePay.getAuditorStageData(this.ctx.stage.id, lastAudit.times, lastAudit.order);
                 const yfPay = stagePay.find(function (x) {
                 const yfPay = stagePay.find(function (x) {
                     return x.ptype === payConst.payType.yf;
                     return x.ptype === payConst.payType.yf;

+ 20 - 0
app/service/stage_pay.js

@@ -295,6 +295,26 @@ module.exports = app => {
         }
         }
 
 
         /**
         /**
+         * 拷贝上一操作人数据 为 下一操作人数据
+         * @param stage - 期数据
+         * @param times - 下一操作人 该期第几次
+         * @param order - 下一操作人顺序
+         * @param transaction - 事务
+         * @returns {Promise<*>}
+         */
+        async copyStagePays4DeleteTimes(stage, times, order, copyTimes, copyOrder, transaction) {
+            const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `name`, `tp`, `expr`, `pause`, `attachment`,' +
+                '    `pre_tp`, `end_tp`, `pre_used`, `pre_finish`, `start_stage_order`) ' +
+                '  SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.name, SP.`tp`, SP.`expr`, SP.`pause`, SP.`attachment`,' +
+                '     SP.`pre_tp`, SP.`end_tp`, SP.`pre_used`, SP.`pre_finish`, SP.`start_stage_order` ' +
+                '  FROM ?? As SP, ?? As P ' +
+                '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? And SP.`pid` = P.`id` And P.`valid`';
+            const sqlParam = [this.tableName, times, order, this.tableName, this.ctx.service.pay.tableName,
+                stage.id, copyTimes, copyOrder];
+            return await transaction.query(sql, sqlParam);
+        }
+
+        /**
          * 保存附件
          * 保存附件
          * @param data
          * @param data
          * @returns {Promise<void>}
          * @returns {Promise<void>}