feat: 查价表单下拉支持匿名加载,供 H5 访客先选仓/国家/属性
All checks were successful
Build and Deploy / deploy (push) Successful in 1m44s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m44s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1caca3c357
commit
a69e69d5b6
@ -0,0 +1,49 @@
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 查价表单下拉选项(国家 / 发货仓 / 货物属性),可供访客匿名加载。
|
||||
/// </summary>
|
||||
public class OrderPriceCheckFormOptionsOutput
|
||||
{
|
||||
/// <summary>目的国家列表。</summary>
|
||||
public List<OrderPriceCheckCountryOptionOutput> Countries { get; set; } = [];
|
||||
|
||||
/// <summary>发货仓列表(仅 id + 名称,不含地址电话)。</summary>
|
||||
public List<OrderPriceCheckWarehouseOptionOutput> Warehouses { get; set; } = [];
|
||||
|
||||
/// <summary>货物属性(字典 cargo_attribute)。</summary>
|
||||
public List<OrderPriceCheckCargoOptionOutput> CargoAttributes { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>查价目的国家选项。</summary>
|
||||
public class OrderPriceCheckCountryOptionOutput
|
||||
{
|
||||
/// <summary>ISO 二字码。</summary>
|
||||
public string CountryCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>中文名。</summary>
|
||||
public string ChineseName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>英文名。</summary>
|
||||
public string EnglishName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>查价发货仓选项。</summary>
|
||||
public class OrderPriceCheckWarehouseOptionOutput
|
||||
{
|
||||
/// <summary>仓库主键。</summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>仓库名称。</summary>
|
||||
public string WarehouseName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>查价货物属性选项。</summary>
|
||||
public class OrderPriceCheckCargoOptionOutput
|
||||
{
|
||||
/// <summary>字典编码。</summary>
|
||||
public string DictCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>字典名称。</summary>
|
||||
public string DictName { get; set; } = string.Empty;
|
||||
}
|
||||
@ -19,6 +19,60 @@ public partial class OrderService
|
||||
|
||||
private sealed record PriceCheckCargoTarget(string Code, string DisplayName, string CargoAttribute);
|
||||
|
||||
private const string CargoAttributeDictType = "cargo_attribute";
|
||||
|
||||
/// <summary>
|
||||
/// 组装查价表单下拉:国家、发货仓名称、货物属性字典。
|
||||
/// </summary>
|
||||
private async Task<OrderPriceCheckFormOptionsOutput> 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<OrderPriceCheckShippingOptionsOutput> BuildPriceCheckShippingOptionsAsync()
|
||||
{
|
||||
var products = await SalesProductRepository.GetListAsync(x => x.IsActive == EnableStatus.Enabled);
|
||||
|
||||
@ -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<OrderPriceCheckShippingOptionsOutput> GetPriceCheckShippingOptionsAsync() =>
|
||||
BuildPriceCheckShippingOptionsAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 查价表单下拉(国家 / 发货仓 / 货物属性)。匿名可读,供 H5 访客先填条件再登录查价。
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("/order/price-check/form-options")]
|
||||
public Task<OrderPriceCheckFormOptionsOutput> GetPriceCheckFormOptionsAsync() =>
|
||||
BuildPriceCheckFormOptionsAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 执行订单运费试算。
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user