lrf 2 lat temu
rodzic
commit
b85d522890

+ 1 - 1
app/controller/business/config/.payOrder.js

@@ -48,6 +48,6 @@ module.exports = {
     requestBody: ['!id'],
   },
   toPayNative: {
-    requestBody: ['!school_id', 'pay_for', 'from_id', 'money', 'time', 'desc'],
+    requestBody: ['!school_id', 'pay_for', 'from_id', 'money', 'time', 'desc', 'config'],
   },
 };

+ 7 - 4
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.lessonStudentService = this.ctx.service.business.lessonStudent;
     this.chargeModel = this.ctx.model.Business.Charge;
     this.tempLessonApplyModel = this.ctx.model.Apply.TempLessonApply;
     this.userModel = this.ctx.model.User.User;
@@ -43,18 +44,20 @@ class PayOrderService extends CrudService {
       // 不知道该去同步哪个表的支付状态,不处理
       return;
     }
-    const { from_id: _id, status: is_pay, money, _id: pay_id } = data;
+    const { from_id: _id, status: is_pay, money, _id: pay_id, config } = data;
     if (pay_for === 'lessonStudent') {
       // 因为上课产生的支付,去找lessonStudent,修改指定学生的支付状态
       await this.lessonStudentModel.updateOne({ _id }, { is_pay });
     } else if (pay_for === 'tempLessonApply') {
-      // 私教课临时上课,需要到临时申请那找到相关数据,再修改lessonStudent
+      // 私教课临时上课,需要到临时申请那找到相关数据
       const tempApply = await this.tempLessonApplyModel.findById(_id);
       if (!tempApply) return;
       tempApply.pay_id = pay_id;
       await tempApply.save();
-      const { lesson_id, student_id } = tempApply;
-      await this.lessonStudentModel.updateOne({ lesson_id, student_id }, { is_pay, pay_id, money });
+      // 修改完申请,再创建 lessonStudent
+      const { lesson_id, student_id, school_id } = tempApply;
+      const obj = { lesson_id, student_id, school_id, is_pay, pay_id, config };
+      await this.lessonStudentService.create(obj);
     } else if (pay_for === 'charge') {
       // 充值
       await this.chargeModel.updateOne({ _id }, { is_pay });