lrf 2 years ago
parent
commit
d93a94759e

+ 1 - 1
app/controller/business/billApply.js

@@ -1,5 +1,5 @@
 'use strict';
-const meta = require('./config/.billApply.js');
+const meta = require('.//config/.billApply.js');
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
 

app/controller/business/config/.billApply.js → app/controller/apply/config/.billApply.js


+ 42 - 0
app/controller/apply/config/.tempLessonApply.js

@@ -0,0 +1,42 @@
+module.exports = {
+  create: {
+    requestBody: ['school_id', 'lesson_id', 'student_id', 'coach_id', 'result', 'reason', 'img_url'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['school_id', 'lesson_id', 'student_id', 'coach_id', 'result', 'reason', 'img_url'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        school_id: 'school_id',
+        lesson_id: 'lesson_id',
+        student_id: 'student_id',
+        coach_id: 'coach_id',
+        result: 'result',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 41 - 0
app/controller/apply/config/.tryLessonApply.js

@@ -0,0 +1,41 @@
+module.exports = {
+  create: {
+    requestBody: ['school_id', 'lesson_id', 'student_id', 'result', 'reason'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['school_id', 'lesson_id', 'student_id', 'result', 'reason'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        school_id: 'school_id',
+        lesson_id: 'lesson_id',
+        student_id: 'student_id',
+        result: 'result',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/apply/tempLessonApply.js

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

+ 13 - 0
app/controller/apply/tryLessonApply.js

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

+ 44 - 0
app/controller/business/config/.payOrder.js

@@ -0,0 +1,44 @@
+module.exports = {
+  create: {
+    requestBody: ['openid', 'school_id', 'user_id', 'pay_for', 'from_id', 'money', 'time', 'order_no', 'desc', 'status'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['openid', 'school_id', 'user_id', 'pay_for', 'from_id', 'money', 'time', 'order_no', 'desc', 'status'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        openid: 'openid',
+        school_id: 'school_id',
+        user_id: 'user_id',
+        order_no: 'order_no',
+        status: 'status',
+        'time@start': 'time@start',
+        'time@end': 'time@end',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/business/payOrder.js

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

app/model/business/billApply.js → app/model/apply/billApply.js


+ 28 - 0
app/model/apply/tempLessonApply.js

@@ -0,0 +1,28 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 临时上课申请
+const tempLessonApply = {
+  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, //
+  student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name' ] }, //
+  coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
+  result: { type: String, required: false, default: '0', zh: '审核结果' }, // 0:未审核;1:审核通过;-1审核失败
+  reason: { type: String, required: false, zh: '审核原因' }, //
+  img_url: { type: Array, required: false, zh: '证据' }, //
+};
+const schema = new Schema(tempLessonApply, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ school_id: 1 });
+schema.index({ lesson_id: 1 });
+schema.index({ student_id: 1 });
+schema.index({ coach_id: 1 });
+schema.index({ result: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('TempLessonApply', schema, 'tempLessonApply');
+};

+ 25 - 0
app/model/apply/tryLessonApply.js

@@ -0,0 +1,25 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 试课表申请
+const tryLessonApply = {
+  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, //
+  student_id: { type: String, required: false, zh: '学生id', ref: 'Student', getProp: [ 'name' ] }, //
+  result: { type: String, required: false, default: '0', zh: '审核结果' }, // 0:未审核;1:审核通过;-1审核拒绝
+  reason: { type: String, required: false, zh: '审核理由' }, //
+};
+const schema = new Schema(tryLessonApply, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ school_id: 1 });
+schema.index({ lesson_id: 1 });
+schema.index({ student_id: 1 });
+schema.index({ result: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('TryLessonApply', schema, 'tryLessonApply');
+};

+ 32 - 0
app/model/business/payOrder.js

@@ -0,0 +1,32 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 付款订单表
+const payOrder = {
+  openid: { type: String, required: false, zh: '微信id' }, // 其实和user_id有些重复,但是这里一定要留痕,因为有可能发生更换绑定
+  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  user_id: { type: String, required: false, zh: '用户id' }, // 不是角色的数据id,是普通用户的那个id,因为付款需要确定openid,和你是什么角色没关系
+  pay_for: { type: String, required: false, zh: '支付原因' }, // lesson:上课,写表名等...
+  from_id: { type: String, required: false, zh: '关联id' }, // 支付原因的数据id.有就写,没有不写
+  money: { type: Number, required: false, zh: '金额' }, //
+  time: { type: String, required: false, zh: '时间' }, //
+  order_no: { type: String, required: false, zh: '订单号' }, //
+  desc: { type: String, required: false, zh: '支付说明' }, //
+  status: { type: String, required: false, default: '0', zh: '支付状态' }, // 0:未支付;1:已支付;-1:支付失败-2:已退款
+};
+const schema = new Schema(payOrder, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ openid: 1 });
+schema.index({ school_id: 1 });
+schema.index({ user_id: 1 });
+schema.index({ order_no: 1 });
+schema.index({ time: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('PayOrder', schema, 'payOrder');
+};

+ 4 - 1
app/router.js

@@ -39,7 +39,10 @@ module.exports = app => {
   require('./z_router/business/lessonCoach')(app); // 课程-教练
   require('./z_router/business/lessonStudent')(app); // 课程-学员
   require('./z_router/business/coachInBill')(app); // 教练费明细
-  require('./z_router/business/billApply')(app); // 教练费申请
+
+  require('./z_router/apply/billApply')(app); // 教练费申请
+  require('./z_router/apply/tryLessonApply')(app); // 试课申请
+  require('./z_router/apply/tempLessonApply')(app); // 临时上课申请
 
   require('./z_router/view/student')(app); // 学生视图
 };

+ 1 - 1
app/service/business/billApply.js

@@ -8,7 +8,7 @@ const assert = require('assert');
 class BillApplyService extends CrudService {
   constructor(ctx) {
     super(ctx, 'billapply');
-    this.model = this.ctx.model.Business.BillApply;
+    this.model = this.ctx.model.Apply.BillApply;
   }
 }
 

+ 15 - 0
app/service/apply/tempLessonApply.js

@@ -0,0 +1,15 @@
+'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');
+
+// 
+class TempLessonApplyService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'templessonapply');
+    this.model = this.ctx.model.Apply.TempLessonApply;
+  }
+}
+
+module.exports = TempLessonApplyService;

+ 15 - 0
app/service/apply/tryLessonApply.js

@@ -0,0 +1,15 @@
+'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');
+
+//
+class TryLessonApplyService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'trylessonapply');
+    this.model = this.ctx.model.Apply.TryLessonApply;
+  }
+}
+
+module.exports = TryLessonApplyService;

+ 16 - 0
app/service/business/payOrder.js

@@ -0,0 +1,16 @@
+'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');
+
+//
+class PayOrderService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'payorder');
+    this.model = this.ctx.model.Business.PayOrder;
+    this.payService = this.ctx.service.wxpay;
+  }
+}
+
+module.exports = PayOrderService;

+ 1 - 1
app/z_router/business/billApply.js

@@ -4,7 +4,7 @@ const path = require('path');
 const regPath = path.resolve('app', 'public', 'routerRegister');
 const routerRegister = require(regPath);
 const rkey = 'billApply';
-const ckey = 'business.billApply';
+const ckey = 'apply.billApply';
 const keyZh = '教练费申请';
 const routes = [
   { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },

+ 19 - 0
app/z_router/apply/tempLessonApply.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'tempLessonApply';
+const ckey = 'apply.tempLessonApply';
+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`, middleware: [ 'password' ], 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);
+};

+ 19 - 0
app/z_router/apply/tryLessonApply.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'tryLessonApply';
+const ckey = 'apply.tryLessonApply';
+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`, middleware: [ 'password' ], 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 - 1
config/config.default.js

@@ -109,7 +109,7 @@ module.exports = appInfo => {
   // 数据库设置
   config.dbName = 'court_v2';
   config.mongoose = {
-    url: `mongodb://127.0.0.1:27017/${config.dbName}`, // 120.48.146.1 127.0.0.1
+    url: `mongodb://120.48.146.1:27017/${config.dbName}`, // 120.48.146.1 127.0.0.1
     options: {
       user: 'admin',
       pass: 'admin',