Browse Source

支付审批设置调整

ellisran 4 tháng trước cách đây
mục cha
commit
f6349c8764
2 tập tin đã thay đổi với 5 bổ sung5 xóa
  1. 2 2
      app/controller/payment_controller.js
  2. 3 3
      app/service/payment_detail.js

+ 2 - 2
app/controller/payment_controller.js

@@ -254,7 +254,7 @@ module.exports = app => {
                         const modes = ctx.subProject.payment_setting ? JSON.parse(ctx.subProject.payment_setting) : ctx.helper._.cloneDeep(paymentConst.setting_modes);
                         const checked = data.checked;
                         if (modes[data.mode_type]) {
-                            const detailCount = await ctx.service.paymentDetail.getCountByPidType(ctx.session.sessionProject.id, modes[data.mode_type].value);
+                            const detailCount = await ctx.service.paymentDetail.getCountByPidType(ctx.subProject.id, modes[data.mode_type].value);
                             if (detailCount > 0 && !checked) {
                                 throw '已存在对应模块的详情,无法关闭该模块';
                             }
@@ -296,7 +296,7 @@ module.exports = app => {
                 }
                 const modes = ctx.subProject.payment_setting ? JSON.parse(ctx.subProject.payment_setting) : ctx.helper._.cloneDeep(paymentConst.setting_modes);
                 for (const m in modes) {
-                    const detailCount = await ctx.service.paymentDetail.getCountByPidType(ctx.session.sessionProject.id, modes[m].value);
+                    const detailCount = await ctx.service.paymentDetail.getCountByPidType(ctx.subProject.id, modes[m].value);
                     modes[m].can_check = !detailCount;
                 }
                 const renderData = {

+ 3 - 3
app/service/payment_detail.js

@@ -324,9 +324,9 @@ module.exports = app => {
             return this.count({ tender_id: tid });
         }
 
-        async getCountByPidType(pid, type = 1) {
-            const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pt ON pd.`tender_id` = pt.`id` WHERE pid = ? AND type = ?';
-            const params = [this.tableName, this.ctx.service.paymentTender.tableName, pid, type];
+        async getCountByPidType(spid, type = 1) {
+            const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pt ON pd.`tender_id` = pt.`id` WHERE pt.spid = ? AND pd.type = ?';
+            const params = [this.tableName, this.ctx.service.paymentTender.tableName, spid, type];
             const result = await this.db.queryOne(sql, params);
             return result ? result.count : 0;
         }