微信小程序支付功能打通

This commit is contained in:
2026-07-13 00:07:17 +08:00
parent f2cdc0222d
commit 450dc44d0e
14 changed files with 73 additions and 28 deletions
@@ -45,7 +45,7 @@ export class TradeController {
@Post(':id/pay')
@UseGuards(PhoneVerifiedGuard)
pay(@CurrentUser() user: AuthUser, @Param('id') id: string) {
return this.tradeService.payOrder(user.actorId, BigInt(id));
return this.tradeService.payOrder(user.actorId, BigInt(id), user.clientApp);
}
@Put(':id/address')
@@ -199,7 +199,7 @@ export class TradeService {
return serializeBigInt(mapOrderCompat(order));
}
async payOrder(userId: bigint, orderId: bigint) {
async payOrder(userId: bigint, orderId: bigint, clientApp?: ClientApp) {
const order = await this.prisma.order.findFirst({
where: { id: orderId, userId },
});
@@ -214,7 +214,8 @@ export class TradeService {
if (!appConfig.mockPay && !openId) {
throw new BadRequestException(WECHAT_AUTH_REQUIRED);
}
const payResult = await this.payProvider.payOrder(orderId, openId);
const payPlatform = clientApp === ClientApp.USER_MINI ? 'mini' : 'h5';
const payResult = await this.payProvider.payOrder(orderId, openId, payPlatform);
if (payResult.mode === 'jsapi') {
return {