From 81d93f59ff46a839d102642501ab2e7b64af0e9e Mon Sep 17 00:00:00 2001 From: imeepos Date: Thu, 25 Sep 2025 20:38:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=94=99=E8=AF=AF=E5=92=8C=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复PaymentModule中PlatformAuthGuard依赖注入问题,导入PlatformModule - 修复PlatformModule导出PlatformAuthGuard供其他模块使用 - 优化支付适配器配置检查,改为警告而非错误,避免阻止应用启动 - 完善微信和抖音支付配置环境变量提示信息 - 确保应用可在支付配置不完整时正常启动 --- src/payment/adapters/douyin-payment.adapter.ts | 2 +- src/payment/adapters/wechat-payment.adapter.ts | 2 +- src/payment/payment.module.ts | 6 ++++++ src/platform/platform.module.ts | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/payment/adapters/douyin-payment.adapter.ts b/src/payment/adapters/douyin-payment.adapter.ts index 23578e3..26b57a3 100644 --- a/src/payment/adapters/douyin-payment.adapter.ts +++ b/src/payment/adapters/douyin-payment.adapter.ts @@ -72,7 +72,7 @@ export class DouyinPaymentAdapter extends BasePaymentAdapter { this.notifyToken = this.configService.get('DOUYIN_NOTIFY_TOKEN') || ''; if (!this.appId || !this.appSecret || !this.merchantId) { - this.logger.error('抖音支付配置不完整,请检查环境变量配置'); + this.logger.warn('抖音支付配置不完整,相关功能将不可用。请配置环境变量: DOUYIN_MINIPROGRAM_APPID, DOUYIN_MINIPROGRAM_SECRET, DOUYIN_MERCHANT_ID'); } } diff --git a/src/payment/adapters/wechat-payment.adapter.ts b/src/payment/adapters/wechat-payment.adapter.ts index b358cac..b4510ae 100644 --- a/src/payment/adapters/wechat-payment.adapter.ts +++ b/src/payment/adapters/wechat-payment.adapter.ts @@ -74,7 +74,7 @@ export class WechatPaymentAdapter extends BasePaymentAdapter { this.serialNumber = this.configService.get('WECHAT_SERIAL_NUMBER') || ''; if (!this.appId || !this.mchId || !this.privateKey || !this.apiV3Key) { - this.logger.error('微信支付配置不完整,请检查环境变量配置'); + this.logger.warn('微信支付配置不完整,相关功能将不可用。请配置环境变量: WECHAT_MINIPROGRAM_APPID, WECHAT_MCH_ID, WECHAT_PRIVATE_KEY, WECHAT_API_V3_KEY'); } } diff --git a/src/payment/payment.module.ts b/src/payment/payment.module.ts index 4feeed0..0ea6846 100644 --- a/src/payment/payment.module.ts +++ b/src/payment/payment.module.ts @@ -4,6 +4,9 @@ import { HttpModule } from '@nestjs/axios'; import { JwtModule } from '@nestjs/jwt'; import { ConfigService } from '@nestjs/config'; +// 平台模块 +import { PlatformModule } from '../platform/platform.module'; + // 实体 import { PaymentOrderEntity } from './entities/payment-order.entity'; import { PaymentTransactionEntity } from './entities/payment-transaction.entity'; @@ -33,6 +36,9 @@ import { PaymentController } from './controllers'; */ @Module({ imports: [ + // 平台模块 (提供 PlatformAuthGuard 和相关服务) + PlatformModule, + // TypeORM 实体注册 TypeOrmModule.forFeature([ // 支付相关实体 diff --git a/src/platform/platform.module.ts b/src/platform/platform.module.ts index be948f2..e7753a2 100644 --- a/src/platform/platform.module.ts +++ b/src/platform/platform.module.ts @@ -70,6 +70,6 @@ import { PlatformAuthGuard } from './guards/platform-auth.guard'; }, ], controllers: [UnifiedUserController], - exports: [UnifiedUserService, PlatformAdapterFactory], + exports: [UnifiedUserService, PlatformAdapterFactory, PlatformAuthGuard], }) export class PlatformModule {}