feat: 销售产品支持官网封面图上传与门户展示
All checks were successful
Build and Deploy / deploy (push) Successful in 1m26s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m26s
产品配置可上传 CoverImage,门户精选线路目录返回封面 URL。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
443813a12b
commit
b31efc7b56
1
db.sql
1
db.sql
@ -584,6 +584,7 @@ CREATE TABLE `t_sales_product` (
|
|||||||
`WeightRuleId` INT NULL COMMENT '计重规则ID',
|
`WeightRuleId` INT NULL COMMENT '计重规则ID',
|
||||||
`WeightRoundingId` INT NULL COMMENT '计重进位ID',
|
`WeightRoundingId` INT NULL COMMENT '计重进位ID',
|
||||||
`ProductDescription` TEXT COMMENT '产品描述',
|
`ProductDescription` TEXT COMMENT '产品描述',
|
||||||
|
`CoverImage` VARCHAR(512) NULL COMMENT '官网线路封面图 object key',
|
||||||
`PreStorageScript` TEXT COMMENT '入库前脚本',
|
`PreStorageScript` TEXT COMMENT '入库前脚本',
|
||||||
`CustomerGuideMarkdown` MEDIUMTEXT COMMENT '对客说明 Markdown',
|
`CustomerGuideMarkdown` MEDIUMTEXT COMMENT '对客说明 Markdown',
|
||||||
`IsActive` TINYINT NOT NULL DEFAULT 2 COMMENT 'EnableStatus:0=None未设置,1=Disabled禁用,2=Enabled启用',
|
`IsActive` TINYINT NOT NULL DEFAULT 2 COMMENT 'EnableStatus:0=None未设置,1=Disabled禁用,2=Enabled启用',
|
||||||
|
|||||||
20
sql/migrate_sales_product_cover_image_20261126.sql
Normal file
20
sql/migrate_sales_product_cover_image_20261126.sql
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
-- 销售产品:官网线路封面图(产品配置可上传;门户精选线路卡片背景)
|
||||||
|
-- 可重复执行
|
||||||
|
|
||||||
|
SET @db := DATABASE();
|
||||||
|
|
||||||
|
SET @exists := (
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @db
|
||||||
|
AND TABLE_NAME = 't_sales_product'
|
||||||
|
AND COLUMN_NAME = 'CoverImage'
|
||||||
|
);
|
||||||
|
SET @sql := IF(
|
||||||
|
@exists = 0,
|
||||||
|
'ALTER TABLE `t_sales_product` ADD COLUMN `CoverImage` VARCHAR(512) NULL COMMENT ''官网线路封面图 object key'' AFTER `ProductDescription`',
|
||||||
|
'SELECT ''t_sales_product.CoverImage already exists'' AS info'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
@ -90,6 +90,16 @@ public class SalesProductDetailOutput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? ProductDescription { get; set; }
|
public string? ProductDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 官网线路封面图 object key(保存用)。
|
||||||
|
/// </summary>
|
||||||
|
public string? CoverImage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 官网线路封面图可访问 URL(预览用)。
|
||||||
|
/// </summary>
|
||||||
|
public string? CoverImageUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预入库脚本。
|
/// 预入库脚本。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -103,6 +103,11 @@ public class SalesProductPortalItemOutput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? ProductDescription { get; set; }
|
public string? ProductDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 官网线路封面图可访问 URL(无图时为空)。
|
||||||
|
/// </summary>
|
||||||
|
public string? CoverImageUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 官网目的地区域编码:us / eu / sea / ca_mx / au / global。
|
/// 官网目的地区域编码:us / eu / sea / ca_mx / au / global。
|
||||||
/// 优先由价格分区国家推导;国际快递跨区时含 global。
|
/// 优先由价格分区国家推导;国际快递跨区时含 global。
|
||||||
|
|||||||
@ -92,6 +92,11 @@ public class SalesProductSaveInput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? ProductDescription { get; set; }
|
public string? ProductDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 官网线路封面图 object key。
|
||||||
|
/// </summary>
|
||||||
|
public string? CoverImage { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预入库脚本。
|
/// 预入库脚本。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using Oms.Application.Dtos.Orders;
|
|||||||
using Oms.Application.Dtos.Shared;
|
using Oms.Application.Dtos.Shared;
|
||||||
using Oms.Application.Services.Approval.Contracts;
|
using Oms.Application.Services.Approval.Contracts;
|
||||||
using Oms.Application.Shared;
|
using Oms.Application.Shared;
|
||||||
|
using Oms.Application.Storage;
|
||||||
using Oms.Domain.ApprovalAggregate.Consts;
|
using Oms.Domain.ApprovalAggregate.Consts;
|
||||||
using Oms.Domain.ChannelsAggregate.Consts;
|
using Oms.Domain.ChannelsAggregate.Consts;
|
||||||
using Oms.Domain.ChannelsAggregate.Entities;
|
using Oms.Domain.ChannelsAggregate.Entities;
|
||||||
@ -615,6 +616,9 @@ public partial class SalesProductService
|
|||||||
entity.WeightRuleId = input.WeightRuleId;
|
entity.WeightRuleId = input.WeightRuleId;
|
||||||
entity.WeightRoundingId = input.WeightRoundingId;
|
entity.WeightRoundingId = input.WeightRoundingId;
|
||||||
entity.ProductDescription = input.ProductDescription;
|
entity.ProductDescription = input.ProductDescription;
|
||||||
|
entity.CoverImage = string.IsNullOrWhiteSpace(input.CoverImage)
|
||||||
|
? null
|
||||||
|
: OmsObjectStorageExtensions.ToStorageKey(input.CoverImage.Trim());
|
||||||
entity.PreStorageScript = input.PreStorageScript;
|
entity.PreStorageScript = input.PreStorageScript;
|
||||||
// 对客说明仅通过 /customer-guide/save 维护,产品配置保存/发布不覆盖
|
// 对客说明仅通过 /customer-guide/save 维护,产品配置保存/发布不覆盖
|
||||||
entity.IsActive = input.IsActive;
|
entity.IsActive = input.IsActive;
|
||||||
@ -857,6 +861,7 @@ public partial class SalesProductService
|
|||||||
WeightRuleId = entity.WeightRuleId,
|
WeightRuleId = entity.WeightRuleId,
|
||||||
WeightRoundingId = entity.WeightRoundingId,
|
WeightRoundingId = entity.WeightRoundingId,
|
||||||
ProductDescription = entity.ProductDescription,
|
ProductDescription = entity.ProductDescription,
|
||||||
|
CoverImage = entity.CoverImage,
|
||||||
PreStorageScript = entity.PreStorageScript,
|
PreStorageScript = entity.PreStorageScript,
|
||||||
CustomerGuideMarkdown = entity.CustomerGuideMarkdown,
|
CustomerGuideMarkdown = entity.CustomerGuideMarkdown,
|
||||||
IsActive = (byte)entity.IsActive,
|
IsActive = (byte)entity.IsActive,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Oms.Application.Dtos.Channels;
|
using Oms.Application.Dtos.Channels;
|
||||||
|
using Oms.Application.Storage;
|
||||||
using Oms.Domain.ChannelsAggregate.Entities;
|
using Oms.Domain.ChannelsAggregate.Entities;
|
||||||
using Oms.Domain.Shared.Enums;
|
using Oms.Domain.Shared.Enums;
|
||||||
using Oms.Domain.SystemAggregate.Repositories;
|
using Oms.Domain.SystemAggregate.Repositories;
|
||||||
@ -119,6 +120,9 @@ public partial class SalesProductService
|
|||||||
TradeTerms = string.IsNullOrWhiteSpace(p.TradeTerms) ? null : p.TradeTerms.Trim().ToUpperInvariant(),
|
TradeTerms = string.IsNullOrWhiteSpace(p.TradeTerms) ? null : p.TradeTerms.Trim().ToUpperInvariant(),
|
||||||
RouteSort = p.RouteSort,
|
RouteSort = p.RouteSort,
|
||||||
ProductDescription = p.ProductDescription,
|
ProductDescription = p.ProductDescription,
|
||||||
|
CoverImageUrl = string.IsNullOrWhiteSpace(p.CoverImage)
|
||||||
|
? null
|
||||||
|
: FileStorage.GetPublicUrl(p.CoverImage),
|
||||||
DestRegions = destRegions,
|
DestRegions = destRegions,
|
||||||
CoverageCountries = coverageCountries.Take(PortalCoverageCountryLimit).ToList(),
|
CoverageCountries = coverageCountries.Take(PortalCoverageCountryLimit).ToList(),
|
||||||
CargoTags = cargoTags
|
CargoTags = cargoTags
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Fake.Application;
|
using Fake.Application;
|
||||||
|
using Fake.ObjectStorage;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Oms.Application.Dtos.Channels;
|
using Oms.Application.Dtos.Channels;
|
||||||
using Oms.Application.Dtos.Shared;
|
using Oms.Application.Dtos.Shared;
|
||||||
using Oms.Application.Services.Approval.Contracts;
|
using Oms.Application.Services.Approval.Contracts;
|
||||||
using Oms.Application.Shared;
|
using Oms.Application.Shared;
|
||||||
|
using Oms.Application.Storage;
|
||||||
using Oms.Domain.ApprovalAggregate.Consts;
|
using Oms.Domain.ApprovalAggregate.Consts;
|
||||||
using Oms.Domain.ApprovalAggregate.Enums;
|
using Oms.Domain.ApprovalAggregate.Enums;
|
||||||
using Oms.Domain.ApprovalAggregate.Repositories;
|
using Oms.Domain.ApprovalAggregate.Repositories;
|
||||||
@ -41,6 +44,21 @@ public partial class SalesProductService : ApplicationService
|
|||||||
private IApprovalDefinitionRepository ApprovalDefinitionRepository =>
|
private IApprovalDefinitionRepository ApprovalDefinitionRepository =>
|
||||||
LazyServiceProvider.GetRequiredService<IApprovalDefinitionRepository>();
|
LazyServiceProvider.GetRequiredService<IApprovalDefinitionRepository>();
|
||||||
|
|
||||||
|
private IObjectStorage FileStorage => LazyServiceProvider.GetRequiredService<IObjectStorage>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上传销售产品官网封面图,返回 object key 与可访问 URL(落库存 key)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">入参:封面图片文件(jpg/png/webp 等,≤5MB)。</param>
|
||||||
|
[HttpPost("/channel/sales-product/upload-cover")]
|
||||||
|
[Consumes("multipart/form-data")]
|
||||||
|
public async Task<object> UploadCoverImageAsync(IFormFile file)
|
||||||
|
{
|
||||||
|
var key = await OmsFileUploadHelper.SaveSalesProductCoverAsync(file, FileStorage);
|
||||||
|
var url = FileStorage.GetPublicUrl(key);
|
||||||
|
return new { key, url, fileUrl = key };
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询销售产品列表。
|
/// 查询销售产品列表。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -78,7 +96,11 @@ public partial class SalesProductService : ApplicationService
|
|||||||
var entity = await GetProductOrThrowAsync(id);
|
var entity = await GetProductOrThrowAsync(id);
|
||||||
var auditUserNameMap = await UserDisplayNameResolver.ResolveManyAsync(
|
var auditUserNameMap = await UserDisplayNameResolver.ResolveManyAsync(
|
||||||
[entity.CreateUserId, entity.UpdateUserId]);
|
[entity.CreateUserId, entity.UpdateUserId]);
|
||||||
return MapDetailOutput(entity, auditUserNameMap);
|
var detail = MapDetailOutput(entity, auditUserNameMap);
|
||||||
|
detail.CoverImageUrl = string.IsNullOrWhiteSpace(entity.CoverImage)
|
||||||
|
? null
|
||||||
|
: FileStorage.GetPublicUrl(entity.CoverImage);
|
||||||
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -32,6 +32,9 @@ public static class OmsFileUploadHelper
|
|||||||
public static Task<string> SaveBrandLogoAsync(IFormFile file, IObjectStorage storage) =>
|
public static Task<string> SaveBrandLogoAsync(IFormFile file, IObjectStorage storage) =>
|
||||||
SaveImageAsync(file, storage, "brand-logo", "品牌 Logo");
|
SaveImageAsync(file, storage, "brand-logo", "品牌 Logo");
|
||||||
|
|
||||||
|
public static Task<string> SaveSalesProductCoverAsync(IFormFile file, IObjectStorage storage) =>
|
||||||
|
SaveImageAsync(file, storage, "sales-product-cover", "销售产品封面图");
|
||||||
|
|
||||||
private static async Task<string> SaveImageAsync(
|
private static async Task<string> SaveImageAsync(
|
||||||
IFormFile? file,
|
IFormFile? file,
|
||||||
IObjectStorage storage,
|
IObjectStorage storage,
|
||||||
|
|||||||
@ -51,6 +51,11 @@ public class SalesProduct : OmsAuditedAggregateRoot
|
|||||||
|
|
||||||
public string? ProductDescription { get; set; }
|
public string? ProductDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 官网线路封面图 object key(如 uploads/sales-product-cover/...)。
|
||||||
|
/// </summary>
|
||||||
|
public string? CoverImage { get; set; }
|
||||||
|
|
||||||
public string? PreStorageScript { get; set; }
|
public string? PreStorageScript { get; set; }
|
||||||
|
|
||||||
public string? CustomerGuideMarkdown { get; set; }
|
public string? CustomerGuideMarkdown { get; set; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user