فهرست منبع

修复计价不加价bug

ellisran 1 روز پیش
والد
کامیت
ea39ae63f8
2فایلهای تغییر یافته به همراه16 افزوده شده و 20 حذف شده
  1. 3 7
      app/service/change.js
  2. 13 13
      app/service/change_audit_list.js

+ 3 - 7
app/service/change.js

@@ -998,8 +998,6 @@ module.exports = app => {
                     // 清单数据更新
                     const bills_list = await this.ctx.service.changeAuditList.getList(changeData.cid, changeData.order_by);
                     let total_price = 0;
-                    let valuation_tp = 0;
-                    let unvaluation_tp = 0;
                     const tp_decimal = changeData.tp_decimal ? changeData.tp_decimal : this.ctx.tender.info.decimal.tp;
                     const updateList = [];
                     for (const bl of bills_list) {
@@ -1014,9 +1012,6 @@ module.exports = app => {
                             list_update.samount = bl.spamount || 0;
                             list_update.checked_amount = bl.spamount || 0;
                             list_update.checked_price = this.ctx.helper.mul(bl.unit_price, list_update.checked_amount, tp_decimal);
-                            // 统计计价和不计价金额
-                            valuation_tp = bl.is_valuation ? this.ctx.helper.add(valuation_tp, list_update.checked_price) : valuation_tp;
-                            unvaluation_tp = !bl.is_valuation ? this.ctx.helper.add(unvaluation_tp, list_update.checked_price) : unvaluation_tp;
                         }
                         updateList.push(list_update);
                     }
@@ -1095,14 +1090,13 @@ module.exports = app => {
                         }
                     }
                     change_update.total_price = total_price;
-                    change_update.valuation_tp = valuation_tp;
-                    change_update.unvaluation_tp = unvaluation_tp;
                     const options = {
                         where: {
                             cid: changeData.cid,
                         },
                     };
                     await this.transaction.update(this.tableName, change_update, options);
+                    await this.ctx.service.changeAuditList.calcCamountSum(this.transaction, false, changeData);
                 }
                 await this.transaction.commit();
                 result = true;
@@ -1247,6 +1241,7 @@ module.exports = app => {
                     },
                 };
                 await this.transaction.update(this.tableName, change_update, options);
+                await this.ctx.service.changeAuditList.calcCamountSum(this.transaction, false, changeData);
 
                 await this.transaction.commit();
                 result = true;
@@ -1389,6 +1384,7 @@ module.exports = app => {
                     },
                 };
                 await this.transaction.update(this.tableName, change_update, options);
+                await this.ctx.service.changeAuditList.calcCamountSum(this.transaction, false, changeData);
                 const sms = new SMS(this.ctx);
                 const code = await sms.contentChange(changeData.code);
                 const shenpiUrl = await this.ctx.helper.urlToShort(

+ 13 - 13
app/service/change_audit_list.js

@@ -509,27 +509,27 @@ module.exports = app => {
                     let unitPrice = 0;
                     for (const cl of list) {
                         if (cl.spamount) {
-                            spamount = this.ctx.helper.accAdd(spamount, cl.spamount);
+                            spamount = this.ctx.helper.add(spamount, cl.spamount);
                             unitPrice = cl.unit_price;
                             if (cl.is_valuation) {
-                                valuation_amount = this.ctx.helper.accAdd(valuation_amount, cl.spamount);
+                                valuation_amount = this.ctx.helper.add(valuation_amount, cl.spamount);
                             } else {
-                                unvaluation_amount = this.ctx.helper.accAdd(unvaluation_amount, cl.spamount);
+                                unvaluation_amount = this.ctx.helper.add(unvaluation_amount, cl.spamount);
                             }
                             const posOrNePrice = this.ctx.helper.mul(cl.spamount, this.ctx.helper.round(cl.unit_price, up_decimal), tp_decimal);
                             if (posOrNePrice >= 0) {
-                                positive_tp = this.ctx.helper.accAdd(positive_tp, posOrNePrice);
+                                positive_tp = this.ctx.helper.add(positive_tp, posOrNePrice);
                             } else {
-                                negative_tp = this.ctx.helper.accAdd(negative_tp, posOrNePrice);
+                                negative_tp = this.ctx.helper.add(negative_tp, posOrNePrice);
                             }
                         }
                     }
                     const price = this.ctx.helper.mul(spamount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal);
                     const valuation_price = this.ctx.helper.mul(valuation_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
                     const unvaluation_price = this.ctx.helper.mul(unvaluation_amount, this.ctx.helper.round(unitPrice, up_decimal), tp_decimal) || 0;
-                    valuation_tp = this.ctx.helper.accAdd(valuation_tp, valuation_price);
-                    unvaluation_tp = this.ctx.helper.accAdd(unvaluation_tp, unvaluation_price);
-                    total_price = this.ctx.helper.accAdd(total_price, price);
+                    valuation_tp = this.ctx.helper.add(valuation_tp, valuation_price);
+                    unvaluation_tp = this.ctx.helper.add(unvaluation_tp, unvaluation_price);
+                    total_price = this.ctx.helper.add(total_price, price);
                     // if (price >= 0) {
                     //     positive_tp = this.ctx.helper.accAdd(positive_tp, price);
                     // } else {
@@ -539,16 +539,16 @@ module.exports = app => {
                     const list = this._.filter(changeList, { gcl_id: g });
                     for (const cl of list) {
                         const price = this.ctx.helper.mul(this.ctx.helper.round(cl.unit_price, up_decimal), cl.spamount, tp_decimal);
-                        total_price = this.ctx.helper.accAdd(total_price, price);
+                        total_price = this.ctx.helper.add(total_price, price);
                         if (price >= 0) {
-                            positive_tp = this.ctx.helper.accAdd(positive_tp, price);
+                            positive_tp = this.ctx.helper.add(positive_tp, price);
                         } else {
-                            negative_tp = this.ctx.helper.accAdd(negative_tp, price);
+                            negative_tp = this.ctx.helper.add(negative_tp, price);
                         }
                         if (cl.is_valuation) {
-                            valuation_tp = this.ctx.helper.accAdd(valuation_tp, price);
+                            valuation_tp = this.ctx.helper.add(valuation_tp, price);
                         } else {
-                            unvaluation_tp = this.ctx.helper.accAdd(unvaluation_tp, price);
+                            unvaluation_tp = this.ctx.helper.add(unvaluation_tp, price);
                         }
                     }
                 }