lrf 2 年之前
父節點
當前提交
ad0ca8b654
共有 3 個文件被更改,包括 26 次插入19 次删除
  1. 17 17
      app/controller/user/config/.cashOut.js
  2. 1 0
      app/model/user/cashOut.js
  3. 8 2
      app/service/user/cashOut.js

+ 17 - 17
app/controller/user/config/.cashOut.js

@@ -1,41 +1,41 @@
 
 module.exports = {
   create: {
-    requestBody: ['!money','!customer','!apply_time','!apply_reason','deal_person','exam_time','exam_reason','status'],
+    requestBody: ['card', '!money', '!customer', '!apply_time', '!apply_reason', 'deal_person', 'exam_time', 'exam_reason', 'status'],
   },
   destroy: {
-    params: ["!id"],
-    service: "delete",
+    params: ['!id'],
+    service: 'delete',
   },
   update: {
-    params: ["!id"],
-    requestBody: ['money','customer','apply_time','apply_reason','deal_person','exam_time','exam_reason','status'],
+    params: ['!id'],
+    requestBody: ['card', 'money', 'customer', 'apply_time', 'apply_reason', 'deal_person', 'exam_time', 'exam_reason', 'status'],
   },
   show: {
     parameters: {
-      params: ["!id"],
+      params: ['!id'],
     },
-    service: "fetch",
+    service: 'fetch',
   },
   index: {
     parameters: {
       query: {
-        "meta.createdAt@start": "meta.createdAt@start",
-        "meta.createdAt@end": "meta.createdAt@end",
-        'customer': 'customer' ,
-        'apply_time': 'apply_time' ,
-        'deal_person': 'deal_person' ,
-        'exam_time': 'exam_time' ,
-        'status': 'status' ,
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        customer: 'customer',
+        apply_time: 'apply_time',
+        deal_person: 'deal_person',
+        exam_time: 'exam_time',
+        status: 'status',
       },
       // options: {
       //   "meta.state": 0 // 默认条件
       // },
     },
-    service: "query",
+    service: 'query',
     options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
       desc: true,
       count: true,
     },

+ 1 - 0
app/model/user/cashOut.js

@@ -11,6 +11,7 @@ const cashOut = {
   deal_person: { type: String, required: false, zh: '审核处理人', ref: 'User.Admin' }, //
   exam_time: { type: String, required: false, zh: '审核时间' }, //
   exam_reason: { type: String, required: false, zh: '审核理由' }, //
+  card: { type: String, required: false, zh: '银行卡号' }, //
   status: { type: String, required: true, default: '0', zh: '审核状态' }, // 字典表:withdrawal_exam_status
 };
 const schema = new Schema(cashOut, { toJSON: { getters: true, virtuals: true } });

+ 8 - 2
app/service/user/cashOut.js

@@ -1,4 +1,3 @@
-
 'use strict';
 const { CrudService } = require('naf-framework-mongoose-free/lib/service');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
@@ -11,7 +10,14 @@ class CashOutService extends CrudService {
     super(ctx, 'cashout');
     this.model = this.ctx.model.User.CashOut;
   }
+
+  async beforeCreate(data) {
+    const { customer } = data;
+    if (!customer) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '缺少提款人');
+    const num = await this.model.count({ customer, status: '0' });
+    if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '您有未处理提现申请,请联系管理员先处理之前的申请');
+    return data;
+  }
 }
 
 module.exports = CashOutService;
-