From f0d0659750332f56d71e79489814b8ea6d0c4e03 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Tue, 14 Jul 2026 20:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=85=E8=A3=B9=E6=98=8E=E7=BB=86=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20AttributeText=20=E5=B1=9E=E6=80=A7=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EOF Co-authored-by: Cursor --- db.sql | 1 + sql/C_parcel_item_AttributeText.sql | 20 +++++++++++++++++++ sql/README.md | 2 +- .../Dtos/Warehouse/WarehouseDtos.cs | 4 ++++ .../Warehouse/WarehouseService.Parcel.cs | 4 ++++ .../Entities/CParcelItem.cs | 3 +++ 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 sql/C_parcel_item_AttributeText.sql diff --git a/db.sql b/db.sql index b18ad53..56cbe57 100644 --- a/db.sql +++ b/db.sql @@ -1379,6 +1379,7 @@ CREATE TABLE `C_parcel_item` ( `Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键', `ParcelId` INT NOT NULL COMMENT '包裹ID → C_parcel.Id', `ProductName` VARCHAR(512) NULL COMMENT '商品名称', + `AttributeText` VARCHAR(256) NULL COMMENT '规格属性', `Quantity` INT NOT NULL DEFAULT 0 COMMENT '数量', `SkuId` INT NULL COMMENT '库内SKU ID → C_sku.Id', `SkuCode` VARCHAR(64) NULL COMMENT '冗余SKU编码', diff --git a/sql/C_parcel_item_AttributeText.sql b/sql/C_parcel_item_AttributeText.sql new file mode 100644 index 0000000..4eebf85 --- /dev/null +++ b/sql/C_parcel_item_AttributeText.sql @@ -0,0 +1,20 @@ +-- 已有库增量:包裹明细增加属性字段 AttributeText +-- 可重复执行 + +SET @col_exists := ( + SELECT COUNT(1) + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'C_parcel_item' + AND COLUMN_NAME = 'AttributeText' +); + +SET @sql := IF( + @col_exists = 0, + 'ALTER TABLE `C_parcel_item` ADD COLUMN `AttributeText` VARCHAR(256) NULL COMMENT ''规格属性'' AFTER `ProductName`', + 'SELECT ''C_parcel_item.AttributeText already exists'' AS info' +); + +PREPARE stmt FROM @sql; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; diff --git a/sql/README.md b/sql/README.md index 60067fe..66e3a46 100644 --- a/sql/README.md +++ b/sql/README.md @@ -3,5 +3,5 @@ OMS / 共用库的建表脚本已统一到仓库根目录 `db.sql`。 - 新环境:直接执行 `db.sql`(会 DROP 后重建,勿在有生产数据的库上执行) -- 已有库:用 diff 对比 `db.sql` 与现库结构后手工 ALTER;本目录下单个表脚本(如 `C_parcel_arrival.sql`)可直接在已有库执行增量建表 +- 已有库:用 diff 对比 `db.sql` 与现库结构后手工 ALTER;本目录下单个表脚本(如 `C_parcel_arrival.sql`、`C_parcel_item_AttributeText.sql`)可直接在已有库执行增量建表 - 数据权限表(`user_org_perm` 等)若 RBAC 与 OMS 分库,请只在 RBAC 库执行 `db.sql` 末尾对应段落 diff --git a/src/Oms.Application/Dtos/Warehouse/WarehouseDtos.cs b/src/Oms.Application/Dtos/Warehouse/WarehouseDtos.cs index 833f177..63e601a 100644 --- a/src/Oms.Application/Dtos/Warehouse/WarehouseDtos.cs +++ b/src/Oms.Application/Dtos/Warehouse/WarehouseDtos.cs @@ -325,6 +325,8 @@ public class WarehouseParcelItemSaveInput public string? ProductName { get; set; } + public string? AttributeText { get; set; } + public int Quantity { get; set; } public string? Remark { get; set; } @@ -336,6 +338,8 @@ public class WarehouseParcelItemOutput public string? ProductName { get; set; } + public string? AttributeText { get; set; } + public int Quantity { get; set; } public int? SkuId { get; set; } diff --git a/src/Oms.Application/Services/Warehouse/WarehouseService.Parcel.cs b/src/Oms.Application/Services/Warehouse/WarehouseService.Parcel.cs index c555c98..26f63f2 100644 --- a/src/Oms.Application/Services/Warehouse/WarehouseService.Parcel.cs +++ b/src/Oms.Application/Services/Warehouse/WarehouseService.Parcel.cs @@ -128,6 +128,9 @@ public partial class WarehouseService { ParcelId = parcel.Id, ProductName = string.IsNullOrWhiteSpace(itemInput.ProductName) ? null : itemInput.ProductName.Trim(), + AttributeText = string.IsNullOrWhiteSpace(itemInput.AttributeText) + ? null + : itemInput.AttributeText.Trim(), Quantity = itemInput.Quantity, Remark = string.IsNullOrWhiteSpace(itemInput.Remark) ? null : itemInput.Remark.Trim() }; @@ -247,6 +250,7 @@ public partial class WarehouseService { Id = item.Id, ProductName = item.ProductName, + AttributeText = item.AttributeText, Quantity = item.Quantity, SkuId = item.SkuId, SkuCode = item.SkuCode, diff --git a/src/Oms.Domain/WarehouseAggregate/Entities/CParcelItem.cs b/src/Oms.Domain/WarehouseAggregate/Entities/CParcelItem.cs index 98b7484..98d8ab1 100644 --- a/src/Oms.Domain/WarehouseAggregate/Entities/CParcelItem.cs +++ b/src/Oms.Domain/WarehouseAggregate/Entities/CParcelItem.cs @@ -10,6 +10,9 @@ public class CParcelItem : OmsAuditedAggregateRoot public string? ProductName { get; set; } + /// 规格属性。 + public string? AttributeText { get; set; } + public int Quantity { get; set; } public int? SkuId { get; set; }