فهرست منبع

变更金额汇总sql小数位bug

ellisran 9 ماه پیش
والد
کامیت
33ad4ec6f0
1فایلهای تغییر یافته به همراه8 افزوده شده و 3 حذف شده
  1. 8 3
      app/service/change.js

+ 8 - 3
app/service/change.js

@@ -631,10 +631,15 @@ module.exports = app => {
          * @return {void}
          */
         async getChangeTp(tenderId) {
-            const sql = 'SELECT SUM(`total_price`) AS tp, SUM(`positive_tp`) AS p_tp, SUM(`negative_tp`) AS n_tp, SUM(`valuation_tp`) AS v_tp, SUM(`unvaluation_tp`) AS uv_tp FROM ?? WHERE tid = ? AND status = ?';
+            const sql = 'SELECT `total_price`, `positive_tp`, `negative_tp`, `valuation_tp`, `unvaluation_tp` FROM ?? WHERE tid = ? AND status = ?';
             const sqlParam = [this.tableName, tenderId, audit.change.status.checked];
-            const result = await this.db.queryOne(sql, sqlParam);
-            return result ? [result.tp, result.p_tp, result.n_tp, result.v_tp, result.uv_tp] : [0, 0, 0, 0, 0];
+            const result = await this.db.query(sql, sqlParam);
+            const tp = this.ctx.helper.sum(this._.map(result, 'total_price'));
+            const p_tp = this.ctx.helper.sum(this._.map(result, 'positive_tp'));
+            const n_tp = this.ctx.helper.sum(this._.map(result, 'negative_tp'));
+            const v_tp = this.ctx.helper.sum(this._.map(result, 'valuation_tp'));
+            const uv_tp = this.ctx.helper.sum(this._.map(result, 'unvaluation_tp'));
+            return result ? [tp, p_tp, n_tp, v_tp, uv_tp] : [0, 0, 0, 0, 0];
         }
 
         /**