lrf 2 yıl önce
ebeveyn
işleme
0d1cd7dc75

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

@@ -10,7 +10,7 @@ const lessonStudent = {
   money: { type: String, required: false, zh: '缴费金额' }, //
   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:支付失败:-2已退款
+  is_pay: { type: String, default: '0', zh: '是否已支付' }, // 0:未支付;1:已支付:-1:支付失败:-3已退款
   pay_id: { type: String, required: false, zh: '支付id', ref: 'PayOrder' }, //
   config: { type: Array, required: false, zh: '学生与教练关系表的设置快照' }, //
 };

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

@@ -8,7 +8,7 @@ const payOrder = {
   school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
   payer_id: { type: String, required: false, zh: '支付的用户id', refPath: 'payer_role' }, // 由payer_role决定是教练还是学员
   payer_role: { type: String, required: false, zh: '支付的用户角色' }, //
-  pay_for: { type: String, required: false, zh: '支付原因' }, // lesson:上课,写表名等...
+  pay_for: { type: String, required: false, zh: '支付原因' }, // lesson:上课,写表名等...; 学生上课(公开课/私教课):lessonStudent; 学生临时上课:tempLessonApply
   from_id: { type: String, required: false, zh: '关联id' }, // 支付原因的数据id.有就写,没有不写
   money: { type: Number, required: false, zh: '金额' }, //
   time: { type: String, required: false, zh: '时间' }, //

+ 9 - 2
app/service/business/payOrder.js

@@ -11,6 +11,7 @@ class PayOrderService extends CrudService {
     this.model = this.ctx.model.Business.PayOrder;
     this.payService = this.ctx.service.wxpay;
     this.lessonStudentModel = this.ctx.model.Business.LessonStudent;
+    this.tempLessonApplyModel = this.ctx.model.Apply.TempLessonApply;
   }
 
   async beforeCreate(data) {
@@ -38,10 +39,16 @@ class PayOrderService extends CrudService {
       // 不知道该去同步哪个表的支付状态,不处理
       return;
     }
-    if (pay_for === 'Lesson') {
+    const { form_id: _id, status: is_pay } = data;
+    if (pay_for === 'lessonStudent') {
       // 因为上课产生的支付,去找lessonStudent,修改指定学生的支付状态
-      const { form_id: _id, status: is_pay } = data;
       await this.lessonStudentModel.updateOne({ _id }, { is_pay });
+    } else if (pay_for === 'tempLessonApply') {
+      // 私教课临时上课,需要到临时申请那找到相关数据,再修改lessonStudent
+      const tempApply = await this.tempLessonApplyModel.findById(_id);
+      if (!tempApply) return;
+      const { lesson_id, student_id } = tempApply;
+      await this.lessonStudentModel.updateOne({ lesson_id, student_id }, { is_pay });
     }
   }