lrf 2 vuotta sitten
vanhempi
commit
bfacff77cc

+ 3 - 2
app/controller/business/config/.lessonStudent.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['pay_id', 'is_pay', 'lesson_id', 'school_id', 'student_id', 'money', 'is_try', 'try_status'],
+    requestBody: ['pay_id', 'is_pay', 'lesson_id', 'school_id', 'student_id', 'money', 'is_try', 'try_status', 'is_sign'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['pay_id', 'is_pay', 'lesson_id', 'school_id', 'student_id', 'money', 'is_try', 'try_status'],
+    requestBody: ['pay_id', 'is_pay', 'lesson_id', 'school_id', 'student_id', 'money', 'is_try', 'try_status', 'is_sign'],
   },
   show: {
     parameters: {
@@ -29,6 +29,7 @@ module.exports = {
         try_status: 'try_status',
         is_pay: 'is_pay',
         pay_id: 'pay_id',
+        is_sign: 'is_sign',
       },
       // options: {
       //   "meta.state": 0 // 默认条件

+ 2 - 2
app/model/apply/tempLessonApply.js

@@ -1,7 +1,7 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 临时上课申请
 const tempLessonApply = {
@@ -10,7 +10,6 @@ const tempLessonApply = {
   student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name' ] }, //
   coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
   img_url: { type: Array, required: false, zh: '证据' }, //
-  money: { type: Decimal128, required: false, zh: '金额' }, //
   pay_id: { type: String, required: false, zh: '支付id', ref: 'PayOrder' }, //
 };
 const schema = new Schema(tempLessonApply, { toJSON: { virtuals: true } });
@@ -24,6 +23,7 @@ schema.index({ result: 1 });
 schema.index({ pay_id: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '金额' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('TempLessonApply', schema, 'tempLessonApply');

+ 2 - 2
app/model/business/charge.js

@@ -1,14 +1,13 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 充值记录
 const charge = {
   school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
   payer_id: { type: String, required: false, zh: '充值用户角色id', refPath: 'payer_role', getProp: [ 'name' ] }, //
   payer_role: { type: String, required: false, zh: '充值用户角色' }, //
-  money: { type: Decimal128, required: false, zh: '充值金额' }, //
   pay_id: { type: String, required: false, zh: '支付id', ref: 'Payorder' }, //
   is_pay: { type: String, required: false, zh: '支付状态' }, // 0:未支付;1:支付成功;-1:支付失败;-3:已退款
   time: { type: String, required: false, zh: '时间' }, //
@@ -22,6 +21,7 @@ schema.index({ payer_role: 1 });
 schema.index({ is_pay: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '充值金额' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('Charge', schema, 'charge');

+ 2 - 2
app/model/business/coachInBill.js

@@ -1,7 +1,7 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 教练费明细
 const coachInBill = {
@@ -9,7 +9,6 @@ const coachInBill = {
   type: { type: String, required: false, zh: '类型' }, // 0:公开课收入;1私教课收入;2提现
   school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
   coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
-  money: { type: Decimal128, required: false, zh: '金额' }, //
 };
 const schema = new Schema(coachInBill, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
@@ -18,6 +17,7 @@ schema.index({ school_id: 1 });
 schema.index({ coach_id: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '金额' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('CoachInBill', schema, 'coachInBill');

+ 2 - 2
app/model/business/lesson.js

@@ -1,7 +1,7 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 课程表
 const lesson = {
@@ -9,7 +9,6 @@ const lesson = {
   title: { type: String, required: false, zh: '课程标题' }, //
   time_start: { type: String, required: false, zh: '开始上课时间' }, //
   time_end: { type: String, required: false, zh: '结束时间' }, //
-  money: { type: Decimal128, zh: '金额' },
   limit: { type: Number, zh: '人数上限' },
   refund_hour: { type: String, zh: '退款期限' },
   type: { type: String, required: false, zh: '课程类型', default: '0' }, // 0:公开课;1私教课
@@ -24,6 +23,7 @@ schema.index({ time_start: 1 });
 schema.index({ time_end: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '金额' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('Lesson', schema, 'lesson');

+ 5 - 5
app/model/business/lessonCoach.js

@@ -1,14 +1,13 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 课程表-教练
 const lessonCoach = {
-  lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: ['title'] }, //
-  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: ['name'] }, //
-  coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: ['name'] }, //
-  money: { type: Decimal128, required: false, zh: '课时费' }, //
+  lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, //
+  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
   is_sign: { type: String, required: false, default: '0', zh: '签到' }, // 0:未到;1:已签到
 };
 const schema = new Schema(lessonCoach, { toJSON: { virtuals: true } });
@@ -20,6 +19,7 @@ schema.index({ coach_id: 1 });
 schema.index({ is_sign: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '课时费' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('LessonCoach', schema, 'lessonCoach');

+ 5 - 5
app/model/business/lessonStudent.js

@@ -1,14 +1,13 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 课程表-学员
 const lessonStudent = {
-  lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: ['name'] }, //
-  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: ['name'] }, //
-  student_id: { type: String, required: false, zh: '学生id', ref: 'Student', getProp: ['name'] }, //
-  money: { type: Decimal128, required: false, zh: '缴费金额' }, //
+  lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'name' ] }, //
+  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  student_id: { type: String, required: false, zh: '学生id', ref: 'Student', getProp: [ 'name' ] }, //
   is_try: { type: String, required: false, default: '0', zh: '是否试课' }, // 0:非试课;1:试课
   try_status: { type: String, default: '0', zh: '试课审核状态' }, // 0:未审核;1:审核通过;2审核拒绝
   is_pay: { type: String, default: '0', zh: '是否已支付' }, // 0:未支付;1:已支付:-1:支付失败:-3已退款
@@ -28,6 +27,7 @@ schema.index({ is_pay: 1 });
 schema.index({ is_sign: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '缴费金额' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('LessonStudent', schema, 'lessonStudent');

+ 2 - 2
app/model/business/payOrder.js

@@ -1,7 +1,7 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 付款订单表
 const payOrder = {
@@ -11,7 +11,6 @@ const payOrder = {
   payer_role: { type: String, required: false, zh: '支付的用户角色' }, //
   pay_for: { type: String, required: false, zh: '支付原因' }, // lesson:上课,写表名等...; 学生上课(公开课/私教课):lessonStudent; 学生临时上课:tempLessonApply
   from_id: { type: String, required: false, zh: '关联id' }, // 支付原因的数据id.有就写,没有不写
-  money: { type: Decimal128, required: false, zh: '金额' }, //
   time: { type: String, required: false, zh: '时间' }, //
   order_no: { type: String, required: false, zh: '订单号' }, //
   desc: { type: String, required: false, zh: '支付说明' }, //
@@ -27,6 +26,7 @@ schema.index({ payer_id: 1 });
 schema.index({ from_id: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '金额' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('PayOrder', schema, 'payOrder');

+ 3 - 3
app/model/relation/relationCoachSchool.js

@@ -1,22 +1,22 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
 // 教练与学校的关系表
 const relationCoachSchool = {
   coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: [ 'name', 'phone', 'level', 'icon' ] }, //
   school_id: { type: String, required: true, zh: '学校id', ref: 'School', getProp: [ 'name', 'phone' ] }, //
   doc: { type: Object, required: false, zh: '教练档案' }, //
-  money: { type: Decimal128, zh: '工资' },
 };
-const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true } });
+const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true, getters: true } });
 schema.index({ id: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.index({ coach_id: 1 });
 schema.index({ school_id: 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '工资' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('RelationCoachSchool', schema, 'relationCoachSchool');

+ 2 - 2
app/model/relation/relationStudentSchool.js

@@ -1,7 +1,7 @@
 'use strict';
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
-const { Decimal128 } = require('mongoose').Types;
+const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 // 学生档案
 const doc = {
   is_past: { type: String, default: '0' }, // 往期学员: 0-当期;1-往期
@@ -13,7 +13,6 @@ const relationStudentSchool = {
   student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name', 'icon', 'level', 'phone' ] }, //
   school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'img_url', 'name', 'phone', 'coach_num', 'student_num', 'address', 'brief' ] }, //
   doc: { type: Object, required: false, zh: '档案' }, //
-  money: { type: Decimal128, zh: '余额' },
 };
 const schema = new Schema(relationStudentSchool, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
@@ -22,6 +21,7 @@ schema.index({ school_id: 1 });
 schema.index({ 'meta.createdAt': 1 });
 
 schema.plugin(metaPlugin);
+schema.plugin(moneyPlugin({ zh: '余额' }));
 module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('RelationStudentSchool', schema, 'relationStudentSchool');

+ 6 - 0
app/service/relation/relationCoachSchool.js

@@ -21,6 +21,12 @@ class RelationCoachSchoolService extends CrudService {
     throw new BusinessError(ErrorCode.DATA_EXISTED, '教练已在学校备案,无需重复添加');
   }
 
+  async afterQuery(filter, data) {
+    // console.log(data);
+    data = JSON.parse(JSON.stringify(data));
+    return data;
+  }
+
 }
 
 module.exports = RelationCoachSchoolService;

+ 1 - 1
app/service/view/student.js

@@ -17,7 +17,7 @@ class StudentService extends CrudService {
     const query = {};
     if (student_id)query.student_id = student_id;
     if (school_id) query.school_id = school_id;
-    const lsList = await this.lessonStudentModel.find(query, { lesson_id: 1, is_pay: 1, is_try: 1 });
+    const lsList = await this.lessonStudentModel.find(query, { lesson_id: 1, is_pay: 1, is_try: 1, is_sign: 1 });
     const lessonIds = lsList.map(i => i.lesson_id);
     let data = await this.lessonModel.find({ _id: lessonIds, ...otherQuery }).skip(parseInt(skip)).limit(parseInt(limit));
     if (data.length > 0) data = JSON.parse(JSON.stringify(data));

+ 1 - 1
package.json

@@ -14,7 +14,7 @@
     "egg-scripts": "^2.11.0",
     "lodash": "^4.17.21",
     "moment": "^2.29.1",
-    "naf-framework-mongoose-free": "^0.0.30"
+    "naf-framework-mongoose-free": "^0.0.32"
   },
   "devDependencies": {
     "autod": "^3.0.1",