|
@@ -94,10 +94,12 @@ module.exports = app => {
|
|
|
c.contract_tp = this.ctx.helper.add(c.contract_tp, p.contract_tp);
|
|
|
c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
|
|
|
c.qc_tp = this.ctx.helper.add(c.qc_tp, p.qc_tp);
|
|
|
- c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
|
|
|
+ c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
|
|
|
+ || !this.ctx.helper.checkZero(c.contract_tp) || !this.ctx.helper.checkZero(c.qc_tp);
|
|
|
pre.splice(pre.indexOf(p), 1);
|
|
|
} else {
|
|
|
- c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
|
|
|
+ c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
|
|
|
+ || !this.ctx.helper.checkZero(c.contract_tp) || !this.ctx.helper.checkZero(c.qc_tp);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -105,13 +107,12 @@ module.exports = app => {
|
|
|
if (p.id !== undefined) delete p.id;
|
|
|
p.sid = stage.id;
|
|
|
p.sorder = stage.order;
|
|
|
- p.used = p.used || !this.ctx.helper.checkZero(p.contract_qty) || !this.ctx.helper.checkZero(p.qc_qty);
|
|
|
}
|
|
|
await transaction.insert(this.tableName, cur ? cur.concat(pre) : pre);
|
|
|
} else {
|
|
|
const sql = 'Insert Into ??(tid, sid, lid, sorder, contract_qty, contract_tp, qc_qty, qc_tp, used)' +
|
|
|
' SELECT b.tid, b.sid, b.lid, ? As `sorder`, b.contract_qty, b.contract_tp, b.qc_qty, b.qc_tp,' +
|
|
|
- ' IFNULL((b.contract_qty <> 0 or b.contract_tp <> 0 or b.qc_qty <> 0 or b.qc_tp <> 0), 0) As used' +
|
|
|
+ ' IF(IFNULL(b.contract_qty, 0) <> 0 or IFNULL(b.contract_tp, 0) <> 0 or IFNULL(b.qc_qty, 0) <> 0 or IFNULL(b.qc_tp, 0) <> 0, 1, 0) As used' +
|
|
|
' FROM ' + this.ctx.service.stageBills.tableName + ' AS b' +
|
|
|
' INNER JOIN(' +
|
|
|
' SELECT Max(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` FROM ' + this.ctx.service.stageBills.tableName +
|