|
@@ -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 });
|
|
|
}
|
|
|
}
|
|
|
|