day len server theo loi Khoi noi, toi xin tuyen bo mien tru trach nhiem
This commit is contained in:
@@ -10,7 +10,12 @@ import type {
|
||||
CancelPaymentLinkRequestType,
|
||||
DataType,
|
||||
} from '@payos/node/lib/type'
|
||||
import { OrderStatus, PaymentStatus, ScheduleStatus } from '@prisma/client'
|
||||
import {
|
||||
ChatRoomType,
|
||||
OrderStatus,
|
||||
PaymentStatus,
|
||||
ScheduleStatus,
|
||||
} from '@prisma/client'
|
||||
export type CreatePaymentBody = CheckoutRequestType
|
||||
export type CreatePaymentResponse = CheckoutResponseDataType
|
||||
@Injectable()
|
||||
@@ -52,7 +57,7 @@ export class PayosService {
|
||||
status: orderStatus,
|
||||
},
|
||||
})
|
||||
const order = await this.prisma.order.findUnique({
|
||||
const order = await this.prisma.order.findUniqueOrThrow({
|
||||
where: { id: payment.orderId },
|
||||
})
|
||||
const schedule = await this.prisma.schedule.findUnique({
|
||||
@@ -62,16 +67,36 @@ export class PayosService {
|
||||
await this.prisma.schedule.update({
|
||||
where: { id: schedule?.id },
|
||||
data: {
|
||||
customerId: order?.userId,
|
||||
orderId: order?.id,
|
||||
status: ScheduleStatus.IN_PROGRESS,
|
||||
},
|
||||
})
|
||||
// get mentor id from managed service
|
||||
const managedService = await this.prisma.managedService.findUniqueOrThrow({
|
||||
where: { id: schedule?.managedServiceId },
|
||||
})
|
||||
const mentorId = managedService.mentorId
|
||||
// get center id from order service
|
||||
const orderService = await this.prisma.service.findUniqueOrThrow({
|
||||
where: { id: order?.serviceId },
|
||||
})
|
||||
const centerId = orderService.centerId
|
||||
// create chatroom for service meeting room
|
||||
await this.prisma.chatRoom.create({
|
||||
data: {
|
||||
type: ChatRoomType.SUPPORT,
|
||||
customerId: order.userId,
|
||||
centerId: centerId,
|
||||
mentorId: mentorId,
|
||||
},
|
||||
})
|
||||
return {
|
||||
message: 'Payment received',
|
||||
}
|
||||
}
|
||||
|
||||
async createPaymentURL(body: any) {
|
||||
async createPaymentURL(body: CheckoutRequestType) {
|
||||
return await this.payos.createPaymentLink(body)
|
||||
}
|
||||
|
||||
@@ -90,6 +115,7 @@ export class PayosService {
|
||||
return await this.payos.cancelPaymentLink(orderId, cancellationReason)
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async refundPayment(body: any) {
|
||||
return body
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user