核心功能:
- 账单CRUD操作(创建、查询、详情、更新状态、删除)
- 支付记录管理(创建支付、审核支付)
- 批量操作支持(批量更新账单状态)
- 统计分析功能(账单统计、逾期账单查询)
- 导出功能(Excel/PDF/CSV)
API端点 (16个):
- GET /api/admin/v1/billings - 账单列表(分页、筛选、排序)
- POST /api/admin/v1/billings - 创建账单
- GET /api/admin/v1/billings/{id} - 账单详情
- DELETE /api/admin/v1/billings/{id} - 删除账单
- PUT /api/admin/v1/billings/{id}/status - 更新状态
- POST /api/admin/v1/billings/batch/status - 批量更新
- GET /api/admin/v1/billings/{id}/payments - 支付记录
- POST /api/admin/v1/billings/{id}/payments - 创建支付
- PUT /api/admin/v1/billings/payments/{paymentId}/verify - 审核支付
- GET /api/admin/v1/billings/statistics - 统计数据
- GET /api/admin/v1/billings/overdue - 逾期账单
- POST /api/admin/v1/billings/export - 导出账单
架构优化:
- 采用CQRS模式分离读写(MediatR + Dapper + EF Core)
- 完整的领域模型设计(TenantBillingStatement, TenantPayment等)
- FluentValidation请求验证
- 状态机管理账单和支付状态流转
API设计优化 (三项改进):
1. 导出API响应Content-Type改为application/octet-stream
2. 支付审核API添加Approved和Notes可选参数,支持通过/拒绝
3. 移除TenantBillings API中重复的TenantId参数
数据库变更:
- 新增账单相关表及关系
- 支持Snowflake ID主键
- 完整的审计字段支持
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
71 lines
3.4 KiB
C#
71 lines
3.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using TakeoutSaaS.Domain.Deliveries.Repositories;
|
|
using TakeoutSaaS.Domain.Inventory.Repositories;
|
|
using TakeoutSaaS.Domain.Merchants.Repositories;
|
|
using TakeoutSaaS.Domain.Orders.Repositories;
|
|
using TakeoutSaaS.Domain.Payments.Repositories;
|
|
using TakeoutSaaS.Domain.Products.Repositories;
|
|
using TakeoutSaaS.Domain.Stores.Repositories;
|
|
using TakeoutSaaS.Domain.Tenants.Repositories;
|
|
using TakeoutSaaS.Domain.Tenants.Services;
|
|
using TakeoutSaaS.Infrastructure.App.Options;
|
|
using TakeoutSaaS.Infrastructure.App.Persistence;
|
|
using TakeoutSaaS.Infrastructure.App.Persistence.Repositories;
|
|
using TakeoutSaaS.Infrastructure.App.Repositories;
|
|
using TakeoutSaaS.Infrastructure.App.Services;
|
|
using TakeoutSaaS.Infrastructure.Common.Extensions;
|
|
using TakeoutSaaS.Shared.Abstractions.Constants;
|
|
|
|
namespace TakeoutSaaS.Infrastructure.App.Extensions;
|
|
|
|
/// <summary>
|
|
/// 业务主库基础设施注册扩展。
|
|
/// </summary>
|
|
public static class AppServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// 注册业务主库 DbContext 与仓储。
|
|
/// </summary>
|
|
/// <param name="services">服务集合。</param>
|
|
/// <param name="configuration">配置源。</param>
|
|
/// <returns>服务集合。</returns>
|
|
public static IServiceCollection AddAppInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.AddDatabaseInfrastructure(configuration);
|
|
services.AddPostgresDbContext<TakeoutAppDbContext>(DatabaseConstants.AppDataSource);
|
|
|
|
services.AddScoped<IMerchantRepository, EfMerchantRepository>();
|
|
services.AddScoped<IMerchantCategoryRepository, EfMerchantCategoryRepository>();
|
|
services.AddScoped<IStoreRepository, EfStoreRepository>();
|
|
services.AddScoped<IProductRepository, EfProductRepository>();
|
|
services.AddScoped<IOrderRepository, EfOrderRepository>();
|
|
services.AddScoped<IPaymentRepository, EfPaymentRepository>();
|
|
services.AddScoped<IDeliveryRepository, EfDeliveryRepository>();
|
|
services.AddScoped<ITenantRepository, EfTenantRepository>();
|
|
services.AddScoped<ITenantBillingRepository, TenantBillingRepository>();
|
|
services.AddScoped<ITenantPaymentRepository, TenantPaymentRepository>();
|
|
services.AddScoped<ITenantAnnouncementRepository, EfTenantAnnouncementRepository>();
|
|
services.AddScoped<ITenantAnnouncementReadRepository, EfTenantAnnouncementReadRepository>();
|
|
services.AddScoped<ITenantNotificationRepository, EfTenantNotificationRepository>();
|
|
services.AddScoped<ITenantPackageRepository, EfTenantPackageRepository>();
|
|
services.AddScoped<ITenantQuotaUsageRepository, EfTenantQuotaUsageRepository>();
|
|
services.AddScoped<IInventoryRepository, EfInventoryRepository>();
|
|
services.AddScoped<IQuotaPackageRepository, EfQuotaPackageRepository>();
|
|
services.AddScoped<IStatisticsRepository, EfStatisticsRepository>();
|
|
services.AddScoped<ISubscriptionRepository, EfSubscriptionRepository>();
|
|
|
|
// 1. 账单领域/导出服务
|
|
services.AddScoped<IBillingDomainService, BillingDomainService>();
|
|
services.AddScoped<IBillingExportService, BillingExportService>();
|
|
|
|
services.AddOptions<AppSeedOptions>()
|
|
.Bind(configuration.GetSection(AppSeedOptions.SectionName))
|
|
.ValidateDataAnnotations();
|
|
|
|
services.AddHostedService<AppDataSeeder>();
|
|
|
|
return services;
|
|
}
|
|
}
|