From a69e69d5b6c6a29fb01541fb058adde001253a5e Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Mon, 26 Oct 2026 10:04:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9F=A5=E4=BB=B7=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=94=AF=E6=8C=81=E5=8C=BF=E5=90=8D=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=EF=BC=8C=E4=BE=9B=20H5=20=E8=AE=BF=E5=AE=A2=E5=85=88?= =?UTF-8?q?=E9=80=89=E4=BB=93/=E5=9B=BD=E5=AE=B6/=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../OrderPriceCheckFormOptionsOutput.cs | 49 +++++++++++++++++ .../Orders/OrderService.ParcelQuote.cs | 54 +++++++++++++++++++ .../Services/Orders/OrderService.cs | 9 ++++ 3 files changed, 112 insertions(+) create mode 100644 src/Oms.Application/Dtos/Orders/OrderPriceCheckFormOptionsOutput.cs diff --git a/src/Oms.Application/Dtos/Orders/OrderPriceCheckFormOptionsOutput.cs b/src/Oms.Application/Dtos/Orders/OrderPriceCheckFormOptionsOutput.cs new file mode 100644 index 0000000..488a32d --- /dev/null +++ b/src/Oms.Application/Dtos/Orders/OrderPriceCheckFormOptionsOutput.cs @@ -0,0 +1,49 @@ +namespace Oms.Application.Dtos.Orders; + +/// +/// 查价表单下拉选项(国家 / 发货仓 / 货物属性),可供访客匿名加载。 +/// +public class OrderPriceCheckFormOptionsOutput +{ + /// 目的国家列表。 + public List Countries { get; set; } = []; + + /// 发货仓列表(仅 id + 名称,不含地址电话)。 + public List Warehouses { get; set; } = []; + + /// 货物属性(字典 cargo_attribute)。 + public List CargoAttributes { get; set; } = []; +} + +/// 查价目的国家选项。 +public class OrderPriceCheckCountryOptionOutput +{ + /// ISO 二字码。 + public string CountryCode { get; set; } = string.Empty; + + /// 中文名。 + public string ChineseName { get; set; } = string.Empty; + + /// 英文名。 + public string EnglishName { get; set; } = string.Empty; +} + +/// 查价发货仓选项。 +public class OrderPriceCheckWarehouseOptionOutput +{ + /// 仓库主键。 + public int Id { get; set; } + + /// 仓库名称。 + public string WarehouseName { get; set; } = string.Empty; +} + +/// 查价货物属性选项。 +public class OrderPriceCheckCargoOptionOutput +{ + /// 字典编码。 + public string DictCode { get; set; } = string.Empty; + + /// 字典名称。 + public string DictName { get; set; } = string.Empty; +} diff --git a/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs b/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs index 7ef6839..929f1db 100644 --- a/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs +++ b/src/Oms.Application/Services/Orders/OrderService.ParcelQuote.cs @@ -19,6 +19,60 @@ public partial class OrderService private sealed record PriceCheckCargoTarget(string Code, string DisplayName, string CargoAttribute); + private const string CargoAttributeDictType = "cargo_attribute"; + + /// + /// 组装查价表单下拉:国家、发货仓名称、货物属性字典。 + /// + private async Task BuildPriceCheckFormOptionsAsync() + { + var countries = (await CountryRepository.GetListAsync()) + .OrderBy(x => x.CountryCode) + .ThenBy(x => x.EnglishName) + .Select(x => new OrderPriceCheckCountryOptionOutput + { + CountryCode = (x.CountryCode ?? string.Empty).Trim().ToUpperInvariant(), + ChineseName = (x.ChineseName ?? string.Empty).Trim(), + EnglishName = (x.EnglishName ?? string.Empty).Trim(), + }) + .Where(x => !string.IsNullOrWhiteSpace(x.CountryCode)) + .ToList(); + + var warehouses = (await WarehouseAddressRepository.GetListAsync()) + .OrderBy(x => x.Sort == null) + .ThenBy(x => x.Sort) + .ThenBy(x => x.Id) + .Select(x => new OrderPriceCheckWarehouseOptionOutput + { + Id = x.Id, + WarehouseName = string.IsNullOrWhiteSpace(x.WarehouseName) + ? x.Id.ToString() + : x.WarehouseName.Trim(), + }) + .Where(x => x.Id > 0) + .ToList(); + + var cargoAttributes = (await DictRepository.GetListAsync(x => x.DictType == CargoAttributeDictType)) + .OrderBy(x => x.DictSort) + .ThenBy(x => x.DictCode) + .Select(x => new OrderPriceCheckCargoOptionOutput + { + DictCode = (x.DictCode ?? string.Empty).Trim(), + DictName = string.IsNullOrWhiteSpace(x.DictName) + ? (x.DictCode ?? string.Empty).Trim() + : x.DictName.Trim(), + }) + .Where(x => !string.IsNullOrWhiteSpace(x.DictCode)) + .ToList(); + + return new OrderPriceCheckFormOptionsOutput + { + Countries = countries, + Warehouses = warehouses, + CargoAttributes = cargoAttributes, + }; + } + private async Task BuildPriceCheckShippingOptionsAsync() { var products = await SalesProductRepository.GetListAsync(x => x.IsActive == EnableStatus.Enabled); diff --git a/src/Oms.Application/Services/Orders/OrderService.cs b/src/Oms.Application/Services/Orders/OrderService.cs index 068e567..ced7591 100644 --- a/src/Oms.Application/Services/Orders/OrderService.cs +++ b/src/Oms.Application/Services/Orders/OrderService.cs @@ -4,6 +4,7 @@ using Fake.Application; using Fake.Domain.Exceptions; using Fake.ObjectStorage; using Fake.UnitOfWork; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using MiniExcelLibs; @@ -573,6 +574,14 @@ public partial class OrderService : ApplicationService public Task GetPriceCheckShippingOptionsAsync() => BuildPriceCheckShippingOptionsAsync(); + /// + /// 查价表单下拉(国家 / 发货仓 / 货物属性)。匿名可读,供 H5 访客先填条件再登录查价。 + /// + [AllowAnonymous] + [HttpGet("/order/price-check/form-options")] + public Task GetPriceCheckFormOptionsAsync() => + BuildPriceCheckFormOptionsAsync(); + /// /// 执行订单运费试算。 ///