|
@@ -836,6 +836,26 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async saveQtyHistory(updateList) {
|
|
|
+ if (!this.ctx.tender || !this.ctx.material) {
|
|
|
+ throw '数据错误';
|
|
|
+ }
|
|
|
+ // 判断是否可修改
|
|
|
+ // 判断t_type是否为费用
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
+ try {
|
|
|
+ if (updateList.length > 0) await transaction.updateRows(this.tableName, updateList);
|
|
|
+ await transaction.update(this.ctx.service.material.tableName, { id: this.ctx.material.id, is_new_qty: 1 });
|
|
|
+ await transaction.commit();
|
|
|
+ return {
|
|
|
+ materialListData: await this.getMaterialData(this.ctx.tender.id, this.ctx.material.id)
|
|
|
+ };
|
|
|
+ } catch (err) {
|
|
|
+ await transaction.rollback();
|
|
|
+ throw err;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
async getMbQuantity(transaction, mid, qty_source, qty_decimal, mb_id, ms_id = null, needRound = 1) {
|
|
|
const msSql = ms_id ? ' AND `ms_id` = ' + ms_id : '';
|
|
|
const sql = 'SELECT SUM(' + this.ctx.helper.getQtySource(qty_source) + '*`quantity`) as quantity FROM ' + this.tableName + ' WHERE `mid`=? AND `mb_id`=?' + msSql + ' AND `is_join`=1';
|