Bladeren bron

调用变更令问题

MaiXinRong 3 jaren geleden
bovenliggende
commit
062222e607
1 gewijzigde bestanden met toevoegingen van 6 en 10 verwijderingen
  1. 6 10
      app/service/stage_change.js

+ 6 - 10
app/service/stage_change.js

@@ -234,23 +234,21 @@ module.exports = app => {
                 if (!nc || nc.qty !== oc.qty) {
                     const qty = nc ? this.round(nc.qty, precision.value) : null;
                     const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus);
-                    if (!change.minus) {
-                        posQty = this.ctx.helper.add(posQty, change.qty);
-                    }
+                    if (!change.minus) posQty = this.ctx.helper.add(posQty, change.qty);
                     if (oc.stimes === this.ctx.stage.curTimes && oc.sorder === this.ctx.stage.curOrder) {
                         change.id = oc.id;
                         updateChanges.push(change);
+                    } else {
+                        newChanges.push(change);
                     }
                 } else {
-                    if (!oc.minus) {
-                        posQty = this.ctx.helper.add(posQty, oc.qty);
-                    }
+                    if (!oc.minus) posQty = this.ctx.helper.add(posQty, oc.qty);
                 }
             }
             for (const c of changes) {
                 const nc = this._.find(oldChanges, { cid: c.cid, cbid: c.cbid });
                 if (!nc) {
-                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus);
+                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value));
                     if (!change.minus) {
                         posQty = this.ctx.helper.add(posQty, change.qty);
                     }
@@ -261,9 +259,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 if (newChanges.length > 0) await transaction.insert(this.tableName, newChanges);
-                for (const c of updateChanges) {
-                    await transaction.update(this.tableName, c);
-                }
+                if (updateChanges.length > 0) await transaction.updateRows(this.tableName, c);
                 await this.ctx.service.stagePos.updateChangeQuantity(transaction, pos, posQty);
                 await transaction.commit();
             } catch (err) {