Browse Source

提现表

guhongwei 2 years ago
parent
commit
61ed8bb0c6

+ 13 - 0
app/controller/user/cashOut.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.cashOut.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+//
+class CashOutController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.user.cashOut;
+  }
+}
+module.exports = CrudController(CashOutController, meta);

+ 43 - 0
app/controller/user/config/.cashOut.js

@@ -0,0 +1,43 @@
+
+module.exports = {
+  create: {
+    requestBody: ['!money','!customer','!apply_time','!apply_reason','deal_person','exam_time','!exam_reason','!status'],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ['money','customer','apply_time','apply_reason','deal_person','exam_time','exam_reason','status'],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    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' ,
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

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

@@ -0,0 +1,31 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
+
+// 提现表
+const cashOut = {
+  customer: { type: String, required: false, zh: '申请人', ref: 'User.User' }, //
+  apply_time: { type: String, required: true, zh: '申请时间' }, //
+  apply_reason: { type: String, required: true, zh: '申请理由' }, //
+  deal_person: { type: String, required: false, zh: '审核处理人', ref: 'User.Admin' }, //
+  exam_time: { type: String, required: false, zh: '审核时间' }, //
+  exam_reason: { type: String, required: true, zh: '审核理由' }, //
+  status: { type: String, required: true, default: '0', zh: '审核状态' }, // 字典表:withdrawal_exam_status
+};
+const schema = new Schema(cashOut, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ customer: 1 });
+schema.index({ apply_time: 1 });
+schema.index({ deal_person: 1 });
+schema.index({ exam_time: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+schema.plugin(MoneyPlugin({ zh: '提现金额', required: true, key: 'money' }));
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('CashOut', schema, 'cashOut');
+};

+ 17 - 0
app/service/user/cashOut.js

@@ -0,0 +1,17 @@
+
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+const moment = require('moment');
+//
+class CashOutService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'cashout');
+    this.model = this.ctx.model.User.CashOut;
+  }
+}
+
+module.exports = CashOutService;
+

+ 19 - 0
app/z_router/user/cashOut.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'cashOut';
+const ckey = 'user.cashOut';
+const keyZh = '提现';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};

+ 1 - 0
app/z_router/user/index.js

@@ -10,4 +10,5 @@ module.exports = app => {
   require('./storeShop')(app); // 收藏店铺
   require('./storeGoods')(app); // 收藏商品
   require('./cashBack')(app); // 返现
+  require('./cashOut')(app); // 提现
 };