build
This commit is contained in:
parent
f18dd7a470
commit
12ee25ad57
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-dotnettools.csharp"
|
||||
]
|
||||
}
|
||||
61
.vscode/launch.json
vendored
Normal file
61
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "SimpleAdmin.Api(F5 调试 API)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build-api",
|
||||
"program": "${workspaceFolder}/src/SimpleAdmin.Api/bin/Debug/net8.0/SimpleAdmin.Api.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/src/SimpleAdmin.Api",
|
||||
"stopAtEntry": false,
|
||||
"console": "integratedTerminal",
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
|
||||
"uriFormat": "%s/index.html"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "调试:模拟订单计费",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build-tests",
|
||||
"program": "${workspaceFolder}/src/Oms.Tests/bin/Debug/net8.0/testhost.dll",
|
||||
"args": [
|
||||
"--runtimeconfig",
|
||||
"${workspaceFolder}/src/Oms.Tests/bin/Debug/net8.0/Oms.Tests.runtimeconfig.json",
|
||||
"--filter",
|
||||
"FullyQualifiedName~SimulateParcelOrderBilling_FullPipeline",
|
||||
"${workspaceFolder}/src/Oms.Tests/bin/Debug/net8.0/Oms.Tests.dll"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/src/Oms.Tests",
|
||||
"console": "integratedTerminal",
|
||||
"stopAtEntry": false
|
||||
},
|
||||
{
|
||||
"name": "Oms.Tests(调试当前测试)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build-tests",
|
||||
"program": "${workspaceFolder}/src/Oms.Tests/bin/Debug/net8.0/testhost.dll",
|
||||
"args": [
|
||||
"--runtimeconfig",
|
||||
"${workspaceFolder}/src/Oms.Tests/bin/Debug/net8.0/Oms.Tests.runtimeconfig.json",
|
||||
"${workspaceFolder}/src/Oms.Tests/bin/Debug/net8.0/Oms.Tests.dll"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/src/Oms.Tests",
|
||||
"console": "integratedTerminal",
|
||||
"stopAtEntry": false
|
||||
},
|
||||
{
|
||||
"name": "附加到进程",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
||||
76
.vscode/tasks.json
vendored
Normal file
76
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "restore",
|
||||
"command": "${env:ProgramFiles}\\dotnet\\dotnet.exe",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"restore",
|
||||
"${workspaceFolder}/SimpleAdmin.sln"
|
||||
],
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "build-api",
|
||||
"command": "${env:ProgramFiles}\\dotnet\\dotnet.exe",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/src/SimpleAdmin.Api/SimpleAdmin.Api.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||
],
|
||||
"dependsOn": "restore",
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "build-tests",
|
||||
"command": "${env:ProgramFiles}\\dotnet\\dotnet.exe",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/src/Oms.Tests/Oms.Tests.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||
],
|
||||
"dependsOn": "restore",
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "test-billing-demo",
|
||||
"command": "${env:ProgramFiles}\\dotnet\\dotnet.exe",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"test",
|
||||
"${workspaceFolder}/src/Oms.Tests/Oms.Tests.csproj",
|
||||
"--filter",
|
||||
"FullyQualifiedName~SimulateParcelOrderBilling_FullPipeline",
|
||||
"--logger",
|
||||
"console;verbosity=detailed"
|
||||
],
|
||||
"dependsOn": "build-tests",
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": "test"
|
||||
},
|
||||
{
|
||||
"label": "test",
|
||||
"command": "${env:ProgramFiles}\\dotnet\\dotnet.exe",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"test",
|
||||
"${workspaceFolder}/src/Oms.Tests/Oms.Tests.csproj",
|
||||
"--no-restore"
|
||||
],
|
||||
"dependsOn": "build-tests",
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
108
Cursor调试环境说明.md
Normal file
108
Cursor调试环境说明.md
Normal file
@ -0,0 +1,108 @@
|
||||
# Cursor 调试环境(最少安装)
|
||||
|
||||
## 已自动完成
|
||||
|
||||
| 项 | 状态 |
|
||||
|----|------|
|
||||
| .NET 8 SDK (`8.0.422`) | 已通过 winget 安装 |
|
||||
| NuGet 包还原 | `dotnet restore` 已成功 |
|
||||
| `.vscode/launch.json` | F5 调试配置 |
|
||||
| `.vscode/tasks.json` | 构建任务 |
|
||||
| `.vscode/extensions.json` | 推荐 C# 扩展 |
|
||||
|
||||
## 你需要手动做(2 步)
|
||||
|
||||
### 1. 安装 Cursor 扩展
|
||||
|
||||
在 Cursor 中打开扩展面板,安装:
|
||||
|
||||
- **C#**(`ms-dotnettools.csharp`)
|
||||
|
||||
打开本项目时若提示「安装推荐扩展」,点 **安装** 即可。
|
||||
|
||||
> 不需要安装完整的 C# Dev Kit,只装 **C#** 扩展即可断点调试。
|
||||
|
||||
### 2. 用正确文件夹打开工作区
|
||||
|
||||
在 Cursor 中打开:
|
||||
|
||||
```
|
||||
C:\Users\wilso\Desktop\oms0414-后端
|
||||
```
|
||||
|
||||
(必须打开含 `SimpleAdmin.sln` 的目录,调试配置才能生效。)
|
||||
|
||||
---
|
||||
|
||||
## 开始调试
|
||||
|
||||
### 方式 A:调试 API(需 MySQL)
|
||||
|
||||
1. 修改 `src/SimpleAdmin.Api/appsettings.Development.json` 里的 `ConnectionStrings:Default` 为你的数据库连接
|
||||
2. 按 **F5**,选择 **「SimpleAdmin.Api(F5 调试 API)」**
|
||||
3. 浏览器访问 `http://localhost:5281/index.html`(Swagger)
|
||||
|
||||
在任意 `.cs` 文件打断点(如 `RechargeService.cs`、`ParcelBillingCalculator.cs`),触发对应接口即可命中。
|
||||
|
||||
### 方式 B:调试单元测试(无需数据库)
|
||||
|
||||
1. 按 **F5**,选择 **「Oms.Tests(调试当前测试)」**
|
||||
2. 或在测试方法上右键 → **Debug Test**(需 C# 扩展识别 xUnit)
|
||||
|
||||
也可在终端运行:
|
||||
|
||||
```powershell
|
||||
dotnet test src/Oms.Tests/Oms.Tests.csproj
|
||||
```
|
||||
|
||||
### 方式 C:测试资源管理器
|
||||
|
||||
安装 C# 扩展后,左侧 **Testing** 面板会列出 `Oms.Tests` 中的用例,可单独运行/调试。
|
||||
|
||||
---
|
||||
|
||||
## 常用快捷键
|
||||
|
||||
| 操作 | 快捷键 |
|
||||
|------|--------|
|
||||
| 开始/继续调试 | F5 |
|
||||
| 单步跳过 | F10 |
|
||||
| 单步进入 | F11 |
|
||||
| 停止调试 | Shift+F5 |
|
||||
| 切换断点 | F9 |
|
||||
|
||||
---
|
||||
|
||||
## 配置说明
|
||||
|
||||
- **Development 环境**:`ASPNETCORE_ENVIRONMENT=Development`,读取 `appsettings.Development.json`
|
||||
- **UseLocalConfigs=true**:不连 Consul,全部用本地配置
|
||||
- **API 端口**:`http://localhost:5281`(与 `launchSettings.json` 一致)
|
||||
|
||||
若本机没有 MySQL,可只调试 **Oms.Tests** 中的纯逻辑(如 `ParcelBillingCalculatorTests`),无需启动 API。
|
||||
|
||||
---
|
||||
|
||||
## 故障排查
|
||||
|
||||
**终端找不到 `dotnet`**
|
||||
|
||||
关闭并重新打开 Cursor(或新开终端),让 PATH 生效。
|
||||
|
||||
**扩展装不上 / 调试按钮灰色**
|
||||
|
||||
确认工作区根目录是 `oms0414-后端`,且已安装 `ms-dotnettools.csharp`。
|
||||
|
||||
**API 启动报数据库连接失败**
|
||||
|
||||
检查 `appsettings.Development.json` 中的 MySQL 连接串,或改用远程测试库。
|
||||
|
||||
**构建失败**
|
||||
|
||||
在项目根目录执行:
|
||||
|
||||
```powershell
|
||||
dotnet build SimpleAdmin.sln
|
||||
```
|
||||
|
||||
根据错误信息修复后再 F5。
|
||||
@ -2,6 +2,7 @@ using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using Oms.Application.Dtos.Channels;
|
||||
using Oms.Application.Dtos.Orders;
|
||||
using Oms.Application.Shared;
|
||||
using Oms.Domain.ChannelsAggregate.Entities;
|
||||
using Oms.Domain.CustomersAggregate.Enums;
|
||||
@ -554,7 +555,7 @@ internal static class ParcelBillingCalculator
|
||||
|
||||
try
|
||||
{
|
||||
var result = new System.Data.DataTable().Compute(expr, string.Empty);
|
||||
var result = new global::System.Data.DataTable().Compute(expr, string.Empty);
|
||||
return result is bool boolResult && boolResult
|
||||
|| result is int intResult && intResult != 0
|
||||
|| result is decimal decimalResult && decimalResult != 0
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Fake.Domain.Exceptions;
|
||||
using Fake.Application;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
|
||||
147
src/Oms.Tests/ParcelBillingCalculatorDemoTests.cs
Normal file
147
src/Oms.Tests/ParcelBillingCalculatorDemoTests.cs
Normal file
@ -0,0 +1,147 @@
|
||||
using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
using Oms.Application.Dtos.Orders;
|
||||
using Oms.Application.Services.Orders;
|
||||
using Oms.Domain.ChannelsAggregate.Entities;
|
||||
using Oms.Domain.OrdersAggregate.Consts;
|
||||
using Oms.Domain.OrdersAggregate.Entities;
|
||||
using Oms.Tests.Support;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Oms.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟小包订单预报计费全流程,便于在 ParcelBillingCalculator 打断点调试。
|
||||
/// F5 选「调试:模拟订单计费」或对本类测试方法 Debug Test。
|
||||
/// </summary>
|
||||
public class ParcelBillingCalculatorDemoTests
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
public ParcelBillingCalculatorDemoTests(ITestOutputHelper output) => _output = output;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟一单美国美西普货小包:30×20×10cm、实重 1.5kg,走计重→进位→应收/应付算价。
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void SimulateParcelOrderBilling_FullPipeline_ShouldMatchDesignDoc()
|
||||
{
|
||||
// —— 1. 模拟 OrderParcelCreateInput 件重尺 ——
|
||||
var orderInput = new
|
||||
{
|
||||
RequestId = "demo-req-001",
|
||||
ClientNo = "CLIENT-DEMO-001",
|
||||
ProductCode = "US-EXPRESS-01",
|
||||
ChannelCode = "CH-US-WEST",
|
||||
CargoAttribute = "普货",
|
||||
Length = 30M,
|
||||
Width = 20M,
|
||||
Height = 10M,
|
||||
ActualWeight = 1.5M,
|
||||
Destination = new { CountryCode = "US", Province = "CA", PostalCode = "90001" }
|
||||
};
|
||||
|
||||
_output.WriteLine("=== 模拟订单入参 ===");
|
||||
_output.WriteLine(JsonSerializer.Serialize(orderInput, new JsonSerializerOptions { WriteIndented = true }));
|
||||
|
||||
var quoteContext = new ParcelQuoteContext
|
||||
{
|
||||
CountryCode = orderInput.Destination.CountryCode,
|
||||
Province = orderInput.Destination.Province,
|
||||
PostalCode = orderInput.Destination.PostalCode,
|
||||
CargoAttribute = ParcelBillingCalculator.MapCargoTypeToAttribute(orderInput.CargoAttribute),
|
||||
Length = orderInput.Length,
|
||||
Width = orderInput.Width,
|
||||
Height = orderInput.Height,
|
||||
ActualWeight = orderInput.ActualWeight
|
||||
};
|
||||
|
||||
// —— 2. KPI 分区匹配(美国 90001 → 美西)——
|
||||
var kpiRule = new KpiAreaInfo
|
||||
{
|
||||
Id = 1,
|
||||
CountryCode = "US",
|
||||
LeftPostcode = "90000",
|
||||
RightPostcode = "96199"
|
||||
};
|
||||
var kpiArea = new KpiArea { Id = 1, Name = "美西分区" };
|
||||
var zoneMatched = ParcelBillingCalculator.IsAreaMatched(
|
||||
kpiRule, quoteContext.CountryCode, quoteContext.Province, quoteContext.City, quoteContext.PostalCode);
|
||||
var zoneName = ParcelBillingCalculator.ResolveZoneName(kpiRule, kpiArea) ?? "美西";
|
||||
|
||||
zoneMatched.Should().BeTrue($"邮编 {quoteContext.PostalCode} 应命中美西分区");
|
||||
_output.WriteLine($"分区匹配: {zoneMatched}, 分区名: {zoneName}");
|
||||
|
||||
// —— 3. 计重(可在 ParcelBillingCalculator.CalculateRawBillableWeight 打断点)——
|
||||
var forecastWeight = ParcelBillingCalculator.BuildForecastWeight(quoteContext);
|
||||
var weightRules = new[] { ParcelBillingTestData.GwRule() };
|
||||
var (volumetricWeight, rawBillable) =
|
||||
ParcelBillingCalculator.CalculateRawBillableWeight(forecastWeight, weightRules);
|
||||
var roundingRules = new[] { ParcelBillingTestData.RoundingRange(0, 30, "0.5") };
|
||||
var chargeableWeight = ParcelBillingCalculator.ApplyRounding(rawBillable, roundingRules);
|
||||
|
||||
_output.WriteLine($"材积重: {volumetricWeight} kg, 原始计费重: {rawBillable} kg, 进位后计费重: {chargeableWeight} kg");
|
||||
|
||||
chargeableWeight.Should().Be(1.5M);
|
||||
|
||||
// —— 4. 应收(卖价)——
|
||||
var (priceVersion, effectiveTime) = ParcelBillingTestData.SnapshotMeta();
|
||||
var receivableSnapshot = ParcelBillingTestData.BuildReceivableSnapshot(
|
||||
ParcelBillingTestData.ReceivablePriceItem(
|
||||
"预报", 1, "freight",
|
||||
ParcelBillingTestData.ContinueFreightDetail()),
|
||||
ParcelBillingTestData.ReceivablePriceItem(
|
||||
"预报", 1, "操作费",
|
||||
ParcelBillingTestData.FixedPriceDetail(5M)));
|
||||
|
||||
var receivableFees = ParcelBillingCalculator.CalculateForecastReceivableFees(
|
||||
receivableSnapshot,
|
||||
priceVersion,
|
||||
effectiveTime,
|
||||
chargeableWeight,
|
||||
zoneName,
|
||||
quoteContext.CargoAttribute,
|
||||
null);
|
||||
|
||||
var receivableSummary = ParcelBillingCalculator.SummarizeFees(receivableFees);
|
||||
|
||||
_output.WriteLine("=== 应收费用 ===");
|
||||
foreach (var fee in receivableFees)
|
||||
{
|
||||
_output.WriteLine($" {fee.CostItem}: {fee.Amount} {fee.Currency} ({fee.ChargingStage})");
|
||||
}
|
||||
_output.WriteLine($"应收合计: {receivableSummary.TotalCost} (运费 {receivableSummary.Freight} + 杂费 {receivableSummary.OtherFees})");
|
||||
|
||||
receivableSummary.Freight.Should().Be(24M); // 1.5kg 续单价:首重18 + 续重6
|
||||
receivableSummary.TotalCost.Should().Be(29M);
|
||||
|
||||
// —— 5. 应付(买价)——
|
||||
var payablePrices = ParcelBillingTestData.BuildPayablePrices(
|
||||
ParcelBillingTestData.PayablePriceItem(
|
||||
"预报", 1, "freight",
|
||||
ParcelBillingTestData.ContinueFreightDetail(
|
||||
firstWeight: 1M, firstPrice: 12M, continueUnit: 0.5M, continuePrice: 4M)));
|
||||
|
||||
var payableFees = ParcelBillingCalculator.CalculateForecastPayableFees(
|
||||
payablePrices,
|
||||
priceVersion,
|
||||
effectiveTime,
|
||||
chargeableWeight,
|
||||
zoneName,
|
||||
quoteContext.CargoAttribute,
|
||||
null);
|
||||
|
||||
var payableSummary = ParcelBillingCalculator.SummarizeFees(payableFees);
|
||||
|
||||
_output.WriteLine("=== 应付费用 ===");
|
||||
foreach (var fee in payableFees)
|
||||
{
|
||||
_output.WriteLine($" {fee.CostItem}: {fee.Amount} {fee.Currency}");
|
||||
}
|
||||
_output.WriteLine($"应付合计: {payableSummary.TotalCost}");
|
||||
|
||||
payableSummary.Freight.Should().Be(16M); // 买价:12 + 4
|
||||
|
||||
_output.WriteLine($"毛利(应收-应付运费): {receivableSummary.Freight - payableSummary.Freight}");
|
||||
}
|
||||
}
|
||||
@ -258,7 +258,7 @@ internal static class WeChatXmlMessageParser
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class WeChatIncomingMessage
|
||||
public sealed class WeChatIncomingMessage
|
||||
{
|
||||
public string? ToUserName { get; init; }
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ using Oms.Domain.CustomersAggregate.Entities;
|
||||
using Oms.Domain.CustomersAggregate.Enums;
|
||||
using Oms.Domain.CustomersAggregate.Repositories;
|
||||
using SimpleAdmin.Api.WeChat.Dtos;
|
||||
using SimpleAdmin.Api.WeChat.Services;
|
||||
|
||||
namespace SimpleAdmin.Api.WeChat;
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Fake.Application;
|
||||
using Fake.Domain.Exceptions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
@ -18,6 +17,7 @@ public class WeChatMpAppService(
|
||||
IOptions<WeChatMpOptions> options,
|
||||
IWeChatMpApiClient weChatMpApiClient,
|
||||
IWeChatEventHandler eventHandler,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILogger<WeChatMpAppService> logger) : ApplicationService
|
||||
{
|
||||
/// <summary>
|
||||
@ -38,11 +38,15 @@ public class WeChatMpAppService(
|
||||
|| string.IsNullOrWhiteSpace(nonce)
|
||||
|| string.IsNullOrWhiteSpace(echostr))
|
||||
{
|
||||
return Content("error", "text/plain; charset=utf-8");
|
||||
return new ContentResult { Content = "error", ContentType = "text/plain; charset=utf-8" };
|
||||
}
|
||||
|
||||
var valid = WeChatSignatureHelper.Validate(options.Value.Token, timestamp, nonce, signature);
|
||||
return Content(valid ? echostr : "error", "text/plain; charset=utf-8");
|
||||
return new ContentResult
|
||||
{
|
||||
Content = valid ? echostr : "error",
|
||||
ContentType = "text/plain; charset=utf-8"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -65,31 +69,33 @@ public class WeChatMpAppService(
|
||||
if (!WeChatSignatureHelper.Validate(options.Value.Token, timestamp, nonce, signature))
|
||||
{
|
||||
logger.LogWarning("微信消息验签失败");
|
||||
return Content("error", "text/plain; charset=utf-8");
|
||||
return new ContentResult { Content = "error", ContentType = "text/plain; charset=utf-8" };
|
||||
}
|
||||
|
||||
using var reader = new StreamReader(HttpContext.Request.Body);
|
||||
var request = httpContextAccessor.HttpContext?.Request
|
||||
?? throw new BusinessException("无法读取微信回调请求");
|
||||
using var reader = new StreamReader(request.Body);
|
||||
var requestBody = await reader.ReadToEndAsync(cancellationToken);
|
||||
if (string.IsNullOrWhiteSpace(requestBody))
|
||||
{
|
||||
return Content(string.Empty, "application/xml; charset=utf-8");
|
||||
return new ContentResult { Content = string.Empty, ContentType = "application/xml; charset=utf-8" };
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(encryptType)
|
||||
&& !string.Equals(encryptType, "raw", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
logger.LogWarning("收到加密微信消息({EncryptType}),当前仅支持明文模式,请在公众平台切换为明文或后续启用 AES。", encryptType);
|
||||
return Content(string.Empty, "application/xml; charset=utf-8");
|
||||
return new ContentResult { Content = string.Empty, ContentType = "application/xml; charset=utf-8" };
|
||||
}
|
||||
|
||||
var message = WeChatXmlMessageParser.Parse(requestBody);
|
||||
if (message == null)
|
||||
{
|
||||
return Content(string.Empty, "application/xml; charset=utf-8");
|
||||
return new ContentResult { Content = string.Empty, ContentType = "application/xml; charset=utf-8" };
|
||||
}
|
||||
|
||||
var reply = await eventHandler.HandleAsync(message, cancellationToken);
|
||||
return Content(reply ?? string.Empty, "application/xml; charset=utf-8");
|
||||
return new ContentResult { Content = reply ?? string.Empty, ContentType = "application/xml; charset=utf-8" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -7,6 +7,38 @@
|
||||
"Microsoft.EntityFrameworkCore": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=127.0.0.1;Port=3306;Database=oms;Uid=root;Pwd=你的密码;CharSet=utf8mb4;"
|
||||
},
|
||||
"App": {
|
||||
"Urls": ["http://localhost:5281"],
|
||||
"CorsOrigins": ["http://localhost:5173", "http://localhost:5281"],
|
||||
"SendStartupNotification": false
|
||||
},
|
||||
"Jwt": {
|
||||
"SecretKey": "local-dev-secret-key-change-me",
|
||||
"Issuer": "SimpleAdmin.Api",
|
||||
"Audience": "SimpleAdmin.Api",
|
||||
"ExpiryInMinutes": "480",
|
||||
"RefreshExpiryInDays": "7",
|
||||
"ClockSkewMinutes": "5"
|
||||
},
|
||||
"JwtSettings": {
|
||||
"SecretKey": "local-dev-secret-key-change-me",
|
||||
"Issuer": "SimpleAdmin.Api",
|
||||
"Audience": "SimpleAdmin.Api",
|
||||
"ExpiryInMinutes": "480",
|
||||
"RefreshExpiryInDays": "7",
|
||||
"ClockSkewMinutes": "5"
|
||||
},
|
||||
"FeiShu": {
|
||||
"Webhook": "https://example.com/webhook",
|
||||
"EnableFeiShuExceptionSubscribe": false
|
||||
},
|
||||
"FeiShuNotice": {
|
||||
"Webhook": "https://example.com/webhook",
|
||||
"EnableFeiShuExceptionSubscribe": false
|
||||
},
|
||||
"Redis": {
|
||||
"ConnectionString": ""
|
||||
},
|
||||
|
||||
531
系统结构说明.md
Normal file
531
系统结构说明.md
Normal file
@ -0,0 +1,531 @@
|
||||
# OMS 后端系统结构说明
|
||||
|
||||
> 项目路径:`C:\Users\wilso\Desktop\oms0414-后端`
|
||||
> 解决方案:`SimpleAdmin.sln`
|
||||
> 技术栈:**.NET 8**、**Fake 模块化框架**、**SqlSugar + MySQL**、**JWT/RBAC**、**Swagger**
|
||||
|
||||
---
|
||||
|
||||
## 1. 总体架构
|
||||
|
||||
系统采用 **DDD 分层 + 模块化** 结构:`ApplicationService` 通过 Fake 框架自动暴露为 HTTP API(无需手写 Controller)。
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph Host["SimpleAdmin.Api(宿主)"]
|
||||
Program["Program / Bootstrap"]
|
||||
Auth["AuthService 认证"]
|
||||
WeChat["微信登录/回调"]
|
||||
end
|
||||
|
||||
subgraph App["Oms.Application(应用层)"]
|
||||
Services["Services 业务服务"]
|
||||
Dtos["Dtos 入参/出参"]
|
||||
Shared["Shared 工具类"]
|
||||
end
|
||||
|
||||
subgraph Domain["Oms.Domain(领域层)"]
|
||||
Entities["Entities 实体"]
|
||||
Repos["Repositories 仓储接口"]
|
||||
Enums["Enums / Consts"]
|
||||
end
|
||||
|
||||
subgraph Infra["Oms.SqlSugarCore(基础设施)"]
|
||||
DbCtx["OmsDbContext"]
|
||||
RepoImpl["Repository 实现"]
|
||||
end
|
||||
|
||||
subgraph Test["测试"]
|
||||
Unit["Oms.Tests"]
|
||||
Integ["SimpleAdmin.Api.IntegrationTests"]
|
||||
end
|
||||
|
||||
Host --> App
|
||||
App --> Domain
|
||||
App --> Infra
|
||||
Infra --> Domain
|
||||
Test --> Host
|
||||
```
|
||||
|
||||
### 项目依赖关系
|
||||
|
||||
| 项目 | 职责 |
|
||||
|------|------|
|
||||
| **SimpleAdmin.Api** | Web 宿主:启动、中间件、认证、微信、Swagger |
|
||||
| **Oms.Application** | 应用服务与 DTO,对外提供 `/customer`、`/order`、`/channel` 等 API |
|
||||
| **Oms.Domain** | 领域实体、枚举、仓储接口(不含数据库实现) |
|
||||
| **Oms.SqlSugarCore** | SqlSugar 仓储实现与 `OmsDbContext` |
|
||||
| **Oms.Tests** | 单元测试(计重算价、工具类等) |
|
||||
| **SimpleAdmin.Api.IntegrationTests** | API 集成测试 |
|
||||
|
||||
### API 路由前缀约定
|
||||
|
||||
| 前缀 | 来源 | 说明 |
|
||||
|------|------|------|
|
||||
| `/rbac/*` | Fake.Rbac + `AuthService` | 用户/角色/权限/登录 |
|
||||
| `/customer/*`、`/order/*` 等 | `Oms.Application.Services.*` | OMS 业务接口 |
|
||||
| `/wechat/*` | `SimpleAdmin.Api.WeChat` | 微信公众号与客户微信登录 |
|
||||
|
||||
JWT 中业务用户整数 ID 的 Claim 名为 **`mapId`**(对应 `user.userid` / `t_customer.UserId`)。
|
||||
|
||||
---
|
||||
|
||||
## 2. 根目录文件
|
||||
|
||||
| 文件/目录 | 作用 |
|
||||
|-----------|------|
|
||||
| `SimpleAdmin.sln` | Visual Studio 解决方案入口 |
|
||||
| `Directory.Build.props` | 全解决方案 MSBuild 公共属性(目标框架、包版本等) |
|
||||
| `NuGet.Config` | NuGet 源与包还原配置 |
|
||||
| `db.sql` | 数据库建表/初始化 SQL |
|
||||
| `sql/` | 补充 SQL 脚本目录 |
|
||||
| `README.md` | 项目快速入门说明 |
|
||||
| `SPEC.md` | 规格/约定文档 |
|
||||
| `design.md` | 设计说明 |
|
||||
| `开发复刻说明.md` | 开发复刻与环境说明 |
|
||||
| `.github/workflows/` | CI/CD(构建、部署流水线) |
|
||||
| `.dockerignore` | Docker 构建忽略规则 |
|
||||
|
||||
---
|
||||
|
||||
## 3. SimpleAdmin.Api(Web 宿主)
|
||||
|
||||
路径:`src/SimpleAdmin.Api/`
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `Program.cs` | 应用入口:调用 Bootstrap 创建并运行 Web 应用 |
|
||||
| `SimpleAdminApiBootstrap.cs` | 统一构建器:Consul 配置、Serilog、Autofac、Fake 模块注册 |
|
||||
| `SimpleAdminApiModule.cs` | 主模块:动态 API 扫描、CORS、Swagger、认证授权、静态文件、中间件管道 |
|
||||
| `SimpleJwtService.cs` | 替换默认 JWT 服务:在 Token Claims 中写入 `mapId`(`user.userid`) |
|
||||
| `SimpleOmsClaimTypes.cs` | OMS 自定义 Claim 类型常量 |
|
||||
|
||||
### Auth/(认证与客户登录)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `AuthService.cs` | OMS 认证中心:`/rbac/auth/login`(管理员/客户)、微信登录、刷新 Token、当前用户、改密、头像上传 |
|
||||
| `AuthRequestDtos.cs` | 登录相关 DTO(`OmsLoginInput`、`OmsLoginType` 等) |
|
||||
| `CustomerRoleSeedContributor.cs` | 数据种子:启动时确保存在 `Customer` 角色 |
|
||||
|
||||
### WeChat/(微信公众号)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `WeChatMpAppService.cs` | 公众号服务器验签、消息回调、登录二维码接口 |
|
||||
| `WeChatCustomerAppService.cs` | 客户微信 OAuth 用户信息、注册、绑定 |
|
||||
| `WeChatServiceExtensions.cs` | `AddOmsWeChat` DI 扩展注册 |
|
||||
| `Dtos/WeChatDtos.cs` | 微信相关请求/响应 DTO |
|
||||
| `Options/WeChatMpOptions.cs` | 公众号 AppId、Secret 等配置项 |
|
||||
| `Services/IWeChatLoginSessionStore.cs` | 微信扫码登录会话存储接口 |
|
||||
| `Services/WeChatLoginSessionStore.cs` | 内存/缓存实现:保存扫码 state 与 openId |
|
||||
| `Services/WeChatMpApiClient.cs` | 调用微信开放平台 API(access_token、用户信息等) |
|
||||
| `Services/WeChatEventHandler.cs` | 处理公众号推送事件(关注、扫码等) |
|
||||
| `Services/WeChatSignatureHelper.cs` | 微信签名校验工具 |
|
||||
|
||||
---
|
||||
|
||||
## 4. Oms.Application(应用层)
|
||||
|
||||
路径:`src/Oms.Application/`
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `OmsApplicationModule.cs` | 应用模块:注册 AutoMapper Profile 扫描 |
|
||||
| `GlobalUsings.cs` | 全局 using 声明 |
|
||||
| `Profiles/OmsApplicationAutoMapperProfile.cs` | Entity ↔ DTO 映射配置 |
|
||||
|
||||
### Shared/(公共工具)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `OmsDocHelper.cs` | 分页参数规范化、日期空值处理等文档约定工具 |
|
||||
| `OmsPasswordHelper.cs` | 客户密码 MD5 哈希 |
|
||||
| `OmsFileUploadHelper.cs` | 充值截图等文件上传至 `wwwroot/uploads` |
|
||||
| `JsonStringArrayHelper.cs` | JSON 字符串数组序列化/反序列化辅助 |
|
||||
| `PagingHelper.cs` | 分页计算辅助 |
|
||||
|
||||
---
|
||||
|
||||
### Services/Channels/(渠道与产品)
|
||||
|
||||
| 文件 | 主要 API | 作用 |
|
||||
|------|----------|------|
|
||||
| `AutoTriggerService.cs` | `/channel/auto-trigger/*` | 自动触发规则 CRUD、启停 |
|
||||
| `KpiAreaService.cs` | `/channel/kpi-area/*` | KPI 分区及明细维护 |
|
||||
| `LabelTemplateService.cs` | `/channel/label-template/save` | 面单模板保存 |
|
||||
| `SalesProductService.cs` | `/channel/sales-product/*` | 销售产品 CRUD、价格、分配、发布/回滚 |
|
||||
| `SalesProductService.Helpers.cs` | — | 销售产品服务私有辅助(映射、发布逻辑等) |
|
||||
| `ServiceChannelService.cs` | `/channel/service-channel/*` | 服务渠道、分组、价格、发布/回滚 |
|
||||
| `ServiceChannelService.Helpers.cs` | — | 服务渠道服务私有辅助 |
|
||||
| `WeightRoundingService.cs` | `/channel/weight-rounding/*` | 重量进位规则及明细 |
|
||||
| `WeightRuleService.cs` | `/channel/weight-rule/*` | 计重规则(材积系数等)及明细 |
|
||||
|
||||
### Services/Customers/
|
||||
|
||||
| 文件 | 主要 API | 作用 |
|
||||
|------|----------|------|
|
||||
| `CustomerService.cs` | `/customer/*` | 客户列表/详情/创建/子客户/更新/删除/重置密码;联动 RBAC 用户 |
|
||||
|
||||
### Services/Operations/(仓内作业)
|
||||
|
||||
| 文件 | 主要 API | 作用 |
|
||||
|------|----------|------|
|
||||
| `InboundRecordService.cs` | `/operation/inbound/*` | 入库登记与最近记录 |
|
||||
| `OutboundRecordService.cs` | `/operation/outbound/*` | 出库登记与最近记录 |
|
||||
| `LabelPrintService.cs` | `/operation/print-label/*` | 面单打印、模板下拉、打印记录 |
|
||||
|
||||
### Services/Orders/(订单)
|
||||
|
||||
| 文件 | 主要 API | 作用 |
|
||||
|------|----------|------|
|
||||
| `OrderService.cs` | `/order/*`(主文件) | 订单列表/详情/支付/申报/拦截/导出/模板/上传/任务查询 |
|
||||
| `OrderService.ParcelBilling.cs` | `/order/parcel/*` | 小包创建、批量创建、计重算价、费用快照写入 |
|
||||
| `OrderService.ParcelQuote.cs` | `/order/price-check` | 价格试算:匹配产品与分区报价 |
|
||||
| `OrderService.Helpers.cs` | — | 订单通用辅助(状态校验、映射等) |
|
||||
| `ParcelBillingCalculator.cs` | — | 静态计重算价引擎:材积重、分区、卖价费用 |
|
||||
| `ParcelQuoteContext.cs` | — | 报价上下文(国家、邮编、尺寸重量等) |
|
||||
| `ParcelQuoteResult.cs` | — | 单产品报价结果模型 |
|
||||
|
||||
### Services/Recharge/(充值)
|
||||
|
||||
| 文件 | 主要 API | 作用 |
|
||||
|------|----------|------|
|
||||
| `RechargeService.cs` | `/recharge/*` | 提交充值、审核/驳回、记录列表、Excel 导出 |
|
||||
|
||||
### Services/System/(系统基础数据)
|
||||
|
||||
| 文件 | 主要 API | 作用 |
|
||||
|------|----------|------|
|
||||
| `CountryService.cs` | `/system/country/list` | 国家列表 |
|
||||
| `DictService.cs` | `/system/dict/*` | 数据字典 CRUD |
|
||||
| `NoticeService.cs` | `/system/notice/*` | 公告 CRUD、已读确认 |
|
||||
| `WarehouseService.cs` | `/system/warehouse/*` | 仓库地址 CRUD |
|
||||
|
||||
---
|
||||
|
||||
### Dtos/(数据传输对象)
|
||||
|
||||
命名约定:
|
||||
|
||||
- `*Input` / `*SaveInput` / `*CreateInput`:请求入参
|
||||
- `*Output`:响应出参
|
||||
- `*PaginatedInput` / `*PaginatedOutput`:分页查询与列表项
|
||||
- `*ListInput` / `*ListOutput`:列表查询(部分渠道模块使用 POST list)
|
||||
|
||||
#### Dtos/Shared/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `IdInput.cs` | 通用主键入参 `{ id }` |
|
||||
| `OmsPageResult.cs` | 分页响应 `{ items, total }` |
|
||||
| `OmsItemsResult.cs` | 无分页列表包装 |
|
||||
| `ToggleStatusInput.cs` | 启停状态切换入参 |
|
||||
|
||||
#### Dtos/Channels/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `AutoTriggerListInput.cs` / `AutoTriggerOutput.cs` / `AutoTriggerSaveInput.cs` | 自动触发规则 |
|
||||
| `KpiAreaListInput.cs` / `KpiAreaOutput.cs` / `KpiAreaSaveInput.cs` | KPI 分区主表 |
|
||||
| `KpiAreaInfoListInput.cs` / `KpiAreaInfoOutput.cs` / `KpiAreaInfoSaveInput.cs` | KPI 分区明细 |
|
||||
| `LabelTemplateSaveInput.cs` / `LabelTemplateSaveOutput.cs` | 面单模板 |
|
||||
| `SalesProductListInput.cs` / `SalesProductListOutput.cs` | 销售产品列表 |
|
||||
| `SalesProductDetailOutput.cs` | 销售产品详情 |
|
||||
| `SalesProductSaveInput.cs` | 销售产品保存 |
|
||||
| `SalesProductPriceListOutput.cs` | 产品价格列表项 |
|
||||
| `SalesProductPriceSaveInput.cs` / `SalesProductPriceSaveAllInput.cs` | 单条/批量保存价格 |
|
||||
| `ChannelPriceDetailInput.cs` / `ChannelPriceDetailOutput.cs` | 价格明细行 |
|
||||
| `ChannelPriceFactorInput.cs` / `ChannelPriceFactorOutput.cs` | 价格因子 |
|
||||
| `SalesProductAllocationOutput.cs` | 产品分配方案 |
|
||||
| `SalesProductAllocationProviderInput.cs` / `SalesProductAllocationProviderOutput.cs` | 分配供应商 |
|
||||
| `SalesProductAllocationSaveInput.cs` | 保存分配配置 |
|
||||
| `SalesProductPublishInput.cs` / `SalesProductRollbackInput.cs` | 发布/回滚 |
|
||||
| `SalesProductPublishListInput.cs` / `SalesProductPublishRecordOutput.cs` | 发布记录 |
|
||||
| `ServiceChannelListInput.cs` / `ServiceChannelListOutput.cs` | 服务渠道列表 |
|
||||
| `ServiceChannelDetailOutput.cs` / `ServiceChannelSaveInput.cs` | 渠道详情与保存 |
|
||||
| `ServiceChannelGroupListInput.cs` / `ServiceChannelGroupListOutput.cs` / `ServiceChannelGroupSaveInput.cs` | 渠道分组 |
|
||||
| `ServiceChannelPriceListOutput.cs` / `ServiceChannelPriceSaveInput.cs` / `ServiceChannelPriceSaveAllInput.cs` | 渠道价格 |
|
||||
| `ServiceChannelPublishInput.cs` / `ServiceChannelRollbackInput.cs` | 渠道发布/回滚 |
|
||||
| `ServiceChannelPublishListInput.cs` / `ServiceChannelPublishRecordOutput.cs` | 渠道发布记录 |
|
||||
| `WeightRuleListInput.cs` / `WeightRuleOutput.cs` / `WeightRuleSaveInput.cs` | 计重规则主表 |
|
||||
| `WeightRuleInfoListInput.cs` / `WeightRuleInfoOutput.cs` / `WeightRuleInfoSaveInput.cs` | 计重规则明细 |
|
||||
| `WeightRoundingListInput.cs` / `WeightRoundingOutput.cs` / `WeightRoundingSaveInput.cs` | 进位规则主表 |
|
||||
| `WeightRoundingInfoListInput.cs` / `WeightRoundingInfoOutput.cs` / `WeightRoundingInfoSaveInput.cs` | 进位规则明细 |
|
||||
|
||||
#### Dtos/Customers/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `CustomerPaginatedInput.cs` / `CustomerPaginatedOutput.cs` | 客户分页查询 |
|
||||
| `CustomerOutput.cs` | 客户详情 |
|
||||
| `CreateCustomerInput.cs` | 创建主客户 |
|
||||
| `CreateSubCustomerInput.cs` | 创建子客户(含权限子集) |
|
||||
| `UpdateCustomerInput.cs` | 更新客户 |
|
||||
| `ResetCustomerPasswordInput.cs` | 重置密码 |
|
||||
|
||||
#### Dtos/Operations/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `CreateInboundRecordInput.cs` / `InboundRecordOutput.cs` | 入库 |
|
||||
| `CreateOutboundRecordInput.cs` / `OutboundRecordOutput.cs` | 出库 |
|
||||
| `PrintLabelInput.cs` / `LabelPrintRecordOutput.cs` | 面单打印 |
|
||||
| `LabelTemplateDropdownOutput.cs` | 打印模板下拉项 |
|
||||
|
||||
#### Dtos/Orders/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `OrderPaginatedInput.cs` / `OrderPaginatedOutput.cs` / `OrderOutput.cs` | 订单列表与详情 |
|
||||
| `OrderActionInput.cs` | 订单操作通用入参(支付/拦截等) |
|
||||
| `OrderItemOutput.cs` / `OrderReceiverOutput.cs` / `OrderSenderOutput.cs` | 订单明细、收发件人 |
|
||||
| `OrderWeightOutput.cs` | 订单重量信息 |
|
||||
| `OrderExportInput.cs` / `OrderExportOutput.cs` | 订单导出 |
|
||||
| `OrderPrintOutput.cs` | 打印数据 |
|
||||
| `OrderPriceCheckInput.cs` / `OrderPriceCheckOutput.cs` | 价格试算 |
|
||||
| `OrderParcelCreateInput.cs` / `OrderParcelCreateOutput.cs` | 单票小包创建 |
|
||||
| `OrderParcelBatchCreateInput.cs` / `OrderParcelBatchCreateOutput.cs` / `OrderParcelBatchCreateItemOutput.cs` | 批量小包创建 |
|
||||
| `OrderParcelItemInput.cs` / `OrderParcelReceiverInput.cs` / `OrderParcelSenderInput.cs` | 小包货品与地址 |
|
||||
| `OrderTemplateListInput.cs` / `OrderTemplateOutput.cs` | 导入模板 |
|
||||
| `OrderUploadInput.cs` / `OrderUploadOutput.cs` | Excel 批量上传 |
|
||||
| `OrderTaskListInput.cs` / `OrderTaskOutput.cs` / `OrderTaskDetailOutput.cs` / `OrderTaskFailOutput.cs` | 异步导入任务 |
|
||||
| `ProductBillingSnapshotDtos.cs` | 计费快照(产品、价格、分区等)内部 DTO |
|
||||
|
||||
#### Dtos/Recharge/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `SubmitRechargeFormInput.cs` | multipart 表单提交充值(含截图文件) |
|
||||
| `SubmitRechargeInput.cs` | JSON 方式提交充值(备用) |
|
||||
| `RechargeRecordOutput.cs` | 单条充值记录 |
|
||||
| `RechargeRecordPaginatedInput.cs` / `RechargeRecordPaginatedOutput.cs` | 充值记录分页 |
|
||||
| `ApproveRechargeInput.cs` / `RejectRechargeInput.cs` | 审核通过/驳回 |
|
||||
| `RechargeExportInput.cs` | 充值导出筛选 |
|
||||
|
||||
#### Dtos/System/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `CountryOutput.cs` | 国家 |
|
||||
| `DictListInput.cs` / `DictOutput.cs` / `DictCreateInput.cs` / `DictUpdateInput.cs` | 字典 |
|
||||
| `NoticeListInput.cs` / `NoticeOutput.cs` / `NoticeCreateInput.cs` / `NoticeUpdateInput.cs` | 公告 |
|
||||
| `WarehousePaginatedInput.cs` / `WarehousePaginatedOutput.cs` / `WarehouseOutput.cs` | 仓库列表与详情 |
|
||||
| `CreateWarehouseInput.cs` / `UpdateWarehouseInput.cs` | 仓库创建/更新 |
|
||||
|
||||
---
|
||||
|
||||
## 5. Oms.Domain(领域层)
|
||||
|
||||
路径:`src/Oms.Domain/`
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `OmsDomainModule.cs` | 领域模块(依赖 Fake DDD 模块) |
|
||||
|
||||
### Shared/
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `OmsAuditedAggregateRoot.cs` | 聚合根基类:int 主键、软删除、创建/更新人与时间 |
|
||||
| `OmsAuditedEntity.cs` | 子实体审计基类 |
|
||||
| `Enums/EnableStatus.cs` | 通用启用/禁用枚举 |
|
||||
|
||||
### CustomersAggregate/(客户)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `Entities/Customer.cs` | 客户实体 `t_customer`(UserId、余额、分组、状态等) |
|
||||
| `Enums/CustomerStatus.cs` | 客户状态:正常/禁用/冻结 |
|
||||
| `Enums/CustomerGroup.cs` | 客户分组 |
|
||||
| `Repositories/ICustomerRepository.cs` | 客户仓储接口(按编号/手机/邮箱查询等) |
|
||||
|
||||
### RechargeAggregate/(充值)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `Entities/RechargeRecord.cs` | 充值记录 `t_recharge_record` |
|
||||
| `Enums/PayType.cs` | 支付方式:微信/支付宝 |
|
||||
| `Enums/RechargeStatus.cs` | 充值状态:待审核/通过/驳回 |
|
||||
| `Repositories/IRechargeRecordRepository.cs` | 充值记录仓储接口 |
|
||||
|
||||
### OrdersAggregate/(订单)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `Entities/Order.cs` | 订单主表 |
|
||||
| `Entities/OrderRecipient.cs` | 收件人 |
|
||||
| `Entities/OrderSender.cs` | 发件人 |
|
||||
| `Entities/OrderDeclaration.cs` | 申报信息 |
|
||||
| `Entities/OrderFee.cs` | 订单费用明细 |
|
||||
| `Entities/OrderWeight.cs` | 重量尺寸(预报/复核等) |
|
||||
| `Entities/OrderTemplate.cs` | 导入模板元数据 |
|
||||
| `Entities/OrderTask.cs` | 批量导入任务 |
|
||||
| `Entities/OrderTaskFail.cs` | 导入失败行 |
|
||||
| `Consts/OrderStatusCodes.cs` | 订单状态常量 |
|
||||
| `Consts/OrderFeeTypeCodes.cs` | 费用类型常量 |
|
||||
| `Consts/OrderWeightTypeCodes.cs` | 重量类型常量 |
|
||||
| `Consts/CargoAttributeCodes.cs` | 货物属性常量 |
|
||||
| `Repositories/IOrderRepository.cs` | 订单仓储(含关联加载) |
|
||||
| `Repositories/IOrderTemplateRepository.cs` | 模板仓储 |
|
||||
| `Repositories/IOrderTaskRepository.cs` | 导入任务仓储 |
|
||||
|
||||
### ChannelsAggregate/(渠道/产品/计价)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `Entities/SalesProduct.cs` | 销售产品 |
|
||||
| `Entities/SalesProductPrice.cs` | 产品销售价格版本 |
|
||||
| `Entities/SalesProductPriceDetail.cs` | 价格分区明细 |
|
||||
| `Entities/SalesProductPriceFactor.cs` | 价格因子 |
|
||||
| `Entities/SalesProductAllocationProvider.cs` | 产品分配供应商 |
|
||||
| `Entities/SalesProductPublishRecord.cs` | 产品发布记录 |
|
||||
| `Entities/ServiceChannel.cs` | 服务渠道 |
|
||||
| `Entities/ServiceChannelGroup.cs` | 渠道分组 |
|
||||
| `Entities/ServiceChannelPrice.cs` | 渠道价格版本 |
|
||||
| `Entities/ServiceChannelPriceDetail.cs` | 渠道价格明细 |
|
||||
| `Entities/ServiceChannelPriceFactor.cs` | 渠道价格因子 |
|
||||
| `Entities/ServiceChannelPublishRecord.cs` | 渠道发布记录 |
|
||||
| `Entities/KpiArea.cs` / `KpiAreaInfo.cs` | KPI 分区 |
|
||||
| `Entities/WeightRule.cs` / `WeightRuleInfo.cs` | 计重规则 |
|
||||
| `Entities/WeightRounding.cs` / `WeightRoundingInfo.cs` | 重量进位 |
|
||||
| `Entities/AutoTrigger.cs` | 自动触发 |
|
||||
| `Entities/LabelTemplate.cs` | 面单模板 |
|
||||
| `Consts/AllocationSchemeCodes.cs` | 分配方案编码 |
|
||||
| `Consts/AreaTypeCodes.cs` | 分区类型编码 |
|
||||
| `Repositories/ISalesProductRepository.cs` | 销售产品仓储 |
|
||||
| `Repositories/IServiceChannelRepository.cs` | 服务渠道仓储 |
|
||||
| `Repositories/IServiceChannelGroupRepository.cs` | 渠道分组仓储 |
|
||||
| `Repositories/IKpiAreaRepository.cs` | KPI 分区仓储 |
|
||||
| `Repositories/IWeightRuleRepository.cs` | 计重规则仓储 |
|
||||
| `Repositories/IWeightRoundingRepository.cs` | 进位规则仓储 |
|
||||
| `Repositories/IAutoTriggerRepository.cs` | 自动触发仓储 |
|
||||
| `Repositories/ILabelTemplateRepository.cs` | 面单模板仓储 |
|
||||
|
||||
### OperationsAggregate/(仓内作业)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `Entities/InboundRecord.cs` | 入库记录 |
|
||||
| `Entities/OutboundRecord.cs` | 出库记录 |
|
||||
| `Entities/LabelPrintRecord.cs` | 面单打印记录 |
|
||||
| `Repositories/IInboundRecordRepository.cs` | 入库仓储 |
|
||||
| `Repositories/IOutboundRecordRepository.cs` | 出库仓储 |
|
||||
| `Repositories/ILabelPrintRecordRepository.cs` | 打印记录仓储 |
|
||||
|
||||
### SystemAggregate/(系统)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `Entities/Country.cs` | 国家 |
|
||||
| `Entities/Dict.cs` | 数据字典 |
|
||||
| `Entities/Notice.cs` | 系统公告 |
|
||||
| `Entities/NoticeRead.cs` | 公告已读记录 |
|
||||
| `Entities/WarehouseAddress.cs` | 仓库地址 |
|
||||
| `Consts/WarehouseCodes.cs` | 仓库相关常量 |
|
||||
| `Repositories/ICountryRepository.cs` | 国家仓储 |
|
||||
| `Repositories/IDictRepository.cs` | 字典仓储 |
|
||||
| `Repositories/INoticeRepository.cs` | 公告仓储 |
|
||||
| `Repositories/INoticeReadRepository.cs` | 已读仓储 |
|
||||
| `Repositories/IWarehouseAddressRepository.cs` | 仓库仓储 |
|
||||
|
||||
---
|
||||
|
||||
## 6. Oms.SqlSugarCore(基础设施层)
|
||||
|
||||
路径:`src/Oms.SqlSugarCore/`
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `OmsSqlSugarCoreModule.cs` | 注册 `OmsDbContext`、MySQL 连接 |
|
||||
| `OmsDbContext.cs` | SqlSugar 数据库上下文 |
|
||||
| `Repositories/OmsSqlSugarRepository.cs` | 通用仓储基类(审计聚合根 CRUD) |
|
||||
|
||||
各业务仓储实现(与 Domain 接口一一对应):
|
||||
|
||||
| 文件 | 实现接口 | 作用 |
|
||||
|------|----------|------|
|
||||
| `Customers/CustomerRepository.cs` | `ICustomerRepository` | 客户表访问 |
|
||||
| `Recharge/RechargeRecordRepository.cs` | `IRechargeRecordRepository` | 充值记录 |
|
||||
| `Orders/OrderRepository.cs` | `IOrderRepository` | 订单及关联表 |
|
||||
| `Orders/OrderTemplateRepository.cs` | `IOrderTemplateRepository` | 订单模板 |
|
||||
| `Orders/OrderTaskRepository.cs` | `IOrderTaskRepository` | 导入任务 |
|
||||
| `Channels/SalesProductRepository.cs` | `ISalesProductRepository` | 销售产品 |
|
||||
| `Channels/ServiceChannelRepository.cs` | `IServiceChannelRepository` | 服务渠道 |
|
||||
| `Channels/ServiceChannelGroupRepository.cs` | `IServiceChannelGroupRepository` | 渠道分组 |
|
||||
| `Channels/KpiAreaRepository.cs` | `IKpiAreaRepository` | KPI 分区 |
|
||||
| `Channels/WeightRuleRepository.cs` | `IWeightRuleRepository` | 计重规则 |
|
||||
| `Channels/WeightRoundingRepository.cs` | `IWeightRoundingRepository` | 进位规则 |
|
||||
| `Channels/AutoTriggerRepository.cs` | `IAutoTriggerRepository` | 自动触发 |
|
||||
| `Channels/LabelTemplateRepository.cs` | `ILabelTemplateRepository` | 面单模板 |
|
||||
| `Operations/InboundRecordRepository.cs` | `IInboundRecordRepository` | 入库 |
|
||||
| `Operations/OutboundRecordRepository.cs` | `IOutboundRecordRepository` | 出库 |
|
||||
| `Operations/LabelPrintRecordRepository.cs` | `ILabelPrintRecordRepository` | 打印记录 |
|
||||
| `System/CountryRepository.cs` | `ICountryRepository` | 国家 |
|
||||
| `System/DictRepository.cs` | `IDictRepository` | 字典 |
|
||||
| `System/NoticeRepository.cs` | `INoticeRepository` | 公告 |
|
||||
| `System/NoticeReadRepository.cs` | `INoticeReadRepository` | 公告已读 |
|
||||
| `System/WarehouseAddressRepository.cs` | `IWarehouseAddressRepository` | 仓库 |
|
||||
|
||||
---
|
||||
|
||||
## 7. Oms.Tests(单元测试)
|
||||
|
||||
路径:`src/Oms.Tests/`
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `GlobalUsings.cs` | 测试项目全局 using |
|
||||
| `OmsDocHelperTests.cs` | `OmsDocHelper` 单元测试 |
|
||||
| `OmsPasswordHelperTests.cs` | 密码哈希单元测试 |
|
||||
| `ParcelBillingCalculatorTests.cs` | 小包计重算价逻辑测试 |
|
||||
| `Support/ParcelBillingTestData.cs` | 算价测试夹具数据 |
|
||||
| `Support/TestCurrentPrincipalAccessor.cs` | 模拟当前用户 Principal |
|
||||
|
||||
---
|
||||
|
||||
## 8. SimpleAdmin.Api.IntegrationTests(集成测试)
|
||||
|
||||
路径:`src/SimpleAdmin.Api.IntegrationTests/`
|
||||
|
||||
| 文件 | 作用 |
|
||||
|------|------|
|
||||
| `GlobalUsings.cs` | 集成测试全局 using |
|
||||
| `Support/SimpleAdminApiTestHost.cs` | 内存 TestServer 宿主封装 |
|
||||
| `AuthApiIntegrationTests.cs` | 认证 API 集成测试 |
|
||||
| `CustomerApiIntegrationTests.cs` | 客户 API 集成测试 |
|
||||
| `CountryApiIntegrationTests.cs` | 国家 API 集成测试 |
|
||||
| `DictApiIntegrationTests.cs` | 字典 API 集成测试 |
|
||||
| `WarehouseApiIntegrationTests.cs` | 仓库 API 集成测试 |
|
||||
|
||||
---
|
||||
|
||||
## 9. 业务模块速查
|
||||
|
||||
| 业务域 | 核心 Service | 主要数据表(实体) |
|
||||
|--------|--------------|-------------------|
|
||||
| 认证 | `AuthService` | RBAC `user` + `t_customer` |
|
||||
| 客户 | `CustomerService` | `t_customer` |
|
||||
| 充值 | `RechargeService` | `t_recharge_record` |
|
||||
| 订单 | `OrderService` | `t_order` 及收发件人、费用、重量等 |
|
||||
| 渠道 | `ServiceChannelService` | 服务渠道及价格、发布记录 |
|
||||
| 产品 | `SalesProductService` | 销售产品及价格、分配、发布 |
|
||||
| 计价规则 | `WeightRuleService`、`WeightRoundingService`、`KpiAreaService` | 计重/进位/KPI 分区 |
|
||||
| 仓内 | `InboundRecordService` 等 | 入出库、打印记录 |
|
||||
| 系统 | `DictService`、`NoticeService`、`WarehouseService` | 字典、公告、仓库 |
|
||||
| 微信 | `WeChatMpAppService`、`WeChatCustomerAppService` | 会话存储(内存) |
|
||||
|
||||
---
|
||||
|
||||
## 10. 本地运行
|
||||
|
||||
```bash
|
||||
cd src/SimpleAdmin.Api
|
||||
dotnet run
|
||||
```
|
||||
|
||||
默认通过 `appsettings.json` / Consul 读取 `ConnectionStrings:Default`(MySQL)。Swagger 在应用启动 URL 根路径可访问。
|
||||
|
||||
---
|
||||
|
||||
*文档根据仓库当前源码自动生成,如有新增 `.cs` 文件,请按相同分层规则补充到对应章节。*
|
||||
Loading…
Reference in New Issue
Block a user