Jelajahi Sumber

迁移旧数据,计算本期,截止本期相关

MaiXinRong 5 bulan lalu
induk
melakukan
a1cdd9c80b
1 mengubah file dengan 8 tambahan dan 1 penghapusan
  1. 8 1
      app/service/safe_stage.js

+ 8 - 1
app/service/safe_stage.js

@@ -299,7 +299,7 @@ module.exports = app => {
             return user;
         }
         async copyPaySafeData(payTenderId) {
-            const details = await this.ctx.service.paymentDetail.getAllDataByCondition({ where: { tender_id: payTenderId, type: 1 } });
+            const details = await this.ctx.service.paymentDetail.getAllDataByCondition({ where: { tender_id: payTenderId, type: 1 }, orders: [['order', 'asc']] });
             const tid = this.ctx.tender.id;
             const conn = await this.db.beginTransaction();
             try {
@@ -314,6 +314,7 @@ module.exports = app => {
                     };
                     insertStage.push(stage);
                     const safeBills = await this.ctx.service.paymentSafeBills.getAllDataByCondition({ where: { detail_id: detail.id } });
+                    let tp = 0, pre_tp = 0;
                     for (const sb of safeBills) {
                         sb.tender_id = tid;
                         delete sb.detail_id;
@@ -326,8 +327,14 @@ module.exports = app => {
                             delete h.order;
                         }
                         sb.cur_his = JSON.stringify(his);
+                        if (sb.tree_is_leaf) {
+                            pre_tp = this.ctx.helper.add(pre_tp, sb.pre_tp);
+                            tp = this.ctx.helper.add(tp, sb.cur_tp);
+                        }
                         insertBills.push(sb);
                     }
+                    stage.pre_bills_tp = pre_tp;
+                    stage.bills_tp = tp;
                     const user = await this._getUserInfo(detail.uid);
                     const audits = await this.ctx.service.paymentDetailAudit.getAllDataByCondition({ where: { td_id: detail.id }, orders: [['times', 'asc'], ['order', 'asc']]});
                     if (detail.status === audit.status.checked) {