feat: 支持秒杀活动
This commit is contained in:
@@ -8,6 +8,6 @@ import { WechatPayService } from './wechat-pay.service'
|
||||
imports: [PrismaModule],
|
||||
controllers: [PaymentController],
|
||||
providers: [PaymentService, WechatPayService],
|
||||
exports: [PaymentService],
|
||||
exports: [PaymentService, WechatPayService],
|
||||
})
|
||||
export class PaymentModule {}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
NotFoundException,
|
||||
} from '@nestjs/common'
|
||||
import { CardType, Order } from '@prisma/client'
|
||||
import { MembershipStatus, OrderStatus } from '@mp-pilates/shared'
|
||||
import { MembershipStatus, OrderStatus, FlashSaleOrderStatus } from '@mp-pilates/shared'
|
||||
import { PrismaService } from '../prisma/prisma.service'
|
||||
import { WechatPayService, WxPaymentParams } from './wechat-pay.service'
|
||||
|
||||
@@ -136,6 +136,22 @@ export class PaymentService {
|
||||
])
|
||||
|
||||
this.logger.log(`Order PAID and Membership created: orderNo=${notification.orderNo}`)
|
||||
|
||||
// ── Flash sale order: mark as PAID ──
|
||||
if (existingOrder.flashSaleId) {
|
||||
await this.prisma.flashSaleOrder.updateMany({
|
||||
where: {
|
||||
orderId: existingOrder.id,
|
||||
status: FlashSaleOrderStatus.RESERVED,
|
||||
},
|
||||
data: {
|
||||
status: FlashSaleOrderStatus.PAID,
|
||||
paidAt: now,
|
||||
},
|
||||
})
|
||||
this.logger.log(`Flash sale order marked PAID for orderNo=${notification.orderNo}`)
|
||||
}
|
||||
|
||||
return this.buildSuccessXml()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user