支付时检测是否已经微信授权
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
orderTabToStatuses,
|
||||
validateMinPurchase,
|
||||
} from '@dukang/domain';
|
||||
import { loadAppConfig, WECHAT_AUTH_REQUIRED } from '@dukang/shared-types';
|
||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
||||
import { BenefitService } from '../benefit/benefit.service';
|
||||
@@ -169,6 +170,10 @@ export class TradeService {
|
||||
|
||||
const user = await this.prisma.user.findUnique({ where: { id: userId } });
|
||||
const openId = user?.wxOpenId ?? undefined;
|
||||
const appConfig = loadAppConfig();
|
||||
if (!appConfig.mockPay && !openId) {
|
||||
throw new BadRequestException(WECHAT_AUTH_REQUIRED);
|
||||
}
|
||||
const payResult = await this.payProvider.payOrder(orderId, openId);
|
||||
|
||||
if (payResult.mode === 'jsapi') {
|
||||
|
||||
Reference in New Issue
Block a user