database bi kiet pha banh roi

This commit is contained in:
2024-11-25 14:17:32 +07:00
parent 9515a3d9b3
commit 28d0374435
6 changed files with 55 additions and 60 deletions

View File

@@ -85,6 +85,9 @@ export class PayosService {
status: ScheduleStatus.IN_PROGRESS,
},
})
if (!schedule) {
throw new Error('Schedule not found')
}
// get mentor id from managed service
const managedService = await tx.managedService.findUniqueOrThrow({
where: { id: schedule?.managedServiceId },
@@ -111,13 +114,18 @@ export class PayosService {
chatRoomId: chatRoom.id,
},
})
// update orderId for schedule dates
// add participants to schedule dates where customer and mentor are
const customerId = order.userId
// update orderId
await tx.scheduleDate.updateMany({
where: { scheduleId: schedule?.id },
where: { scheduleId: schedule.id },
data: {
orderId: order.id,
participantIds: [customerId, mentorId],
},
})
/* --------------- send first message from mentor to customer --------------- */
await tx.message.create({
data: {