Browse Source

合同支付,奖罚金相关基数计算调整

MaiXinRong 13 hours ago
parent
commit
2a30f762d1
2 changed files with 5 additions and 1 deletions
  1. 4 0
      app/service/phase_pay.js
  2. 1 1
      app/service/stage_bonus.js

+ 4 - 0
app/service/phase_pay.js

@@ -141,6 +141,8 @@ module.exports = app => {
             const bonusSum = await this.ctx.service.stageBonus.getSumTp(relaStage);
             result.bonus_positive_tp = bonusSum.positive_tp || 0;
             result.bonus_negative_tp = bonusSum.negative_tp || 0;
+            result.bonus_reward_tp = bonusSum.reward_tp || 0;
+            result.bonus_forfeit_tp = bonusSum.forfeit_tp || 0;
             result.bonus_tp = bonusSum.sum_tp || 0;
             const jgclSum = await this.ctx.service.stageJgcl.getSumTp(relaStage);
             result.jgcl_tp = jgclSum.sum_tp || 0;
@@ -164,6 +166,8 @@ module.exports = app => {
 
                 result.pre_bonus_positive_tp = this.ctx.helper.add(prePhase.calc_base.bonus_positive_tp, prePhase.calc_base.pre_bonus_positive_tp);
                 result.pre_bonus_negative_tp = this.ctx.helper.add(prePhase.calc_base.bonus_negative_tp, prePhase.calc_base.pre_bonus_negative_tp);
+                result.pre_bonus_reward_tp = this.ctx.helper.add(prePhase.calc_base.bonus_reward_tp, prePhase.calc_base.pre_bonus_reward_tp);
+                result.pre_bonus_forfeit_tp = this.ctx.helper.add(prePhase.calc_base.bonus_forfeit_tp, prePhase.calc_base.pre_bonus_forfeit_tp);
                 result.pre_bonus_tp = this.ctx.helper.add(prePhase.calc_base.bonus_tp, prePhase.calc_base.pre_bonus_tp);
                 result.pre_jgcl_tp = this.ctx.helper.add(prePhase.calc_base.jgcl_tp, prePhase.calc_base.pre_jgcl_tp);
                 result.pre_other_tp = this.ctx.helper.add(prePhase.calc_base.other_tp, prePhase.calc_base.pre_other_tp);

+ 1 - 1
app/service/stage_bonus.js

@@ -233,7 +233,7 @@ module.exports = app => {
             const stages = stage instanceof Array ? stage : [stage];
             const condition = {};
             condition.sid = stage.length === 1 ? stage[0].id : stages.map(x => { return x.id; }).join(',');
-            const sql = `SELECT SUM(IF(tp > 0, tp, 0)) AS positive_tp, SUM(IF(tp < 0, tp, 0)) AS negative_tp, SUM(tp) AS sum_tp From ${this.tableName} ` + this.ctx.helper.whereSql(condition);
+            const sql = `SELECT SUM(IF(tp > 0, tp, 0)) AS positive_tp, SUM(IF(tp < 0, tp, 0)) AS negative_tp, SUM(IF(b_type = '奖金'), tp, 0) AS reward_tp, SUM(IF(b_type = '罚金'), tp, 0) AS forfeit_tp, SUM(tp) AS sum_tp From ${this.tableName} ` + this.ctx.helper.whereSql(condition);
             return await this.db.queryOne(sql);
         }
     }