Commit 6368489b authored by 任国军's avatar 任国军

add getBackColumns

parent b4c1716a
Pipeline #27243 passed with stage
in 23 seconds
...@@ -113,6 +113,15 @@ class BackController extends Controller { ...@@ -113,6 +113,15 @@ class BackController extends Controller {
await service.course.back.exportUsedRedeemCode(queryParams); await service.course.back.exportUsedRedeemCode(queryParams);
} }
// 获取额外字段
async getBackColumns() {
const { ctx, service } = this;
const ret = await service.course.back.getBackColumns();
ctx.success(ret);
}
} }
module.exports = BackController; module.exports = BackController;
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE } = app.Sequelize;
const CourseBackColumn = app.classModel.define('course_back_column', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
},
title: STRING,
column: STRING,
status: INTEGER,
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
}, {
timestamps: false,
tableName: 'course_back_column',
});
return CourseBackColumn;
};
...@@ -14,4 +14,5 @@ module.exports = app => { ...@@ -14,4 +14,5 @@ module.exports = app => {
router.get('third', '/export/redeem', auth, 'course.back.exportRedeemCode'); router.get('third', '/export/redeem', auth, 'course.back.exportRedeemCode');
router.get('third', '/export/redeem/used', auth, 'course.back.exportUsedRedeemCode'); router.get('third', '/export/redeem/used', auth, 'course.back.exportUsedRedeemCode');
router.get('third', '/redeem/used', auth, 'course.back.getUsedRedeemCodeList'); router.get('third', '/redeem/used', auth, 'course.back.getUsedRedeemCodeList');
router.get('third', '/column/all', 'course.back.getBackColumns');
}; };
...@@ -88,7 +88,7 @@ class BackService extends Service { ...@@ -88,7 +88,7 @@ class BackService extends Service {
ctx.failed('用户异常'); ctx.failed('用户异常');
} }
const filter = { where: { type: 1, status: 1, is_deleted: 0 }, limit, offset, attributes: [ 'id', 'order_no', 'class_id', 'pay', 'pay_time', 'address' ], order: [[ 'pay_time', 'desc' ]] }; const filter = { where: { type: 1, status: 1, is_deleted: 0 }, limit, offset, attributes: [ 'id', 'order_no', 'class_id', 'pay', 'pay_time', 'address', 'columns' ], order: [[ 'pay_time', 'desc' ]] };
let filterClassIds = []; let filterClassIds = [];
if (!ctx.isEmpty(input.class_name)) { if (!ctx.isEmpty(input.class_name)) {
const classList = await ctx.classModel.V5.CourseV5Class.findAll({ where: { name: { $like: `%${input.class_name}%` } }, attributes: [ 'id' ] }); const classList = await ctx.classModel.V5.CourseV5Class.findAll({ where: { name: { $like: `%${input.class_name}%` } }, attributes: [ 'id' ] });
...@@ -139,6 +139,7 @@ class BackService extends Service { ...@@ -139,6 +139,7 @@ class BackService extends Service {
pay: v.pay, pay: v.pay,
pay_time: v.pay_time, pay_time: v.pay_time,
address: ctx.isEmpty(v.address) ? {} : JSON.parse(v.address), address: ctx.isEmpty(v.address) ? {} : JSON.parse(v.address),
columns: ctx.isEmpty(v.columns) ? {} : JSON.parse(v.columns),
}); });
} }
...@@ -513,6 +514,19 @@ class BackService extends Service { ...@@ -513,6 +514,19 @@ class BackService extends Service {
return true; return true;
} }
// 获取额外字段
async getBackColumns() {
const { ctx } = this;
const columns = await ctx.classModel.CourseBackColumn.findAll({ where: { status: 1 }, attributes: [ 'title', 'column' ] });
const ret = {
list: columns,
};
return ret;
}
} }
module.exports = BackService; module.exports = BackService;
...@@ -366,7 +366,6 @@ class UserService extends Service { ...@@ -366,7 +366,6 @@ class UserService extends Service {
const { ctx } = this; const { ctx } = this;
const userUuid = ctx.userUuid; const userUuid = ctx.userUuid;
const id = input.id || 0; const id = input.id || 0;
const address = input.address || '';
const columns = ctx.isEmpty(input.columns) ? {} : JSON.parse(input.columns); const columns = ctx.isEmpty(input.columns) ? {} : JSON.parse(input.columns);
if (ctx.isEmpty(userUuid)) { if (ctx.isEmpty(userUuid)) {
...@@ -385,11 +384,14 @@ class UserService extends Service { ...@@ -385,11 +384,14 @@ class UserService extends Service {
ctx.failed('课程不存在'); ctx.failed('课程不存在');
} }
// // 获取用户地址 // 获取用户地址
// const address = await ctx.classModel.V5.CourseUserAddress.findOne({ where: { user_uuid: ctx.userUuid, is_deleted: 0 }, attributes: [ 'province', 'city', 'area', 'address', 'name', 'phone' ], raw: true }); let address = '';
// if (ctx.isEmpty(address)) { if (classInfo.has_address === 1) {
// ctx.failed('地址不能为空'); address = await ctx.classModel.V5.CourseUserAddress.findOne({ where: { user_uuid: ctx.userUuid, is_deleted: 0 }, attributes: [ 'id', 'province', 'city', 'area', 'address', 'name', 'phone' ], raw: true });
// } if (ctx.isEmpty(address)) {
ctx.failed('地址不能为空');
}
}
const orderNo = '11' + moment().format('YYYYMMDDHHMMSS') + await this.getRandomNumber(6); const orderNo = '11' + moment().format('YYYYMMDDHHMMSS') + await this.getRandomNumber(6);
if (ctx.isEmpty(order)) { if (ctx.isEmpty(order)) {
......
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