chore: update configuration and improve schema imports
- Updated biome.json to include "graphql.d.ts" in the ignored files list. - Updated subproject commit reference in epess-database to the latest version. - Removed unused script from package.json and streamlined module file extensions in tsconfig.json. - Consolidated exclude patterns in tsconfig.build.json for clarity. - Refactored imports across multiple schema files for consistency and improved readability. - Enhanced various schema files by ensuring proper import order and removing redundant code. - Improved error handling and data integrity checks in several service and schema files.
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import PayOS from '@payos/node'
|
||||
import type {
|
||||
CancelPaymentLinkRequestType,
|
||||
CheckoutRequestType,
|
||||
CheckoutResponseDataType,
|
||||
WebhookType,
|
||||
WebhookDataType,
|
||||
CancelPaymentLinkRequestType,
|
||||
DataType,
|
||||
WebhookDataType,
|
||||
WebhookType,
|
||||
} from '@payos/node/lib/type'
|
||||
import {
|
||||
ChatRoomType,
|
||||
@@ -18,6 +17,7 @@ import {
|
||||
ScheduleDateStatus,
|
||||
ScheduleStatus,
|
||||
} from '@prisma/client'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
export type CreatePaymentBody = CheckoutRequestType
|
||||
export type CreatePaymentResponse = CheckoutResponseDataType
|
||||
@Injectable()
|
||||
@@ -47,8 +47,7 @@ export class PayosService {
|
||||
Logger.error(`Invalid checksum: ${JSON.stringify(data)}`)
|
||||
throw new Error('Invalid checksum')
|
||||
}
|
||||
const paymentStatus =
|
||||
paymentData.code === '00' ? PaymentStatus.PAID : PaymentStatus.CANCELLED
|
||||
const paymentStatus = paymentData.code === '00' ? PaymentStatus.PAID : PaymentStatus.CANCELLED
|
||||
/* ---------------------------- begin transaction --------------------------- */
|
||||
try {
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
@@ -59,10 +58,7 @@ export class PayosService {
|
||||
status: paymentStatus,
|
||||
},
|
||||
})
|
||||
const orderStatus =
|
||||
paymentStatus === PaymentStatus.PAID
|
||||
? OrderStatus.PAID
|
||||
: OrderStatus.FAILED
|
||||
const orderStatus = paymentStatus === PaymentStatus.PAID ? OrderStatus.PAID : OrderStatus.FAILED
|
||||
// update order status
|
||||
await tx.order.update({
|
||||
where: { id: payment.orderId },
|
||||
@@ -129,8 +125,7 @@ export class PayosService {
|
||||
/* --------------- send first message from mentor to customer --------------- */
|
||||
await tx.message.create({
|
||||
data: {
|
||||
content:
|
||||
'Xin chào, mình là hướng dẫn viên của bạn, hãy bắt đầu học ngay nhé!',
|
||||
content: 'Xin chào, mình là hướng dẫn viên của bạn, hãy bắt đầu học ngay nhé!',
|
||||
type: MessageType.TEXT,
|
||||
chatRoomId: chatRoom.id,
|
||||
senderId: mentorId,
|
||||
@@ -158,10 +153,7 @@ export class PayosService {
|
||||
return await this.payos.getPaymentLinkInformation(orderId)
|
||||
}
|
||||
|
||||
async cancelPaymentURL(
|
||||
orderId: string | number,
|
||||
cancellationReason?: string,
|
||||
) {
|
||||
async cancelPaymentURL(orderId: string | number, cancellationReason?: string) {
|
||||
return await this.payos.cancelPaymentLink(orderId, cancellationReason)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user