|
@@ -144,10 +144,11 @@ module.exports = app => {
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
const material_month = this.ctx.material.months ? this.ctx.material.months.split(',') : [];
|
|
|
- await transaction.update(this.tableName, { msg_tp: data.value }, { where: { mb_id: data.mb_id, yearmonth: data.yearmonth } });
|
|
|
- const monthList = await transaction.select(this.tableName, { where: { mb_id: data.mb_id } });
|
|
|
+ await transaction.update(this.tableName, { msg_tp: data.value }, { where: { mb_id: data.mb_id, yearmonth: data.yearmonth, mid: this.ctx.material.id } });
|
|
|
+ const monthList = await transaction.select(this.tableName, { where: { mb_id: data.mb_id, mid: this.ctx.material.id } });
|
|
|
const mbInfo = await transaction.get(this.ctx.service.materialBills.tableName, { id: data.mb_id });
|
|
|
if (monthList.length !== 0) {
|
|
|
+ console.log(monthList);
|
|
|
const mb_msg_tp_sum = this._.sumBy(monthList, 'msg_tp');
|
|
|
const month_num = material_month.length - this.ctx.helper.arrayCount(this._.map(monthList, 'msg_tp'), null);
|
|
|
const new_msg_tp = month_num !== 0 ? this.ctx.helper.round(this.ctx.helper.div(mb_msg_tp_sum, month_num), 3) : null;
|