Browse Source

调用变更令Bug

MaiXinRong 6 năm trước cách đây
mục cha
commit
699713d9f4
3 tập tin đã thay đổi với 9 bổ sung6 xóa
  1. 3 3
      app/service/stage_bills.js
  2. 3 1
      app/service/stage_change.js
  3. 3 2
      app/service/stage_pos.js

+ 3 - 3
app/service/stage_bills.js

@@ -31,14 +31,14 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getLastestStageData(tid, sid, lid) {
-            const lidSql = lid ? ' And Bills.lid in (?)' : '';
+            const lidSql = lid ? ' And lid in (?)' : '';
             const sql = 'SELECT * FROM ' + this.tableName + ' As Bills ' +
                         '  INNER JOIN ( ' +
                         '    SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `lid` From ' + this.tableName +
+                        '      WHERE tid = ? And sid = ?' + lidSql +
                         '      GROUP BY `lid`' +
                         '  ) As MaxFilter ' +
-                        '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid' +
-                        '  WHERE Bills.tid = ? And Bills.sid = ?' + lidSql;
+                        '  ON Bills.times = MaxFilter.times And Bills.order = MaxFilter.order And Bills.lid = MaxFilter.lid';
             const sqlParam = [tid, sid];
             if (!lid) {
                 return await this.db.query(sql, sqlParam);

+ 3 - 1
app/service/stage_change.js

@@ -196,8 +196,10 @@ module.exports = app => {
             // 获取返回数据
             try {
                 const data = {};
+                console.log(pos);
                 data.bills = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.lid]);
-                data.pos = await this.ctx.service.stagePos.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.id])
+                console.log(data.bills);
+                data.pos = await this.ctx.service.stagePos.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.id]);
                 return data;
             } catch(err) {
                 throw '获取数据错误,请刷新页面';

+ 3 - 2
app/service/stage_pos.js

@@ -269,10 +269,10 @@ module.exports = app => {
         }
 
         async updateChangeQuantity(transaction, pos, qty) {
-            const orgPos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.pid);
+            const orgPos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.id);
             const userOrder = this.ctx.stage.curAuditor ? this.ctx.stage.curAuditor.order : 0;
             if (orgPos && orgPos.times === this.ctx.stage.times && orgPos.order === userOrder) {
-                await transaction.update(this.tableName, {qc_qty: qty}, {where: {id: osp.id}});
+                await transaction.update(this.tableName, {qc_qty: qty}, {where: {id: orgPos.id}});
             } else {
                 await transaction.insert(this.tableName, {
                     tid: this.ctx.tender.id,
@@ -310,6 +310,7 @@ module.exports = app => {
                 '  ) As Gather';
             const param = [tid, sid, lid];
             const sqlParam = param.concat(param);
+            console.log(this.db.format(calcQtySql, sqlParam));
             if (transaction) {
                 return await transaction.queryOne(calcQtySql, sqlParam);
             } else {