瀏覽代碼

合同支付计算调整

MaiXinRong 2 年之前
父節點
當前提交
6d090d2cf0
共有 2 個文件被更改,包括 24 次插入5 次删除
  1. 23 4
      app/lib/pay_calc.js
  2. 1 1
      app/service/stage_pay.js

+ 23 - 4
app/lib/pay_calc.js

@@ -190,10 +190,24 @@ class PayCalculate {
     }
 
     getLeafOrder(data, pays, parentOrder) {
-        if (!data) return [];
-        if (!data.expr) return [`f${data.order}`];
+        // if (!data) return [];
+        // if (!data.expr) return [`f${data.order}`];
+        // const orderParam = data.expr.match(this.orderReg);
+        // if (!orderParam || orderParam.length === 0) return [`f${data.order}`];
+        //
+        // const result = [...orderParam];
+        // for (const op of orderParam) {
+        //     const order = op.substring(1, op.length);
+        //     if (parseInt(order) === data.order || op === parentOrder) {
+        //         result.push(op);
+        //     } else {
+        //         result.push(...this.getLeafOrder(pays[parseInt(order) -1], pays, `f${data.order}`));
+        //     }
+        // }
+        // return this.ctx.helper._.uniq(result);
+        if (!data || !data.expr) return [];
         const orderParam = data.expr.match(this.orderReg);
-        if (!orderParam || orderParam.length === 0) return [`f${data.order}`];
+        if (!orderParam || orderParam.length === 0) return [];
 
         const result = [...orderParam];
         for (const op of orderParam) {
@@ -201,7 +215,12 @@ class PayCalculate {
             if (parseInt(order) === data.order || op === parentOrder) {
                 result.push(op);
             } else {
-                result.push(...this.getLeafOrder(pays[parseInt(order) -1], pays, `f${data.order}`));
+                const sub = this.getLeafOrder(pays[parseInt(order) -1], pays, `f${data.order}`);
+                if (sub.length > 0) {
+                    result.push(...sub);
+                } else {
+                    result.push(op);
+                }
             }
         }
         return this.ctx.helper._.uniq(result);

+ 1 - 1
app/service/stage_pay.js

@@ -481,7 +481,7 @@ module.exports = app => {
                 // 假删除
                 const result = await transaction.update(this.ctx.service.pay.tableName, { id: id, valid: false });
                 if (result.affectedRows !== 1) throw '删除合同支付项失败';
-                await transaction.updateRows(this.ctx.service.pay.tableName, updateData);
+                if (updateData.length > 0) await transaction.updateRows(this.ctx.service.pay.tableName, updateData);
                 for (const usd of updateStageData) {
                     await transaction.update(this.tableName, usd.update, usd.condition);
                 }