Ver código fonte

本期合同计量,本期数量变更计量,本期完成计量计算问题

MaiXinRong 5 anos atrás
pai
commit
7dd4a5dfa9
2 arquivos alterados com 9 adições e 6 exclusões
  1. 6 2
      app/service/stage.js
  2. 3 4
      app/service/stage_bills.js

+ 6 - 2
app/service/stage.js

@@ -155,7 +155,7 @@ module.exports = app => {
             // 最新一期计量(未审批完成),当前操作人的期详细数据,应实时计算
             if (stage.status !== auditConst.status.checked && stage.check_calc) {
                 const curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
-                const isActive = curAuditor ? curAuditor.id === this.ctx.session.sessionUser.accountId : stage.user_id === this.ctx.session.sessionUser.accountId;
+                const isActive = curAuditor ? curAuditor.aid === this.ctx.session.sessionUser.accountId : stage.user_id === this.ctx.session.sessionUser.accountId;
                 stage.curTimes = stage.status === auditConst.status.checkNo ? stage.times - 1 : stage.times;
                 stage.curOrder = curAuditor ? curAuditor.order : 0;
                 if (isActive) {
@@ -191,12 +191,16 @@ module.exports = app => {
             // 最新一期计量(未审批完成),当前操作人的期详细数据,应实时计算
             if (stages.length > 0 && stages[0].status !== auditConst.status.checked) {
                 const stage = stages[0];
+                console.log(stage);
                 const curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
-                const isActive = curAuditor ? curAuditor.id === this.ctx.session.sessionUser.accountId : stage.user_id === this.ctx.session.sessionUser.accountId;
+                console.log(curAuditor);
+                const isActive = curAuditor ? curAuditor.aid === this.ctx.session.sessionUser.accountId : stage.user_id === this.ctx.session.sessionUser.accountId;
+                console.log(isActive);
                 if (isActive) {
                     stage.curTimes = stage.times;
                     stage.curOrder = curAuditor ? curAuditor.order : 0;
                     const tpData = await this.ctx.service.stageBills.getSumTotalPrice(stage);
+                    console.log(tpData);
                     stage.contract_tp = tpData.contract_tp;
                     stage.qc_tp = tpData.qc_tp;
                     stage.yf_tp = await this.ctx.service.stagePay.getYfTotalPrice(stage);

+ 3 - 4
app/service/stage_bills.js

@@ -359,12 +359,11 @@ module.exports = app => {
         async getSumTotalPrice(stage) {
             const sql = 'SELECT Sum(`contract_tp`) As `contract_tp`, Sum(`qc_tp`) As `qc_tp` FROM ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` From ' + this.tableName +
-                '      WHERE `times` <= ? AND `order` <= ?' +
+                '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid`, `sid` From ' + this.tableName +
+                '      WHERE `times` <= ? AND `order` <= ? AND `sid` = ?' +
                 '      GROUP BY `lid`' +
                 '  ) As MaxFilter ' +
-                '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.flow And Bills.lid = MaxFilter.lid' +
-                '  WHERE Bills.sid = ?';
+                '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.flow And Bills.lid = MaxFilter.lid And Bills.sid = MaxFilter.sid';
             const sqlParam = [stage.curTimes, stage.curOrder, stage.id];
             const result = await this.db.queryOne(sql, sqlParam);
             return result;