admin/src/Oms.Application/OmsApplicationModule.cs
zzh 52df7307f6
All checks were successful
Build and Deploy / deploy (push) Successful in 1m20s
feat: 仓租费率与日结扣费接入账户流水,并补充待支付微信通知
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 14:56:54 +08:00

83 lines
3.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Diagnostics;
using Fake;
using Fake.EventBus.RabbitMQ;
using Fake.Modularity;
using Fake.ObjectMapping.AutoMapper;
using FreeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Oms.Application.Helpers;
using Oms.Application.Integrations.SmallBagTrack;
using Oms.Application.Integrations.Itfx;
using Oms.Application.Integrations.PlatformShop;
using Oms.Application.Labeling;
using Oms.Application.Labeling.Hiprint;
using Oms.Application.Services.Approval;
using Oms.Application.Services.Approval.Contracts;
using Oms.Application.Services.Channels;
using Oms.Application.Services.Recharge;
using Oms.Application.Services.Storage;
using Oms.Application.Shared;
using Oms.Application.Workers;
using Oms.Domain;
namespace Oms.Application;
/// <summary>
/// OMS 应用层模块注册。
/// 对象存储由 Api 宿主注册 Fake.ObjectStorage(Local / TencentCos);文件元数据走 Fake.FileManagement。
/// </summary>
[DependsOn(
typeof(OmsDomainModule),
typeof(FakeObjectMappingAutoMapperModule),
typeof(FakeEventBusRabbitMqModule)
)]
public class OmsApplicationModule : FakeModule
{
/// <inheritdoc />
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
context.Services.Configure<FakeAutoMapperOptions>(options =>
{
options.ScanProfiles<OmsApplicationModule>();
});
var redisOptions = configuration.GetSection("Redis").Get<ConnectionStringBuilder>();
if (redisOptions == null || string.IsNullOrWhiteSpace(redisOptions.Host))
{
throw new FakeException("未找到Redis相关配置,请检查配置文件中是否包含名为Redis的节点(且包含 Host)");
}
RedisHelper.Init(redisOptions, showLogInfo: Debugger.IsAttached);
context.Services.AddMemoryCache();
// 面单 PDF:显式注册接口,避免约定注册未暴露 ILabelPdfRenderer 导致激活失败
context.Services.AddTransient<HiprintTemplateParser>();
context.Services.AddTransient<ILabelPdfRenderer, QuestPdfLabelRenderer>();
context.Services.AddTransient<LabelPdfGenerationService>();
// 审批终审 Handler:约定注册只暴露 I{类名},须显式挂到 IApprovalOperationHandler,
// 否则 Approve 会空跑成 Executed、不落发布/入账。
context.Services.AddTransient<IApprovalOperationHandler, SalesProductPricePublishApprovalHandler>();
context.Services.AddTransient<IApprovalOperationHandler, RechargeCreditApprovalHandler>();
context.Services.AddTransient<IApprovalOperationHandler, NoopApprovalHandler>();
context.Services.AddHttpClient(FileStorageService.UrlFetchClientName, client =>
{
client.Timeout = TimeSpan.FromSeconds(60);
});
context.Services.AddOmsSmallBagTrack(configuration);
context.Services.AddOmsItfxIntegration(configuration);
context.Services.AddOmsPlatformShopIntegration(configuration);
context.Services.AddOmsOrderBatchMessaging(configuration);
context.Services.AddAiLlmClient();
context.Services.AddHostedService<XhsScheduledPublishWorker>();
context.Services.AddHostedService<MarketingBackgroundWorker>();
context.Services.AddHostedService<WarehouseRentBillingWorker>();
}
}