微信SDK接通

This commit is contained in:
2026-07-01 19:56:44 +08:00
parent a1cbfc7241
commit aea1513836
38 changed files with 1610 additions and 92 deletions
@@ -167,7 +167,19 @@ export class TradeService {
throw new BadRequestException('订单状态不可支付');
}
const { externalNo } = await this.payProvider.payOrder(orderId);
const user = await this.prisma.user.findUnique({ where: { id: userId } });
const openId = user?.wxOpenId ?? undefined;
const payResult = await this.payProvider.payOrder(orderId, openId);
if (payResult.mode === 'jsapi') {
return {
mode: 'jsapi' as const,
orderId: order.id.toString(),
prepay: payResult.prepay,
};
}
const { externalNo } = payResult;
const now = new Date();
await this.prisma.$transaction(async (tx) => {