Commit aa24657c authored by 姜登's avatar 姜登

add type

parent 80c8e433
Pipeline #18270 passed with stage
in 4 seconds
/*
* @Descripttion:
* @version:
* @Author: jd
* @Date: 2019-06-10 19:49:32
* @LastEditors: jd
* @LastEditTime: 2019-12-18 13:56:06
*/
'use strict';
const Controller = require('egg').Controller;
......@@ -24,6 +32,11 @@ class RechargeController extends Controller {
required: true,
type: 'date',
},
type: {
required: true,
type: 'enum',
value: [ '包年', '预充', '后付', '抵扣', '退款', '其他' ],
},
remark: {
required: false,
type: 'string',
......@@ -36,7 +49,7 @@ class RechargeController extends Controller {
const { ctx, service } = this;
ctx.validate(this.indexRule, ctx.query);
await service.user.getUserInfo();
const ret = await service.userDetail.findAll(this.model, { user_id: ctx.query.user_id }, ['id', 'user_id', 'money', 'receive_time', 'remark', 'operator'], ctx.pagination);
const ret = await service.userDetail.findAll(this.model, { user_id: ctx.query.user_id }, [ 'id', 'user_id', 'money', 'receive_time', 'remark', 'operator' ], ctx.pagination);
const total = await service.userDetail.count(this.model, { user_id: ctx.query.user_id });
ctx.success({ data: ret, total, ...ctx.pagination });
}
......@@ -44,13 +57,13 @@ class RechargeController extends Controller {
async create() {
const { ctx, service } = this;
ctx.validate(this.createRule, ctx.request.body);
const { user_id, money, receive_time, remark } = ctx.request.body;
const { user_id, money, receive_time, remark, type } = ctx.request.body;
const user = await service.user.getUserInfo();
const ret = await service.userDetail.findOne(this.usermodel, { user_id }, ['user_id']);
const ret = await service.userDetail.findOne(this.usermodel, { user_id }, [ 'user_id' ]);
if (!ret) {
ctx.throw(400, '无效的user_id');
}
await service.userDetail.create(this.model, { user_id, money, receive_time, remark, operator: user.name });
await service.userDetail.create(this.model, { user_id, money, receive_time, remark, operator: user.name, type });
ctx.success({ user_id });
}
}
......
/*
* @Descripttion:
* @version:
* @Author: jd
* @Date: 2019-06-13 20:14:12
* @LastEditors: jd
* @LastEditTime: 2019-12-18 18:54:34
*/
'use strict';
const moment = require('moment');
......@@ -55,6 +63,11 @@ module.exports = app => {
},
field: 'receive_time',
},
type: {
type: DataTypes.STRING(20),
allowNull: true,
field: 'type',
},
}, {
tableName: 'recharge_detail',
timestamps: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment