Commit d19ba81f authored by 任国军's avatar 任国军

add pay_columns

parent 957df6fc
Pipeline #27144 passed with stage
in 10 seconds
...@@ -21,6 +21,7 @@ module.exports = app => { ...@@ -21,6 +21,7 @@ module.exports = app => {
type: INTEGER, type: INTEGER,
redeem: STRING, redeem: STRING,
address: STRING, address: STRING,
columns: TEXT,
status: INTEGER, status: INTEGER,
is_deleted: INTEGER, is_deleted: INTEGER,
created_time: { created_time: {
......
...@@ -17,6 +17,7 @@ module.exports = app => { ...@@ -17,6 +17,7 @@ module.exports = app => {
logo: STRING, logo: STRING,
description: TEXT, description: TEXT,
title: STRING, title: STRING,
pay_column: STRING,
status: INTEGER, status: INTEGER,
is_deleted: INTEGER, is_deleted: INTEGER,
created_time: { created_time: {
......
...@@ -203,11 +203,11 @@ class InstitutionSubService extends Service { ...@@ -203,11 +203,11 @@ class InstitutionSubService extends Service {
classInfo.institution_logo = ctx.isEmpty(institution) ? '' : institution.logo; classInfo.institution_logo = ctx.isEmpty(institution) ? '' : institution.logo;
classInfo.institution_description = ctx.isEmpty(institution) ? '' : institution.description; classInfo.institution_description = ctx.isEmpty(institution) ? '' : institution.description;
classInfo.institution_title = ctx.isEmpty(institution) ? '' : institution.title; classInfo.institution_title = ctx.isEmpty(institution) ? '' : institution.title;
classInfo.institution_pay_column = ctx.isEmpty(institution) || ctx.isEmpty(institution.pay_column) ? [] : JSON.parse(institution.pay_column);
classInfo.pay_count += orderCount; classInfo.pay_count += orderCount;
classInfo.video_count = videoCount; classInfo.video_count = videoCount;
classInfo.frequency = frequency; classInfo.frequency = frequency;
classInfo.relation = relation; classInfo.relation = relation;
// classInfo.ext = ctx.isEmpty(institution) ? {} : JSON.parse(institution.ext);
return classInfo; return classInfo;
} }
...@@ -224,7 +224,7 @@ class InstitutionSubService extends Service { ...@@ -224,7 +224,7 @@ class InstitutionSubService extends Service {
const userCollection = await ctx.classModel.V5.CourseUserCollection.findAndCountAll({ where: { user_uuid: ctx.userUuid, is_deleted: 0, type: 3 }, raw: true }); const userCollection = await ctx.classModel.V5.CourseUserCollection.findAndCountAll({ where: { user_uuid: ctx.userUuid, is_deleted: 0, type: 3 }, raw: true });
const collectedIds = R.pluck('type_id', userCollection.rows); const collectedIds = R.pluck('type_id', userCollection.rows);
const filter = { where: { id: { $in: collectedIds }, status: 1, is_deleted: 0 }, limit: page_size, offset, attributes, raw: true }; const filter = { where: { id: { $in: collectedIds }, status: 1, is_deleted: 0 }, limit: page_size, offset, attributes, raw: true };
const classList = await ctx.classModel.V5.CourseV5Class.findAll(filter); const classList = await ctx.classModel.V5.CourseV5Class.findAll(filter);·
for (const i in classList) { for (const i in classList) {
classList[i].price_type = await this.getClassPriceType(classList[i].price_type); classList[i].price_type = await this.getClassPriceType(classList[i].price_type);
classList[i].mode = await this.getClassMode(classList[i].mode); classList[i].mode = await this.getClassMode(classList[i].mode);
......
...@@ -362,9 +362,12 @@ class UserService extends Service { ...@@ -362,9 +362,12 @@ class UserService extends Service {
// 购买课程 // 购买课程
async buyClass(id) { async buyClass(input) {
const { ctx } = this; const { ctx } = this;
const userUuid = ctx.userUuid; const userUuid = ctx.userUuid;
const id = input.id || 0;
const address = input.address || '';
const columns = ctx.isEmpty(input.columns) ? {} : JSON.parse(input.columns);
if (ctx.isEmpty(userUuid)) { if (ctx.isEmpty(userUuid)) {
ctx.failed('用户异常'); ctx.failed('用户异常');
...@@ -382,11 +385,11 @@ class UserService extends Service { ...@@ -382,11 +385,11 @@ 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 }); // 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 });
if (ctx.isEmpty(address)) { // if (ctx.isEmpty(address)) {
ctx.failed('地址不能为空'); // 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)) {
...@@ -397,12 +400,13 @@ class UserService extends Service { ...@@ -397,12 +400,13 @@ class UserService extends Service {
pay: classInfo.pay_price, pay: classInfo.pay_price,
type: 1, type: 1,
address: JSON.stringify(address), address: JSON.stringify(address),
columns: JSON.stringify(columns),
}; };
await ctx.classModel.V5.CourseUserOrder.create(data); await ctx.classModel.V5.CourseUserOrder.create(data);
order = await ctx.classModel.V5.CourseUserOrder.findOne({ where: { user_uuid: userUuid, class_id: id, is_deleted: 0 }, order: [[ 'id', 'asc' ]] }); order = await ctx.classModel.V5.CourseUserOrder.findOne({ where: { user_uuid: userUuid, class_id: id, is_deleted: 0 }, order: [[ 'id', 'asc' ]] });
} }
await ctx.classModel.V5.CourseUserOrder.update({ pay: classInfo.pay_price, order_no: orderNo, type: 1, redeem: '', address: JSON.stringify(address), status: 0 }, { where: { id: order.id } }); await ctx.classModel.V5.CourseUserOrder.update({ pay: classInfo.pay_price, order_no: orderNo, type: 1, redeem: '', address: JSON.stringify(address), columns: JSON.stringify(columns), status: 0 }, { where: { id: order.id } });
let response = await this.service.course.v5.wechat.pay({ pay: order.pay, order_no: orderNo, body: `趣选课-订单${orderNo}` }); let response = await this.service.course.v5.wechat.pay({ pay: order.pay, order_no: orderNo, body: `趣选课-订单${orderNo}` });
response = await ctx.helper.xmlTojson(response); response = await ctx.helper.xmlTojson(response);
......
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