Browse Source

修复资金测试bug

ellisran 7 months ago
parent
commit
c592bb696d
1 changed files with 4 additions and 2 deletions
  1. 4 2
      app/service/financial_pay_contract.js

+ 4 - 2
app/service/financial_pay_contract.js

@@ -102,7 +102,6 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, data);
-                await this.calcCamountSum(fpid, transaction);
                 const tp = await this.calcCamountSum(fpid, transaction);
                 await transaction.commit();
                 return { tp };
@@ -138,17 +137,20 @@ module.exports = app => {
 
         async calcCamountSum(fpid, transaction) {
             // 防止小数位不精确,采用取值计算
-            const sql = 'SELECT pay_price FROM ?? WHERE fpid = ?';
+            const sql = 'SELECT `small_expenses`, `pay_price` FROM ?? WHERE fpid = ?';
             const sqlParam = [this.tableName, fpid];
             const list = await transaction.query(sql, sqlParam);
             let total_price = 0;
+            let small_expenses_tp = 0;
             // const tp_decimal = this.ctx.change.decimal.tp;
             for (const l of list) {
                 total_price = this.ctx.helper.accAdd(total_price, l.pay_price || 0);
+                small_expenses_tp = this.ctx.helper.accAdd(small_expenses_tp, l.small_expenses ? l.pay_price || 0 : 0);
             }
             const updateData = {
                 id: fpid,
                 total_price,
+                small_expenses_tp,
             };
             await transaction.update(this.ctx.service.financialPay.tableName, updateData);
             return total_price;