fix: 修复应用启动错误和依赖注入问题

- 修复PaymentModule中PlatformAuthGuard依赖注入问题,导入PlatformModule
- 修复PlatformModule导出PlatformAuthGuard供其他模块使用
- 优化支付适配器配置检查,改为警告而非错误,避免阻止应用启动
- 完善微信和抖音支付配置环境变量提示信息
- 确保应用可在支付配置不完整时正常启动
This commit is contained in:
imeepos 2025-09-25 20:38:14 +08:00
parent ca8710686b
commit 81d93f59ff
4 changed files with 9 additions and 3 deletions

View File

@ -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');
}
}

View File

@ -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');
}
}

View File

@ -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([
// 支付相关实体

View File

@ -70,6 +70,6 @@ import { PlatformAuthGuard } from './guards/platform-auth.guard';
},
],
controllers: [UnifiedUserController],
exports: [UnifiedUserService, PlatformAdapterFactory],
exports: [UnifiedUserService, PlatformAdapterFactory, PlatformAuthGuard],
})
export class PlatformModule {}