|
|
@@ -12,7 +12,7 @@ const auditConst = require('../const/audit').material;
|
|
|
const materialConst = require('../const/material');
|
|
|
const MaterialCalculator = require('../lib/material_calc');
|
|
|
|
|
|
-const needUpdateArray = ['m_price', 'remark'];
|
|
|
+const needUpdateArray = ['weight_num', 'm_price', 'remark'];
|
|
|
|
|
|
module.exports = app => {
|
|
|
class MaterialExponentShard extends app.BaseService {
|
|
|
@@ -167,14 +167,14 @@ module.exports = app => {
|
|
|
let sumByChange = 0;
|
|
|
let constant = 0;
|
|
|
for (const ex of exponentList) {
|
|
|
+ const stageEx = this._.find(stageExponentList, { me_id: ex.id });
|
|
|
if (ex.type === materialConst.ex_type[0].value) {
|
|
|
- constant = ex.weight_num ? ex.weight_num : 0;
|
|
|
+ constant = stageEx.weight_num ? stageEx.weight_num : 0;
|
|
|
expr += constant.toString();
|
|
|
} else if (ex.type === materialConst.ex_type[1].value) {
|
|
|
- const stageEx = this._.find(stageExponentList, { me_id: ex.id });
|
|
|
- const calc_num = ex.basic_price > 0 ? this.ctx.helper.mul(ex.weight_num, this.ctx.helper.div(stageEx.m_price, ex.basic_price)) : 0;
|
|
|
+ const calc_num = ex.basic_price > 0 ? this.ctx.helper.mul(stageEx.weight_num, this.ctx.helper.div(stageEx.m_price, ex.basic_price)) : 0;
|
|
|
const change = calc_num ? this.ctx.helper.round(calc_num, decimal.qty) : 0;
|
|
|
- expr = expr + (change !== 0 ? '+' + ex.weight_num.toString() + '*(' + stageEx.m_price.toString() + '/' + ex.basic_price.toString() + ')' : '');
|
|
|
+ expr = expr + (change !== 0 ? '+' + stageEx.weight_num.toString() + '*(' + stageEx.m_price.toString() + '/' + ex.basic_price.toString() + ')' : '');
|
|
|
sumByChange = this.ctx.helper.add(sumByChange, change);
|
|
|
}
|
|
|
}
|
|
|
@@ -270,6 +270,7 @@ module.exports = app => {
|
|
|
ms_id: materialStageInfo.id,
|
|
|
me_id: me.id,
|
|
|
type: me.type,
|
|
|
+ weight_num: me.weight_num,
|
|
|
m_price: me.m_price,
|
|
|
remark: me.remark,
|
|
|
};
|
|
|
@@ -298,6 +299,7 @@ module.exports = app => {
|
|
|
me_id: e.id,
|
|
|
ms_id: ms.id,
|
|
|
type: e.type,
|
|
|
+ weight_num: e.weight_num,
|
|
|
m_price: e.m_price,
|
|
|
};
|
|
|
insertStageExponentData.push(oneStageExponentData);
|