Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4fcc0bf7a9
325
db.sql
325
db.sql
@ -29,6 +29,15 @@ DROP TABLE IF EXISTS `role_data_scope`;
|
||||
DROP TABLE IF EXISTS `role_org_perm`;
|
||||
DROP TABLE IF EXISTS `user_org_perm`;
|
||||
DROP TABLE IF EXISTS `t_xhs_media`;
|
||||
DROP TABLE IF EXISTS `t_kb_article`;
|
||||
DROP TABLE IF EXISTS `t_kb_category`;
|
||||
DROP TABLE IF EXISTS `t_mcp_tool`;
|
||||
DROP TABLE IF EXISTS `t_pickup_order_line`;
|
||||
DROP TABLE IF EXISTS `t_pickup_order`;
|
||||
DROP TABLE IF EXISTS `t_9610_order_item`;
|
||||
DROP TABLE IF EXISTS `t_9610_order`;
|
||||
DROP TABLE IF EXISTS `t_ai_skill`;
|
||||
DROP TABLE IF EXISTS `t_ai_provider`;
|
||||
DROP TABLE IF EXISTS `t_xhs_ai_provider`;
|
||||
DROP TABLE IF EXISTS `t_xhs_human_config`;
|
||||
DROP TABLE IF EXISTS `t_xhs_skill`;
|
||||
@ -117,6 +126,9 @@ CREATE TABLE `t_order` (
|
||||
`ExportCustomsMode` VARCHAR(32) NULL COMMENT '出口报关方式',
|
||||
`PredeclareFailReason` VARCHAR(512) NULL COMMENT '预报失败原因',
|
||||
`AllocationPendingReason` VARCHAR(512) NULL COMMENT '待排货原因(排货或渠道买价未匹配)',
|
||||
`AllocationScheme` VARCHAR(32) NULL COMMENT '最近一次排货方案 costLowest/timeFastest/overallBest/designated',
|
||||
`AllocationTraceJson` JSON NULL COMMENT '最近一次排货过程快照 JSON',
|
||||
`AllocationTraceTime` DATETIME NULL COMMENT '排货快照写入时间',
|
||||
`SalesProductRulesVersion` VARCHAR(64) NULL COMMENT '销售产品规则快照版本',
|
||||
`SalesProductPriceVersion` VARCHAR(64) NULL COMMENT '销售产品价格快照版本',
|
||||
`OrderStatus` VARCHAR(32) NOT NULL COMMENT '订单状态',
|
||||
@ -135,9 +147,20 @@ CREATE TABLE `t_order` (
|
||||
`PreviousOrderStatus` VARCHAR(32) NULL COMMENT '进入异常状态前的订单状态',
|
||||
`WarehouseId` INT NULL COMMENT '仓库ID',
|
||||
`CustomerId` INT NULL COMMENT '客户ID',
|
||||
`MemberLevelId` INT NULL COMMENT '下单时会员等级Id快照',
|
||||
`PriceTierKey` VARCHAR(64) NULL COMMENT '下单时价区键快照',
|
||||
`ReceivableSubtotal` DECIMAL(18,4) NULL COMMENT '应收小计(折扣前)',
|
||||
`ForecastReceivableAmount` DECIMAL(18,4) NULL COMMENT '预报应收快照(创建预报后固化,入库不覆盖)',
|
||||
`ForecastPayableAmount` DECIMAL(18,4) NULL COMMENT '预报应付快照(创建预报后固化,入库不覆盖)',
|
||||
`LevelDiscountAmount` DECIMAL(18,4) NOT NULL DEFAULT 0 COMMENT '会员等级折扣金额',
|
||||
`CouponInstanceId` INT NULL COMMENT '使用的优惠券实例Id',
|
||||
`CouponDiscountAmount` DECIMAL(18,4) NOT NULL DEFAULT 0 COMMENT '优惠券抵扣金额',
|
||||
`PayableAmount` DECIMAL(18,4) NULL COMMENT '应付金额(对客应收)',
|
||||
`OrderSource` VARCHAR(32) NULL COMMENT '订单来源:manual/pickup/upload/batch/platform',
|
||||
`PickupTime` DATETIME NULL COMMENT '预约揽收时间',
|
||||
`CustomerSenderAddressId` INT NULL COMMENT '发件地址簿 Id',
|
||||
`InboundMethod` VARCHAR(16) NULL COMMENT '到仓方式 selfShip/doorPickup',
|
||||
`PickupOrderId` INT NULL COMMENT '关联揽收单Id(冗余)',
|
||||
`OrganizationId` CHAR(36) NULL COMMENT '数据归属组织',
|
||||
`SecretLevel` TINYINT NOT NULL DEFAULT 2 COMMENT '数据密级 1-4',
|
||||
`SenderId` INT NULL COMMENT '发件人ID',
|
||||
@ -156,6 +179,9 @@ CREATE TABLE `t_order` (
|
||||
`Quantity` INT NULL COMMENT '包裹数量',
|
||||
`IsIntercept` TINYINT NOT NULL DEFAULT 0 COMMENT '是否拦截:0-否,1-是',
|
||||
`IsRemote` TINYINT NOT NULL DEFAULT 0 COMMENT '是否偏远:0-否,1-是',
|
||||
`AdditionalServices` VARCHAR(512) NULL COMMENT '客户勾选附加服务字典code JSON数组',
|
||||
`FulfillmentType` VARCHAR(16) NULL DEFAULT 'direct' COMMENT '履约类型 direct/warehouse',
|
||||
`FulfillmentSource` VARCHAR(32) NULL COMMENT '代发来源 storeFulfill/postBind',
|
||||
`LabelTemplateId` INT NULL COMMENT '出单标签模板Id',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
@ -175,9 +201,14 @@ CREATE TABLE `t_order` (
|
||||
KEY `idx_ord_recipient` (`RecipientId`),
|
||||
KEY `idx_ord_declaration` (`DeclarationId`),
|
||||
KEY `idx_ord_org_secret_ctime` (`OrganizationId`, `SecretLevel`, `CreateTime`),
|
||||
KEY `idx_ord_source_ctime` (`OrderSource`, `CreateTime`)
|
||||
KEY `idx_ord_source_ctime` (`OrderSource`, `CreateTime`),
|
||||
KEY `idx_order_pickup` (`PickupOrderId`),
|
||||
KEY `idx_order_inbound_method` (`InboundMethod`),
|
||||
KEY `idx_ord_fulfillment_customer` (`FulfillmentType`, `CustomerId`, `OrderStatus`)
|
||||
) COMMENT='订单表';
|
||||
|
||||
-- 存量库升级脚本见:sql/migrate_t_order_fulfillment_type.sql(勿复制带 ... 的示例)
|
||||
|
||||
CREATE TABLE `t_order_file` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
|
||||
`OrderId` INT NOT NULL COMMENT '订单Id',
|
||||
@ -452,12 +483,16 @@ CREATE TABLE `t_order_exception_event` (
|
||||
`Content` TEXT NULL COMMENT '内容快照',
|
||||
`IssueTemplateId` INT NULL COMMENT '模板Id',
|
||||
`NotifyMethod` VARCHAR(64) NULL COMMENT '通知方式快照',
|
||||
`HandlerNames` VARCHAR(256) NULL COMMENT '处理人快照',
|
||||
`HandlerType` VARCHAR(16) NULL COMMENT '处理人类型',
|
||||
`HandlerUserId` INT NULL COMMENT '处理人用户Id(customer 时为订单客户账号)',
|
||||
`ClaimType` VARCHAR(32) NULL COMMENT '理赔类型',
|
||||
`ClaimAmount` DECIMAL(18,4) NULL COMMENT '索赔金额',
|
||||
`ClaimCurrency` VARCHAR(16) NULL COMMENT '索赔币种',
|
||||
`ClaimReason` VARCHAR(512) NULL COMMENT '理赔原因',
|
||||
`Remark` VARCHAR(512) NULL COMMENT '操作备注',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '操作人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
@ -473,6 +508,9 @@ CREATE TABLE `t_sales_product` (
|
||||
`ProductGroup` VARCHAR(32) NULL COMMENT '分组(专线/快递/邮政)',
|
||||
`MinTimeliness` INT NULL COMMENT '最小时效(天)',
|
||||
`MaxTimeliness` INT NULL COMMENT '最大时效(天)',
|
||||
`TradeTerms` VARCHAR(16) NULL COMMENT '贸易条款:DDP/DDU',
|
||||
`RouteSort` INT NOT NULL DEFAULT 0 COMMENT '官网线路排序,越小越靠前',
|
||||
`AdditionalServices` VARCHAR(512) NULL COMMENT '可选附加服务字典code JSON数组',
|
||||
`CustomerWaybill` VARCHAR(32) NULL COMMENT '系统面单/客户面单',
|
||||
`BlacklistAreaId` INT NULL COMMENT '黑名单区ID',
|
||||
`RemoteAreaId` INT NULL COMMENT '偏远分区ID',
|
||||
@ -493,6 +531,7 @@ CREATE TABLE `t_sales_product` (
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_sp_code` (`ProductCode`),
|
||||
KEY `idx_sp_group_active` (`ProductGroup`, `IsActive`),
|
||||
KEY `idx_sp_route_sort` (`RouteSort`, `IsActive`),
|
||||
KEY `idx_sp_scheme` (`Scheme`),
|
||||
KEY `idx_sp_weight_rule` (`WeightRuleId`),
|
||||
KEY `idx_sp_weight_rounding` (`WeightRoundingId`)
|
||||
@ -576,6 +615,7 @@ CREATE TABLE `t_sales_product_publish_record` (
|
||||
`PublishUser` VARCHAR(64) NOT NULL COMMENT '发布人',
|
||||
`PublishTime` DATETIME NOT NULL COMMENT '发布时间',
|
||||
`Description` VARCHAR(512) NULL COMMENT '版本备注',
|
||||
`AiAnalysisReport` MEDIUMTEXT NULL COMMENT '价格发布AI风险分析报告',
|
||||
`Content` JSON NULL COMMENT '发布内容JSON快照',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
@ -613,6 +653,7 @@ CREATE TABLE `t_service_channel` (
|
||||
`ForecastType` VARCHAR(32) NULL COMMENT '预报单号类型(customer/waybill/tracking)',
|
||||
`ForecastCode` VARCHAR(128) NULL COMMENT '预报单号',
|
||||
`Description` TEXT COMMENT '描述',
|
||||
`RemoteAreaId` INT NULL COMMENT '偏远分区KPI AreaId',
|
||||
`PreScript` TEXT COMMENT '入库前脚本',
|
||||
`IsActive` TINYINT NOT NULL DEFAULT 2 COMMENT 'EnableStatus:0=None未设置,1=Disabled禁用,2=Enabled启用',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
@ -823,6 +864,8 @@ CREATE TABLE `t_issue_template` (
|
||||
`Title` VARCHAR(128) NOT NULL COMMENT '问题标题',
|
||||
`Content` TEXT NOT NULL COMMENT '问题内容',
|
||||
`NotifyMethod` VARCHAR(64) NOT NULL COMMENT '通知方式,逗号分隔',
|
||||
`HandlerType` VARCHAR(16) NULL COMMENT '处理人类型:customer=订单所属客户 user=指定用户',
|
||||
`HandlerUserId` INT NULL COMMENT '指定处理人用户Id(HandlerType=user 时必填)',
|
||||
`Status` TINYINT NOT NULL DEFAULT 2 COMMENT 'EnableStatus:0=None未设置,1=Disabled禁用,2=Enabled启用',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
@ -932,6 +975,8 @@ CREATE TABLE `t_customer` (
|
||||
`WechatNickname` VARCHAR(64) NULL COMMENT '微信昵称',
|
||||
`Email` VARCHAR(64) NULL COMMENT '邮箱,用于登录/找回密码',
|
||||
`Phone` VARCHAR(16) NULL COMMENT '手机号,用于联系;可空,唯一(NULL 可多条)',
|
||||
`MemberLevelId` INT NULL COMMENT '会员等级Id',
|
||||
`PriceTierKey` VARCHAR(64) NULL COMMENT '价区键(卖价 CustomerGroupValues JSON 键)',
|
||||
`Balance` DECIMAL(18,2) NOT NULL DEFAULT 0.00 COMMENT '账户余额',
|
||||
`TotalQuota` DECIMAL(18,2) NOT NULL DEFAULT 0.00 COMMENT '总额度',
|
||||
`UsedQuota` DECIMAL(18,2) NOT NULL DEFAULT 0.00 COMMENT '已用额度',
|
||||
@ -1300,7 +1345,11 @@ CREATE TABLE `c_sku` (
|
||||
`CustomerId` INT NOT NULL COMMENT '客户ID → t_customer.Id',
|
||||
`SkuCode` VARCHAR(64) NOT NULL COMMENT '库内SKU编码',
|
||||
`SkuName` VARCHAR(256) NOT NULL COMMENT 'SKU名称',
|
||||
`SkuNameEn` VARCHAR(256) NULL COMMENT 'SKU英文名称',
|
||||
`SkuImageUrl` VARCHAR(512) NULL COMMENT '图片URL',
|
||||
`UnitPrice` DECIMAL(12,4) NULL COMMENT '单价',
|
||||
`ExHsCode` VARCHAR(64) NULL COMMENT '出口HSCode',
|
||||
`ImHsCode` VARCHAR(64) NULL COMMENT '进口HSCode',
|
||||
`WeightG` DECIMAL(10,2) NULL COMMENT '重量(g)',
|
||||
`LengthCm` DECIMAL(10,2) NULL COMMENT '长(cm)',
|
||||
`WidthCm` DECIMAL(10,2) NULL COMMENT '宽(cm)',
|
||||
@ -1733,7 +1782,7 @@ CREATE TABLE `t_xhs_human_config` (
|
||||
UNIQUE KEY `uk_xhs_human_customer` (`CustomerId`)
|
||||
) COMMENT='小红书拟人行为与防封配置表';
|
||||
|
||||
CREATE TABLE `t_xhs_ai_provider` (
|
||||
CREATE TABLE `t_ai_provider` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`CustomerId` INT NOT NULL COMMENT '客户ID;0 表示全局',
|
||||
`ProviderKey` VARCHAR(32) NOT NULL COMMENT 'ai_chatgpt / ai_zhipu 等',
|
||||
@ -1751,9 +1800,266 @@ CREATE TABLE `t_xhs_ai_provider` (
|
||||
`UpdateUserId` INT NULL,
|
||||
`UpdateTime` DATETIME NULL,
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_xhs_ai_provider` (`CustomerId`, `ProviderKey`),
|
||||
KEY `idx_xhs_ai_customer` (`CustomerId`, `Enabled`)
|
||||
) COMMENT='小红书 AI 提供商配置表';
|
||||
UNIQUE KEY `uk_ai_provider` (`CustomerId`, `ProviderKey`),
|
||||
KEY `idx_ai_customer` (`CustomerId`, `Enabled`)
|
||||
) COMMENT='全局 AI 提供商配置表(CustomerId=0 表示平台级)';
|
||||
|
||||
CREATE TABLE `t_ai_skill` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`SkillKey` VARCHAR(64) NOT NULL COMMENT '稳定键',
|
||||
`Scene` VARCHAR(32) NOT NULL COMMENT '场景 pricePublish/autoTriggerFormula/receiverAddressParse/itfxPrefixScript',
|
||||
`Name` VARCHAR(128) NOT NULL COMMENT '展示名',
|
||||
`Description` VARCHAR(512) NULL COMMENT '简介',
|
||||
`Content` LONGTEXT NOT NULL COMMENT '发给模型的正文',
|
||||
`SortOrder` INT NOT NULL DEFAULT 0 COMMENT '排序',
|
||||
`Enabled` TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用:0-否,1-是',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_ai_skill_key` (`SkillKey`),
|
||||
KEY `idx_ai_skill_scene` (`Scene`, `Enabled`, `SortOrder`)
|
||||
) COMMENT='平台级 AI Skill(提示词/规范)';
|
||||
|
||||
CREATE TABLE `t_mcp_tool` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
|
||||
`ToolKey` VARCHAR(64) NOT NULL COMMENT '工具编码,如 oms.price_check',
|
||||
`DisplayName` VARCHAR(128) NOT NULL COMMENT '显示名称',
|
||||
`Description` VARCHAR(1000) NOT NULL COMMENT '给 AI 的工具描述',
|
||||
`Enabled` TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用:0-否,1-是',
|
||||
`SortOrder` INT NOT NULL DEFAULT 0 COMMENT '排序,越小越靠前',
|
||||
`Remark` VARCHAR(512) NULL COMMENT '备注',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_mcp_tool_key` (`ToolKey`),
|
||||
KEY `idx_mcp_tool_enabled` (`Enabled`, `SortOrder`, `Id`)
|
||||
) COMMENT='MCP 工具配置表';
|
||||
|
||||
CREATE TABLE `t_pickup_order` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
|
||||
`PickupNo` VARCHAR(32) NOT NULL COMMENT '揽收单号',
|
||||
`RequestId` VARCHAR(64) NULL COMMENT '请求幂等ID',
|
||||
`CustomerId` INT NOT NULL COMMENT '客户Id',
|
||||
`OrganizationId` CHAR(36) NULL COMMENT '数据归属组织',
|
||||
`SecretLevel` TINYINT NOT NULL DEFAULT 2 COMMENT '数据密级 1-4',
|
||||
`SenderAddressId` INT NOT NULL COMMENT '发件地址簿Id',
|
||||
`SenderName` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '取件联系人快照',
|
||||
`SenderCompany` VARCHAR(255) NULL COMMENT '公司快照',
|
||||
`SenderCountry` INT NULL COMMENT '国家 t_country.Id 快照',
|
||||
`SenderCountryCode` VARCHAR(8) NULL COMMENT '国家码快照',
|
||||
`SenderProvince` VARCHAR(50) NULL COMMENT '省快照',
|
||||
`SenderCity` VARCHAR(50) NULL COMMENT '市快照',
|
||||
`SenderZipCode` VARCHAR(50) NULL COMMENT '邮编快照',
|
||||
`SenderStreetAddress1` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '地址1快照',
|
||||
`SenderStreetAddress2` VARCHAR(500) NULL COMMENT '地址2快照',
|
||||
`SenderStreetAddress3` VARCHAR(500) NULL COMMENT '地址3快照',
|
||||
`SenderHouseNumber` VARCHAR(50) NULL COMMENT '门牌号快照',
|
||||
`SenderPhone` VARCHAR(50) NULL COMMENT '手机快照',
|
||||
`SenderTelePhone` VARCHAR(50) NULL COMMENT '电话快照',
|
||||
`SenderEmail` VARCHAR(60) NULL COMMENT '邮箱快照',
|
||||
`WarehouseId` INT NOT NULL COMMENT '送到仓库Id',
|
||||
`CarrierCode` VARCHAR(64) NULL COMMENT '承运商编码(draft可空)',
|
||||
`CarrierService` VARCHAR(64) NULL COMMENT '承运服务(draft可空)',
|
||||
`CarrierWaybillNo` VARCHAR(64) NULL COMMENT '承运商回执单号',
|
||||
`ExpectPickupTime` DATETIME NOT NULL COMMENT '期望揽收时间',
|
||||
`PickupWindowStart` DATETIME NULL COMMENT '时间窗起',
|
||||
`PickupWindowEnd` DATETIME NULL COMMENT '时间窗止',
|
||||
`ActualPickupTime` DATETIME NULL COMMENT '实际取件时间',
|
||||
`Status` VARCHAR(32) NOT NULL DEFAULT 'draft' COMMENT 'draft/scheduled/dispatched/picked/inbound/cancelled/failed',
|
||||
`ParcelCount` INT NOT NULL DEFAULT 0 COMMENT '关联票数',
|
||||
`TotalActualWeight` DECIMAL(18,3) NULL COMMENT '汇总实重',
|
||||
`ChargeableWeight` DECIMAL(18,3) NULL COMMENT '计费重',
|
||||
`Currency` VARCHAR(8) NOT NULL DEFAULT 'CNY' COMMENT '币种',
|
||||
`FreightAmount` DECIMAL(18,2) NULL COMMENT '对客揽收运费',
|
||||
`OtherFeeAmount` DECIMAL(18,2) NULL COMMENT '对客其他费',
|
||||
`ReceivableAmount` DECIMAL(18,2) NULL COMMENT '对客应收合计',
|
||||
`PayStatus` VARCHAR(16) NOT NULL DEFAULT 'unpaid' COMMENT 'unpaid/paid',
|
||||
`PayTime` DATETIME NULL COMMENT '支付时间',
|
||||
`PayMode` VARCHAR(16) NOT NULL DEFAULT 'prepaid' COMMENT 'prepaid/collect',
|
||||
`CarrierPayableAmount` DECIMAL(18,2) NULL COMMENT '应付承运商',
|
||||
`SettlementStatus` VARCHAR(16) NOT NULL DEFAULT 'none' COMMENT 'none/pending/settled',
|
||||
`SettlementBatchNo` VARCHAR(64) NULL COMMENT '结算批次号',
|
||||
`SettledAt` DATETIME NULL COMMENT '结算时间',
|
||||
`Remark` VARCHAR(512) NULL COMMENT '备注',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_pickup_no` (`PickupNo`),
|
||||
UNIQUE KEY `uk_pickup_request_id` (`RequestId`),
|
||||
KEY `idx_pickup_customer_status` (`CustomerId`, `Status`, `CreateTime`),
|
||||
KEY `idx_pickup_warehouse_time` (`WarehouseId`, `ExpectPickupTime`),
|
||||
KEY `idx_pickup_pay` (`PayStatus`),
|
||||
KEY `idx_pickup_settle` (`SettlementStatus`),
|
||||
KEY `idx_pickup_org_secret_ctime` (`OrganizationId`, `SecretLevel`, `CreateTime`)
|
||||
) COMMENT='揽收单(上门取件履约+对客收款+承运结算)';
|
||||
|
||||
CREATE TABLE `t_pickup_order_line` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
|
||||
`PickupOrderId` INT NOT NULL COMMENT '揽收单Id',
|
||||
`OrderId` INT NOT NULL COMMENT '物流订单Id',
|
||||
`ServiceNo` VARCHAR(64) NULL COMMENT '运单号快照(便于列表)',
|
||||
`ClientNo` VARCHAR(64) NULL COMMENT '客户单号快照',
|
||||
`SortNo` INT NOT NULL DEFAULT 0 COMMENT '展示序',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_pickup_line_order` (`OrderId`),
|
||||
UNIQUE KEY `uk_pickup_line_pair` (`PickupOrderId`, `OrderId`),
|
||||
KEY `idx_pickup_line_header` (`PickupOrderId`, `IsDeleted`)
|
||||
) COMMENT='揽收单关联物流订单(1揽收:N物流)';
|
||||
|
||||
CREATE TABLE `t_9610_order` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`OrderId` INT NOT NULL COMMENT '关联运单 t_order.Id',
|
||||
`ServiceNo` VARCHAR(64) NULL COMMENT '运单号冗余',
|
||||
`CustomerId` INT NOT NULL DEFAULT 0 COMMENT '客户Id',
|
||||
`Status` VARCHAR(16) NOT NULL DEFAULT 'pending' COMMENT 'pending待申报 / declared已申报',
|
||||
`PlatformCode` VARCHAR(16) NOT NULL DEFAULT '' COMMENT '电商平台',
|
||||
`EcomCorpCode` VARCHAR(18) NULL COMMENT '电商企业代码',
|
||||
`EcomCorpName` VARCHAR(100) NULL COMMENT '电商企业名称',
|
||||
`ProducerCode` VARCHAR(18) NULL COMMENT '生产销售单位代码',
|
||||
`ProducerName` VARCHAR(100) NULL COMMENT '生产销售单位',
|
||||
`ClientNo` VARCHAR(48) NOT NULL DEFAULT '' COMMENT '客户单号(对齐 t_order.ClientNo)',
|
||||
`BusinessType` CHAR(1) NOT NULL DEFAULT 'B' COMMENT '业务类型 A简化/B汇总',
|
||||
`Region` VARCHAR(10) NULL COMMENT '区域 SZ/other',
|
||||
`AgentDeclare` VARCHAR(2) NULL COMMENT '是否代理申报 是/否',
|
||||
`ActualSellerCode` VARCHAR(18) NULL COMMENT '实际卖家信用代码',
|
||||
`PreRecordFlag` CHAR(1) NULL COMMENT '汇总预录 0已预录 1未预录',
|
||||
`IsSummarySimple` TINYINT NOT NULL DEFAULT 0 COMMENT '是否汇总简化申报',
|
||||
`GrossWeight` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT '毛重KG',
|
||||
`Currency` VARCHAR(4) NOT NULL DEFAULT 'CNY' COMMENT '币制',
|
||||
`DestCountry` VARCHAR(4) NOT NULL DEFAULT '' COMMENT '目的国',
|
||||
`Freight` DECIMAL(19,5) NULL COMMENT '运费',
|
||||
`FreightCurrency` VARCHAR(4) NULL COMMENT '运费币制',
|
||||
`FreightMark` INT NULL COMMENT '运费标志 1率2单价3总价',
|
||||
`PackageType` INT NULL COMMENT '包装种类代码',
|
||||
`PackageQty` INT NULL COMMENT '件数',
|
||||
`ShipmentNo` VARCHAR(32) NULL COMMENT '出货单号',
|
||||
`CustomsOrderNo` VARCHAR(32) NULL COMMENT '海关订单号(申报回写)',
|
||||
`DownstreamRefNo` VARCHAR(32) NULL COMMENT '申报回写的 referenceNo 快照',
|
||||
`EnterpriseBizNo` VARCHAR(48) NULL COMMENT '企业唯一编号(上游 copNo)',
|
||||
`ManifestNo` VARCHAR(48) NULL COMMENT '清单编号(上游 invtNo)',
|
||||
`ClearanceTime` VARCHAR(48) NULL COMMENT '结关日期原文',
|
||||
`CustomsInboundTime` VARCHAR(48) NULL COMMENT '海关入库时间原文',
|
||||
`CustomsState` VARCHAR(4) NULL COMMENT '海关状态',
|
||||
`DeclareCustomsCode` VARCHAR(4) NULL COMMENT '申报地海关代码',
|
||||
`PlatformCorpCode` VARCHAR(18) NULL COMMENT '电商平台代码',
|
||||
`PlatformName` VARCHAR(100) NULL COMMENT '电商平台名称',
|
||||
`LogisticsCorpCode` VARCHAR(18) NULL COMMENT '物流企业代码',
|
||||
`LogisticsCorpName` VARCHAR(100) NULL COMMENT '物流企业名称',
|
||||
`IeMark` VARCHAR(4) NULL COMMENT '进出口标记 I/E',
|
||||
`ExportPortCode` VARCHAR(4) NULL COMMENT '出口口岸代码',
|
||||
`ExportDate` VARCHAR(32) NULL COMMENT '出口日期原文',
|
||||
`DeclareAgentCode` VARCHAR(18) NULL COMMENT '申报企业代码',
|
||||
`DeclareAgentName` VARCHAR(100) NULL COMMENT '申报企业名称',
|
||||
`TradeModeCode` VARCHAR(4) NULL COMMENT '贸易方式代码',
|
||||
`TransportMode` VARCHAR(4) NULL COMMENT '运输方式代码',
|
||||
`DeclareTime` DATETIME NULL COMMENT '申报成功时间',
|
||||
`ManifestSyncTime` DATETIME NULL COMMENT '清单数据最近同步时间',
|
||||
`FailReason` VARCHAR(512) NULL COMMENT '最近失败原因',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_9610_order_id` (`OrderId`),
|
||||
KEY `idx_9610_status_ctime` (`Status`, `CreateTime`),
|
||||
KEY `idx_9610_service_no` (`ServiceNo`),
|
||||
KEY `idx_9610_client_no` (`ClientNo`),
|
||||
KEY `idx_9610_customer` (`CustomerId`, `CreateTime`),
|
||||
KEY `idx_9610_manifest` (`ManifestNo`)
|
||||
) COMMENT='9610汇总申报单';
|
||||
|
||||
CREATE TABLE `t_9610_order_item` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`Customs9610OrderId` INT NOT NULL COMMENT 't_9610_order.Id',
|
||||
`OrderDeclarationId` INT NULL COMMENT '溯源 t_order_declaration.Id',
|
||||
`Sku` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'SKU(对齐 t_order_declaration.Sku)',
|
||||
`CnName` VARCHAR(250) NOT NULL DEFAULT '' COMMENT '中文品名(对齐 t_order_declaration.CnName)',
|
||||
`ExHsCode` VARCHAR(10) NULL COMMENT '出口海关编码(对齐 t_order_declaration.ExHsCode)',
|
||||
`DeclareElement` VARCHAR(255) NULL COMMENT '申报要素',
|
||||
`Barcode` VARCHAR(255) NULL COMMENT '条形码',
|
||||
`DestCountry` VARCHAR(255) NULL COMMENT '目的国(地区)代码',
|
||||
`ItemCurrency` VARCHAR(3) NULL COMMENT '币制',
|
||||
`UnitPrice` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT '单价(对齐 t_order_declaration.UnitPrice)',
|
||||
`Amount` DECIMAL(19,5) NULL COMMENT '总价(对齐 t_order_declaration.Amount)',
|
||||
`Quantity` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT '数量(对齐 t_order_declaration.Quantity)',
|
||||
`LegalQty` DECIMAL(19,5) NULL COMMENT '法定数量',
|
||||
`Unit` VARCHAR(3) NULL COMMENT '计量单位(对齐 t_order_declaration.Unit)',
|
||||
`LegalUnit` VARCHAR(3) NULL COMMENT '法定计量单位',
|
||||
`Freight` DECIMAL(12,4) NULL COMMENT '行运费',
|
||||
`SortNo` INT NOT NULL DEFAULT 0 COMMENT '排序',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `idx_9610_item_header` (`Customs9610OrderId`, `IsDeleted`)
|
||||
) COMMENT='9610申报商品明细';
|
||||
|
||||
CREATE TABLE `t_kb_category` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`Code` VARCHAR(64) NOT NULL COMMENT '稳定键,如 pricing',
|
||||
`Name` VARCHAR(128) NOT NULL COMMENT '展示名(中文)',
|
||||
`SortOrder` INT NOT NULL DEFAULT 0 COMMENT '排序,越小越前',
|
||||
`Enabled` TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用:0-否,1-是',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_kb_category_code` (`Code`),
|
||||
KEY `idx_kb_category_enabled_sort` (`Enabled`, `SortOrder`)
|
||||
) COMMENT='知识库分类';
|
||||
|
||||
CREATE TABLE `t_kb_article` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`CategoryId` INT NOT NULL COMMENT '分类 Id',
|
||||
`Title` VARCHAR(200) NOT NULL COMMENT '标题(中文)',
|
||||
`Summary` VARCHAR(500) NULL COMMENT '列表摘要',
|
||||
`Content` LONGTEXT NOT NULL COMMENT 'Markdown 正文(中文)',
|
||||
`Audience` VARCHAR(16) NOT NULL DEFAULT 'customer' COMMENT '受众 customer/internal',
|
||||
`Status` VARCHAR(16) NOT NULL DEFAULT 'draft' COMMENT 'draft/published/offline',
|
||||
`Tags` VARCHAR(256) NULL COMMENT '逗号分隔标签',
|
||||
`RelatedPath` VARCHAR(256) NULL COMMENT '站内关联 path',
|
||||
`RelatedLabel` VARCHAR(64) NULL COMMENT '关联按钮文案',
|
||||
`IsPinned` TINYINT NOT NULL DEFAULT 0 COMMENT '置顶:0-否,1-是',
|
||||
`SortOrder` INT NOT NULL DEFAULT 0 COMMENT '同类排序',
|
||||
`PublishTime` DATETIME NULL COMMENT '发布时间',
|
||||
`ExpireTime` DATETIME NULL COMMENT '过期时间',
|
||||
`ViewCount` INT NOT NULL DEFAULT 0 COMMENT '浏览次数',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `idx_kb_article_list` (`Status`, `Audience`, `CategoryId`, `IsPinned`, `SortOrder`),
|
||||
KEY `idx_kb_article_publish` (`Status`, `Audience`, `PublishTime`),
|
||||
KEY `idx_kb_article_hot` (`Status`, `Audience`, `IsPinned`, `ViewCount`)
|
||||
) COMMENT='知识库文章';
|
||||
|
||||
CREATE TABLE `t_xhs_media` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
@ -2050,4 +2356,13 @@ CREATE TABLE `data_perm_access_log` (
|
||||
KEY `idx_perm_access_resource` (`DataResourceCode`, `CreateTime`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据权限访问审计(可采样)';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 增量迁移(已有库执行;全新安装可忽略)
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- ALTER TABLE `c_sku`
|
||||
-- ADD COLUMN `SkuNameEn` VARCHAR(256) NULL COMMENT 'SKU英文名称' AFTER `SkuName`,
|
||||
-- ADD COLUMN `UnitPrice` DECIMAL(12,4) NULL COMMENT '单价' AFTER `SkuImageUrl`,
|
||||
-- ADD COLUMN `ExHsCode` VARCHAR(64) NULL COMMENT '出口HSCode' AFTER `UnitPrice`,
|
||||
-- ADD COLUMN `ImHsCode` VARCHAR(64) NULL COMMENT '进口HSCode' AFTER `ExHsCode`;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
-- 微信注册简化:客户手机号改为可空(空值请用 NULL,勿存空字符串)
|
||||
-- 执行环境:生产库先备份;与 docs/微信注册简化与联系方式补全方案.md 一致
|
||||
|
||||
ALTER TABLE `t_customer`
|
||||
MODIFY COLUMN `Phone` VARCHAR(16) NULL COMMENT '手机号,用于联系;可空,唯一(NULL 可多条)';
|
||||
@ -1,6 +0,0 @@
|
||||
-- 自动触发时机:预报 并入 下单
|
||||
UPDATE t_auto_trigger
|
||||
SET TriggerTiming = N'下单'
|
||||
WHERE TriggerTiming IN (N'预报', N'forecast', N'order_create', N'OrderCreate')
|
||||
OR TriggerTiming LIKE N'%预报%'
|
||||
OR LOWER(TriggerTiming) LIKE N'%forecast%';
|
||||
@ -1,5 +0,0 @@
|
||||
-- Add DownstreamServiceNo to t_order (provider service no from createOrderOne Data.serviceNo)
|
||||
-- Backup production DB before running.
|
||||
|
||||
ALTER TABLE `t_order`
|
||||
ADD COLUMN `DownstreamServiceNo` VARCHAR(64) NULL COMMENT 'Downstream provider service no' AFTER `TrackNo`;
|
||||
@ -1,50 +0,0 @@
|
||||
-- 订单附件表;将原 LabelUrl 迁移为 systemLabel 后删除订单旧面单字段。
|
||||
-- 在 MySQL 执行前请先备份。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `t_order_file` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
|
||||
`OrderId` INT NOT NULL COMMENT '订单Id',
|
||||
`FileType` VARCHAR(32) NOT NULL COMMENT '附件类型:tradeProof交易证明/systemLabel系统面单/downstreamLabel下游面单/lastMileLabel末端面单/infraredImage红外图片',
|
||||
`FileName` VARCHAR(255) NULL COMMENT '原始文件名',
|
||||
`FileUrl` VARCHAR(512) NOT NULL COMMENT '文件地址(相对路径或外链)',
|
||||
`ContentType` VARCHAR(128) NULL COMMENT '文件MIME类型',
|
||||
`FileSize` BIGINT NULL COMMENT '文件大小(字节)',
|
||||
`Sort` INT NOT NULL DEFAULT 0 COMMENT '同类型内排序',
|
||||
`Source` VARCHAR(32) NOT NULL DEFAULT 'upload' COMMENT '来源:upload上传/systemGenerate系统生成/downstream下游回传/migrate迁移',
|
||||
`Remark` VARCHAR(512) NULL COMMENT '备注',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `idx_ord_file_order_type` (`OrderId`, `FileType`, `IsDeleted`)
|
||||
) COMMENT='订单附件表';
|
||||
|
||||
-- 迁移已有系统面单地址(若 LabelUrl 列已删除可跳过本段)
|
||||
INSERT INTO `t_order_file` (`OrderId`, `FileType`, `FileName`, `FileUrl`, `ContentType`, `Sort`, `Source`, `CreateUserId`, `CreateTime`)
|
||||
SELECT
|
||||
`Id`,
|
||||
'systemLabel',
|
||||
SUBSTRING_INDEX(`LabelUrl`, '/', -1),
|
||||
`LabelUrl`,
|
||||
'application/pdf',
|
||||
0,
|
||||
'migrate',
|
||||
0,
|
||||
NOW()
|
||||
FROM `t_order`
|
||||
WHERE `LabelUrl` IS NOT NULL
|
||||
AND TRIM(`LabelUrl`) <> ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `t_order_file` f
|
||||
WHERE f.`OrderId` = `t_order`.`Id`
|
||||
AND f.`FileType` = 'systemLabel'
|
||||
AND f.`IsDeleted` = 0
|
||||
);
|
||||
|
||||
ALTER TABLE `t_order`
|
||||
DROP COLUMN `LabelUrl`,
|
||||
DROP COLUMN `LabelGenerateStatus`,
|
||||
DROP COLUMN `LabelGenerateError`;
|
||||
@ -1,20 +0,0 @@
|
||||
-- 若 t_order_file 已按英文注释建表,执行本脚本改为中文注释(不改结构)。
|
||||
|
||||
ALTER TABLE `t_order_file`
|
||||
MODIFY COLUMN `Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
|
||||
MODIFY COLUMN `OrderId` INT NOT NULL COMMENT '订单Id',
|
||||
MODIFY COLUMN `FileType` VARCHAR(32) NOT NULL COMMENT '附件类型:tradeProof交易证明/systemLabel系统面单/downstreamLabel下游面单/lastMileLabel末端面单/infraredImage红外图片',
|
||||
MODIFY COLUMN `FileName` VARCHAR(255) NULL COMMENT '原始文件名',
|
||||
MODIFY COLUMN `FileUrl` VARCHAR(512) NOT NULL COMMENT '文件地址(相对路径或外链)',
|
||||
MODIFY COLUMN `ContentType` VARCHAR(128) NULL COMMENT '文件MIME类型',
|
||||
MODIFY COLUMN `FileSize` BIGINT NULL COMMENT '文件大小(字节)',
|
||||
MODIFY COLUMN `Sort` INT NOT NULL DEFAULT 0 COMMENT '同类型内排序',
|
||||
MODIFY COLUMN `Source` VARCHAR(32) NOT NULL DEFAULT 'upload' COMMENT '来源:upload上传/systemGenerate系统生成/downstream下游回传/migrate迁移',
|
||||
MODIFY COLUMN `Remark` VARCHAR(512) NULL COMMENT '备注',
|
||||
MODIFY COLUMN `IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
MODIFY COLUMN `ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
MODIFY COLUMN `CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
MODIFY COLUMN `CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
MODIFY COLUMN `UpdateUserId` INT NULL COMMENT '更新人',
|
||||
MODIFY COLUMN `UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
COMMENT='订单附件表';
|
||||
@ -1,12 +0,0 @@
|
||||
-- 修复:微信注册无邮箱时曾写入 user.Email='',撞 uk_user_email 导致后续注册提示「邮箱已被占用」
|
||||
-- 将空邮箱改为「客户编号@noemail.local」占位(与 CustomerContactHelper.ResolveRbacEmailOrPlaceholder 一致)
|
||||
|
||||
UPDATE `user` u
|
||||
INNER JOIN `t_customer` c ON c.`UserId` = u.`userid`
|
||||
SET u.`Email` = CONCAT(LOWER(TRIM(c.`CustomerCode`)), '@noemail.local')
|
||||
WHERE u.`Email` IS NULL OR TRIM(u.`Email`) = '';
|
||||
|
||||
-- 无客户关联的残留空邮箱
|
||||
UPDATE `user`
|
||||
SET `Email` = CONCAT('u', `userid`, '@noemail.local')
|
||||
WHERE `Email` IS NULL OR TRIM(`Email`) = '';
|
||||
@ -1,32 +0,0 @@
|
||||
-- MCP 工具配置(启用/描述覆盖),与代码内置目录合并
|
||||
-- 对齐 t_system_other_config / t_order_file 等配置表结构习惯
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `t_mcp_tool` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
|
||||
`ToolKey` VARCHAR(64) NOT NULL COMMENT '工具编码,如 oms.price_check',
|
||||
`DisplayName` VARCHAR(128) NOT NULL COMMENT '显示名称',
|
||||
`Description` VARCHAR(1000) NOT NULL COMMENT '给 AI 的工具描述',
|
||||
`Enabled` TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用:0-否,1-是',
|
||||
`SortOrder` INT NOT NULL DEFAULT 0 COMMENT '排序,越小越靠前',
|
||||
`Remark` VARCHAR(512) NULL COMMENT '备注',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT '并发戳',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`UpdateUserId` INT NULL COMMENT '更新人',
|
||||
`UpdateTime` DATETIME NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_mcp_tool_key` (`ToolKey`),
|
||||
KEY `idx_mcp_tool_enabled` (`Enabled`, `SortOrder`, `Id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MCP 工具配置表';
|
||||
|
||||
INSERT INTO `t_mcp_tool` (`ToolKey`, `DisplayName`, `Description`, `Enabled`, `SortOrder`, `Remark`)
|
||||
VALUES
|
||||
('oms.price_check', '查价格', '根据目的国、重量等查询运费报价,返回可用渠道与价格摘要。', 1, 10, '内置:封装 /order/price-check'),
|
||||
('oms.channel_guide', '查渠道对客说明', '按销售产品代码/名称查询对客说明(禁运、可寄品名等),判断客户品名是否可承运。', 1, 20, '内置:读销售产品 CustomerGuideMarkdown'),
|
||||
('oms.track_query', '查轨迹', '根据运单号/客户单号查询物流轨迹时间轴摘要。', 1, 30, '内置:轨迹中心 GetDetailTimeline')
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`DisplayName` = VALUES(`DisplayName`),
|
||||
`Description` = VALUES(`Description`),
|
||||
`SortOrder` = VALUES(`SortOrder`),
|
||||
`Remark` = VALUES(`Remark`);
|
||||
@ -1,38 +0,0 @@
|
||||
-- 若已按旧版建过 t_mcp_tool,执行本脚本补齐字段(幂等)
|
||||
|
||||
ALTER TABLE `t_mcp_tool`
|
||||
ADD COLUMN IF NOT EXISTS `Remark` VARCHAR(512) NULL COMMENT '备注' AFTER `SortOrder`;
|
||||
|
||||
-- MySQL 8.0.12 前无 IF NOT EXISTS 时,可改用下面手工判断;8.0.29+ 支持 ADD COLUMN IF NOT EXISTS
|
||||
-- 并发戳:已存在则跳过
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_mcp_tool'
|
||||
AND COLUMN_NAME = 'ConcurrencyStamp'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col_exists = 0,
|
||||
'ALTER TABLE `t_mcp_tool` ADD COLUMN `ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT ''并发戳'' AFTER `IsDeleted`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx_exists := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_mcp_tool'
|
||||
AND INDEX_NAME = 'idx_mcp_tool_enabled'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@idx_exists = 0,
|
||||
'ALTER TABLE `t_mcp_tool` ADD KEY `idx_mcp_tool_enabled` (`Enabled`, `SortOrder`, `Id`)',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
ALTER TABLE `t_mcp_tool` COMMENT = 'MCP 工具配置表';
|
||||
@ -1,46 +0,0 @@
|
||||
-- 价区键迁到客户:与会员等级解耦
|
||||
-- 新注册默认价区键/会员等级均为「普通会员」;计价时空键回落「普通客户」
|
||||
|
||||
-- 1) 客户表增加价区键
|
||||
ALTER TABLE `t_customer`
|
||||
ADD COLUMN `PriceTierKey` VARCHAR(64) NULL COMMENT '价区键(卖价 CustomerGroupValues JSON 键)' AFTER `MemberLevelId`;
|
||||
|
||||
-- 2) 从原会员等级价区键回填(依赖本脚本执行前 t_member_level 仍有 PriceTierKey)
|
||||
UPDATE `t_customer` c
|
||||
INNER JOIN `t_member_level` ml ON ml.`Id` = c.`MemberLevelId` AND ml.`IsDeleted` = 0
|
||||
SET c.`PriceTierKey` = NULLIF(TRIM(ml.`PriceTierKey`), '')
|
||||
WHERE c.`IsDeleted` = 0
|
||||
AND (c.`PriceTierKey` IS NULL OR TRIM(c.`PriceTierKey`) = '')
|
||||
AND ml.`PriceTierKey` IS NOT NULL
|
||||
AND TRIM(ml.`PriceTierKey`) <> '';
|
||||
|
||||
-- 3) 仍为空的主客户:默认「普通会员」(与新注册一致)
|
||||
UPDATE `t_customer`
|
||||
SET `PriceTierKey` = '普通会员'
|
||||
WHERE `IsDeleted` = 0
|
||||
AND (`ParentCustomerId` IS NULL OR `ParentCustomerId` = 0)
|
||||
AND (`PriceTierKey` IS NULL OR TRIM(`PriceTierKey`) = '');
|
||||
|
||||
-- 4) 子客户跟随主客户价区
|
||||
UPDATE `t_customer` sub
|
||||
INNER JOIN `t_customer` main ON main.`Id` = sub.`ParentCustomerId` AND main.`IsDeleted` = 0
|
||||
SET sub.`PriceTierKey` = main.`PriceTierKey`
|
||||
WHERE sub.`IsDeleted` = 0
|
||||
AND sub.`ParentCustomerId` IS NOT NULL
|
||||
AND sub.`ParentCustomerId` <> 0;
|
||||
|
||||
-- 5) 删除会员等级上的价区键列(须在插入默认等级前执行,避免 NOT NULL 约束)
|
||||
ALTER TABLE `t_member_level` DROP COLUMN `PriceTierKey`;
|
||||
|
||||
-- 6) 确保存在启用的「普通会员」等级(供新注册默认挂靠)
|
||||
INSERT INTO `t_member_level` (
|
||||
`LevelCode`, `LevelName`, `MinPoints`, `ExtraDiscountRate`, `Sort`,
|
||||
`Status`, `IsDeleted`, `CreateTime`
|
||||
)
|
||||
SELECT '普通会员', '普通会员', 0, 0, 0, 2, 0, NOW()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `t_member_level`
|
||||
WHERE `IsDeleted` = 0
|
||||
AND (`LevelName` = '普通会员' OR `LevelCode` = '普通会员')
|
||||
);
|
||||
@ -1,3 +0,0 @@
|
||||
-- 销售产品:贸易条款 DDP / DDU(查价线路返回并展示于价卡)
|
||||
ALTER TABLE `t_sales_product`
|
||||
ADD COLUMN `TradeTerms` VARCHAR(16) NULL COMMENT '贸易条款:DDP/DDU' AFTER `MaxTimeliness`;
|
||||
80
sql/migrate_dict_employee_position.sql
Normal file
80
sql/migrate_dict_employee_position.sql
Normal file
@ -0,0 +1,80 @@
|
||||
-- 员工档案「岗位 / 职级」字典初始数据(幂等:已存在同 DictType+DictCode 则跳过)
|
||||
-- dictType: employee_position / employee_job_level
|
||||
-- MySQL 5.7+ / 8.0
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- ========== 岗位 employee_position ==========
|
||||
INSERT INTO `t_dict_type` (`DictType`, `Remark`, `TypeSort`, `IsDeleted`, `CreateUserId`)
|
||||
SELECT 'employee_position', '员工岗位', 0, 0, 0
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `t_dict_type` WHERE `DictType` = 'employee_position' AND `IsDeleted` = 0
|
||||
);
|
||||
|
||||
INSERT INTO `t_dict` (`DictType`, `DictSort`, `DictCode`, `DictName`, `IsDeleted`, `CreateUserId`)
|
||||
SELECT v.`DictType`, v.`DictSort`, v.`DictCode`, v.`DictName`, 0, 0
|
||||
FROM (
|
||||
SELECT 'employee_position' AS DictType, 1 AS DictSort, 'generalManager' AS DictCode, '总经理' AS DictName
|
||||
UNION ALL SELECT 'employee_position', 2, 'deputyGeneralManager', '副总经理'
|
||||
UNION ALL SELECT 'employee_position', 3, 'logisticsAdvisor', '物流顾问'
|
||||
UNION ALL SELECT 'employee_position', 4, 'csManager', '客服主管'
|
||||
UNION ALL SELECT 'employee_position', 5, 'csSpecialist', '客服专员'
|
||||
UNION ALL SELECT 'employee_position', 6, 'opsManager', '运营经理'
|
||||
UNION ALL SELECT 'employee_position', 7, 'opsSpecialist', '运营专员'
|
||||
UNION ALL SELECT 'employee_position', 8, 'financeManager', '财务经理'
|
||||
UNION ALL SELECT 'employee_position', 9, 'financeSpecialist', '财务专员'
|
||||
UNION ALL SELECT 'employee_position', 10, 'warehouseManager', '仓储主管'
|
||||
UNION ALL SELECT 'employee_position', 11, 'warehouseClerk', '仓管员'
|
||||
UNION ALL SELECT 'employee_position', 12, 'customsSpecialist', '关务专员'
|
||||
UNION ALL SELECT 'employee_position', 13, 'productManager', '产品经理'
|
||||
UNION ALL SELECT 'employee_position', 14, 'techEngineer', '技术工程师'
|
||||
UNION ALL SELECT 'employee_position', 15, 'hrAdmin', '人事行政'
|
||||
UNION ALL SELECT 'employee_position', 16, 'marketingSpecialist', '市场专员'
|
||||
UNION ALL SELECT 'employee_position', 17, 'dispatcher', '调度员'
|
||||
) AS v
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `t_dict` d
|
||||
WHERE d.`DictType` = v.`DictType`
|
||||
AND d.`DictCode` = v.`DictCode`
|
||||
AND d.`IsDeleted` = 0
|
||||
);
|
||||
|
||||
UPDATE `t_dict`
|
||||
SET `IsDeleted` = 1,
|
||||
`UpdateTime` = NOW()
|
||||
WHERE `DictType` = 'employee_position'
|
||||
AND `DictCode` IN (
|
||||
'salesDirector',
|
||||
'salesManager',
|
||||
'salesSpecialist',
|
||||
'logisticsAdvisorDirector',
|
||||
'logisticsAdvisorManager'
|
||||
)
|
||||
AND `IsDeleted` = 0;
|
||||
|
||||
-- ========== 职级 employee_job_level(一级~五级) ==========
|
||||
INSERT INTO `t_dict_type` (`DictType`, `Remark`, `TypeSort`, `IsDeleted`, `CreateUserId`)
|
||||
SELECT 'employee_job_level', '员工职级', 0, 0, 0
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `t_dict_type` WHERE `DictType` = 'employee_job_level' AND `IsDeleted` = 0
|
||||
);
|
||||
|
||||
INSERT INTO `t_dict` (`DictType`, `DictSort`, `DictCode`, `DictName`, `IsDeleted`, `CreateUserId`)
|
||||
SELECT v.`DictType`, v.`DictSort`, v.`DictCode`, v.`DictName`, 0, 0
|
||||
FROM (
|
||||
SELECT 'employee_job_level' AS DictType, 1 AS DictSort, '1' AS DictCode, '一级' AS DictName
|
||||
UNION ALL SELECT 'employee_job_level', 2, '2', '二级'
|
||||
UNION ALL SELECT 'employee_job_level', 3, '3', '三级'
|
||||
UNION ALL SELECT 'employee_job_level', 4, '4', '四级'
|
||||
UNION ALL SELECT 'employee_job_level', 5, '5', '五级'
|
||||
) AS v
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `t_dict` d
|
||||
WHERE d.`DictType` = v.`DictType`
|
||||
AND d.`DictCode` = v.`DictCode`
|
||||
AND d.`IsDeleted` = 0
|
||||
);
|
||||
36
sql/migrate_sales_product_route_sort.sql
Normal file
36
sql/migrate_sales_product_route_sort.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- t_sales_product:官网线路展示排序(幂等;列已存在则跳过)
|
||||
-- 数值越小越靠前;默认 0
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_sales_product'
|
||||
AND COLUMN_NAME = 'RouteSort'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_sales_product` ADD COLUMN `RouteSort` INT NOT NULL DEFAULT 0 COMMENT ''官网线路排序,越小越靠前'' AFTER `TradeTerms`',
|
||||
'SELECT ''skip RouteSort'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_sales_product'
|
||||
AND INDEX_NAME = 'idx_sp_route_sort'
|
||||
);
|
||||
SET @sql_idx := IF(
|
||||
@idx = 0,
|
||||
'ALTER TABLE `t_sales_product` ADD KEY `idx_sp_route_sort` (`RouteSort`, `IsActive`)',
|
||||
'SELECT ''skip idx_sp_route_sort'' AS msg'
|
||||
);
|
||||
PREPARE stmt_idx FROM @sql_idx;
|
||||
EXECUTE stmt_idx;
|
||||
DEALLOCATE PREPARE stmt_idx;
|
||||
81
sql/migrate_t_9610_align_item_fields.sql
Normal file
81
sql/migrate_t_9610_align_item_fields.sql
Normal file
@ -0,0 +1,81 @@
|
||||
-- 9610 商品明细命名对齐 t_order_declaration(幂等)
|
||||
-- ItemNo→Sku, ItemName→CnName, Gcode→ExHsCode, Price→UnitPrice, Qty→Quantity,
|
||||
-- TotalAmount→Amount, DeclareUnit→Unit
|
||||
-- 海关专属保留:Gmodel / Barcode / DestCountry / ItemCurrency / LegalQty / LegalUnit / Freight / SortNo
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- ItemNo → Sku
|
||||
SET @hasOld := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='ItemNo');
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Sku');
|
||||
SET @sql := IF(@hasOld>0 AND @hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `ItemNo` `Sku` VARCHAR(32) NOT NULL DEFAULT '''' COMMENT ''SKU(对齐 t_order_declaration.Sku / 上游 itemNo)''',
|
||||
'SELECT ''skip ItemNo->Sku'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ItemName → CnName
|
||||
SET @hasOld := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='ItemName');
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='CnName');
|
||||
SET @sql := IF(@hasOld>0 AND @hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `ItemName` `CnName` VARCHAR(250) NOT NULL DEFAULT '''' COMMENT ''中文品名(对齐 t_order_declaration.CnName / 上游 itemName)''',
|
||||
'SELECT ''skip ItemName->CnName'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Gcode → ExHsCode
|
||||
SET @hasOld := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Gcode');
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='ExHsCode');
|
||||
SET @sql := IF(@hasOld>0 AND @hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `Gcode` `ExHsCode` VARCHAR(10) NULL COMMENT ''出口海关编码(对齐 t_order_declaration.ExHsCode / 上游 gcode)''',
|
||||
'SELECT ''skip Gcode->ExHsCode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Price → UnitPrice
|
||||
SET @hasOld := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Price');
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='UnitPrice');
|
||||
SET @sql := IF(@hasOld>0 AND @hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `Price` `UnitPrice` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT ''单价(对齐 t_order_declaration.UnitPrice)''',
|
||||
'SELECT ''skip Price->UnitPrice'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- TotalAmount → Amount(可能尚未存在 TotalAmount)
|
||||
SET @hasOld := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='TotalAmount');
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Amount');
|
||||
SET @sql := IF(@hasOld>0 AND @hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `TotalAmount` `Amount` DECIMAL(19,5) NULL COMMENT ''总价(对齐 t_order_declaration.Amount / 上游 totalPrice)''',
|
||||
'SELECT ''skip TotalAmount->Amount'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Amount');
|
||||
SET @sql := IF(@hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` ADD COLUMN `Amount` DECIMAL(19,5) NULL COMMENT ''总价(对齐 t_order_declaration.Amount)'' AFTER `UnitPrice`',
|
||||
'SELECT ''skip add Amount'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Qty → Quantity
|
||||
SET @hasOld := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Qty');
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Quantity');
|
||||
SET @sql := IF(@hasOld>0 AND @hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `Qty` `Quantity` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT ''数量(对齐 t_order_declaration.Quantity,精度保留海关小数)''',
|
||||
'SELECT ''skip Qty->Quantity'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- DeclareUnit → Unit
|
||||
SET @hasOld := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='DeclareUnit');
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Unit');
|
||||
SET @sql := IF(@hasOld>0 AND @hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `DeclareUnit` `Unit` VARCHAR(3) NULL COMMENT ''计量单位(对齐 t_order_declaration.Unit / 上游 unit)''',
|
||||
'SELECT ''skip DeclareUnit->Unit'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @hasNew := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Unit');
|
||||
SET @sql := IF(@hasNew=0,
|
||||
'ALTER TABLE `t_9610_order_item` ADD COLUMN `Unit` VARCHAR(3) NULL COMMENT ''计量单位(对齐 t_order_declaration.Unit)'' AFTER `LegalQty`',
|
||||
'SELECT ''skip add Unit'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Gmodel 注释:海关申报要素(由运单 Model/Specifications/Attributes/Material 拼接)
|
||||
SET @has := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Gmodel');
|
||||
SET @sql := IF(@has>0,
|
||||
'ALTER TABLE `t_9610_order_item` MODIFY COLUMN `Gmodel` VARCHAR(255) NULL COMMENT ''申报要素(海关;由运单型号/规格等拼接,上游 gmodel)''',
|
||||
'SELECT ''skip Gmodel comment'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
118
sql/migrate_t_9610_align_order_nos.sql
Normal file
118
sql/migrate_t_9610_align_order_nos.sql
Normal file
@ -0,0 +1,118 @@
|
||||
-- 9610 单号命名对齐运单 t_order(幂等)
|
||||
-- ReferenceNo → ClientNo(客户单号)
|
||||
-- LogisticsNo 并入 ServiceNo(运单号)后删除 LogisticsNo
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- 1) ReferenceNo → ClientNo
|
||||
SET @hasRef := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ReferenceNo'
|
||||
);
|
||||
SET @hasClient := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ClientNo'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@hasRef > 0 AND @hasClient = 0,
|
||||
'ALTER TABLE `t_9610_order` CHANGE COLUMN `ReferenceNo` `ClientNo` VARCHAR(48) NOT NULL DEFAULT '''' COMMENT ''客户单号(对齐 t_order.ClientNo / 上游 referenceNo)''',
|
||||
'SELECT ''skip ReferenceNo->ClientNo'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 索引名顺带调整(旧 idx_9610_ref → idx_9610_client_no)
|
||||
SET @idxRef := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND INDEX_NAME='idx_9610_ref'
|
||||
);
|
||||
SET @idxClient := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND INDEX_NAME='idx_9610_client_no'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@idxRef > 0 AND @idxClient = 0,
|
||||
'ALTER TABLE `t_9610_order` RENAME INDEX `idx_9610_ref` TO `idx_9610_client_no`',
|
||||
'SELECT ''skip rename idx_9610_ref'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idxClient := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND INDEX_NAME='idx_9610_client_no'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@idxClient = 0,
|
||||
'ALTER TABLE `t_9610_order` ADD KEY `idx_9610_client_no` (`ClientNo`)',
|
||||
'SELECT ''skip add idx_9610_client_no'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 2) LogisticsNo → 回填 ServiceNo,再删列
|
||||
SET @hasLog := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='LogisticsNo'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@hasLog > 0,
|
||||
'UPDATE `t_9610_order` SET `ServiceNo` = NULLIF(TRIM(`LogisticsNo`), '''') WHERE (`ServiceNo` IS NULL OR TRIM(`ServiceNo`) = '''') AND `LogisticsNo` IS NOT NULL AND TRIM(`LogisticsNo`) <> ''''',
|
||||
'SELECT ''skip backfill ServiceNo'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idxLog := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND INDEX_NAME='idx_9610_logistics'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@idxLog > 0,
|
||||
'ALTER TABLE `t_9610_order` DROP INDEX `idx_9610_logistics`',
|
||||
'SELECT ''skip drop idx_9610_logistics'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @hasLog := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='LogisticsNo'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@hasLog > 0,
|
||||
'ALTER TABLE `t_9610_order` DROP COLUMN `LogisticsNo`',
|
||||
'SELECT ''skip drop LogisticsNo'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ServiceNo 索引(检索)
|
||||
SET @idxSvc := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND INDEX_NAME='idx_9610_service_no'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@idxSvc = 0,
|
||||
'ALTER TABLE `t_9610_order` ADD KEY `idx_9610_service_no` (`ServiceNo`)',
|
||||
'SELECT ''skip idx_9610_service_no'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- OrderNo 注释对齐:海关下游订单编号(非运单 DownstreamServiceNo)
|
||||
SET @hasOrderNo := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='OrderNo'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@hasOrderNo > 0,
|
||||
'ALTER TABLE `t_9610_order` MODIFY COLUMN `OrderNo` VARCHAR(32) NULL COMMENT ''海关下游订单编号(申报回写,非 t_order.DownstreamServiceNo)''',
|
||||
'SELECT ''skip OrderNo comment'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- DownstreamRefNo 注释
|
||||
SET @hasDr := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='DownstreamRefNo'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@hasDr > 0,
|
||||
'ALTER TABLE `t_9610_order` MODIFY COLUMN `DownstreamRefNo` VARCHAR(32) NULL COMMENT ''申报回写的 referenceNo 快照''',
|
||||
'SELECT ''skip DownstreamRefNo comment'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
170
sql/migrate_t_9610_manifest_fields.sql
Normal file
170
sql/migrate_t_9610_manifest_fields.sql
Normal file
@ -0,0 +1,170 @@
|
||||
-- 9610:补齐「获取清单数据」回写字段(幂等;列已存在则跳过)
|
||||
-- 字段名为 OMS 自有命名,与上游 CEB 字段对照见注释
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- ========== t_9610_order ==========
|
||||
|
||||
-- EnterpriseBizNo ← copNo 企业唯一编号
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EnterpriseBizNo');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `EnterpriseBizNo` VARCHAR(48) NULL COMMENT ''企业唯一编号(上游 copNo)'' AFTER `DownstreamRefNo`', 'SELECT ''skip EnterpriseBizNo'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ManifestNo ← invtNo 清单编号
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ManifestNo');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `ManifestNo` VARCHAR(48) NULL COMMENT ''清单编号(上游 invtNo)'' AFTER `EnterpriseBizNo`', 'SELECT ''skip ManifestNo'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ClearanceTime ← clearanceTime 结关日期(原文,格式不固定)
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ClearanceTime');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `ClearanceTime` VARCHAR(48) NULL COMMENT ''结关日期原文'' AFTER `ManifestNo`', 'SELECT ''skip ClearanceTime'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- CustomsInboundTime ← warehouseTime 海关入库时间
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='CustomsInboundTime');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `CustomsInboundTime` VARCHAR(48) NULL COMMENT ''海关入库时间原文'' AFTER `ClearanceTime`', 'SELECT ''skip CustomsInboundTime'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- CustomsState ← customsStatus 海关状态
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='CustomsState');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `CustomsState` VARCHAR(4) NULL COMMENT ''海关状态'' AFTER `CustomsInboundTime`', 'SELECT ''skip CustomsState'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- DeclareCustomsCode ← customsCode 申报地海关
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='DeclareCustomsCode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `DeclareCustomsCode` VARCHAR(4) NULL COMMENT ''申报地海关代码'' AFTER `CustomsState`', 'SELECT ''skip DeclareCustomsCode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- EbpCode ← ebpCode
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EbpCode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `EbpCode` VARCHAR(18) NULL COMMENT ''电商平台代码'' AFTER `DeclareCustomsCode`', 'SELECT ''skip EbpCode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- EbpName ← ebpName
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EbpName');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `EbpName` VARCHAR(100) NULL COMMENT ''电商平台名称'' AFTER `EbpCode`', 'SELECT ''skip EbpName'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- LogisticsCorpCode ← logisticsCode
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='LogisticsCorpCode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `LogisticsCorpCode` VARCHAR(18) NULL COMMENT ''物流企业代码'' AFTER `EbpName`', 'SELECT ''skip LogisticsCorpCode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- LogisticsCorpName ← logisticsName
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='LogisticsCorpName');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `LogisticsCorpName` VARCHAR(100) NULL COMMENT ''物流企业名称'' AFTER `LogisticsCorpCode`', 'SELECT ''skip LogisticsCorpName'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- IeMark ← ieFlag I/E
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='IeMark');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `IeMark` VARCHAR(4) NULL COMMENT ''进出口标记 I/E'' AFTER `LogisticsCorpName`', 'SELECT ''skip IeMark'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ExportPortCode ← portCode
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ExportPortCode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `ExportPortCode` VARCHAR(4) NULL COMMENT ''出口口岸代码'' AFTER `IeMark`', 'SELECT ''skip ExportPortCode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ExportDate ← ieDate
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ExportDate');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `ExportDate` VARCHAR(32) NULL COMMENT ''出口日期原文'' AFTER `ExportPortCode`', 'SELECT ''skip ExportDate'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- DeclareAgentCode ← agentCode
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='DeclareAgentCode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `DeclareAgentCode` VARCHAR(18) NULL COMMENT ''申报企业代码'' AFTER `ExportDate`', 'SELECT ''skip DeclareAgentCode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- DeclareAgentName ← agentName
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='DeclareAgentName');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `DeclareAgentName` VARCHAR(100) NULL COMMENT ''申报企业名称'' AFTER `DeclareAgentCode`', 'SELECT ''skip DeclareAgentName'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- TradeModeCode ← tradeMode
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='TradeModeCode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `TradeModeCode` VARCHAR(4) NULL COMMENT ''贸易方式代码'' AFTER `DeclareAgentName`', 'SELECT ''skip TradeModeCode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- TransportMode ← trafMode
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='TransportMode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `TransportMode` VARCHAR(4) NULL COMMENT ''运输方式代码'' AFTER `TradeModeCode`', 'SELECT ''skip TransportMode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- FreightCurrency ← fCurrency
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='FreightCurrency');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `FreightCurrency` VARCHAR(4) NULL COMMENT ''运费币制'' AFTER `Freight`', 'SELECT ''skip FreightCurrency'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- FreightMark ← fFlag 1率/2单价/3总价
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='FreightMark');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `FreightMark` INT NULL COMMENT ''运费标志 1率2单价3总价'' AFTER `FreightCurrency`', 'SELECT ''skip FreightMark'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- PackageType ← wrapType
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='PackageType');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `PackageType` INT NULL COMMENT ''包装种类代码'' AFTER `FreightMark`', 'SELECT ''skip PackageType'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- PackageQty ← packNo
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='PackageQty');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `PackageQty` INT NULL COMMENT ''件数'' AFTER `PackageType`', 'SELECT ''skip PackageQty'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ManifestSyncTime 最近一次清单回写时间
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ManifestSyncTime');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order` ADD COLUMN `ManifestSyncTime` DATETIME NULL COMMENT ''清单数据最近同步时间'' AFTER `DeclareTime`', 'SELECT ''skip ManifestSyncTime'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 运费精度对齐上游 DECIMAL(19,5)
|
||||
SET @colType := (
|
||||
SELECT COLUMN_TYPE FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='Freight'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@colType IS NOT NULL AND @colType NOT LIKE 'decimal(19,5)%',
|
||||
'ALTER TABLE `t_9610_order` MODIFY COLUMN `Freight` DECIMAL(19,5) NULL COMMENT ''运费''',
|
||||
'SELECT ''skip Freight precision'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ManifestNo 索引(幂等)
|
||||
SET @idx := (SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND INDEX_NAME='idx_9610_manifest');
|
||||
SET @sql := IF(@idx=0, 'ALTER TABLE `t_9610_order` ADD KEY `idx_9610_manifest` (`ManifestNo`)', 'SELECT ''skip idx_9610_manifest'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ========== t_9610_order_item ==========
|
||||
|
||||
-- Barcode ← barCode
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Barcode');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order_item` ADD COLUMN `Barcode` VARCHAR(255) NULL COMMENT ''条形码'' AFTER `Gmodel`', 'SELECT ''skip Barcode'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- DestCountry ← country 目的国
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='DestCountry');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order_item` ADD COLUMN `DestCountry` VARCHAR(255) NULL COMMENT ''目的国(地区)代码'' AFTER `Barcode`', 'SELECT ''skip DestCountry'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ItemCurrency ← currency
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='ItemCurrency');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order_item` ADD COLUMN `ItemCurrency` VARCHAR(3) NULL COMMENT ''币制'' AFTER `DestCountry`', 'SELECT ''skip ItemCurrency'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- LegalQty ← qty1 法定数量
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='LegalQty');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order_item` ADD COLUMN `LegalQty` DECIMAL(19,5) NULL COMMENT ''法定数量'' AFTER `Quantity`', 'SELECT ''skip LegalQty'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Unit ← unit(对齐运单;旧名 DeclareUnit 由 align_item_fields 迁移)
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Unit');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order_item` ADD COLUMN `Unit` VARCHAR(3) NULL COMMENT ''计量单位'' AFTER `LegalQty`', 'SELECT ''skip Unit'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- LegalUnit ← unit1
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='LegalUnit');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order_item` ADD COLUMN `LegalUnit` VARCHAR(3) NULL COMMENT ''法定计量单位'' AFTER `Unit`', 'SELECT ''skip LegalUnit'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Amount ← totalPrice
|
||||
SET @col := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Amount');
|
||||
SET @sql := IF(@col=0, 'ALTER TABLE `t_9610_order_item` ADD COLUMN `Amount` DECIMAL(19,5) NULL COMMENT ''总价'' AFTER `UnitPrice`', 'SELECT ''skip Amount'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
122
sql/migrate_t_9610_order.sql
Normal file
122
sql/migrate_t_9610_order.sql
Normal file
@ -0,0 +1,122 @@
|
||||
-- 9610 汇总申报单(ExportCustomsMode=9610Summary)
|
||||
-- 幂等:表已存在则跳过
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- t_9610_order
|
||||
SET @exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.TABLES
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 't_9610_order'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@exists = 0,
|
||||
'CREATE TABLE `t_9610_order` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT ''主键'',
|
||||
`OrderId` INT NOT NULL COMMENT ''关联运单 t_order.Id'',
|
||||
`ServiceNo` VARCHAR(64) NULL COMMENT ''运单号冗余'',
|
||||
`CustomerId` INT NOT NULL DEFAULT 0 COMMENT ''客户Id'',
|
||||
`Status` VARCHAR(16) NOT NULL DEFAULT ''pending'' COMMENT ''pending待申报 / declared已申报'',
|
||||
`PlatformCode` VARCHAR(16) NOT NULL DEFAULT '''' COMMENT ''电商平台'',
|
||||
`EcomCorpCode` VARCHAR(18) NULL COMMENT ''电商企业代码'',
|
||||
`EcomCorpName` VARCHAR(100) NULL COMMENT ''电商企业名称'',
|
||||
`ProducerCode` VARCHAR(18) NULL COMMENT ''生产销售单位代码'',
|
||||
`ProducerName` VARCHAR(100) NULL COMMENT ''生产销售单位'',
|
||||
`ClientNo` VARCHAR(48) NOT NULL DEFAULT '''' COMMENT ''客户单号(对齐 t_order.ClientNo)'',
|
||||
`BusinessType` CHAR(1) NOT NULL DEFAULT ''B'' COMMENT ''业务类型 A简化/B汇总'',
|
||||
`Region` VARCHAR(10) NULL COMMENT ''区域 SZ/other'',
|
||||
`AgentDeclare` VARCHAR(2) NULL COMMENT ''是否代理申报 是/否'',
|
||||
`ActualSellerCode` VARCHAR(18) NULL COMMENT ''实际卖家信用代码'',
|
||||
`PreRecordFlag` CHAR(1) NULL COMMENT ''汇总预录 0已预录 1未预录'',
|
||||
`IsSummarySimple` TINYINT NOT NULL DEFAULT 0 COMMENT ''是否汇总简化申报'',
|
||||
`GrossWeight` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT ''毛重KG'',
|
||||
`Currency` VARCHAR(4) NOT NULL DEFAULT ''CNY'' COMMENT ''币制'',
|
||||
`DestCountry` VARCHAR(4) NOT NULL DEFAULT '''' COMMENT ''目的国'',
|
||||
`Freight` DECIMAL(19,5) NULL COMMENT ''运费'',
|
||||
`FreightCurrency` VARCHAR(4) NULL COMMENT ''运费币制'',
|
||||
`FreightMark` INT NULL COMMENT ''运费标志 1率2单价3总价'',
|
||||
`PackageType` INT NULL COMMENT ''包装种类代码'',
|
||||
`PackageQty` INT NULL COMMENT ''件数'',
|
||||
`ShipmentNo` VARCHAR(32) NULL COMMENT ''出货单号'',
|
||||
`CustomsOrderNo` VARCHAR(32) NULL COMMENT ''海关订单号(申报回写)'',
|
||||
`DownstreamRefNo` VARCHAR(32) NULL COMMENT ''申报回写的 referenceNo 快照'',
|
||||
`EnterpriseBizNo` VARCHAR(48) NULL COMMENT ''企业唯一编号(上游 copNo)'',
|
||||
`ManifestNo` VARCHAR(48) NULL COMMENT ''清单编号(上游 invtNo)'',
|
||||
`ClearanceTime` VARCHAR(48) NULL COMMENT ''结关日期原文'',
|
||||
`CustomsInboundTime` VARCHAR(48) NULL COMMENT ''海关入库时间原文'',
|
||||
`CustomsState` VARCHAR(4) NULL COMMENT ''海关状态'',
|
||||
`DeclareCustomsCode` VARCHAR(4) NULL COMMENT ''申报地海关代码'',
|
||||
`PlatformCorpCode` VARCHAR(18) NULL COMMENT ''电商平台代码'',
|
||||
`PlatformName` VARCHAR(100) NULL COMMENT ''电商平台名称'',
|
||||
`LogisticsCorpCode` VARCHAR(18) NULL COMMENT ''物流企业代码'',
|
||||
`LogisticsCorpName` VARCHAR(100) NULL COMMENT ''物流企业名称'',
|
||||
`IeMark` VARCHAR(4) NULL COMMENT ''进出口标记 I/E'',
|
||||
`ExportPortCode` VARCHAR(4) NULL COMMENT ''出口口岸代码'',
|
||||
`ExportDate` VARCHAR(32) NULL COMMENT ''出口日期原文'',
|
||||
`DeclareAgentCode` VARCHAR(18) NULL COMMENT ''申报企业代码'',
|
||||
`DeclareAgentName` VARCHAR(100) NULL COMMENT ''申报企业名称'',
|
||||
`TradeModeCode` VARCHAR(4) NULL COMMENT ''贸易方式代码'',
|
||||
`TransportMode` VARCHAR(4) NULL COMMENT ''运输方式代码'',
|
||||
`DeclareTime` DATETIME NULL COMMENT ''申报成功时间'',
|
||||
`ManifestSyncTime` DATETIME NULL COMMENT ''清单数据最近同步时间'',
|
||||
`FailReason` VARCHAR(512) NULL COMMENT ''最近失败原因'',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT ''软删除'',
|
||||
`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT (UUID()) COMMENT ''并发戳'',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT ''创建人'',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''创建时间'',
|
||||
`UpdateUserId` INT NULL COMMENT ''更新人'',
|
||||
`UpdateTime` DATETIME NULL COMMENT ''更新时间'',
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY `uk_9610_order_id` (`OrderId`),
|
||||
KEY `idx_9610_status_ctime` (`Status`, `CreateTime`),
|
||||
KEY `idx_9610_service_no` (`ServiceNo`),
|
||||
KEY `idx_9610_client_no` (`ClientNo`),
|
||||
KEY `idx_9610_customer` (`CustomerId`, `CreateTime`),
|
||||
KEY `idx_9610_manifest` (`ManifestNo`)
|
||||
) COMMENT=''9610汇总申报单''',
|
||||
'SELECT ''skip t_9610_order'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- t_9610_order_item
|
||||
SET @exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.TABLES
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 't_9610_order_item'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@exists = 0,
|
||||
'CREATE TABLE `t_9610_order_item` (
|
||||
`Id` INT NOT NULL AUTO_INCREMENT COMMENT ''主键'',
|
||||
`Customs9610OrderId` INT NOT NULL COMMENT ''t_9610_order.Id'',
|
||||
`OrderDeclarationId` INT NULL COMMENT ''溯源 t_order_declaration.Id'',
|
||||
`Sku` VARCHAR(32) NOT NULL DEFAULT '''' COMMENT ''SKU(对齐 t_order_declaration.Sku)'',
|
||||
`CnName` VARCHAR(250) NOT NULL DEFAULT '''' COMMENT ''中文品名(对齐 t_order_declaration.CnName)'',
|
||||
`ExHsCode` VARCHAR(10) NULL COMMENT ''出口海关编码(对齐 t_order_declaration.ExHsCode)'',
|
||||
`DeclareElement` VARCHAR(255) NULL COMMENT ''申报要素'',
|
||||
`Barcode` VARCHAR(255) NULL COMMENT ''条形码'',
|
||||
`DestCountry` VARCHAR(255) NULL COMMENT ''目的国(地区)代码'',
|
||||
`ItemCurrency` VARCHAR(3) NULL COMMENT ''币制'',
|
||||
`UnitPrice` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT ''单价(对齐 t_order_declaration.UnitPrice)'',
|
||||
`Amount` DECIMAL(19,5) NULL COMMENT ''总价(对齐 t_order_declaration.Amount)'',
|
||||
`Quantity` DECIMAL(19,5) NOT NULL DEFAULT 0 COMMENT ''数量(对齐 t_order_declaration.Quantity)'',
|
||||
`LegalQty` DECIMAL(19,5) NULL COMMENT ''法定数量'',
|
||||
`Unit` VARCHAR(3) NULL COMMENT ''计量单位(对齐 t_order_declaration.Unit)'',
|
||||
`LegalUnit` VARCHAR(3) NULL COMMENT ''法定计量单位'',
|
||||
`Freight` DECIMAL(12,4) NULL COMMENT ''行运费'',
|
||||
`SortNo` INT NOT NULL DEFAULT 0 COMMENT ''排序'',
|
||||
`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT ''软删除'',
|
||||
`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT ''创建人'',
|
||||
`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''创建时间'',
|
||||
`UpdateUserId` INT NULL COMMENT ''更新人'',
|
||||
`UpdateTime` DATETIME NULL COMMENT ''更新时间'',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `idx_9610_item_header` (`Customs9610OrderId`, `IsDeleted`)
|
||||
) COMMENT=''9610申报商品明细''',
|
||||
'SELECT ''skip t_9610_order_item'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
90
sql/migrate_t_9610_rename_by_meaning.sql
Normal file
90
sql/migrate_t_9610_rename_by_meaning.sql
Normal file
@ -0,0 +1,90 @@
|
||||
-- 9610 其余字段按业务含义重命名(幂等 CHANGE)
|
||||
-- 申报头:Ebp→PlatformCode, Ebc*→EcomCorp*, Owner*→Producer*, FormType→BusinessType,
|
||||
-- IsAgent→AgentDeclare, ActBuyer→ActualSellerCode, SoLabelFlag→PreRecordFlag,
|
||||
-- IsSimple→IsSummarySimple, Country→DestCountry, BlNo→ShipmentNo,
|
||||
-- EbpCode/EbpName→PlatformCorpCode/PlatformName, OrderNo→CustomsOrderNo
|
||||
-- 明细:Gmodel→DeclareElement
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- helper pattern repeated
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='Ebp');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='PlatformCode');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `Ebp` `PlatformCode` VARCHAR(16) NOT NULL DEFAULT '''' COMMENT ''电商平台''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EbcCode');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EcomCorpCode');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `EbcCode` `EcomCorpCode` VARCHAR(18) NULL COMMENT ''电商企业代码''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EbcName');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EcomCorpName');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `EbcName` `EcomCorpName` VARCHAR(100) NULL COMMENT ''电商企业名称''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='OwnerCode');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ProducerCode');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `OwnerCode` `ProducerCode` VARCHAR(18) NULL COMMENT ''生产销售单位代码''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='OwnerName');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ProducerName');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `OwnerName` `ProducerName` VARCHAR(100) NULL COMMENT ''生产销售单位''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='FormType');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='BusinessType');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `FormType` `BusinessType` CHAR(1) NOT NULL DEFAULT ''B'' COMMENT ''业务类型 A简化/B汇总''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='IsAgent');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='AgentDeclare');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `IsAgent` `AgentDeclare` VARCHAR(2) NULL COMMENT ''是否代理申报 是/否''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ActBuyer');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ActualSellerCode');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `ActBuyer` `ActualSellerCode` VARCHAR(18) NULL COMMENT ''实际卖家信用代码''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='SoLabelFlag');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='PreRecordFlag');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `SoLabelFlag` `PreRecordFlag` CHAR(1) NULL COMMENT ''汇总预录 0已预录/1未预录''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='IsSimple');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='IsSummarySimple');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `IsSimple` `IsSummarySimple` TINYINT NOT NULL DEFAULT 0 COMMENT ''是否汇总简化申报''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='Country');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='DestCountry');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `Country` `DestCountry` VARCHAR(4) NOT NULL DEFAULT '''' COMMENT ''目的国''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='BlNo');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='ShipmentNo');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `BlNo` `ShipmentNo` VARCHAR(32) NULL COMMENT ''出货单号''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='OrderNo');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='CustomsOrderNo');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `OrderNo` `CustomsOrderNo` VARCHAR(32) NULL COMMENT ''海关订单号''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EbpCode');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='PlatformCorpCode');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `EbpCode` `PlatformCorpCode` VARCHAR(18) NULL COMMENT ''电商平台代码''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='EbpName');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order' AND COLUMN_NAME='PlatformName');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order` CHANGE COLUMN `EbpName` `PlatformName` VARCHAR(100) NULL COMMENT ''电商平台名称''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
|
||||
SET @o:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='Gmodel');
|
||||
SET @n:=(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='t_9610_order_item' AND COLUMN_NAME='DeclareElement');
|
||||
SET @sql:=IF(@o>0 AND @n=0,'ALTER TABLE `t_9610_order_item` CHANGE COLUMN `Gmodel` `DeclareElement` VARCHAR(255) NULL COMMENT ''申报要素''','SELECT 1');
|
||||
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
|
||||
118
sql/migrate_t_order_exception_event_handler.sql
Normal file
118
sql/migrate_t_order_exception_event_handler.sql
Normal file
@ -0,0 +1,118 @@
|
||||
-- 订单异常事件表:补齐 Handler* / ConcurrencyStamp(幂等;列已存在则自动跳过)
|
||||
-- 修复:Unknown column 'HandlerNames' / 'ConcurrencyStamp' in 'field list'
|
||||
-- MySQL 5.7+ / 8.0
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- HandlerNames
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order_exception_event'
|
||||
AND COLUMN_NAME = 'HandlerNames'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_order_exception_event` ADD COLUMN `HandlerNames` VARCHAR(256) NULL COMMENT ''处理人快照''',
|
||||
'SELECT ''skip HandlerNames'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- HandlerType
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order_exception_event'
|
||||
AND COLUMN_NAME = 'HandlerType'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_order_exception_event` ADD COLUMN `HandlerType` VARCHAR(16) NULL COMMENT ''处理人类型''',
|
||||
'SELECT ''skip HandlerType'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- HandlerUserId
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order_exception_event'
|
||||
AND COLUMN_NAME = 'HandlerUserId'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_order_exception_event` ADD COLUMN `HandlerUserId` INT NULL COMMENT ''处理人用户Id(customer 时为订单客户账号)''',
|
||||
'SELECT ''skip HandlerUserId'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ConcurrencyStamp(AggregateRoot 并发戳;避免 DEFAULT(UUID()) 触发 1674 复制不安全)
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order_exception_event'
|
||||
AND COLUMN_NAME = 'ConcurrencyStamp'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_order_exception_event` ADD COLUMN `ConcurrencyStamp` CHAR(36) NULL COMMENT ''并发戳''',
|
||||
'SELECT ''skip ConcurrencyStamp add'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order_exception_event'
|
||||
AND COLUMN_NAME = 'ConcurrencyStamp'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col > 0,
|
||||
'UPDATE `t_order_exception_event`
|
||||
SET `ConcurrencyStamp` = LOWER(CONCAT(
|
||||
LPAD(HEX(`Id`), 8, ''0''),
|
||||
''-0000-4000-8000-'',
|
||||
LPAD(HEX(`Id` * 9973), 12, ''0'')
|
||||
))
|
||||
WHERE `ConcurrencyStamp` IS NULL OR `ConcurrencyStamp` = ''''',
|
||||
'SELECT ''skip ConcurrencyStamp backfill'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order_exception_event'
|
||||
AND COLUMN_NAME = 'ConcurrencyStamp'
|
||||
);
|
||||
SET @isNullable := (
|
||||
SELECT IFNULL(MAX(CASE WHEN IS_NULLABLE = 'YES' THEN 1 ELSE 0 END), 0)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order_exception_event'
|
||||
AND COLUMN_NAME = 'ConcurrencyStamp'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col > 0 AND @isNullable = 1,
|
||||
'ALTER TABLE `t_order_exception_event` MODIFY COLUMN `ConcurrencyStamp` CHAR(36) NOT NULL COMMENT ''并发戳''',
|
||||
'SELECT ''skip ConcurrencyStamp not null'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
70
sql/migrate_t_order_fulfillment_type.sql
Normal file
70
sql/migrate_t_order_fulfillment_type.sql
Normal file
@ -0,0 +1,70 @@
|
||||
-- 代发订单:t_order 履约类型字段(幂等;列/索引已存在则自动跳过)
|
||||
-- MySQL 5.7+ / 8.0
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- FulfillmentType
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order'
|
||||
AND COLUMN_NAME = 'FulfillmentType'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_order` ADD COLUMN `FulfillmentType` VARCHAR(16) NULL DEFAULT ''direct'' COMMENT ''履约类型 direct/warehouse'' AFTER `AdditionalServices`',
|
||||
'SELECT ''skip FulfillmentType'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- FulfillmentSource
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order'
|
||||
AND COLUMN_NAME = 'FulfillmentSource'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_order` ADD COLUMN `FulfillmentSource` VARCHAR(32) NULL COMMENT ''代发来源 storeFulfill/postBind'' AFTER `FulfillmentType`',
|
||||
'SELECT ''skip FulfillmentSource'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- idx_ord_fulfillment_customer
|
||||
SET @idx := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_order'
|
||||
AND INDEX_NAME = 'idx_ord_fulfillment_customer'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@idx = 0,
|
||||
'ALTER TABLE `t_order` ADD KEY `idx_ord_fulfillment_customer` (`FulfillmentType`, `CustomerId`, `OrderStatus`)',
|
||||
'SELECT ''skip idx_ord_fulfillment_customer'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 历史:已有绑定行的订单标记为 warehouse
|
||||
UPDATE `t_order` o
|
||||
INNER JOIN (
|
||||
SELECT DISTINCT b.`OrderId`
|
||||
FROM `t_order_stock_bind` b
|
||||
WHERE b.`IsDeleted` = 0
|
||||
AND b.`Status` IN ('bound', 'deducted')
|
||||
) x ON x.`OrderId` = o.`Id`
|
||||
SET o.`FulfillmentType` = 'warehouse';
|
||||
|
||||
-- 其余空值兜底为 direct
|
||||
UPDATE `t_order`
|
||||
SET `FulfillmentType` = 'direct'
|
||||
WHERE `FulfillmentType` IS NULL OR `FulfillmentType` = '';
|
||||
49
sql/migrate_t_pickup_order_line_service_no.sql
Normal file
49
sql/migrate_t_pickup_order_line_service_no.sql
Normal file
@ -0,0 +1,49 @@
|
||||
-- 揽收明细:补齐运单号/客户单号快照(幂等;列已存在则跳过)
|
||||
-- 对应实体 PickupOrderLine.ServiceNo / ClientNo
|
||||
-- 报错 Unknown column 'ServiceNo' in 'field list' 时执行本脚本
|
||||
-- MySQL 5.7+ / 8.0
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- ServiceNo
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_pickup_order_line'
|
||||
AND COLUMN_NAME = 'ServiceNo'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_pickup_order_line` ADD COLUMN `ServiceNo` VARCHAR(64) NULL COMMENT ''运单号快照(便于列表)'' AFTER `OrderId`',
|
||||
'SELECT ''skip ServiceNo'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ClientNo
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 't_pickup_order_line'
|
||||
AND COLUMN_NAME = 'ClientNo'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `t_pickup_order_line` ADD COLUMN `ClientNo` VARCHAR(64) NULL COMMENT ''客户单号快照'' AFTER `ServiceNo`',
|
||||
'SELECT ''skip ClientNo'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 存量行从订单表回填快照(仅空值)
|
||||
UPDATE `t_pickup_order_line` pl
|
||||
INNER JOIN `t_order` o ON o.`Id` = pl.`OrderId`
|
||||
SET
|
||||
pl.`ServiceNo` = IFNULL(NULLIF(pl.`ServiceNo`, ''), o.`ServiceNo`),
|
||||
pl.`ClientNo` = IFNULL(NULLIF(pl.`ClientNo`, ''), o.`ClientNo`)
|
||||
WHERE pl.`IsDeleted` = 0
|
||||
AND (pl.`ServiceNo` IS NULL OR pl.`ServiceNo` = '' OR pl.`ClientNo` IS NULL OR pl.`ClientNo` = '');
|
||||
20
sql/migrate_user_wecom_kf_url.sql
Normal file
20
sql/migrate_user_wecom_kf_url.sql
Normal file
@ -0,0 +1,20 @@
|
||||
-- user 表:企业微信客服接入链接(幂等;列已存在则跳过)
|
||||
-- MySQL 5.7+ / 8.0
|
||||
|
||||
SET @db := DATABASE();
|
||||
|
||||
SET @col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db
|
||||
AND TABLE_NAME = 'user'
|
||||
AND COLUMN_NAME = 'WecomKfUrl'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col = 0,
|
||||
'ALTER TABLE `user` ADD COLUMN `WecomKfUrl` VARCHAR(512) NULL COMMENT ''企业微信客服接入链接''',
|
||||
'SELECT ''skip WecomKfUrl'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
72
src/Oms.Application/Dtos/Ai/AiDtos.cs
Normal file
72
src/Oms.Application/Dtos/Ai/AiDtos.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Ai;
|
||||
|
||||
public class AiProviderOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ProviderKey { get; set; } = string.Empty;
|
||||
|
||||
public string ProviderType { get; set; } = string.Empty;
|
||||
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
|
||||
public string? ApiKey { get; set; }
|
||||
|
||||
public string? ApiSecret { get; set; }
|
||||
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
|
||||
public class AiProviderSaveInput
|
||||
{
|
||||
[Required]
|
||||
public string ProviderKey { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string ProviderType { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
|
||||
public string? ApiKey { get; set; }
|
||||
|
||||
public string? ApiSecret { get; set; }
|
||||
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public class AiChatInput
|
||||
{
|
||||
[Required]
|
||||
public string ProviderKey { get; set; } = string.Empty;
|
||||
|
||||
public string? Model { get; set; }
|
||||
|
||||
[Required]
|
||||
public List<AiChatMessageInput> Messages { get; set; } = [];
|
||||
|
||||
public string Scene { get; set; } = "assistant";
|
||||
}
|
||||
|
||||
public class AiChatMessageInput
|
||||
{
|
||||
public string Role { get; set; } = "user";
|
||||
|
||||
public string Content { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class AiChatOutput
|
||||
{
|
||||
public string Content { get; set; } = string.Empty;
|
||||
}
|
||||
70
src/Oms.Application/Dtos/Ai/AiSkillDtos.cs
Normal file
70
src/Oms.Application/Dtos/Ai/AiSkillDtos.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Ai;
|
||||
|
||||
public class AiSkillOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string SkillKey { get; set; } = string.Empty;
|
||||
|
||||
public string Scene { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public string Content { get; set; } = string.Empty;
|
||||
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
|
||||
public class AiSkillListInput
|
||||
{
|
||||
/// <summary>可选场景过滤</summary>
|
||||
public string? Scene { get; set; }
|
||||
|
||||
/// <summary>是否包含正文;调用方列表可 false,管理页 true</summary>
|
||||
public bool IncludeContent { get; set; } = true;
|
||||
|
||||
/// <summary>是否仅启用</summary>
|
||||
public bool EnabledOnly { get; set; }
|
||||
}
|
||||
|
||||
public class AiSkillGetInput
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? SkillKey { get; set; }
|
||||
}
|
||||
|
||||
public class AiSkillSaveInput
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string SkillKey { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Scene { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Content { get; set; } = string.Empty;
|
||||
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public class AiSkillDeleteInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
@ -23,6 +23,14 @@ public class IssueTemplateOutput
|
||||
|
||||
public List<string> NotifyMethods { get; set; } = [];
|
||||
|
||||
public string? HandlerType { get; set; }
|
||||
|
||||
public string? HandlerTypeName { get; set; }
|
||||
|
||||
public int? HandlerUserId { get; set; }
|
||||
|
||||
public string? HandlerUserName { get; set; }
|
||||
|
||||
public byte Status { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
@ -19,5 +19,9 @@ public class IssueTemplateSaveInput
|
||||
|
||||
public string? NotifyMethod { get; set; }
|
||||
|
||||
public string? HandlerType { get; set; }
|
||||
|
||||
public int? HandlerUserId { get; set; }
|
||||
|
||||
public EnableStatus Status { get; set; } = EnableStatus.Enabled;
|
||||
}
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Channels;
|
||||
|
||||
/// <summary>
|
||||
/// 销售产品计费模拟入参(基于当前库内卖价,非必须已发布)。
|
||||
/// </summary>
|
||||
public class SalesProductBillingSimulateInput
|
||||
{
|
||||
[Required]
|
||||
public int SalesProductId { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(8)]
|
||||
public string CountryCode { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(64)]
|
||||
public string? Province { get; set; }
|
||||
|
||||
[StringLength(64)]
|
||||
public string? City { get; set; }
|
||||
|
||||
[StringLength(32)]
|
||||
public string? ZipCode { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal Length { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal Width { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal Height { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal ActualWeight { get; set; }
|
||||
|
||||
[StringLength(32)]
|
||||
public string? CargoAttribute { get; set; }
|
||||
|
||||
public int? WarehouseId { get; set; }
|
||||
|
||||
public List<string>? AdditionalServices { get; set; }
|
||||
|
||||
public decimal? DeclaredSum { get; set; }
|
||||
|
||||
[StringLength(16)]
|
||||
public string? DeclaredCurrency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可选覆盖是否偏远;未传时按产品偏远分区命中。
|
||||
/// </summary>
|
||||
public bool? IsRemote { get; set; }
|
||||
|
||||
[StringLength(64)]
|
||||
public string? PriceTierKey { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销售产品计费模拟出参。
|
||||
/// </summary>
|
||||
public class SalesProductBillingSimulateOutput
|
||||
{
|
||||
public decimal ChargeableWeight { get; set; }
|
||||
|
||||
public List<string> ZoneKeys { get; set; } = [];
|
||||
|
||||
public bool IsRemote { get; set; }
|
||||
|
||||
public List<SalesProductBillingSimulateFeeOutput> ReceivableFees { get; set; } = [];
|
||||
|
||||
public List<SalesProductBillingSimulateFeeOutput> PayableFees { get; set; } = [];
|
||||
|
||||
public Dictionary<string, decimal> ReceivableTotal { get; set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public Dictionary<string, decimal> PayableTotal { get; set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// 同币种毛利(应收合计 - 应付合计);多币种时为 null。
|
||||
/// </summary>
|
||||
public decimal? Margin { get; set; }
|
||||
|
||||
public List<string> Warnings { get; set; } = [];
|
||||
}
|
||||
|
||||
public class SalesProductBillingSimulateFeeOutput
|
||||
{
|
||||
public string CostItem { get; set; } = string.Empty;
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
public string Currency { get; set; } = string.Empty;
|
||||
|
||||
public string? Formula { get; set; }
|
||||
}
|
||||
@ -40,6 +40,16 @@ public class SalesProductDetailOutput
|
||||
/// </summary>
|
||||
public string? TradeTerms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路排序,数值越小越靠前。
|
||||
/// </summary>
|
||||
public int RouteSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可选附加服务字典 code JSON 数组。
|
||||
/// </summary>
|
||||
public string? AdditionalServices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统面单类型。
|
||||
/// </summary>
|
||||
|
||||
@ -35,6 +35,16 @@ public class SalesProductListOutput
|
||||
/// </summary>
|
||||
public int? MaxTimeliness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路排序,数值越小越靠前。
|
||||
/// </summary>
|
||||
public int RouteSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可选附加服务字典 code JSON 数组。
|
||||
/// </summary>
|
||||
public string? AdditionalServices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统面单类型。
|
||||
/// </summary>
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
namespace Oms.Application.Dtos.Channels;
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路目录出参(公开字段)。
|
||||
/// </summary>
|
||||
public class SalesProductPortalCatalogOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 分组列表(已排除国内揽收,且仅含有产品的分组)。
|
||||
/// </summary>
|
||||
public List<SalesProductPortalGroupOutput> Groups { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 启用中的销售产品(已排除国内揽收)。
|
||||
/// </summary>
|
||||
public List<SalesProductPortalItemOutput> Items { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路分组。
|
||||
/// </summary>
|
||||
public class SalesProductPortalGroupOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 分组编码(字典 code)。
|
||||
/// </summary>
|
||||
public string Code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组名称。
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路产品卡片字段。
|
||||
/// </summary>
|
||||
public class SalesProductPortalItemOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键。
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称。
|
||||
/// </summary>
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 产品分组编码。
|
||||
/// </summary>
|
||||
public string? ProductGroup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品分组名称。
|
||||
/// </summary>
|
||||
public string ProductGroupName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 最小时效(天)。
|
||||
/// </summary>
|
||||
public int? MinTimeliness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大时效(天)。
|
||||
/// </summary>
|
||||
public int? MaxTimeliness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 贸易条款(DDP/DDU)。
|
||||
/// </summary>
|
||||
public string? TradeTerms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路排序,数值越小越靠前。
|
||||
/// </summary>
|
||||
public int RouteSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品说明。
|
||||
/// </summary>
|
||||
public string? ProductDescription { get; set; }
|
||||
}
|
||||
@ -15,6 +15,11 @@ public class SalesProductPriceSaveAllInput
|
||||
/// </summary>
|
||||
public bool Publish { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 价格发布 AI 风险分析报告(Publish=true 时必填)。
|
||||
/// </summary>
|
||||
public string? AiAnalysisReport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 价格项集合。
|
||||
/// </summary>
|
||||
|
||||
@ -19,4 +19,9 @@ public class SalesProductPublishInput
|
||||
/// 描述。
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 价格发布 AI 风险分析报告(operatorType=price 时必填)。
|
||||
/// </summary>
|
||||
public string? AiAnalysisReport { get; set; }
|
||||
}
|
||||
|
||||
@ -45,6 +45,11 @@ public class SalesProductPublishRecordOutput
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 价格发布 AI 风险分析报告。
|
||||
/// </summary>
|
||||
public string? AiAnalysisReport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 内容。
|
||||
/// </summary>
|
||||
|
||||
@ -42,6 +42,16 @@ public class SalesProductSaveInput
|
||||
/// </summary>
|
||||
public string? TradeTerms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路排序,数值越小越靠前。
|
||||
/// </summary>
|
||||
public int RouteSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可选附加服务字典 code JSON 数组。
|
||||
/// </summary>
|
||||
public string? AdditionalServices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统面单类型(旧枚举字段,兼容展示)。
|
||||
/// </summary>
|
||||
|
||||
@ -55,6 +55,11 @@ public class ServiceChannelDetailOutput
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 偏远分区 KPI AreaId。
|
||||
/// </summary>
|
||||
public int? RemoteAreaId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预处理脚本。
|
||||
/// </summary>
|
||||
|
||||
@ -55,6 +55,11 @@ public class ServiceChannelListOutput
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 偏远分区 KPI AreaId。
|
||||
/// </summary>
|
||||
public int? RemoteAreaId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用。
|
||||
/// </summary>
|
||||
|
||||
@ -52,6 +52,11 @@ public class ServiceChannelSaveInput
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 偏远分区 KPI AreaId。
|
||||
/// </summary>
|
||||
public int? RemoteAreaId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预处理脚本。
|
||||
/// </summary>
|
||||
|
||||
@ -118,4 +118,10 @@ public class CreateCustomerInput
|
||||
[StringLength(16)]
|
||||
public string? InviteCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 顾问邀请码(所属顾问绑定,值为员工 Account;仅 CustomerService 为空时生效)。
|
||||
/// </summary>
|
||||
[StringLength(64)]
|
||||
public string? AdvisorCode { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@ -19,4 +19,9 @@ public class CustomerServiceAdvisorOutput
|
||||
/// 微信二维码(URL 或 Base64)。
|
||||
/// </summary>
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 企业微信客服接入链接。
|
||||
/// </summary>
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
|
||||
@ -32,12 +32,32 @@ public class ReceivablePayablePaginatedInput
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单创建时间起。
|
||||
/// 客户编码关键词(模糊匹配)。
|
||||
/// </summary>
|
||||
public string? CustomerCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仅保留各运单费用项的当前生效阶段。
|
||||
/// </summary>
|
||||
public bool EffectiveStageOnly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单创建时间起(timeField=createTime 时生效,兼容旧参数)。
|
||||
/// </summary>
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单创建时间止。
|
||||
/// 订单创建时间止(timeField=createTime 时生效,兼容旧参数)。
|
||||
/// </summary>
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间筛选字段:createTime / receiveTime / shipTime / payTime。
|
||||
/// </summary>
|
||||
public string? TimeField { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 支付状态:0 未支付,1 已支付。
|
||||
/// </summary>
|
||||
public int? IsPaid { get; set; }
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ namespace Oms.Application.Dtos.Finance;
|
||||
/// </summary>
|
||||
public class ReceivablePayablePaginatedOutput
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public string ServiceNo { get; set; } = string.Empty;
|
||||
|
||||
public string? ClientNo { get; set; }
|
||||
@ -37,6 +39,8 @@ public class ReceivablePayablePaginatedOutput
|
||||
|
||||
public string CostItem { get; set; } = string.Empty;
|
||||
|
||||
public string? CostItemName { get; set; }
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
public string Currency { get; set; } = string.Empty;
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
namespace Oms.Application.Dtos.Finance;
|
||||
|
||||
/// <summary>
|
||||
/// 应收应付汇总出参。
|
||||
/// </summary>
|
||||
public class ReceivablePayableSummaryOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 匹配筛选条件的费用明细总行数。
|
||||
/// </summary>
|
||||
public int TotalLines { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 按费用类型 + 币种汇总。
|
||||
/// </summary>
|
||||
public List<ReceivablePayableSummaryItemOutput> Items { get; set; } = [];
|
||||
}
|
||||
|
||||
public class ReceivablePayableSummaryItemOutput
|
||||
{
|
||||
public string FeeType { get; set; } = string.Empty;
|
||||
|
||||
public string? FeeTypeName { get; set; }
|
||||
|
||||
public string Currency { get; set; } = string.Empty;
|
||||
|
||||
public decimal TotalAmount { get; set; }
|
||||
|
||||
public int LineCount { get; set; }
|
||||
}
|
||||
138
src/Oms.Application/Dtos/Kb/KbDtos.cs
Normal file
138
src/Oms.Application/Dtos/Kb/KbDtos.cs
Normal file
@ -0,0 +1,138 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Kb;
|
||||
|
||||
public static class KbAudienceCodes
|
||||
{
|
||||
public const string Customer = "customer";
|
||||
public const string Internal = "internal";
|
||||
}
|
||||
|
||||
public static class KbArticleStatusCodes
|
||||
{
|
||||
public const string Draft = "draft";
|
||||
public const string Published = "published";
|
||||
public const string Offline = "offline";
|
||||
}
|
||||
|
||||
public class KbCategoryOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int SortOrder { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
|
||||
public class KbCategorySaveInput
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Code { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public class KbCategoryDeleteInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class KbArticleOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CategoryId { get; set; }
|
||||
public string? CategoryName { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string? Summary { get; set; }
|
||||
public string? Content { get; set; }
|
||||
public string Audience { get; set; } = KbAudienceCodes.Customer;
|
||||
public string Status { get; set; } = KbArticleStatusCodes.Draft;
|
||||
public string? Tags { get; set; }
|
||||
public string? RelatedPath { get; set; }
|
||||
public string? RelatedLabel { get; set; }
|
||||
public bool IsPinned { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
public DateTime? PublishTime { get; set; }
|
||||
public DateTime? ExpireTime { get; set; }
|
||||
public int ViewCount { get; set; }
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
}
|
||||
|
||||
public class KbArticleListInput
|
||||
{
|
||||
public int Page { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 30;
|
||||
public string? Keyword { get; set; }
|
||||
public int? CategoryId { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public string? Audience { get; set; }
|
||||
public bool? IsPinned { get; set; }
|
||||
public bool IncludeContent { get; set; }
|
||||
}
|
||||
|
||||
public class KbArticleSaveInput
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CategoryId { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public string? Summary { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Content { get; set; } = string.Empty;
|
||||
|
||||
public string Audience { get; set; } = KbAudienceCodes.Customer;
|
||||
|
||||
public string Status { get; set; } = KbArticleStatusCodes.Draft;
|
||||
|
||||
public string? Tags { get; set; }
|
||||
|
||||
public string? RelatedPath { get; set; }
|
||||
|
||||
public string? RelatedLabel { get; set; }
|
||||
|
||||
public bool IsPinned { get; set; }
|
||||
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
public DateTime? ExpireTime { get; set; }
|
||||
}
|
||||
|
||||
public class KbArticleIdInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class KbArticlePinInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
public bool IsPinned { get; set; }
|
||||
}
|
||||
|
||||
public class KbPortalArticleListInput
|
||||
{
|
||||
public int Page { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 20;
|
||||
public string? Keyword { get; set; }
|
||||
public int? CategoryId { get; set; }
|
||||
}
|
||||
|
||||
public class KbPortalHotInput
|
||||
{
|
||||
public int Top { get; set; } = 10;
|
||||
}
|
||||
@ -59,4 +59,9 @@ public class InboundOrderLookupOutput
|
||||
/// 订单状态名称。
|
||||
/// </summary>
|
||||
public string? OrderStatusName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 待排货/计费失败原因。
|
||||
/// </summary>
|
||||
public string? AllocationPendingReason { get; set; }
|
||||
}
|
||||
|
||||
@ -75,6 +75,26 @@ public class InboundRecordOutput
|
||||
/// </summary>
|
||||
public string? OperatorName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单主键。
|
||||
/// </summary>
|
||||
public int? OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单状态码。
|
||||
/// </summary>
|
||||
public string? OrderStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单状态名称。
|
||||
/// </summary>
|
||||
public string? OrderStatusName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 待排货/计费失败原因(有则展示)。
|
||||
/// </summary>
|
||||
public string? AllocationPendingReason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间。
|
||||
/// </summary>
|
||||
|
||||
313
src/Oms.Application/Dtos/Orders/Customs9610Dtos.cs
Normal file
313
src/Oms.Application/Dtos/Orders/Customs9610Dtos.cs
Normal file
@ -0,0 +1,313 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
public class Customs9610ListInput
|
||||
{
|
||||
public int Page { get; set; } = 1;
|
||||
|
||||
public int PageSize { get; set; } = 30;
|
||||
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// pending / declared;空=全部。
|
||||
/// </summary>
|
||||
public string? Status { get; set; }
|
||||
|
||||
public string? Keyword { get; set; }
|
||||
|
||||
public DateTime? CreateTimeStart { get; set; }
|
||||
|
||||
public DateTime? CreateTimeEnd { get; set; }
|
||||
}
|
||||
|
||||
public class Customs9610IdInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class Customs9610IdsInput
|
||||
{
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<int> Ids { get; set; } = [];
|
||||
}
|
||||
|
||||
public class Customs9610StatusCountsOutput
|
||||
{
|
||||
public int Total { get; set; }
|
||||
|
||||
public int Pending { get; set; }
|
||||
|
||||
public int Declared { get; set; }
|
||||
}
|
||||
|
||||
public class Customs9610ItemInput
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public int? OrderDeclarationId { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(32)]
|
||||
public string Sku { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[StringLength(250)]
|
||||
public string CnName { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(10)]
|
||||
public string? ExHsCode { get; set; }
|
||||
|
||||
[StringLength(255)]
|
||||
public string? DeclareElement { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal UnitPrice { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
public decimal? Freight { get; set; }
|
||||
|
||||
public int SortNo { get; set; }
|
||||
}
|
||||
|
||||
public class Customs9610UpdateInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(16)]
|
||||
public string PlatformCode { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(18)]
|
||||
public string? EcomCorpCode { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string? EcomCorpName { get; set; }
|
||||
|
||||
[StringLength(18)]
|
||||
public string? ProducerCode { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string? ProducerName { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(48)]
|
||||
public string ClientNo { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[StringLength(48)]
|
||||
public string ServiceNo { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[StringLength(1)]
|
||||
public string BusinessType { get; set; } = "B";
|
||||
|
||||
[StringLength(10)]
|
||||
public string? Region { get; set; }
|
||||
|
||||
[StringLength(2)]
|
||||
public string? AgentDeclare { get; set; }
|
||||
|
||||
[StringLength(18)]
|
||||
public string? ActualSellerCode { get; set; }
|
||||
|
||||
[StringLength(1)]
|
||||
public string? PreRecordFlag { get; set; }
|
||||
|
||||
public bool IsSummarySimple { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal GrossWeight { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(4)]
|
||||
public string Currency { get; set; } = "CNY";
|
||||
|
||||
[Required]
|
||||
[StringLength(4)]
|
||||
public string DestCountry { get; set; } = string.Empty;
|
||||
|
||||
public decimal? Freight { get; set; }
|
||||
|
||||
[StringLength(32)]
|
||||
public string? ShipmentNo { get; set; }
|
||||
|
||||
[MinLength(1)]
|
||||
public List<Customs9610ItemInput> Items { get; set; } = [];
|
||||
}
|
||||
|
||||
public class Customs9610ItemOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int? OrderDeclarationId { get; set; }
|
||||
|
||||
public string Sku { get; set; } = string.Empty;
|
||||
|
||||
public string CnName { get; set; } = string.Empty;
|
||||
|
||||
public string? ExHsCode { get; set; }
|
||||
|
||||
public string? DeclareElement { get; set; }
|
||||
|
||||
public string? Barcode { get; set; }
|
||||
|
||||
public string? DestCountry { get; set; }
|
||||
|
||||
public string? ItemCurrency { get; set; }
|
||||
|
||||
public decimal UnitPrice { get; set; }
|
||||
|
||||
public decimal? Amount { get; set; }
|
||||
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
public decimal? LegalQty { get; set; }
|
||||
|
||||
public string? Unit { get; set; }
|
||||
|
||||
public string? LegalUnit { get; set; }
|
||||
|
||||
public decimal? Freight { get; set; }
|
||||
|
||||
public int SortNo { get; set; }
|
||||
}
|
||||
|
||||
public class Customs9610OrderOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public string? ServiceNo { get; set; }
|
||||
|
||||
public int CustomerId { get; set; }
|
||||
|
||||
public string? CustomerName { get; set; }
|
||||
|
||||
public string Status { get; set; } = string.Empty;
|
||||
|
||||
public string PlatformCode { get; set; } = string.Empty;
|
||||
|
||||
public string? EcomCorpCode { get; set; }
|
||||
|
||||
public string? EcomCorpName { get; set; }
|
||||
|
||||
public string? ProducerCode { get; set; }
|
||||
|
||||
public string? ProducerName { get; set; }
|
||||
|
||||
public string ClientNo { get; set; } = string.Empty;
|
||||
|
||||
public string BusinessType { get; set; } = "B";
|
||||
|
||||
public string? Region { get; set; }
|
||||
|
||||
public string? AgentDeclare { get; set; }
|
||||
|
||||
public string? ActualSellerCode { get; set; }
|
||||
|
||||
public string? PreRecordFlag { get; set; }
|
||||
|
||||
public bool IsSummarySimple { get; set; }
|
||||
|
||||
public decimal GrossWeight { get; set; }
|
||||
|
||||
public string Currency { get; set; } = "CNY";
|
||||
|
||||
public string DestCountry { get; set; } = string.Empty;
|
||||
|
||||
public decimal? Freight { get; set; }
|
||||
|
||||
public string? FreightCurrency { get; set; }
|
||||
|
||||
public int? FreightMark { get; set; }
|
||||
|
||||
public int? PackageType { get; set; }
|
||||
|
||||
public int? PackageQty { get; set; }
|
||||
|
||||
public string? ShipmentNo { get; set; }
|
||||
|
||||
public string? CustomsOrderNo { get; set; }
|
||||
|
||||
public string? DownstreamRefNo { get; set; }
|
||||
|
||||
public string? EnterpriseBizNo { get; set; }
|
||||
|
||||
public string? ManifestNo { get; set; }
|
||||
|
||||
public string? ClearanceTime { get; set; }
|
||||
|
||||
public string? CustomsInboundTime { get; set; }
|
||||
|
||||
public string? CustomsState { get; set; }
|
||||
|
||||
public string? DeclareCustomsCode { get; set; }
|
||||
|
||||
public string? PlatformCorpCode { get; set; }
|
||||
|
||||
public string? PlatformName { get; set; }
|
||||
|
||||
public string? LogisticsCorpCode { get; set; }
|
||||
|
||||
public string? LogisticsCorpName { get; set; }
|
||||
|
||||
public string? IeMark { get; set; }
|
||||
|
||||
public string? ExportPortCode { get; set; }
|
||||
|
||||
public string? ExportDate { get; set; }
|
||||
|
||||
public string? DeclareAgentCode { get; set; }
|
||||
|
||||
public string? DeclareAgentName { get; set; }
|
||||
|
||||
public string? TradeModeCode { get; set; }
|
||||
|
||||
public string? TransportMode { get; set; }
|
||||
|
||||
public DateTime? DeclareTime { get; set; }
|
||||
|
||||
public DateTime? ManifestSyncTime { get; set; }
|
||||
|
||||
public string? FailReason { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
public List<Customs9610ItemOutput>? Items { get; set; }
|
||||
}
|
||||
|
||||
public class Customs9610DeclareResult
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public bool Success { get; set; }
|
||||
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public string? CustomsOrderNo { get; set; }
|
||||
|
||||
public string? Status { get; set; }
|
||||
|
||||
public int? HttpStatusCode { get; set; }
|
||||
|
||||
public string? ResponseBody { get; set; }
|
||||
}
|
||||
|
||||
public class Customs9610DeclareBatchOutput
|
||||
{
|
||||
public int SuccessCount { get; set; }
|
||||
|
||||
public int FailCount { get; set; }
|
||||
|
||||
public List<Customs9610DeclareResult> Items { get; set; } = [];
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 工作台代发订单统计。
|
||||
/// </summary>
|
||||
public class FulfillWorkplaceStatsOutput
|
||||
{
|
||||
/// <summary>待绑定包裹/库存。</summary>
|
||||
public int PendingBind { get; set; }
|
||||
|
||||
/// <summary>国内快递在途。</summary>
|
||||
public int DomesticInTransit { get; set; }
|
||||
|
||||
/// <summary>已到仓,待仓库拣货。</summary>
|
||||
public int ArrivedPendingPick { get; set; }
|
||||
|
||||
/// <summary>已出库(拣货扣减完成)。</summary>
|
||||
public int OutboundDone { get; set; }
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 未付款订单更新附加服务入参。
|
||||
/// </summary>
|
||||
public class OrderAdditionalServicesUpdateInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单主键。
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附加服务字典 code 列表。
|
||||
/// </summary>
|
||||
public List<string>? AdditionalServices { get; set; }
|
||||
}
|
||||
84
src/Oms.Application/Dtos/Orders/OrderAllocationTraceDtos.cs
Normal file
84
src/Oms.Application/Dtos/Orders/OrderAllocationTraceDtos.cs
Normal file
@ -0,0 +1,84 @@
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 订单排货过程(快照或现算)。
|
||||
/// </summary>
|
||||
public class OrderAllocationTraceOutput
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>true=历史快照;false=按当前规则现算。</summary>
|
||||
public bool FromSnapshot { get; set; }
|
||||
|
||||
public string? Scheme { get; set; }
|
||||
|
||||
public string? SchemeName { get; set; }
|
||||
|
||||
/// <summary>productDefault / reallocate / designated</summary>
|
||||
public string? SchemeSource { get; set; }
|
||||
|
||||
public string? SchemeSourceName { get; set; }
|
||||
|
||||
public decimal? ChargeableWeight { get; set; }
|
||||
|
||||
/// <summary>订单解析出的价格分区键(用于对照买价明细分区)。</summary>
|
||||
public List<string> ZoneKeys { get; set; } = [];
|
||||
|
||||
public string? ChargingStage { get; set; }
|
||||
|
||||
public string? ChargingStageName { get; set; }
|
||||
|
||||
public string? SelectedChannelCode { get; set; }
|
||||
|
||||
public string? SelectedChannelName { get; set; }
|
||||
|
||||
public string? FailReason { get; set; }
|
||||
|
||||
public DateTime? TraceTime { get; set; }
|
||||
|
||||
public List<OrderAllocationCandidateOutput> Candidates { get; set; } = [];
|
||||
|
||||
public List<OrderAllocationSkippedOutput> Skipped { get; set; } = [];
|
||||
}
|
||||
|
||||
public class OrderAllocationCandidateOutput
|
||||
{
|
||||
public int ServiceChannelId { get; set; }
|
||||
|
||||
public string ChannelCode { get; set; } = string.Empty;
|
||||
|
||||
public string? ChannelName { get; set; }
|
||||
|
||||
/// <summary>应付合计(价格优先主指标)。</summary>
|
||||
public decimal TotalPayableCost { get; set; }
|
||||
|
||||
/// <summary>时效天数(时效优先主指标)。</summary>
|
||||
public int? MinTime { get; set; }
|
||||
|
||||
/// <summary>综合权重(综合最优主指标)。</summary>
|
||||
public int Weight { get; set; }
|
||||
|
||||
public bool Selected { get; set; }
|
||||
|
||||
public List<OrderAllocationFeeLineOutput> FeeLines { get; set; } = [];
|
||||
}
|
||||
|
||||
public class OrderAllocationSkippedOutput
|
||||
{
|
||||
public int? ServiceChannelId { get; set; }
|
||||
|
||||
public string? ChannelCode { get; set; }
|
||||
|
||||
public string? ChannelName { get; set; }
|
||||
|
||||
public string Reason { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class OrderAllocationFeeLineOutput
|
||||
{
|
||||
public string? CostItem { get; set; }
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
public string? Currency { get; set; }
|
||||
}
|
||||
@ -29,6 +29,67 @@ public class OrderMarkProblematicInput
|
||||
public string? Content { get; set; }
|
||||
|
||||
public string? Remark { get; set; }
|
||||
|
||||
public string? HandlerNames { get; set; }
|
||||
}
|
||||
|
||||
public class OrderExceptionEventProcessInput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? Remark { get; set; }
|
||||
}
|
||||
|
||||
public class OrderExceptionEventOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public string EventType { get; set; } = string.Empty;
|
||||
|
||||
public string? IssueType { get; set; }
|
||||
|
||||
public string? IssueTypeName { get; set; }
|
||||
|
||||
public string? Title { get; set; }
|
||||
|
||||
public string? Content { get; set; }
|
||||
|
||||
public string? NotifyMethod { get; set; }
|
||||
|
||||
public string? NotifyMethodNames { get; set; }
|
||||
|
||||
public string? HandlerNames { get; set; }
|
||||
|
||||
public string? HandlerType { get; set; }
|
||||
|
||||
public string? HandlerTypeName { get; set; }
|
||||
|
||||
public int? HandlerUserId { get; set; }
|
||||
|
||||
public string? HandleStatus { get; set; }
|
||||
|
||||
public string? HandleStatusName { get; set; }
|
||||
|
||||
public string? CreateBy { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public string? ProcessedBy { get; set; }
|
||||
|
||||
public DateTime? ProcessedTime { get; set; }
|
||||
|
||||
public string? Remark { get; set; }
|
||||
}
|
||||
|
||||
public class OrderExceptionEventListOutput
|
||||
{
|
||||
public List<OrderExceptionEventOutput> Items { get; set; } = [];
|
||||
|
||||
public int PendingCount { get; set; }
|
||||
|
||||
public int ProcessedCount { get; set; }
|
||||
}
|
||||
|
||||
public class OrderMarkClaimedInput
|
||||
|
||||
@ -17,6 +17,19 @@ public class OrderExportInput
|
||||
[Newtonsoft.Json.JsonProperty("orderSource")]
|
||||
public string? OrderSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 履约类型:all / direct / warehouse。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("fulfillmentType")]
|
||||
public string? FulfillmentType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代发进度筛选(pendingBind / domesticInTransit / arrivedPendingPick / outboundDone)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("fulfillProgress")]
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("fulfillProgress")]
|
||||
public string? FulfillProgress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关键词。
|
||||
/// </summary>
|
||||
|
||||
@ -51,10 +51,20 @@ public class OrderItemOutput
|
||||
public decimal? Weight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// HS 编码。
|
||||
/// HS 编码(兼容旧字段,优先出口编码)。
|
||||
/// </summary>
|
||||
public string? HsCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进口 HS 编码。
|
||||
/// </summary>
|
||||
public string? ImHsCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出口 HS 编码。
|
||||
/// </summary>
|
||||
public string? ExHsCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SKU 图片。
|
||||
/// </summary>
|
||||
|
||||
@ -40,6 +40,11 @@ public class OrderOutput
|
||||
/// </summary>
|
||||
public string? ProductName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 销售产品最大时效(天)。
|
||||
/// </summary>
|
||||
public int? MaxTimeliness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 渠道编码。
|
||||
/// </summary>
|
||||
@ -125,6 +130,71 @@ public class OrderOutput
|
||||
/// </summary>
|
||||
public int? CustomerSenderAddressId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 到仓方式:selfShip / doorPickup。
|
||||
/// </summary>
|
||||
public string? InboundMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 履约类型:direct / warehouse。
|
||||
/// </summary>
|
||||
public string? FulfillmentType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代发来源:storeFulfill / postBind。
|
||||
/// </summary>
|
||||
public string? FulfillmentSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绑定状态聚合:none / bound / deducted。
|
||||
/// </summary>
|
||||
public string? StockBindStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绑定行数。
|
||||
/// </summary>
|
||||
public int StockBindLineCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绑定件数合计。
|
||||
/// </summary>
|
||||
public int StockBindQtyTotal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 国内快递单号(绑定行去重,逗号分隔)。
|
||||
/// </summary>
|
||||
public string? DomesticTrackingNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代发进度:pendingBind / domesticInTransit / arrivedPendingPick / outboundDone。
|
||||
/// </summary>
|
||||
public string? FulfillProgress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主拣货库位(绑定行最小 BinCode,供拣货队列排序展示)。
|
||||
/// </summary>
|
||||
public string? PrimaryBinCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绑定 SKU 编码汇总(逗号分隔,列表展示/拣货筛选用)。
|
||||
/// </summary>
|
||||
public string? PrimarySkuCodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联揽收单 Id。
|
||||
/// </summary>
|
||||
public int? PickupOrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联揽收系统单号(OMS PickupNo)。
|
||||
/// </summary>
|
||||
public string? PickupNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 国内承运商回执单号(揽收承运商运单号)。
|
||||
/// </summary>
|
||||
public string? CarrierWaybillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 幂等请求标识。
|
||||
/// </summary>
|
||||
@ -145,6 +215,16 @@ public class OrderOutput
|
||||
/// </summary>
|
||||
public string? AllocationPendingReason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最近一次排货方案。
|
||||
/// </summary>
|
||||
public string? AllocationScheme { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已有排货过程快照。
|
||||
/// </summary>
|
||||
public bool HasAllocationTrace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申报币种。
|
||||
/// </summary>
|
||||
@ -258,6 +338,26 @@ public class OrderOutput
|
||||
/// </summary>
|
||||
public bool IsRemote { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户勾选附加服务字典 code 列表。
|
||||
/// </summary>
|
||||
public List<string> AdditionalServices { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 是否勾选保险附加服务。
|
||||
/// </summary>
|
||||
public bool HasInsurance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预报应收快照(入库不覆盖)。
|
||||
/// </summary>
|
||||
public decimal? ForecastReceivableAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预报应付快照(入库不覆盖)。
|
||||
/// </summary>
|
||||
public decimal? ForecastPayableAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间。
|
||||
/// </summary>
|
||||
|
||||
@ -38,6 +38,27 @@ public class OrderPaginatedInput
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("orderSource")]
|
||||
public string? OrderSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 履约类型:all / direct / warehouse。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("fulfillmentType")]
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("fulfillmentType")]
|
||||
public string? FulfillmentType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绑定状态聚合:all / none / bound / deducted。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("stockBindStatus")]
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("stockBindStatus")]
|
||||
public string? StockBindStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代发进度:all / pendingBind / domesticInTransit / arrivedPendingPick / outboundDone。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("fulfillProgress")]
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("fulfillProgress")]
|
||||
public string? FulfillProgress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户 ID(管理端可选;不传则查全部)。
|
||||
/// </summary>
|
||||
@ -45,6 +66,13 @@ public class OrderPaginatedInput
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("customerId")]
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发货仓 ID(拣货队列等按仓筛选)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("warehouseId")]
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("warehouseId")]
|
||||
public int? WarehouseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关键词。
|
||||
/// </summary>
|
||||
@ -71,7 +99,7 @@ public class OrderPaginatedInput
|
||||
public List<OrderListFieldFilterDto>? Filters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序字段白名单:createTime / updateTime / serviceNo / clientNo / trackNo / payableAmount / payTime / shipTime / receiveTime / signTime。
|
||||
/// 排序字段白名单:createTime / updateTime / serviceNo / clientNo / trackNo / primaryBinCode / payableAmount / payTime / shipTime / receiveTime / signTime。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("sortField")]
|
||||
[global::System.Text.Json.Serialization.JsonPropertyName("sortField")]
|
||||
|
||||
@ -115,6 +115,16 @@ public class OrderParcelCreateInput
|
||||
/// </summary>
|
||||
public decimal? DeclaredSum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户勾选附加服务字典 code 列表(落库序列化为 JSON 数组)。
|
||||
/// </summary>
|
||||
public List<string>? AdditionalServices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否偏远(预计算后可写入,供下单前公式/计费条件求值)。
|
||||
/// </summary>
|
||||
public byte? IsRemote { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量。
|
||||
/// </summary>
|
||||
@ -144,4 +154,29 @@ public class OrderParcelCreateInput
|
||||
/// 仅保存为草稿,不执行预报计费与状态推进。
|
||||
/// </summary>
|
||||
public bool SaveAsDraft { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 到仓方式:selfShip / doorPickup。
|
||||
/// </summary>
|
||||
public string? InboundMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上门揽收时发件地址簿 Id。
|
||||
/// </summary>
|
||||
public int? SenderAddressId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 期望揽收时间(上门揽收)。
|
||||
/// </summary>
|
||||
public DateTime? ExpectPickupTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 承运商编码(可后补)。
|
||||
/// </summary>
|
||||
public string? CarrierCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 承运服务(可后补)。
|
||||
/// </summary>
|
||||
public string? CarrierService { get; set; }
|
||||
}
|
||||
|
||||
@ -39,4 +39,24 @@ public class OrderParcelCreateOutput
|
||||
/// 收件国家/地区中文名称。
|
||||
/// </summary>
|
||||
public string? ConsigneeCountryName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 同步创建的揽收单号(上门揽收成功时)。
|
||||
/// </summary>
|
||||
public string? PickupNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 同步创建的揽收单 Id。
|
||||
/// </summary>
|
||||
public int? PickupOrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 国内承运运单号(上门揽收时可选)。
|
||||
/// </summary>
|
||||
public string? CarrierWaybillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 揽收单创建失败原因(运单已成功时仅作提示)。
|
||||
/// </summary>
|
||||
public string? PickupCreateError { get; set; }
|
||||
}
|
||||
|
||||
@ -69,4 +69,19 @@ public class OrderPriceCheckInput
|
||||
/// 选用的优惠券实例 Id。
|
||||
/// </summary>
|
||||
public int? CouponInstanceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 勾选附加服务字典 code(用于计费条件求值)。
|
||||
/// </summary>
|
||||
public List<string>? AdditionalServices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申报总金额(百分比申报类公式)。
|
||||
/// </summary>
|
||||
public decimal? DeclaredSum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申报币种。
|
||||
/// </summary>
|
||||
public string? DeclaredCurrency { get; set; }
|
||||
}
|
||||
|
||||
@ -57,6 +57,11 @@ public class OrderPriceCheckOutput
|
||||
/// </summary>
|
||||
public string? ProductGroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品说明(线路简要说明,对客展示)。
|
||||
/// </summary>
|
||||
public string? ProductDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 体积重量。
|
||||
/// </summary>
|
||||
|
||||
59
src/Oms.Application/Dtos/Orders/OrderReallocateDtos.cs
Normal file
59
src/Oms.Application/Dtos/Orders/OrderReallocateDtos.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 单票重新排货入参。
|
||||
/// </summary>
|
||||
public class OrderReallocateInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排货方案:costLowest / timeFastest / overallBest / designated。
|
||||
/// </summary>
|
||||
[Required]
|
||||
[StringLength(32)]
|
||||
public string Scheme { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 指定渠道时必填。
|
||||
/// </summary>
|
||||
public int? ServiceChannelId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量重新排货入参(同步兜底)。
|
||||
/// </summary>
|
||||
public class OrderReallocateBatchInput
|
||||
{
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<int> OrderIds { get; set; } = [];
|
||||
|
||||
[Required]
|
||||
[StringLength(32)]
|
||||
public string Scheme { get; set; } = string.Empty;
|
||||
|
||||
public int? ServiceChannelId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询指定渠道可选项(按订单排货池交集)。
|
||||
/// </summary>
|
||||
public class OrderReallocateChannelOptionsInput
|
||||
{
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<int> OrderIds { get; set; } = [];
|
||||
}
|
||||
|
||||
public class OrderReallocateChannelOptionOutput
|
||||
{
|
||||
public int ServiceChannelId { get; set; }
|
||||
|
||||
public string ChannelCode { get; set; } = string.Empty;
|
||||
|
||||
public string? ChannelName { get; set; }
|
||||
}
|
||||
@ -17,6 +17,10 @@ public class OrderReceiverParseAddressInput
|
||||
/// <summary>可选模型覆盖。</summary>
|
||||
[MaxLength(128)]
|
||||
public string? Model { get; set; }
|
||||
|
||||
/// <summary>可选 Skill Key;为空时使用内置「oms-receiver-address-parse」。</summary>
|
||||
[MaxLength(128)]
|
||||
public string? SkillKey { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>地址解析结果 + 完整性校验。</summary>
|
||||
|
||||
@ -20,4 +20,10 @@ public class OrderStatusCountsOutput
|
||||
/// </summary>
|
||||
public Dictionary<string, OrderHandleStatusCountsOutput> HandleCounts { get; set; } =
|
||||
new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// 代发进度分组数量(fulfillmentType=warehouse 时返回)。
|
||||
/// </summary>
|
||||
public Dictionary<string, int> FulfillProgressCounts { get; set; } =
|
||||
new(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
@ -21,4 +21,9 @@ public class OrderUploadInput
|
||||
/// 默认发件地址 ID(地址管理中的发件人地址)。
|
||||
/// </summary>
|
||||
public int? SenderAddressId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户主键(管理端代客下单时必传)。
|
||||
/// </summary>
|
||||
public int? CustomerId { get; set; }
|
||||
}
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 工作台业务线趋势(运单 / 代发 / 揽收新增量)。
|
||||
/// </summary>
|
||||
public class OrderWorkplaceBusinessTrendOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 维度:day / week / month。
|
||||
/// </summary>
|
||||
public string Dimension { get; set; } = "day";
|
||||
|
||||
/// <summary>
|
||||
/// 趋势点(按时间正序)。
|
||||
/// </summary>
|
||||
public List<OrderWorkplaceBusinessTrendPointOutput> Points { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单个时间桶的三类业务量。
|
||||
/// </summary>
|
||||
public class OrderWorkplaceBusinessTrendPointOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 展示标签。
|
||||
/// </summary>
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 运单新增(非仓内代发)。
|
||||
/// </summary>
|
||||
public int WaybillCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代发订单新增(仓内履约)。
|
||||
/// </summary>
|
||||
public int FulfillCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 揽收单新增。
|
||||
/// </summary>
|
||||
public int PickupCount { get; set; }
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 工作台费用趋势(按日/周/月)。
|
||||
/// </summary>
|
||||
public class OrderWorkplaceSpendTrendOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 维度:day / week / month。
|
||||
/// </summary>
|
||||
public string Dimension { get; set; } = "day";
|
||||
|
||||
/// <summary>
|
||||
/// 区间合计:运费支出(客户应付)。
|
||||
/// </summary>
|
||||
public decimal TotalSpend { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区间合计:订单数。
|
||||
/// </summary>
|
||||
public int TotalOrders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区间合计:单票均价。
|
||||
/// </summary>
|
||||
public decimal AvgAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 趋势点(按时间正序)。
|
||||
/// </summary>
|
||||
public List<OrderWorkplaceSpendTrendPointOutput> Points { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单个时间桶的费用汇总。
|
||||
/// </summary>
|
||||
public class OrderWorkplaceSpendTrendPointOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 展示标签。
|
||||
/// </summary>
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 订单数(创建时间)。
|
||||
/// </summary>
|
||||
public int OrderCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 运费支出合计(Order.PayableAmount)。
|
||||
/// </summary>
|
||||
public decimal SpendAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单票均价。
|
||||
/// </summary>
|
||||
public decimal AvgAmount { get; set; }
|
||||
}
|
||||
@ -41,15 +41,20 @@ public class OrderWorkplaceStatsOutput
|
||||
public int Shipped { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 待上网数量。
|
||||
/// 待支付数量。
|
||||
/// </summary>
|
||||
public int PendingOnline { get; set; }
|
||||
public int PendingPayment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题件数量。
|
||||
/// </summary>
|
||||
public int Problematic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 理赔件数量。
|
||||
/// </summary>
|
||||
public int Claimed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 店铺数量。
|
||||
/// </summary>
|
||||
@ -59,4 +64,14 @@ public class OrderWorkplaceStatsOutput
|
||||
/// 店铺订单待处理数量(履约状态 pending)。
|
||||
/// </summary>
|
||||
public int StoreOrderPending { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代发订单统计(仓内履约)。
|
||||
/// </summary>
|
||||
public FulfillWorkplaceStatsOutput Fulfill { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 揽收订单统计。
|
||||
/// </summary>
|
||||
public PickupWorkplaceStatsOutput Pickup { get; set; } = new();
|
||||
}
|
||||
|
||||
290
src/Oms.Application/Dtos/Orders/PickupOrderDtos.cs
Normal file
290
src/Oms.Application/Dtos/Orders/PickupOrderDtos.cs
Normal file
@ -0,0 +1,290 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
public class PickupOrderCreateInput
|
||||
{
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求幂等键(可选)。
|
||||
/// </summary>
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int SenderAddressId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int WarehouseId { get; set; }
|
||||
|
||||
public string? CarrierCode { get; set; }
|
||||
|
||||
public string? CarrierService { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime ExpectPickupTime { get; set; }
|
||||
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<int> OrderIds { get; set; } = [];
|
||||
|
||||
[StringLength(512)]
|
||||
public string? Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可选:创建时直接写入对客运费(未写则保持未确认)。
|
||||
/// </summary>
|
||||
public decimal? FreightAmount { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderIdInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderIdsInput
|
||||
{
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<int> Ids { get; set; } = [];
|
||||
}
|
||||
|
||||
public class PickupOrderBatchPayItemOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? PickupNo { get; set; }
|
||||
|
||||
public bool Success { get; set; }
|
||||
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public decimal? Amount { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderBatchPayOutput
|
||||
{
|
||||
public int SuccessCount { get; set; }
|
||||
|
||||
public int FailCount { get; set; }
|
||||
|
||||
public decimal PaidAmount { get; set; }
|
||||
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public List<PickupOrderBatchPayItemOutput> Items { get; set; } = [];
|
||||
}
|
||||
|
||||
public class PickupOrderOrdersInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<int> OrderIds { get; set; } = [];
|
||||
}
|
||||
|
||||
public class PickupOrderListInput
|
||||
{
|
||||
public int Page { get; set; } = 1;
|
||||
|
||||
public int PageSize { get; set; } = 30;
|
||||
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
public string? Status { get; set; }
|
||||
|
||||
public string? PayStatus { get; set; }
|
||||
|
||||
public string? Keyword { get; set; }
|
||||
|
||||
public int? WarehouseId { get; set; }
|
||||
|
||||
public DateTime? CreateTimeStart { get; set; }
|
||||
|
||||
public DateTime? CreateTimeEnd { get; set; }
|
||||
|
||||
public DateTime? ExpectPickupTimeStart { get; set; }
|
||||
|
||||
public DateTime? ExpectPickupTimeEnd { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderStatusCountsOutput
|
||||
{
|
||||
public int Total { get; set; }
|
||||
|
||||
public int PendingPayment { get; set; }
|
||||
|
||||
public Dictionary<string, int> Counts { get; set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public class PickupOrderConfirmFreightInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal FreightAmount { get; set; }
|
||||
|
||||
public decimal? OtherFeeAmount { get; set; }
|
||||
|
||||
public decimal? CarrierPayableAmount { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderScheduleInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 兼容旧字段,已不再作为预约必填;承运服务改用销售产品编码。
|
||||
/// </summary>
|
||||
public string? CarrierCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 承运服务:国内揽收分组销售产品编码。
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string CarrierService { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 国内承运商回执单号(手工录入或对接返回)。
|
||||
/// </summary>
|
||||
public string? CarrierWaybillNo { get; set; }
|
||||
|
||||
public DateTime? ExpectPickupTime { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderRescheduleInput
|
||||
{
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime ExpectPickupTime { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderRejectItem
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public string? ServiceNo { get; set; }
|
||||
|
||||
public string Reason { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class PickupOrderLineOutput
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public string? ServiceNo { get; set; }
|
||||
|
||||
public string? ClientNo { get; set; }
|
||||
|
||||
public string? OrderStatus { get; set; }
|
||||
|
||||
public int? WarehouseId { get; set; }
|
||||
|
||||
public decimal? ChargeableWeight { get; set; }
|
||||
}
|
||||
|
||||
public class PickupOrderOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string PickupNo { get; set; } = string.Empty;
|
||||
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public int CustomerId { get; set; }
|
||||
|
||||
public string? CustomerName { get; set; }
|
||||
|
||||
public string? OrganizationId { get; set; }
|
||||
|
||||
public int SecretLevel { get; set; }
|
||||
|
||||
public int SenderAddressId { get; set; }
|
||||
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
public string? SenderPhone { get; set; }
|
||||
|
||||
public string? SenderTelePhone { get; set; }
|
||||
|
||||
public string? SenderEmail { get; set; }
|
||||
|
||||
public string? SenderCompany { get; set; }
|
||||
|
||||
public int? SenderCountry { get; set; }
|
||||
|
||||
public string? SenderCountryCode { get; set; }
|
||||
|
||||
public string? SenderProvince { get; set; }
|
||||
|
||||
public string? SenderCity { get; set; }
|
||||
|
||||
public string? SenderZipCode { get; set; }
|
||||
|
||||
public string? SenderStreetAddress1 { get; set; }
|
||||
|
||||
public string? SenderStreetAddress2 { get; set; }
|
||||
|
||||
public string? SenderStreetAddress3 { get; set; }
|
||||
|
||||
public string? SenderHouseNumber { get; set; }
|
||||
|
||||
public int WarehouseId { get; set; }
|
||||
|
||||
public string? WarehouseName { get; set; }
|
||||
|
||||
public string? CarrierCode { get; set; }
|
||||
|
||||
public string? CarrierService { get; set; }
|
||||
|
||||
public string? CarrierWaybillNo { get; set; }
|
||||
|
||||
public DateTime ExpectPickupTime { get; set; }
|
||||
|
||||
public DateTime? ActualPickupTime { get; set; }
|
||||
|
||||
public string Status { get; set; } = string.Empty;
|
||||
|
||||
public int ParcelCount { get; set; }
|
||||
|
||||
public decimal? TotalActualWeight { get; set; }
|
||||
|
||||
public decimal? ChargeableWeight { get; set; }
|
||||
|
||||
public string Currency { get; set; } = "CNY";
|
||||
|
||||
public decimal? FreightAmount { get; set; }
|
||||
|
||||
public decimal? OtherFeeAmount { get; set; }
|
||||
|
||||
public decimal? ReceivableAmount { get; set; }
|
||||
|
||||
public string PayStatus { get; set; } = string.Empty;
|
||||
|
||||
public DateTime? PayTime { get; set; }
|
||||
|
||||
public string PayMode { get; set; } = string.Empty;
|
||||
|
||||
public decimal? CarrierPayableAmount { get; set; }
|
||||
|
||||
public string SettlementStatus { get; set; } = string.Empty;
|
||||
|
||||
public string? SettlementBatchNo { get; set; }
|
||||
|
||||
public string? Remark { get; set; }
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
public List<PickupOrderLineOutput> Orders { get; set; } = [];
|
||||
|
||||
public List<PickupOrderRejectItem> Rejected { get; set; } = [];
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
namespace Oms.Application.Dtos.Orders;
|
||||
|
||||
/// <summary>
|
||||
/// 工作台揽收订单统计。
|
||||
/// </summary>
|
||||
public class PickupWorkplaceStatsOutput
|
||||
{
|
||||
/// <summary>待支付(有应收且未支付,不含取消/失败)。</summary>
|
||||
public int PendingPayment { get; set; }
|
||||
|
||||
/// <summary>草稿,待确认下发。</summary>
|
||||
public int PendingSchedule { get; set; }
|
||||
|
||||
/// <summary>已预约/已派单,待取件。</summary>
|
||||
public int PendingPickup { get; set; }
|
||||
|
||||
/// <summary>已取件,待到仓。</summary>
|
||||
public int PendingInbound { get; set; }
|
||||
}
|
||||
@ -147,6 +147,11 @@ public class PlatformStoreOrderListInput : PlatformStorePageInput
|
||||
{
|
||||
public int? StoreId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台编码:tiktok / temu / shopee / lazada;空或 all 表示全部。
|
||||
/// </summary>
|
||||
public string? PlatformCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 履约状态:pending / toShip / shipped / canceled / suspended / completed;空或 all 表示全部。
|
||||
/// </summary>
|
||||
@ -254,6 +259,12 @@ public class PlatformStoreOrderOutput
|
||||
|
||||
public string? LinkedServiceNo { get; set; }
|
||||
|
||||
/// <summary>列表摘要:首个商品名称。</summary>
|
||||
public string? FirstProductName { get; set; }
|
||||
|
||||
/// <summary>列表摘要:首个商品图片。</summary>
|
||||
public string? FirstProductImageUrl { get; set; }
|
||||
|
||||
public DateTime? LastSyncTime { get; set; }
|
||||
|
||||
public List<PlatformStoreOrderLineOutput> Lines { get; set; } = [];
|
||||
|
||||
@ -11,6 +11,11 @@ public class UserProfileData
|
||||
public string? WechatId { get; set; }
|
||||
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 企业微信客服接入链接(微信外接入)。
|
||||
/// </summary>
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
|
||||
public class OmsUserCreateInput : UserCreateDto
|
||||
@ -22,6 +27,8 @@ public class OmsUserCreateInput : UserCreateDto
|
||||
public string? WechatId { get; set; }
|
||||
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
|
||||
public class OmsUserUpdateInput : UserUpdateDto
|
||||
@ -31,6 +38,8 @@ public class OmsUserUpdateInput : UserUpdateDto
|
||||
public string? WechatId { get; set; }
|
||||
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
|
||||
public class OmsUserDetailDto : UserDto
|
||||
@ -42,4 +51,6 @@ public class OmsUserDetailDto : UserDto
|
||||
public string? WechatId { get; set; }
|
||||
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
|
||||
@ -32,14 +32,13 @@ public class NoticeCreateInput
|
||||
public byte IsPopup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接收对象类型:user/customer。
|
||||
/// 接收对象类型:user/customer。公告全体广播时可空(后端按 user 占位)。
|
||||
/// </summary>
|
||||
[Required]
|
||||
[StringLength(16)]
|
||||
public string ReceiverType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 接收主体 ID 列表。
|
||||
/// 接收主体 ID 列表。公告传空表示全体生效;站内信必填。
|
||||
/// </summary>
|
||||
public List<int> ReceiverIds { get; set; } = [];
|
||||
}
|
||||
|
||||
@ -29,4 +29,9 @@ public class NoticeListInput
|
||||
/// 关键词,匹配标题或内容。
|
||||
/// </summary>
|
||||
public string? Keyword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仅未读(相对当前登录主体)。
|
||||
/// </summary>
|
||||
public bool? OnlyUnread { get; set; }
|
||||
}
|
||||
|
||||
@ -60,6 +60,11 @@ public class NoticeOutput
|
||||
/// </summary>
|
||||
public int ReadCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前登录主体是否已读。
|
||||
/// </summary>
|
||||
public bool IsRead { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接收总人数。
|
||||
/// </summary>
|
||||
|
||||
@ -32,8 +32,16 @@ public class WarehouseSkuOutput
|
||||
|
||||
public string SkuName { get; set; } = string.Empty;
|
||||
|
||||
public string? SkuNameEn { get; set; }
|
||||
|
||||
public string? SkuImageUrl { get; set; }
|
||||
|
||||
public decimal? UnitPrice { get; set; }
|
||||
|
||||
public string? ExHsCode { get; set; }
|
||||
|
||||
public string? ImHsCode { get; set; }
|
||||
|
||||
public decimal? WeightG { get; set; }
|
||||
|
||||
public decimal? LengthCm { get; set; }
|
||||
@ -44,7 +52,7 @@ public class WarehouseSkuOutput
|
||||
|
||||
public string? Remark { get; set; }
|
||||
|
||||
public int TotalQty { get; set; }
|
||||
public int? TotalQty { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
@ -63,8 +71,16 @@ public class WarehouseSkuSaveInput
|
||||
[Required]
|
||||
public string SkuName { get; set; } = string.Empty;
|
||||
|
||||
public string? SkuNameEn { get; set; }
|
||||
|
||||
public string? SkuImageUrl { get; set; }
|
||||
|
||||
public decimal? UnitPrice { get; set; }
|
||||
|
||||
public string? ExHsCode { get; set; }
|
||||
|
||||
public string? ImHsCode { get; set; }
|
||||
|
||||
public decimal? WeightG { get; set; }
|
||||
|
||||
public decimal? LengthCm { get; set; }
|
||||
@ -563,6 +579,7 @@ public class WarehouseParcelArrivalListInput : WarehousePageInput
|
||||
|
||||
public class WarehouseParcelArrivalCreateInput
|
||||
{
|
||||
/// <summary>已废弃:到仓按仓库+快递单号定位包裹,客户归属取自包裹。</summary>
|
||||
public int? CustomerId { get; set; }
|
||||
|
||||
[Required]
|
||||
@ -591,4 +608,20 @@ public class WarehouseParcelArrivalOutput
|
||||
public int CreateUserId { get; set; }
|
||||
|
||||
public string? CreateBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 到仓包裹已绑定的代发物流单(bound 状态)。
|
||||
/// </summary>
|
||||
public List<WarehouseParcelArrivalLinkedOrderOutput> LinkedOrders { get; set; } = [];
|
||||
}
|
||||
|
||||
public class WarehouseParcelArrivalLinkedOrderOutput
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public string ServiceNo { get; set; } = string.Empty;
|
||||
|
||||
public string? ClientNo { get; set; }
|
||||
|
||||
public string? FulfillProgress { get; set; }
|
||||
}
|
||||
|
||||
@ -320,75 +320,6 @@ public class XhsSkillSaveInput
|
||||
public object? Recipe { get; set; }
|
||||
}
|
||||
|
||||
public class XhsAiProviderOutput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ProviderKey { get; set; } = string.Empty;
|
||||
|
||||
public string ProviderType { get; set; } = string.Empty;
|
||||
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
|
||||
public string? ApiKey { get; set; }
|
||||
|
||||
public string? ApiSecret { get; set; }
|
||||
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
|
||||
public class XhsAiProviderSaveInput
|
||||
{
|
||||
[Required]
|
||||
public string ProviderKey { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string ProviderType { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
|
||||
public string? ApiKey { get; set; }
|
||||
|
||||
public string? ApiSecret { get; set; }
|
||||
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public class XhsAiChatInput
|
||||
{
|
||||
[Required]
|
||||
public string ProviderKey { get; set; } = string.Empty;
|
||||
|
||||
public string? Model { get; set; }
|
||||
|
||||
[Required]
|
||||
public List<XhsAiChatMessageInput> Messages { get; set; } = [];
|
||||
|
||||
public string Scene { get; set; } = "assistant";
|
||||
}
|
||||
|
||||
public class XhsAiChatMessageInput
|
||||
{
|
||||
public string Role { get; set; } = "user";
|
||||
|
||||
public string Content { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class XhsAiChatOutput
|
||||
{
|
||||
public string Content { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class XhsAnalysisStartInput
|
||||
{
|
||||
[Required]
|
||||
|
||||
@ -21,4 +21,15 @@ public interface IItfxForwardClient
|
||||
string appSecret,
|
||||
object body,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// 通用 ForwardWithSubscribe(standardCode 可配,如 9610 申报暂定码)。
|
||||
/// </summary>
|
||||
Task<ItfxForwardResult> ForwardWithSubscribeAsync(
|
||||
string standardCode,
|
||||
string supplierCode,
|
||||
string appKey,
|
||||
string appSecret,
|
||||
object body,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
@ -21,7 +21,24 @@ internal sealed class ItfxForwardClient(
|
||||
WriteIndented = true
|
||||
};
|
||||
|
||||
public async Task<ItfxForwardResult> ForwardCreateOrderOneAsync(
|
||||
public Task<ItfxForwardResult> ForwardCreateOrderOneAsync(
|
||||
string supplierCode,
|
||||
string appKey,
|
||||
string appSecret,
|
||||
object body,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return ForwardWithSubscribeAsync(
|
||||
CreateOrderOneStandardCode,
|
||||
supplierCode,
|
||||
appKey,
|
||||
appSecret,
|
||||
body,
|
||||
cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<ItfxForwardResult> ForwardWithSubscribeAsync(
|
||||
string standardCode,
|
||||
string supplierCode,
|
||||
string appKey,
|
||||
string appSecret,
|
||||
@ -34,9 +51,19 @@ internal sealed class ItfxForwardClient(
|
||||
throw new InvalidOperationException("Itfx BaseUrl not configured");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(standardCode))
|
||||
{
|
||||
throw new InvalidOperationException("Itfx standardCode is empty");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(supplierCode))
|
||||
{
|
||||
throw new InvalidOperationException("Itfx supplierCode is empty");
|
||||
}
|
||||
|
||||
var root = $"{settings.BaseUrl.Trim().TrimEnd('/')}/InterfaceForward/ForwardWithSubscribe";
|
||||
var url =
|
||||
$"{root}?standardCode={CreateOrderOneStandardCode}&supplierCode={Uri.EscapeDataString(supplierCode)}";
|
||||
$"{root}?standardCode={Uri.EscapeDataString(standardCode.Trim())}&supplierCode={Uri.EscapeDataString(supplierCode.Trim())}";
|
||||
var requestJson = JsonSerializer.Serialize(body, JsonOptions);
|
||||
|
||||
using var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
|
||||
@ -13,4 +13,24 @@ public class ItfxGatewayOptions
|
||||
public string BaseUrl { get; set; } = "http://api.nanafa.com/itfx";
|
||||
|
||||
public int TimeoutSeconds { get; set; } = 30;
|
||||
|
||||
/// <summary>
|
||||
/// 9610 汇总申报上游标准码(暂定,可在配置覆盖)。
|
||||
/// </summary>
|
||||
public string Customs9610StandardCode { get; set; } = "customs9610Declare";
|
||||
|
||||
/// <summary>
|
||||
/// 9610 获取清单数据上游标准码(暂定)。
|
||||
/// </summary>
|
||||
public string Customs9610ManifestStandardCode { get; set; } = "customs9610Manifest";
|
||||
|
||||
/// <summary>
|
||||
/// 9610 获取报关单上游标准码(暂定)。
|
||||
/// </summary>
|
||||
public string Customs9610DeclarationFormStandardCode { get; set; } = "customs9610DeclarationForm";
|
||||
|
||||
/// <summary>
|
||||
/// 9610 申报默认 supplierCode;空则回退订单 DownstreamSupplierCode。
|
||||
/// </summary>
|
||||
public string? Customs9610SupplierCode { get; set; }
|
||||
}
|
||||
|
||||
@ -37,4 +37,8 @@
|
||||
<InternalsVisibleTo Include="Oms.Tests" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Services\Ai\AiSkillSeedContent.json" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -55,7 +55,7 @@ public class OmsApplicationModule : FakeModule
|
||||
context.Services.AddOmsItfxIntegration(configuration);
|
||||
context.Services.AddOmsPlatformShopIntegration(configuration);
|
||||
context.Services.AddOmsOrderBatchMessaging(configuration);
|
||||
context.Services.AddXhsLlmClient();
|
||||
context.Services.AddAiLlmClient();
|
||||
context.Services.AddHostedService<XhsScheduledPublishWorker>();
|
||||
context.Services.AddHostedService<MarketingBackgroundWorker>();
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ public class CustomerServiceAdvisorResolver(FakeRbacDbContext dbContext) : IScop
|
||||
Name = row.Name,
|
||||
WechatId = row.WechatId,
|
||||
WechatQrCode = row.WechatQrCode,
|
||||
WecomKfUrl = row.WecomKfUrl,
|
||||
};
|
||||
}
|
||||
|
||||
@ -44,7 +45,8 @@ public class CustomerServiceAdvisorResolver(FakeRbacDbContext dbContext) : IScop
|
||||
SELECT
|
||||
u.`Name` AS `Name`,
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND u.`userid` = {0}
|
||||
@ -62,7 +64,8 @@ public class CustomerServiceAdvisorResolver(FakeRbacDbContext dbContext) : IScop
|
||||
SELECT
|
||||
u.`Name` AS `Name`,
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
WHERE u.`IsDeleted` = 0
|
||||
AND (u.`Name` = {0} OR u.`Account` = {0})
|
||||
@ -82,5 +85,7 @@ public class CustomerServiceAdvisorResolver(FakeRbacDbContext dbContext) : IScop
|
||||
public string? WechatId { get; set; }
|
||||
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ internal static class OmsUserProfileMapper
|
||||
detail.EmployeeNo = profile.EmployeeNo;
|
||||
detail.WechatId = profile.WechatId;
|
||||
detail.WechatQrCode = profile.WechatQrCode;
|
||||
detail.WecomKfUrl = profile.WecomKfUrl;
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
u.`Phone` AS `Phone`,
|
||||
u.`EmployeeNo` AS `EmployeeNo`,
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
WHERE u.`Id` = {0} AND u.`IsDeleted` = 0
|
||||
LIMIT 1
|
||||
@ -41,6 +42,7 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
EmployeeNo = row.EmployeeNo,
|
||||
WechatId = row.WechatId,
|
||||
WechatQrCode = row.WechatQrCode,
|
||||
WecomKfUrl = row.WecomKfUrl,
|
||||
};
|
||||
}
|
||||
|
||||
@ -60,7 +62,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
u.`Phone` AS `Phone`,
|
||||
u.`EmployeeNo` AS `EmployeeNo`,
|
||||
u.`WechatId` AS `WechatId`,
|
||||
u.`WechatQrCode` AS `WechatQrCode`
|
||||
u.`WechatQrCode` AS `WechatQrCode`,
|
||||
u.`WecomKfUrl` AS `WecomKfUrl`
|
||||
FROM `user` u
|
||||
WHERE u.`Id` IN ({inClause}) AND u.`IsDeleted` = 0
|
||||
""";
|
||||
@ -74,6 +77,7 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
EmployeeNo = x.EmployeeNo,
|
||||
WechatId = x.WechatId,
|
||||
WechatQrCode = x.WechatQrCode,
|
||||
WecomKfUrl = x.WecomKfUrl,
|
||||
});
|
||||
}
|
||||
|
||||
@ -85,7 +89,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
`Phone` = {1},
|
||||
`EmployeeNo` = {2},
|
||||
`WechatId` = {3},
|
||||
`WechatQrCode` = {4}
|
||||
`WechatQrCode` = {4},
|
||||
`WecomKfUrl` = {5}
|
||||
WHERE `Id` = {0} AND `IsDeleted` = 0
|
||||
""";
|
||||
|
||||
@ -98,6 +103,7 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
(object?)NormalizeOptional(profile.EmployeeNo),
|
||||
(object?)NormalizeOptional(profile.WechatId),
|
||||
(object?)NormalizeOptional(profile.WechatQrCode),
|
||||
(object?)NormalizeOptional(profile.WecomKfUrl),
|
||||
],
|
||||
cancellationToken);
|
||||
}
|
||||
@ -112,7 +118,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
SET
|
||||
`Phone` = {1},
|
||||
`WechatId` = {2},
|
||||
`WechatQrCode` = {3}
|
||||
`WechatQrCode` = {3},
|
||||
`WecomKfUrl` = {4}
|
||||
WHERE `Id` = {0} AND `IsDeleted` = 0
|
||||
""";
|
||||
|
||||
@ -123,6 +130,7 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
(object?)NormalizeOptional(profile.Phone),
|
||||
(object?)NormalizeOptional(profile.WechatId),
|
||||
(object?)NormalizeOptional(profile.WechatQrCode),
|
||||
(object?)NormalizeOptional(profile.WecomKfUrl),
|
||||
],
|
||||
cancellationToken);
|
||||
}
|
||||
@ -208,6 +216,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
public string? WechatId { get; set; }
|
||||
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
|
||||
private sealed class UserProfileListRow
|
||||
@ -221,6 +231,8 @@ public class UserProfileRepository(FakeRbacDbContext dbContext) : IScopedDepende
|
||||
public string? WechatId { get; set; }
|
||||
|
||||
public string? WechatQrCode { get; set; }
|
||||
|
||||
public string? WecomKfUrl { get; set; }
|
||||
}
|
||||
|
||||
private sealed class EmployeeNoRow
|
||||
|
||||
@ -1,48 +1,51 @@
|
||||
using Fake.Application;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oms.Application.Dtos.Ai;
|
||||
using Oms.Application.Dtos.Shared;
|
||||
using Oms.Application.Dtos.Xhs;
|
||||
using Oms.Application.Shared;
|
||||
using Oms.Domain.AiAggregate.Entities;
|
||||
using Oms.Domain.AiAggregate.Repositories;
|
||||
using Oms.Domain.CustomersAggregate.Repositories;
|
||||
using Oms.Domain.XhsAggregate.Entities;
|
||||
using Oms.Domain.XhsAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Xhs;
|
||||
namespace Oms.Application.Services.Ai;
|
||||
|
||||
[ApiExplorerSettings(GroupName = "OMS-Xhs")]
|
||||
public class XhsAiService : ApplicationService
|
||||
/// <summary>
|
||||
/// 全局 AI 提供商与对话服务(系统级,非业务域专属)。
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "OMS-Ai")]
|
||||
public class AiService : ApplicationService
|
||||
{
|
||||
private const string SecretMask = "******";
|
||||
|
||||
private IXhsAiProviderRepository AiProviderRepository => LazyServiceProvider.GetRequiredService<IXhsAiProviderRepository>();
|
||||
private IAiProviderRepository AiProviderRepository => LazyServiceProvider.GetRequiredService<IAiProviderRepository>();
|
||||
private ICustomerRepository CustomerRepository => LazyServiceProvider.GetRequiredService<ICustomerRepository>();
|
||||
|
||||
/// <summary>
|
||||
/// 查询AI服务商列表
|
||||
/// 查询 AI 服务商列表。
|
||||
/// </summary>
|
||||
[HttpPost("/xhs/ai/provider/list")]
|
||||
public async Task<OmsItemsResult<XhsAiProviderOutput>> ListProvidersAsync()
|
||||
[HttpPost("/ai/provider/list")]
|
||||
public async Task<OmsItemsResult<AiProviderOutput>> ListProvidersAsync()
|
||||
{
|
||||
var customerId = await OmsSessionHelper.ResolveXhsCustomerIdAsync(CustomerRepository, CurrentUser);
|
||||
var items = await AiProviderRepository.GetListAsync(x => x.CustomerId == customerId || x.CustomerId == 0);
|
||||
return new OmsItemsResult<XhsAiProviderOutput>
|
||||
return new OmsItemsResult<AiProviderOutput>
|
||||
{
|
||||
Items = items.Select(x => MapProvider(x, maskSecret: true)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存AI服务商配置
|
||||
/// 保存 AI 服务商配置。
|
||||
/// </summary>
|
||||
[HttpPost("/xhs/ai/provider/save")]
|
||||
public async Task<XhsAiProviderOutput> SaveProviderAsync(XhsAiProviderSaveInput input)
|
||||
[HttpPost("/ai/provider/save")]
|
||||
public async Task<AiProviderOutput> SaveProviderAsync(AiProviderSaveInput input)
|
||||
{
|
||||
var customerId = await OmsSessionHelper.ResolveXhsCustomerIdAsync(CustomerRepository, CurrentUser);
|
||||
var providerKey = input.ProviderKey.Trim();
|
||||
var entity = await AiProviderRepository.GetByProviderKeyAsync(customerId, providerKey);
|
||||
if (entity == null)
|
||||
{
|
||||
entity = new XhsAiProvider { CustomerId = customerId, ProviderKey = providerKey };
|
||||
entity = new AiProvider { CustomerId = customerId, ProviderKey = providerKey };
|
||||
}
|
||||
|
||||
entity.ProviderType = input.ProviderType.Trim();
|
||||
@ -85,22 +88,22 @@ public class XhsAiService : ApplicationService
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AI对话
|
||||
/// AI 对话。
|
||||
/// </summary>
|
||||
[HttpPost("/xhs/ai/chat")]
|
||||
public async Task<XhsAiChatOutput> ChatAsync(XhsAiChatInput input)
|
||||
[HttpPost("/ai/chat")]
|
||||
public async Task<AiChatOutput> ChatAsync(AiChatInput input)
|
||||
{
|
||||
var customerId = await OmsSessionHelper.ResolveXhsCustomerIdAsync(CustomerRepository, CurrentUser);
|
||||
var provider = await ResolveProviderAsync(customerId, input.ProviderKey.Trim());
|
||||
var llm = LazyServiceProvider.GetRequiredService<XhsLlmClient>();
|
||||
var llm = LazyServiceProvider.GetRequiredService<AiLlmClient>();
|
||||
var content = await llm.ChatCompletionAsync(
|
||||
provider,
|
||||
input.Messages.Select(x => (x.Role, x.Content)).ToList(),
|
||||
input.Model);
|
||||
return new XhsAiChatOutput { Content = content };
|
||||
return new AiChatOutput { Content = content };
|
||||
}
|
||||
|
||||
internal async Task<XhsAiProvider> ResolveProviderAsync(int customerId, string providerKey)
|
||||
internal async Task<AiProvider> ResolveProviderAsync(int customerId, string providerKey)
|
||||
{
|
||||
var provider = await AiProviderRepository.GetByProviderKeyAsync(customerId, providerKey);
|
||||
if (provider == null || !provider.Enabled)
|
||||
@ -116,7 +119,7 @@ public class XhsAiService : ApplicationService
|
||||
return provider;
|
||||
}
|
||||
|
||||
private static XhsAiProviderOutput MapProvider(XhsAiProvider entity, bool maskSecret) => new()
|
||||
private static AiProviderOutput MapProvider(AiProvider entity, bool maskSecret) => new()
|
||||
{
|
||||
Id = entity.Id,
|
||||
ProviderKey = entity.ProviderKey,
|
||||
1
src/Oms.Application/Services/Ai/AiSkillSeedContent.json
Normal file
1
src/Oms.Application/Services/Ai/AiSkillSeedContent.json
Normal file
File diff suppressed because one or more lines are too long
251
src/Oms.Application/Services/Ai/AiSkillService.cs
Normal file
251
src/Oms.Application/Services/Ai/AiSkillService.cs
Normal file
@ -0,0 +1,251 @@
|
||||
using System.Text.Json;
|
||||
using Fake.Application;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oms.Application.Dtos.Ai;
|
||||
using Oms.Application.Dtos.Shared;
|
||||
using Oms.Domain.AiAggregate.Entities;
|
||||
using Oms.Domain.AiAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Ai;
|
||||
|
||||
/// <summary>
|
||||
/// 平台级 AI Skill 管理(提示词/规范正文)。
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "OMS-Ai")]
|
||||
public class AiSkillService : ApplicationService
|
||||
{
|
||||
public const string ScenePricePublish = "pricePublish";
|
||||
public const string SceneAutoTriggerFormula = "autoTriggerFormula";
|
||||
public const string SceneBillingConditionFormula = "billingConditionFormula";
|
||||
public const string SceneReceiverAddressParse = "receiverAddressParse";
|
||||
public const string SceneItfxPrefixScript = "itfxPrefixScript";
|
||||
public const string SceneItfxParameterMap = "itfxParameterMap";
|
||||
|
||||
public const string KeyPricePublish = "oms-sales-price-publish-risk";
|
||||
public const string KeyAutoTriggerFormula = "oms-auto-trigger-formula";
|
||||
public const string KeyBillingConditionFormula = "oms-billing-condition-formula";
|
||||
public const string KeyReceiverAddressParse = "oms-receiver-address-parse";
|
||||
public const string KeyItfxPrefixScript = "itfx-prefix-script";
|
||||
public const string KeyItfxCreateOrderMap = "itfx-create-order-map";
|
||||
|
||||
private IAiSkillRepository AiSkillRepository => LazyServiceProvider.GetRequiredService<IAiSkillRepository>();
|
||||
|
||||
/// <summary>
|
||||
/// Skill 列表(可按场景过滤)。
|
||||
/// </summary>
|
||||
[HttpPost("/ai/skill/list")]
|
||||
public async Task<OmsItemsResult<AiSkillOutput>> ListAsync(AiSkillListInput input)
|
||||
{
|
||||
await EnsureBuiltinSkillsAsync();
|
||||
var scene = NormalizeOptional(input.Scene);
|
||||
var items = await AiSkillRepository.GetListAsync(x =>
|
||||
(scene == null || x.Scene == scene) &&
|
||||
(!input.EnabledOnly || x.Enabled));
|
||||
var ordered = items.OrderBy(x => x.SortOrder).ThenBy(x => x.Id).ToList();
|
||||
return new OmsItemsResult<AiSkillOutput>
|
||||
{
|
||||
Items = ordered.Select(x => Map(x, input.IncludeContent)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按 Id 或 SkillKey 获取 Skill(含正文)。
|
||||
/// </summary>
|
||||
[HttpPost("/ai/skill/get")]
|
||||
public async Task<AiSkillOutput> GetAsync(AiSkillGetInput input)
|
||||
{
|
||||
await EnsureBuiltinSkillsAsync();
|
||||
AiSkill? entity = null;
|
||||
if (input.Id is > 0)
|
||||
{
|
||||
entity = await AiSkillRepository.FirstOrDefaultAsync(x => x.Id == input.Id.Value);
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(input.SkillKey))
|
||||
{
|
||||
entity = await AiSkillRepository.GetBySkillKeyAsync(input.SkillKey.Trim());
|
||||
}
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
throw new BusinessException("Skill 不存在");
|
||||
}
|
||||
|
||||
return Map(entity, includeContent: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增或更新 Skill。
|
||||
/// </summary>
|
||||
[HttpPost("/ai/skill/save")]
|
||||
public async Task<AiSkillOutput> SaveAsync(AiSkillSaveInput input)
|
||||
{
|
||||
var skillKey = input.SkillKey.Trim();
|
||||
var scene = input.Scene.Trim();
|
||||
if (string.IsNullOrWhiteSpace(skillKey) || string.IsNullOrWhiteSpace(scene))
|
||||
{
|
||||
throw new BusinessException("SkillKey / Scene 不能为空");
|
||||
}
|
||||
|
||||
AiSkill? entity = null;
|
||||
if (input.Id is > 0)
|
||||
{
|
||||
entity = await AiSkillRepository.FirstOrDefaultAsync(x => x.Id == input.Id.Value);
|
||||
}
|
||||
|
||||
entity ??= await AiSkillRepository.GetBySkillKeyAsync(skillKey);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
entity = new AiSkill { SkillKey = skillKey };
|
||||
}
|
||||
else if (!string.Equals(entity.SkillKey, skillKey, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var conflict = await AiSkillRepository.GetBySkillKeyAsync(skillKey);
|
||||
if (conflict != null && conflict.Id != entity.Id)
|
||||
{
|
||||
throw new BusinessException($"SkillKey 已存在:{skillKey}");
|
||||
}
|
||||
|
||||
entity.SkillKey = skillKey;
|
||||
}
|
||||
|
||||
entity.Scene = scene;
|
||||
entity.Name = input.Name.Trim();
|
||||
entity.Description = NormalizeOptional(input.Description);
|
||||
entity.Content = input.Content ?? string.Empty;
|
||||
entity.SortOrder = input.SortOrder;
|
||||
entity.Enabled = input.Enabled;
|
||||
|
||||
if (entity.Id > 0)
|
||||
{
|
||||
await AiSkillRepository.UpdateAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
await AiSkillRepository.InsertAsync(entity);
|
||||
}
|
||||
|
||||
return Map(entity, includeContent: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 软删除 Skill。
|
||||
/// </summary>
|
||||
[HttpPost("/ai/skill/delete")]
|
||||
public async Task DeleteAsync(AiSkillDeleteInput input)
|
||||
{
|
||||
var entity = await AiSkillRepository.FirstOrDefaultAsync(x => x.Id == input.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
throw new BusinessException("Skill 不存在");
|
||||
}
|
||||
|
||||
await AiSkillRepository.DeleteAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 供内部调用:按 key 取正文,不存在返回 null。
|
||||
/// </summary>
|
||||
public async Task<string?> TryGetContentByKeyAsync(string skillKey)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(skillKey)) return null;
|
||||
await EnsureBuiltinSkillsAsync();
|
||||
var entity = await AiSkillRepository.GetBySkillKeyAsync(skillKey.Trim());
|
||||
if (entity == null || !entity.Enabled || string.IsNullOrWhiteSpace(entity.Content))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return entity.Content;
|
||||
}
|
||||
|
||||
private async Task EnsureBuiltinSkillsAsync()
|
||||
{
|
||||
var seeds = LoadSeedDefinitions();
|
||||
foreach (var seed in seeds)
|
||||
{
|
||||
var existing = await AiSkillRepository.GetBySkillKeyAsync(seed.SkillKey);
|
||||
if (existing != null) continue;
|
||||
|
||||
await AiSkillRepository.InsertAsync(new AiSkill
|
||||
{
|
||||
SkillKey = seed.SkillKey,
|
||||
Scene = seed.Scene,
|
||||
Name = seed.Name,
|
||||
Description = seed.Description,
|
||||
Content = seed.Content,
|
||||
SortOrder = seed.SortOrder,
|
||||
Enabled = true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static List<SeedDef> LoadSeedDefinitions()
|
||||
{
|
||||
var asm = typeof(AiSkillService).Assembly;
|
||||
var resourceName = asm.GetManifestResourceNames()
|
||||
.FirstOrDefault(n => n.EndsWith("AiSkillSeedContent.json", StringComparison.OrdinalIgnoreCase));
|
||||
if (resourceName == null)
|
||||
{
|
||||
throw new InvalidOperationException("未找到嵌入资源 AiSkillSeedContent.json");
|
||||
}
|
||||
|
||||
using var stream = asm.GetManifestResourceStream(resourceName)!;
|
||||
using var reader = new StreamReader(stream);
|
||||
var json = reader.ReadToEnd();
|
||||
var payload = JsonSerializer.Deserialize<SeedPayload>(json, new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
})
|
||||
?? throw new InvalidOperationException("AiSkillSeedContent.json 解析失败");
|
||||
|
||||
return
|
||||
[
|
||||
new SeedDef(KeyPricePublish, ScenePricePublish, "销售产品价格发布风险",
|
||||
"对比线上生效价与待发布价,输出中文风险报告", payload.Price, 10),
|
||||
new SeedDef(KeyAutoTriggerFormula, SceneAutoTriggerFormula, "自动触发公式助手",
|
||||
"根据中文描述生成可粘贴的自动触发公式(字段目录由前端追加)", payload.Formula, 20),
|
||||
new SeedDef(KeyBillingConditionFormula, SceneBillingConditionFormula, "计费条件公式助手",
|
||||
"根据中文描述生成价格项计费条件公式(字段目录由前端追加)", payload.BillingCondition, 25),
|
||||
new SeedDef(KeyReceiverAddressParse, SceneReceiverAddressParse, "收件地址 AI 解析",
|
||||
"解析粘贴的收件地址为结构化字段并做粗校验", payload.Address, 30),
|
||||
new SeedDef(KeyItfxPrefixScript, SceneItfxPrefixScript, "接口通前置脚本",
|
||||
"按用户需求生成 Natasha C# 前置签名脚本", payload.Itfx, 40),
|
||||
new SeedDef(KeyItfxCreateOrderMap, SceneItfxParameterMap, "创建订单自动映射",
|
||||
"按订单基本信息/收件人/发件人/申报信息四模块初步匹配上下游参数", payload.ParameterMap, 50),
|
||||
];
|
||||
}
|
||||
|
||||
private static AiSkillOutput Map(AiSkill entity, bool includeContent) => new()
|
||||
{
|
||||
Id = entity.Id,
|
||||
SkillKey = entity.SkillKey,
|
||||
Scene = entity.Scene,
|
||||
Name = entity.Name,
|
||||
Description = entity.Description,
|
||||
Content = includeContent ? entity.Content : string.Empty,
|
||||
SortOrder = entity.SortOrder,
|
||||
Enabled = entity.Enabled
|
||||
};
|
||||
|
||||
private static string? NormalizeOptional(string? value) =>
|
||||
string.IsNullOrWhiteSpace(value) ? null : value.Trim();
|
||||
|
||||
private sealed record SeedDef(
|
||||
string SkillKey,
|
||||
string Scene,
|
||||
string Name,
|
||||
string Description,
|
||||
string Content,
|
||||
int SortOrder);
|
||||
|
||||
private sealed class SeedPayload
|
||||
{
|
||||
public string Price { get; set; } = string.Empty;
|
||||
public string Formula { get; set; } = string.Empty;
|
||||
public string BillingCondition { get; set; } = string.Empty;
|
||||
public string Itfx { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public string ParameterMap { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@ -24,6 +24,9 @@ public class IssueTemplateService : ApplicationService
|
||||
private DataPermRepository DataPermRepository =>
|
||||
LazyServiceProvider.GetRequiredService<DataPermRepository>();
|
||||
|
||||
private OmsRbacUserDisplayNameResolver UserDisplayNameResolver =>
|
||||
LazyServiceProvider.GetRequiredService<OmsRbacUserDisplayNameResolver>();
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询问题模板列表。
|
||||
/// </summary>
|
||||
@ -40,7 +43,8 @@ public class IssueTemplateService : ApplicationService
|
||||
new Dictionary<string, bool> { [nameof(IssueTemplate.UpdateTime)] = false, [nameof(IssueTemplate.Id)] = false });
|
||||
var total = await IssueTemplateRepository.CountAsync(predicate);
|
||||
var orgNameMap = await ResolveOrganizationNameMapAsync(entities);
|
||||
var items = entities.Select(x => MapOutput(x, orgNameMap)).ToList();
|
||||
var handlerUserNameMap = await ResolveHandlerUserNameMapAsync(entities);
|
||||
var items = entities.Select(x => MapOutput(x, orgNameMap, handlerUserNameMap)).ToList();
|
||||
return new OmsPageResult<IssueTemplateOutput> { Items = items, Total = total };
|
||||
}
|
||||
|
||||
@ -52,7 +56,8 @@ public class IssueTemplateService : ApplicationService
|
||||
{
|
||||
var entity = await GetEntityOrThrowAsync(id);
|
||||
var orgNameMap = await ResolveOrganizationNameMapAsync([entity]);
|
||||
return MapOutput(entity, orgNameMap);
|
||||
var handlerUserNameMap = await ResolveHandlerUserNameMapAsync([entity]);
|
||||
return MapOutput(entity, orgNameMap, handlerUserNameMap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -69,6 +74,8 @@ public class IssueTemplateService : ApplicationService
|
||||
Title = normalized.Title,
|
||||
Content = normalized.Content,
|
||||
NotifyMethod = normalized.NotifyMethod,
|
||||
HandlerType = normalized.HandlerType,
|
||||
HandlerUserId = normalized.HandlerUserId,
|
||||
Status = normalized.Status
|
||||
};
|
||||
await IssueTemplateRepository.InsertAsync(entity);
|
||||
@ -87,6 +94,8 @@ public class IssueTemplateService : ApplicationService
|
||||
entity.Title = normalized.Title;
|
||||
entity.Content = normalized.Content;
|
||||
entity.NotifyMethod = normalized.NotifyMethod;
|
||||
entity.HandlerType = normalized.HandlerType;
|
||||
entity.HandlerUserId = normalized.HandlerUserId;
|
||||
entity.Status = normalized.Status;
|
||||
await IssueTemplateRepository.UpdateAsync(entity);
|
||||
}
|
||||
@ -212,6 +221,38 @@ public class IssueTemplateService : ApplicationService
|
||||
throw new BusinessException("请至少选择一种通知方式");
|
||||
}
|
||||
|
||||
var handlerType = input.HandlerType?.Trim().ToLowerInvariant();
|
||||
if (string.IsNullOrWhiteSpace(handlerType))
|
||||
{
|
||||
handlerType = IssueHandlerTypeCodes.User;
|
||||
}
|
||||
|
||||
if (!IssueHandlerTypeCodes.All.Contains(handlerType))
|
||||
{
|
||||
throw new BusinessException("处理人类型不合法");
|
||||
}
|
||||
|
||||
int? handlerUserId = null;
|
||||
if (IssueHandlerTypeCodes.IsUser(handlerType))
|
||||
{
|
||||
if (input.HandlerUserId is not int userId || userId <= 0)
|
||||
{
|
||||
throw new BusinessException("请选择指定处理人");
|
||||
}
|
||||
|
||||
handlerUserId = userId;
|
||||
}
|
||||
else if (IssueHandlerTypeCodes.IsCustomer(handlerType))
|
||||
{
|
||||
var methods = IssueNotifyMethodCodes.ParseList(notifyMethod);
|
||||
if (methods.Any(x => !string.Equals(x, IssueNotifyMethodCodes.InApp, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
throw new BusinessException("处理人为客户时,目前仅支持站内信通知");
|
||||
}
|
||||
|
||||
notifyMethod = IssueNotifyMethodCodes.InApp;
|
||||
}
|
||||
|
||||
var organizationId = NormalizeOrganizationId(input.OrganizationId);
|
||||
if (!string.IsNullOrWhiteSpace(organizationId))
|
||||
{
|
||||
@ -238,6 +279,8 @@ public class IssueTemplateService : ApplicationService
|
||||
Title = title,
|
||||
Content = content,
|
||||
NotifyMethod = notifyMethod,
|
||||
HandlerType = handlerType,
|
||||
HandlerUserId = handlerUserId,
|
||||
Status = input.Status
|
||||
};
|
||||
}
|
||||
@ -280,9 +323,20 @@ public class IssueTemplateService : ApplicationService
|
||||
: await DataPermRepository.GetOrganizationNamesAsync(orgIds);
|
||||
}
|
||||
|
||||
private async Task<IReadOnlyDictionary<int, string>> ResolveHandlerUserNameMapAsync(
|
||||
IReadOnlyCollection<IssueTemplate> entities)
|
||||
{
|
||||
var userIds = entities
|
||||
.Where(x => IssueHandlerTypeCodes.IsUser(x.HandlerType) && x.HandlerUserId is > 0)
|
||||
.Select(x => x.HandlerUserId!.Value)
|
||||
.Distinct();
|
||||
return await UserDisplayNameResolver.ResolveManyAsync(userIds);
|
||||
}
|
||||
|
||||
private static IssueTemplateOutput MapOutput(
|
||||
IssueTemplate entity,
|
||||
IReadOnlyDictionary<Guid, string> orgNameMap)
|
||||
IReadOnlyDictionary<Guid, string> orgNameMap,
|
||||
IReadOnlyDictionary<int, string> handlerUserNameMap)
|
||||
{
|
||||
string? organizationName = null;
|
||||
if (!string.IsNullOrWhiteSpace(entity.OrganizationId)
|
||||
@ -307,6 +361,12 @@ public class IssueTemplateService : ApplicationService
|
||||
Content = entity.Content,
|
||||
NotifyMethod = entity.NotifyMethod,
|
||||
NotifyMethods = IssueNotifyMethodCodes.ParseList(entity.NotifyMethod),
|
||||
HandlerType = entity.HandlerType,
|
||||
HandlerTypeName = IssueHandlerTypeCodes.GetDisplayName(entity.HandlerType),
|
||||
HandlerUserId = entity.HandlerUserId,
|
||||
HandlerUserName = entity.HandlerUserId is int handlerUserId && handlerUserId > 0
|
||||
? OmsRbacUserDisplayNameResolver.FormatUserId(handlerUserId, handlerUserNameMap)
|
||||
: null,
|
||||
Status = (byte)entity.Status,
|
||||
CreateTime = entity.CreateTime,
|
||||
UpdateTime = OmsDocHelper.NullIfDefault(entity.UpdateTime)
|
||||
@ -325,6 +385,10 @@ public class IssueTemplateService : ApplicationService
|
||||
|
||||
public string NotifyMethod { get; set; } = string.Empty;
|
||||
|
||||
public string HandlerType { get; set; } = IssueHandlerTypeCodes.User;
|
||||
|
||||
public int? HandlerUserId { get; set; }
|
||||
|
||||
public EnableStatus Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,448 @@
|
||||
using Fake.Application;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oms.Application.Dtos.Channels;
|
||||
using Oms.Application.Dtos.Orders;
|
||||
using Oms.Application.Services.Orders;
|
||||
using Oms.Application.Services.Orders.Issues;
|
||||
using Oms.Application.Shared;
|
||||
using Oms.Domain.ChannelsAggregate.Entities;
|
||||
using Oms.Domain.OrdersAggregate.Consts;
|
||||
using Oms.Domain.OrdersAggregate.Entities;
|
||||
using Oms.Domain.SystemAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Channels;
|
||||
|
||||
public partial class SalesProductService
|
||||
{
|
||||
private IWarehouseAddressRepository WarehouseAddressRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IWarehouseAddressRepository>();
|
||||
|
||||
/// <summary>
|
||||
/// 基于当前库内卖价(非必须已发布)模拟计费,用于运营核对附加服务/偏远/申报比例等。
|
||||
/// </summary>
|
||||
[HttpPost("/channel/sales-product/billing/simulate")]
|
||||
public async Task<SalesProductBillingSimulateOutput> SimulateBillingAsync(
|
||||
[FromBody] SalesProductBillingSimulateInput input)
|
||||
{
|
||||
if (input.Length <= 0 || input.Width <= 0 || input.Height <= 0 || input.ActualWeight <= 0)
|
||||
{
|
||||
throw new BusinessException("长宽高与实重必须大于0");
|
||||
}
|
||||
|
||||
var product = await GetProductOrThrowAsync(input.SalesProductId);
|
||||
var countryCode = input.CountryCode?.Trim().ToUpperInvariant()
|
||||
?? throw new BusinessException("目的国家不能为空");
|
||||
if (string.IsNullOrWhiteSpace(countryCode))
|
||||
{
|
||||
throw new BusinessException("目的国家不能为空");
|
||||
}
|
||||
|
||||
var warnings = new List<string>();
|
||||
var priceSnapshot = await BuildPricePublishSnapshotAsync(product.Id);
|
||||
var rulesSnapshot = await BuildRulesPublishSnapshotAsync(product.Id);
|
||||
|
||||
var weight = new OrderWeight
|
||||
{
|
||||
Type = OrderWeightTypeCodes.Forecast,
|
||||
Length = input.Length,
|
||||
Width = input.Width,
|
||||
Height = input.Height,
|
||||
ActualWeight = input.ActualWeight,
|
||||
Cubic = ParcelBillingCalculator.CalculateCubic(input.Length, input.Width, input.Height)
|
||||
};
|
||||
|
||||
decimal chargeableWeight;
|
||||
try
|
||||
{
|
||||
chargeableWeight = await ResolveSimulateChargeableWeightAsync(product, rulesSnapshot, weight);
|
||||
}
|
||||
catch (BusinessException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
throw new BusinessException($"计费重计算失败:{ex.Message}");
|
||||
}
|
||||
|
||||
var zoneKeys = ParcelBillingCalculator.TryResolveZoneKeysFromPriceSnapshot(
|
||||
priceSnapshot,
|
||||
countryCode,
|
||||
input.Province,
|
||||
input.City,
|
||||
input.ZipCode);
|
||||
if (zoneKeys == null || zoneKeys.Count == 0)
|
||||
{
|
||||
throw new BusinessException("价格分区未匹配");
|
||||
}
|
||||
|
||||
var isRemote = input.IsRemote
|
||||
?? await IsSimulateRemoteHitAsync(product, rulesSnapshot, countryCode, input.Province, input.City, input.ZipCode);
|
||||
|
||||
var additionalServices = (input.AdditionalServices ?? [])
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Select(x => x.Trim())
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
var allowed = OmsDocHelper.DeserializeJson<List<string>>(product.AdditionalServices) ?? [];
|
||||
var allowedSet = allowed
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Select(x => x.Trim())
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
var invalidServices = additionalServices.Where(x => !allowedSet.Contains(x)).ToList();
|
||||
if (invalidServices.Count > 0)
|
||||
{
|
||||
warnings.Add($"附加服务不在产品可选范围:{string.Join(", ", invalidServices)}");
|
||||
additionalServices = additionalServices.Where(allowedSet.Contains).ToList();
|
||||
}
|
||||
|
||||
var cargoAttribute = string.IsNullOrWhiteSpace(input.CargoAttribute)
|
||||
? CargoAttributeCodes.General
|
||||
: input.CargoAttribute.Trim();
|
||||
var warehouseName = await ResolveSimulateWarehouseNameAsync(input.WarehouseId);
|
||||
var priceTierKey = string.IsNullOrWhiteSpace(input.PriceTierKey) ? null : input.PriceTierKey.Trim();
|
||||
var priceVersion = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
var priceEffectiveTime = DateTime.Now;
|
||||
|
||||
var conditionContext = OrderRuleEvaluationContext.FromOrderOnly(new Order
|
||||
{
|
||||
ProductCode = product.ProductCode,
|
||||
ConsigneeCountry = countryCode,
|
||||
CargoAttribute = cargoAttribute,
|
||||
WarehouseId = input.WarehouseId,
|
||||
DeclaredSum = input.DeclaredSum,
|
||||
DeclaredCurrency = input.DeclaredCurrency,
|
||||
IsRemote = isRemote ? (byte)1 : (byte)0,
|
||||
AdditionalServices = additionalServices.Count == 0
|
||||
? null
|
||||
: OmsDocHelper.SerializeJson(additionalServices)
|
||||
});
|
||||
|
||||
var remoteAreaId = product.RemoteAreaId is > 0 ? product.RemoteAreaId : rulesSnapshot.RemoteAreaId;
|
||||
var remoteZoneKeys = isRemote
|
||||
? ParcelBillingCalculator.BuildRemoteZoneKeys(remoteAreaId, rulesSnapshot.RemoteAreaName)
|
||||
: Array.Empty<string>();
|
||||
|
||||
var receivableLines = ParcelBillingCalculator.CalculateQuoteReceivableFeeLines(
|
||||
priceSnapshot,
|
||||
priceVersion,
|
||||
priceEffectiveTime,
|
||||
chargeableWeight,
|
||||
zoneKeys,
|
||||
cargoAttribute,
|
||||
priceTierKey,
|
||||
input.WarehouseId,
|
||||
warehouseName,
|
||||
conditionContext,
|
||||
input.DeclaredSum,
|
||||
input.DeclaredCurrency,
|
||||
remoteZoneKeys);
|
||||
|
||||
if (receivableLines.Count == 0 && ParcelBillingCalculator.HasEnabledReceivablePriceItems(priceSnapshot))
|
||||
{
|
||||
var detail = ParcelBillingCalculator.ExplainQuotePriceMiss(
|
||||
priceSnapshot,
|
||||
chargeableWeight,
|
||||
zoneKeys,
|
||||
cargoAttribute,
|
||||
priceTierKey,
|
||||
input.WarehouseId,
|
||||
warehouseName);
|
||||
warnings.Add($"卖价未匹配到有效价格:{detail}");
|
||||
}
|
||||
|
||||
var receivableFees = receivableLines.Select(x => new SalesProductBillingSimulateFeeOutput
|
||||
{
|
||||
CostItem = x.Fee.CostItem,
|
||||
Amount = x.Fee.Amount,
|
||||
Currency = x.Fee.Currency ?? string.Empty,
|
||||
Formula = x.FormulaPart
|
||||
}).ToList();
|
||||
|
||||
var payableFees = new List<SalesProductBillingSimulateFeeOutput>();
|
||||
try
|
||||
{
|
||||
payableFees = await TrySimulatePayableFeesAsync(
|
||||
product,
|
||||
rulesSnapshot,
|
||||
zoneKeys,
|
||||
chargeableWeight,
|
||||
cargoAttribute,
|
||||
input.WarehouseId,
|
||||
warehouseName,
|
||||
isRemote,
|
||||
remoteZoneKeys,
|
||||
input.DeclaredSum,
|
||||
input.DeclaredCurrency,
|
||||
priceVersion,
|
||||
priceEffectiveTime,
|
||||
warnings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
warnings.Add($"应付估算失败:{ex.Message}");
|
||||
}
|
||||
|
||||
var receivableTotal = SumByCurrency(receivableFees);
|
||||
var payableTotal = SumByCurrency(payableFees);
|
||||
decimal? margin = null;
|
||||
if (receivableTotal.Count == 1
|
||||
&& payableTotal.Count == 1
|
||||
&& string.Equals(receivableTotal.Keys.First(), payableTotal.Keys.First(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
margin = receivableTotal.Values.First() - payableTotal.Values.First();
|
||||
}
|
||||
else if (receivableTotal.Count > 1 || payableTotal.Count > 1)
|
||||
{
|
||||
warnings.Add("多币种费用无法直接计算毛利");
|
||||
}
|
||||
else if (receivableTotal.Count == 1 && payableTotal.Count == 0)
|
||||
{
|
||||
warnings.Add("仅返回应收估算,无应付费用");
|
||||
}
|
||||
|
||||
return new SalesProductBillingSimulateOutput
|
||||
{
|
||||
ChargeableWeight = chargeableWeight,
|
||||
ZoneKeys = zoneKeys.ToList(),
|
||||
IsRemote = isRemote,
|
||||
ReceivableFees = receivableFees,
|
||||
PayableFees = payableFees,
|
||||
ReceivableTotal = receivableTotal,
|
||||
PayableTotal = payableTotal,
|
||||
Margin = margin,
|
||||
Warnings = warnings
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<decimal> ResolveSimulateChargeableWeightAsync(
|
||||
SalesProduct product,
|
||||
SalesProductRulesPublishSnapshotDto rulesSnapshot,
|
||||
OrderWeight weight)
|
||||
{
|
||||
var weightRuleId = product.WeightRuleId is > 0
|
||||
? product.WeightRuleId
|
||||
: rulesSnapshot.WeightRuleId;
|
||||
if (weightRuleId is not > 0)
|
||||
{
|
||||
throw new BusinessException("未配置计重规则");
|
||||
}
|
||||
|
||||
IReadOnlyList<WeightRuleInfo> ruleInfos;
|
||||
if (rulesSnapshot.WeightRuleInfos is { Count: > 0 })
|
||||
{
|
||||
ruleInfos = RulesSnapshotHelper.ToWeightRuleEntities(rulesSnapshot.WeightRuleInfos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ruleInfos = await WeightRuleRepository.GetAllInfosByRuleIdAsync(weightRuleId.Value);
|
||||
}
|
||||
|
||||
var (_, rawWeight) = ParcelBillingCalculator.CalculateRawBillableWeight(weight, ruleInfos);
|
||||
|
||||
var weightRoundingId = product.WeightRoundingId is > 0
|
||||
? product.WeightRoundingId
|
||||
: rulesSnapshot.WeightRoundingId;
|
||||
if (weightRoundingId is not > 0)
|
||||
{
|
||||
throw new BusinessException("未配置计重进位");
|
||||
}
|
||||
|
||||
IReadOnlyList<WeightRoundingInfo> ranges;
|
||||
if (rulesSnapshot.WeightRoundingInfos is { Count: > 0 })
|
||||
{
|
||||
ranges = RulesSnapshotHelper.ToWeightRoundingEntities(rulesSnapshot.WeightRoundingInfos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ranges = await WeightRoundingRepository.GetAllInfosByRoundingIdAsync(weightRoundingId.Value);
|
||||
}
|
||||
|
||||
return ParcelBillingCalculator.ApplyRounding(rawWeight, ranges);
|
||||
}
|
||||
|
||||
private async Task<bool> IsSimulateRemoteHitAsync(
|
||||
SalesProduct product,
|
||||
SalesProductRulesPublishSnapshotDto rulesSnapshot,
|
||||
string countryCode,
|
||||
string? province,
|
||||
string? city,
|
||||
string? zipCode)
|
||||
{
|
||||
var areaId = product.RemoteAreaId is > 0 ? product.RemoteAreaId : rulesSnapshot.RemoteAreaId;
|
||||
if (areaId is not > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rulesSnapshot.RemoteAreaInfos is { Count: > 0 })
|
||||
{
|
||||
return RulesSnapshotHelper.IsAreaHitFromSnapshot(
|
||||
rulesSnapshot.RemoteAreaInfos,
|
||||
countryCode,
|
||||
province,
|
||||
city,
|
||||
zipCode);
|
||||
}
|
||||
|
||||
var rules = await KpiAreaRepository.GetAllInfosByAreaIdAsync(areaId.Value);
|
||||
return rules.Any(rule => ParcelBillingCalculator.IsAreaMatched(
|
||||
rule,
|
||||
countryCode,
|
||||
province,
|
||||
city,
|
||||
zipCode));
|
||||
}
|
||||
|
||||
private async Task<string?> ResolveSimulateWarehouseNameAsync(int? warehouseId)
|
||||
{
|
||||
if (warehouseId is not > 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var warehouse = await WarehouseAddressRepository.FirstOrDefaultAsync(x => x.Id == warehouseId.Value);
|
||||
return warehouse?.WarehouseName;
|
||||
}
|
||||
|
||||
private async Task<List<SalesProductBillingSimulateFeeOutput>> TrySimulatePayableFeesAsync(
|
||||
SalesProduct product,
|
||||
SalesProductRulesPublishSnapshotDto rulesSnapshot,
|
||||
IReadOnlyList<string> zoneKeys,
|
||||
decimal chargeableWeight,
|
||||
string cargoAttribute,
|
||||
int? warehouseId,
|
||||
string? warehouseName,
|
||||
bool isRemote,
|
||||
IReadOnlyList<string> remoteZoneKeys,
|
||||
decimal? declaredSum,
|
||||
string? declaredCurrency,
|
||||
string priceVersion,
|
||||
DateTime priceEffectiveTime,
|
||||
List<string> warnings)
|
||||
{
|
||||
var providers = rulesSnapshot.Providers.Count > 0
|
||||
? rulesSnapshot.Providers
|
||||
: (await GetAllocationCoreAsync(product.Id)).Providers
|
||||
.Select(PublishSnapshotSlimmer.SlimAllocationProvider)
|
||||
.ToList();
|
||||
var filtered = AllocationResolver.FilterProviders(providers, customerId: null);
|
||||
var provider = filtered.OrderBy(x => x.SerialNumber).FirstOrDefault(x => x.ServiceChannelId is > 0);
|
||||
if (provider?.ServiceChannelId is not > 0)
|
||||
{
|
||||
warnings.Add("未配置可用排货服务渠道,跳过应付估算");
|
||||
return [];
|
||||
}
|
||||
|
||||
var channelPrices = await BuildChannelPriceOutputsAsync(provider.ServiceChannelId.Value);
|
||||
if (channelPrices.Count == 0)
|
||||
{
|
||||
warnings.Add($"服务渠道 {provider.ServiceChannelId} 无买价,跳过应付估算");
|
||||
return [];
|
||||
}
|
||||
|
||||
var channel = await ServiceChannelRepository.FirstOrDefaultAsync(x => x.Id == provider.ServiceChannelId.Value);
|
||||
var payableRemoteZoneKeys = isRemote
|
||||
? ParcelBillingCalculator.BuildRemoteZoneKeys(
|
||||
channel?.RemoteAreaId is > 0 ? channel.RemoteAreaId : null)
|
||||
: Array.Empty<string>();
|
||||
// 渠道未配偏远分区时回落产品偏远键,便于模拟偏远费行
|
||||
if (isRemote && payableRemoteZoneKeys.Count == 0)
|
||||
{
|
||||
payableRemoteZoneKeys = remoteZoneKeys;
|
||||
}
|
||||
|
||||
var payableContext = OrderRuleEvaluationContext.FromOrderOnly(new Order
|
||||
{
|
||||
ProductCode = product.ProductCode,
|
||||
ConsigneeCountry = null,
|
||||
CargoAttribute = cargoAttribute,
|
||||
WarehouseId = warehouseId,
|
||||
DeclaredSum = declaredSum,
|
||||
DeclaredCurrency = declaredCurrency,
|
||||
IsRemote = isRemote ? (byte)1 : (byte)0
|
||||
});
|
||||
|
||||
var payable = ParcelBillingCalculator.CalculatePayableFees(
|
||||
channelPrices,
|
||||
priceVersion,
|
||||
priceEffectiveTime,
|
||||
chargeableWeight,
|
||||
zoneKeys,
|
||||
cargoAttribute,
|
||||
OrderFeeChargingStageCodes.Forecast,
|
||||
warehouseId,
|
||||
warehouseName,
|
||||
payableContext,
|
||||
declaredSum,
|
||||
declaredCurrency,
|
||||
payableRemoteZoneKeys);
|
||||
|
||||
if (payable.Count == 0)
|
||||
{
|
||||
warnings.Add($"服务渠道 {provider.ServiceChannelId} 买价未匹配,跳过应付估算");
|
||||
return [];
|
||||
}
|
||||
|
||||
warnings.Add($"应付按排货服务渠道 {provider.ServiceChannelId} 估算(首个可用渠道)");
|
||||
return payable.Select(x => new SalesProductBillingSimulateFeeOutput
|
||||
{
|
||||
CostItem = x.CostItem,
|
||||
Amount = x.Amount,
|
||||
Currency = x.Currency ?? string.Empty
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private async Task<List<ServiceChannelPriceListOutput>> BuildChannelPriceOutputsAsync(int serviceChannelId)
|
||||
{
|
||||
var prices = await ServiceChannelRepository.GetPricesAsync(serviceChannelId);
|
||||
var priceIds = prices.Select(x => x.Id).ToArray();
|
||||
var factorMap = (await ServiceChannelRepository.GetPriceFactorsAsync(priceIds))
|
||||
.GroupBy(x => x.PriceId)
|
||||
.ToDictionary(x => x.Key, x => x.OrderBy(item => item.SerialNumber).ToList());
|
||||
var detailMap = (await ServiceChannelRepository.GetPriceDetailsAsync(priceIds))
|
||||
.GroupBy(x => x.PriceId)
|
||||
.ToDictionary(x => x.Key, x => x.OrderBy(item => item.Id).ToList());
|
||||
|
||||
return prices.Select(price => new ServiceChannelPriceListOutput
|
||||
{
|
||||
Id = price.Id,
|
||||
ServiceChannelId = price.ServiceChannelId,
|
||||
SerialNumber = price.SerialNumber,
|
||||
Status = (byte)price.Status,
|
||||
PriceName = price.PriceName,
|
||||
CostItem = price.CostItem,
|
||||
CostUnit = price.CostUnit,
|
||||
Currency = price.Currency,
|
||||
ChargingCondition = price.ChargingCondition,
|
||||
Factors = factorMap.TryGetValue(price.Id, out var factors)
|
||||
? factors.Select(f => new ChannelPriceFactorOutput
|
||||
{
|
||||
Id = f.Id,
|
||||
PriceId = f.PriceId,
|
||||
SerialNumber = f.SerialNumber,
|
||||
Factor = f.Factor,
|
||||
FactorValues = OmsDocHelper.DeserializeJson<List<string>>(f.FactorValues) ?? []
|
||||
}).ToList()
|
||||
: [],
|
||||
Details = detailMap.TryGetValue(price.Id, out var details)
|
||||
? details.Select(d => new ChannelPriceDetailOutput
|
||||
{
|
||||
Id = d.Id,
|
||||
PriceId = d.PriceId,
|
||||
FactorValuesJson = OmsDocHelper.DeserializeJsonObject(d.FactorValuesJson),
|
||||
CalculationFormula = d.CalculationFormula,
|
||||
CalculatedValue = d.CalculatedValue,
|
||||
CustomerGroupValues = OmsDocHelper.DeserializeJsonObject(d.CustomerGroupValues)
|
||||
}).ToList()
|
||||
: []
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private static Dictionary<string, decimal> SumByCurrency(IEnumerable<SalesProductBillingSimulateFeeOutput> fees)
|
||||
{
|
||||
return fees
|
||||
.GroupBy(x => string.IsNullOrWhiteSpace(x.Currency) ? "UNK" : x.Currency.Trim(), StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(g => g.Key, g => g.Sum(x => x.Amount), StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
@ -153,6 +153,7 @@ public partial class SalesProductService
|
||||
PublishUser = entity.PublishUser,
|
||||
PublishTime = entity.PublishTime,
|
||||
Description = entity.Description,
|
||||
AiAnalysisReport = entity.AiAnalysisReport,
|
||||
Content = operatorType == PriceOperatorType
|
||||
? OmsDocHelper.ParseSalesProductPricePublishContentForApi(entity.Content)
|
||||
: OmsDocHelper.ToSnapshotApiContent(OmsDocHelper.DeserializeRulesSnapshot(entity.Content)),
|
||||
@ -210,6 +211,8 @@ public partial class SalesProductService
|
||||
MinTimeliness = product.MinTimeliness,
|
||||
MaxTimeliness = product.MaxTimeliness,
|
||||
TradeTerms = product.TradeTerms,
|
||||
RouteSort = product.RouteSort,
|
||||
AdditionalServices = product.AdditionalServices,
|
||||
CustomerWaybill = product.CustomerWaybill,
|
||||
LabelTemplateId = product.LabelTemplateId,
|
||||
BlacklistAreaId = product.BlacklistAreaId,
|
||||
@ -219,7 +222,8 @@ public partial class SalesProductService
|
||||
WeightRoundingId = product.WeightRoundingId,
|
||||
ProductDescription = product.ProductDescription,
|
||||
PreStorageScript = product.PreStorageScript,
|
||||
CustomerGuideMarkdown = product.CustomerGuideMarkdown,
|
||||
// 对客说明不常变动,且有独立保存入口;规则发布快照跳过,避免配置发布被其 diff 干扰
|
||||
CustomerGuideMarkdown = null,
|
||||
IsActive = product.IsActive,
|
||||
Scheme = product.Scheme
|
||||
};
|
||||
@ -227,11 +231,25 @@ public partial class SalesProductService
|
||||
/// <summary>
|
||||
/// 为当前配置生成发布快照。
|
||||
/// </summary>
|
||||
private async Task CreatePublishRecordAsync(int salesProductId, string operatorType, string? description)
|
||||
private async Task CreatePublishRecordAsync(
|
||||
int salesProductId,
|
||||
string operatorType,
|
||||
string? description,
|
||||
string? aiAnalysisReport = null)
|
||||
{
|
||||
object snapshot = operatorType == PriceOperatorType
|
||||
? await BuildPricePublishSnapshotAsync(salesProductId)
|
||||
: await BuildRulesPublishSnapshotAsync(salesProductId);
|
||||
object snapshot;
|
||||
if (operatorType == PriceOperatorType)
|
||||
{
|
||||
var priceSnapshot = await BuildPricePublishSnapshotAsync(salesProductId);
|
||||
ValidateBillingPriceItemRules(
|
||||
priceSnapshot.Prices.Select(p => MapPriceSaveInput(p, salesProductId)).ToList());
|
||||
await PriceAreaSnapshotHelper.EnsureSingleResolvedPriceAreaAsync(priceSnapshot, KpiAreaRepository);
|
||||
snapshot = priceSnapshot;
|
||||
}
|
||||
else
|
||||
{
|
||||
snapshot = await BuildRulesPublishSnapshotAsync(salesProductId);
|
||||
}
|
||||
|
||||
// Content 中保存完整快照,回滚时直接从快照恢复,避免依赖当前库内状态。
|
||||
await SalesProductRepository.InsertPublishRecordAsync(new SalesProductPublishRecord
|
||||
@ -243,6 +261,7 @@ public partial class SalesProductService
|
||||
PublishUser = string.IsNullOrWhiteSpace(CurrentUser.UserName) ? CurrentUser.GetId<int>().ToString() : CurrentUser.UserName!,
|
||||
PublishTime = DateTime.Now,
|
||||
Description = description,
|
||||
AiAnalysisReport = string.IsNullOrWhiteSpace(aiAnalysisReport) ? null : aiAnalysisReport.Trim(),
|
||||
Content = OmsDocHelper.SerializeSnapshotJson(snapshot)
|
||||
});
|
||||
}
|
||||
@ -316,16 +335,19 @@ public partial class SalesProductService
|
||||
entity.MinTimeliness = input.MinTimeliness;
|
||||
entity.MaxTimeliness = input.MaxTimeliness;
|
||||
entity.TradeTerms = NormalizeTradeTerms(input.TradeTerms);
|
||||
entity.RouteSort = input.RouteSort < 0 ? 0 : input.RouteSort;
|
||||
entity.AdditionalServices = NormalizeAdditionalServices(input.AdditionalServices);
|
||||
entity.CustomerWaybill = input.CustomerWaybill;
|
||||
entity.LabelTemplateId = input.LabelTemplateId;
|
||||
entity.BlacklistAreaId = input.BlacklistAreaId;
|
||||
entity.RemoteAreaId = input.RemoteAreaId;
|
||||
entity.PriceAreaId = input.PriceAreaId;
|
||||
// 价格分区改由卖价明细分区推断并固化进发布快照,产品表不再持久化 PriceAreaId。
|
||||
entity.PriceAreaId = null;
|
||||
entity.WeightRuleId = input.WeightRuleId;
|
||||
entity.WeightRoundingId = input.WeightRoundingId;
|
||||
entity.ProductDescription = input.ProductDescription;
|
||||
entity.PreStorageScript = input.PreStorageScript;
|
||||
entity.CustomerGuideMarkdown = input.CustomerGuideMarkdown;
|
||||
// 对客说明仅通过 /customer-guide/save 维护,产品配置保存/发布不覆盖
|
||||
entity.IsActive = input.IsActive;
|
||||
entity.Scheme = string.IsNullOrWhiteSpace(input.Scheme) ? AllocationSchemeCodes.CostLowest : input.Scheme;
|
||||
}
|
||||
@ -336,6 +358,85 @@ public partial class SalesProductService
|
||||
return value is "DDP" or "DDU" ? value : null;
|
||||
}
|
||||
|
||||
private static SalesProductPricePublishSnapshotDto BuildPriceSnapshotFromSaveInputs(
|
||||
int salesProductId,
|
||||
IReadOnlyList<SalesProductPriceSaveInput> prices) =>
|
||||
new()
|
||||
{
|
||||
SalesProductId = salesProductId,
|
||||
Prices = prices.Select(price => new SalesProductPriceSnapshotItemDto
|
||||
{
|
||||
Id = price.Id ?? 0,
|
||||
SerialNumber = price.SerialNumber,
|
||||
Status = (byte)price.Status,
|
||||
PriceName = price.PriceName,
|
||||
CostItem = price.CostItem,
|
||||
CostUnit = price.CostUnit,
|
||||
Currency = price.Currency,
|
||||
ChargingCondition = price.ChargingCondition,
|
||||
Details = price.Details.Select(detail => new ChannelPriceDetailOutput
|
||||
{
|
||||
Id = detail.Id ?? 0,
|
||||
FactorValuesJson = detail.FactorValuesJson,
|
||||
CalculationFormula = detail.CalculationFormula,
|
||||
CalculatedValue = detail.CalculatedValue,
|
||||
CustomerGroupValues = detail.CustomerGroupValues
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 保险/偏远费等附加费用项的计费条件校验。
|
||||
/// </summary>
|
||||
private static void ValidateBillingPriceItemRules(IReadOnlyList<SalesProductPriceSaveInput> prices)
|
||||
{
|
||||
foreach (var price in prices)
|
||||
{
|
||||
var costItem = price.CostItem?.Trim() ?? string.Empty;
|
||||
var condition = price.ChargingCondition?.Trim() ?? string.Empty;
|
||||
if (costItem.Equals("insurance", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(condition)
|
||||
|| string.Equals(condition, "无", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new Fake.Application.BusinessException("保险费用项必须配置非空计费条件(不能为「无」)");
|
||||
}
|
||||
}
|
||||
|
||||
if (costItem.Equals("remoteFee", StringComparison.OrdinalIgnoreCase)
|
||||
|| costItem.Equals("remote_fee", StringComparison.OrdinalIgnoreCase)
|
||||
|| costItem.Contains("偏远", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!condition.Contains("是否偏远", StringComparison.Ordinal))
|
||||
{
|
||||
throw new Fake.Application.BusinessException("偏远费用项的计费条件必须包含「是否偏远」");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string? NormalizeAdditionalServices(string? raw)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(raw))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var trimmed = raw.Trim();
|
||||
var codes = OmsDocHelper.DeserializeJson<List<string>>(trimmed);
|
||||
if (codes == null)
|
||||
{
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
var normalized = codes
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Select(x => x.Trim())
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
return normalized.Count == 0 ? null : OmsDocHelper.SerializeJson(normalized);
|
||||
}
|
||||
|
||||
private static SalesProductListOutput MapListOutput(SalesProduct entity)
|
||||
{
|
||||
return new SalesProductListOutput
|
||||
@ -346,6 +447,8 @@ public partial class SalesProductService
|
||||
ProductGroup = entity.ProductGroup,
|
||||
MinTimeliness = entity.MinTimeliness,
|
||||
MaxTimeliness = entity.MaxTimeliness,
|
||||
RouteSort = entity.RouteSort,
|
||||
AdditionalServices = entity.AdditionalServices,
|
||||
CustomerWaybill = entity.CustomerWaybill,
|
||||
LabelTemplateId = entity.LabelTemplateId,
|
||||
BlacklistAreaId = entity.BlacklistAreaId,
|
||||
@ -374,6 +477,8 @@ public partial class SalesProductService
|
||||
MinTimeliness = entity.MinTimeliness,
|
||||
MaxTimeliness = entity.MaxTimeliness,
|
||||
TradeTerms = entity.TradeTerms,
|
||||
RouteSort = entity.RouteSort,
|
||||
AdditionalServices = entity.AdditionalServices,
|
||||
CustomerWaybill = entity.CustomerWaybill,
|
||||
LabelTemplateId = entity.LabelTemplateId,
|
||||
BlacklistAreaId = entity.BlacklistAreaId,
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oms.Application.Dtos.Channels;
|
||||
using Oms.Domain.Shared.Enums;
|
||||
using Oms.Domain.SystemAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Channels;
|
||||
|
||||
public partial class SalesProductService
|
||||
{
|
||||
private const string SalesProductGroupDictType = "sales_product_group";
|
||||
private const string UngroupedProductGroupCode = "_ungrouped";
|
||||
private const string DomesticPickupGroupNameKeyword = "国内揽收";
|
||||
|
||||
private IDictRepository DictRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IDictRepository>();
|
||||
|
||||
/// <summary>
|
||||
/// 官网线路目录(匿名):仅启用产品,排除「国内揽收」分组。
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("/channel/sales-product/portal/catalog")]
|
||||
public async Task<SalesProductPortalCatalogOutput> GetPortalCatalogAsync()
|
||||
{
|
||||
var products = await SalesProductRepository.GetListAsync(x => x.IsActive == EnableStatus.Enabled);
|
||||
var dictRows = await DictRepository.GetListAsync(x => x.DictType == SalesProductGroupDictType);
|
||||
|
||||
var domesticPickupGroupCodes = dictRows
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.DictName)
|
||||
&& x.DictName.Trim().Contains(DomesticPickupGroupNameKeyword))
|
||||
.Select(x => (x.DictCode ?? string.Empty).Trim())
|
||||
.Where(code => !string.IsNullOrWhiteSpace(code))
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var groupNameMap = dictRows
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.DictCode))
|
||||
.GroupBy(x => x.DictCode!.Trim(), StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(
|
||||
g => g.Key,
|
||||
g =>
|
||||
{
|
||||
var name = g.First().DictName?.Trim();
|
||||
return string.IsNullOrWhiteSpace(name) ? g.Key : name;
|
||||
},
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
groupNameMap[UngroupedProductGroupCode] = "未分组";
|
||||
|
||||
var filtered = products
|
||||
.Where(p =>
|
||||
{
|
||||
var groupCode = string.IsNullOrWhiteSpace(p.ProductGroup)
|
||||
? UngroupedProductGroupCode
|
||||
: p.ProductGroup.Trim();
|
||||
return !domesticPickupGroupCodes.Contains(groupCode);
|
||||
})
|
||||
.OrderBy(p => p.RouteSort)
|
||||
.ThenBy(p => p.MinTimeliness ?? int.MaxValue)
|
||||
.ThenBy(p => p.ProductName, StringComparer.OrdinalIgnoreCase)
|
||||
.ThenBy(p => p.Id)
|
||||
.ToList();
|
||||
|
||||
var usedGroupCodes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
var items = filtered.Select(p =>
|
||||
{
|
||||
var groupCode = string.IsNullOrWhiteSpace(p.ProductGroup)
|
||||
? UngroupedProductGroupCode
|
||||
: p.ProductGroup.Trim();
|
||||
usedGroupCodes.Add(groupCode);
|
||||
groupNameMap.TryGetValue(groupCode, out var groupName);
|
||||
return new SalesProductPortalItemOutput
|
||||
{
|
||||
Id = p.Id,
|
||||
ProductName = p.ProductName,
|
||||
ProductGroup = groupCode == UngroupedProductGroupCode ? null : groupCode,
|
||||
ProductGroupName = string.IsNullOrWhiteSpace(groupName) ? groupCode : groupName,
|
||||
MinTimeliness = p.MinTimeliness,
|
||||
MaxTimeliness = p.MaxTimeliness,
|
||||
TradeTerms = string.IsNullOrWhiteSpace(p.TradeTerms) ? null : p.TradeTerms.Trim().ToUpperInvariant(),
|
||||
RouteSort = p.RouteSort,
|
||||
ProductDescription = p.ProductDescription
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
var groups = new List<SalesProductPortalGroupOutput>();
|
||||
var consumed = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var dict in dictRows.OrderBy(x => x.DictSort).ThenBy(x => x.DictCode))
|
||||
{
|
||||
var code = dict.DictCode?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(code)
|
||||
|| domesticPickupGroupCodes.Contains(code)
|
||||
|| !usedGroupCodes.Contains(code)
|
||||
|| !consumed.Add(code))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
groups.Add(new SalesProductPortalGroupOutput
|
||||
{
|
||||
Code = code,
|
||||
Name = string.IsNullOrWhiteSpace(dict.DictName) ? code : dict.DictName.Trim()
|
||||
});
|
||||
}
|
||||
|
||||
if (usedGroupCodes.Contains(UngroupedProductGroupCode) && consumed.Add(UngroupedProductGroupCode))
|
||||
{
|
||||
groups.Add(new SalesProductPortalGroupOutput
|
||||
{
|
||||
Code = UngroupedProductGroupCode,
|
||||
Name = groupNameMap[UngroupedProductGroupCode]
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var code in usedGroupCodes.OrderBy(x => x, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!consumed.Add(code)) continue;
|
||||
groupNameMap.TryGetValue(code, out var name);
|
||||
groups.Add(new SalesProductPortalGroupOutput
|
||||
{
|
||||
Code = code,
|
||||
Name = string.IsNullOrWhiteSpace(name) ? code : name
|
||||
});
|
||||
}
|
||||
|
||||
return new SalesProductPortalCatalogOutput
|
||||
{
|
||||
Groups = groups,
|
||||
Items = items
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -158,6 +158,7 @@ public partial class SalesProductService : ApplicationService
|
||||
public async Task CreatePriceAsync(SalesProductPriceSaveInput input)
|
||||
{
|
||||
await GetProductOrThrowAsync(input.SalesProductId);
|
||||
ValidateBillingPriceItemRules([input]);
|
||||
await SalesProductRepository.InsertPriceAsync(
|
||||
new SalesProductPrice
|
||||
{
|
||||
@ -188,6 +189,7 @@ public partial class SalesProductService : ApplicationService
|
||||
throw new BusinessException("价格项归属不匹配");
|
||||
}
|
||||
|
||||
ValidateBillingPriceItemRules([input]);
|
||||
price.SerialNumber = input.SerialNumber;
|
||||
price.Status = input.Status;
|
||||
price.PriceName = input.PriceName;
|
||||
@ -234,6 +236,10 @@ public partial class SalesProductService : ApplicationService
|
||||
public async Task SavePriceAsync(SalesProductPriceSaveAllInput input)
|
||||
{
|
||||
await GetProductOrThrowAsync(input.SalesProductId);
|
||||
ValidateBillingPriceItemRules(input.Prices);
|
||||
await PriceAreaSnapshotHelper.EnsureSingleResolvedPriceAreaAsync(
|
||||
BuildPriceSnapshotFromSaveInputs(input.SalesProductId, input.Prices),
|
||||
KpiAreaRepository);
|
||||
var prices = new List<SalesProductPrice>();
|
||||
var factors = new List<SalesProductPriceFactor>();
|
||||
var details = new List<SalesProductPriceDetail>();
|
||||
@ -262,7 +268,16 @@ public partial class SalesProductService : ApplicationService
|
||||
await SalesProductRepository.ReplacePricesAsync(input.SalesProductId, prices, factors, details);
|
||||
if (input.Publish)
|
||||
{
|
||||
await CreatePublishRecordAsync(input.SalesProductId, PriceOperatorType, "保存并发布价格");
|
||||
if (string.IsNullOrWhiteSpace(input.AiAnalysisReport))
|
||||
{
|
||||
throw new Fake.Application.BusinessException("价格发布前须完成 AI 风险分析并保存报告");
|
||||
}
|
||||
|
||||
await CreatePublishRecordAsync(
|
||||
input.SalesProductId,
|
||||
PriceOperatorType,
|
||||
"保存并发布价格",
|
||||
input.AiAnalysisReport);
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +364,17 @@ public partial class SalesProductService : ApplicationService
|
||||
[HttpPost("/channel/sales-product/publish")]
|
||||
public async Task PublishAsync(SalesProductPublishInput input)
|
||||
{
|
||||
await CreatePublishRecordAsync(input.SalesProductId, NormalizeOperatorType(input.OperatorType), input.Description);
|
||||
var operatorType = NormalizeOperatorType(input.OperatorType);
|
||||
if (operatorType == PriceOperatorType && string.IsNullOrWhiteSpace(input.AiAnalysisReport))
|
||||
{
|
||||
throw new Fake.Application.BusinessException("价格发布前须完成 AI 风险分析并保存报告");
|
||||
}
|
||||
|
||||
await CreatePublishRecordAsync(
|
||||
input.SalesProductId,
|
||||
operatorType,
|
||||
input.Description,
|
||||
input.AiAnalysisReport);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -226,6 +226,7 @@ public partial class ServiceChannelService
|
||||
ForecastType = entity.ForecastType,
|
||||
ForecastCode = entity.ForecastCode,
|
||||
Description = entity.Description,
|
||||
RemoteAreaId = entity.RemoteAreaId,
|
||||
PreScript = entity.PreScript,
|
||||
IsActive = entity.IsActive
|
||||
};
|
||||
@ -307,10 +308,32 @@ public partial class ServiceChannelService
|
||||
entity.ForecastType = input.ForecastType;
|
||||
entity.ForecastCode = input.ForecastCode;
|
||||
entity.Description = input.Description;
|
||||
entity.RemoteAreaId = input.RemoteAreaId;
|
||||
entity.PreScript = input.PreScript;
|
||||
entity.IsActive = input.IsActive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 买价偏远费等附加费用项的计费条件校验。
|
||||
/// </summary>
|
||||
private static void ValidateBillingPriceItemRules(IReadOnlyList<ServiceChannelPriceSaveInput> prices)
|
||||
{
|
||||
foreach (var price in prices)
|
||||
{
|
||||
var costItem = price.CostItem?.Trim() ?? string.Empty;
|
||||
var condition = price.ChargingCondition?.Trim() ?? string.Empty;
|
||||
if (costItem.Equals("remoteFee", StringComparison.OrdinalIgnoreCase)
|
||||
|| costItem.Equals("remote_fee", StringComparison.OrdinalIgnoreCase)
|
||||
|| costItem.Contains("偏远", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!condition.Contains("是否偏远", StringComparison.Ordinal))
|
||||
{
|
||||
throw new Fake.Application.BusinessException("偏远费用项的计费条件必须包含「是否偏远」");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ServiceChannelGroupListOutput MapGroupListOutput(ServiceChannelGroup entity)
|
||||
{
|
||||
return new ServiceChannelGroupListOutput
|
||||
@ -338,6 +361,7 @@ public partial class ServiceChannelService
|
||||
ForecastType = entity.ForecastType,
|
||||
ForecastCode = entity.ForecastCode,
|
||||
Description = entity.Description,
|
||||
RemoteAreaId = entity.RemoteAreaId,
|
||||
IsActive = (byte)entity.IsActive,
|
||||
CreateTime = entity.CreateTime,
|
||||
UpdateTime = OmsDocHelper.NullIfDefault(entity.UpdateTime)
|
||||
@ -361,6 +385,7 @@ public partial class ServiceChannelService
|
||||
ForecastType = entity.ForecastType,
|
||||
ForecastCode = entity.ForecastCode,
|
||||
Description = entity.Description,
|
||||
RemoteAreaId = entity.RemoteAreaId,
|
||||
PreScript = entity.PreScript,
|
||||
IsActive = (byte)entity.IsActive,
|
||||
CreateTime = entity.CreateTime,
|
||||
|
||||
@ -208,6 +208,7 @@ public partial class ServiceChannelService : ApplicationService
|
||||
public async Task CreatePriceAsync(ServiceChannelPriceSaveInput input)
|
||||
{
|
||||
await GetEntityOrThrowAsync(input.ServiceChannelId);
|
||||
ValidateBillingPriceItemRules([input]);
|
||||
await ServiceChannelRepository.InsertPriceAsync(
|
||||
new ServiceChannelPrice
|
||||
{
|
||||
@ -238,6 +239,7 @@ public partial class ServiceChannelService : ApplicationService
|
||||
throw new BusinessException("买价项归属不匹配");
|
||||
}
|
||||
|
||||
ValidateBillingPriceItemRules([input]);
|
||||
price.SerialNumber = input.SerialNumber;
|
||||
price.Status = input.Status;
|
||||
price.PriceName = input.PriceName;
|
||||
@ -284,6 +286,7 @@ public partial class ServiceChannelService : ApplicationService
|
||||
public async Task SavePriceAsync(ServiceChannelPriceSaveAllInput input)
|
||||
{
|
||||
await GetEntityOrThrowAsync(input.ServiceChannelId);
|
||||
ValidateBillingPriceItemRules(input.Prices);
|
||||
var prices = new List<ServiceChannelPrice>();
|
||||
var factors = new List<ServiceChannelPriceFactor>();
|
||||
var details = new List<ServiceChannelPriceDetail>();
|
||||
|
||||
@ -140,6 +140,7 @@ public class CustomerAccountFlowService : ApplicationService
|
||||
{
|
||||
CustomerAccountFlowBizTypes.Recharge => "充值入账",
|
||||
CustomerAccountFlowBizTypes.OrderPay => "订单支付",
|
||||
CustomerAccountFlowBizTypes.PickupPay => "揽收支付",
|
||||
_ => bizType
|
||||
};
|
||||
}
|
||||
|
||||
@ -233,6 +233,10 @@ public class CustomerService : ApplicationService
|
||||
input.InviteCode,
|
||||
ReferralCodeRepository,
|
||||
CustomerRepository);
|
||||
await StaffAdvisorBinder.BindAdvisorOnCreateAsync(
|
||||
entity,
|
||||
input.AdvisorCode,
|
||||
RbacDbContext);
|
||||
await CustomerRepository.InsertAsync(entity);
|
||||
try
|
||||
{
|
||||
|
||||
@ -1,46 +1,49 @@
|
||||
using Fake.Application;
|
||||
using Fake.Users;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using Oms.Application.DataPerm;
|
||||
using Oms.Application.Dtos.Finance;
|
||||
using Oms.Application.Dtos.Shared;
|
||||
using Oms.Application.Services.Orders;
|
||||
using Oms.Application.Shared;
|
||||
using Oms.Domain.CustomersAggregate.Repositories;
|
||||
using Oms.Domain.OrdersAggregate;
|
||||
using Oms.Domain.OrdersAggregate.Consts;
|
||||
using Oms.Domain.OrdersAggregate.Repositories;
|
||||
using Oms.Domain.SystemAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Finance;
|
||||
|
||||
/// <summary>
|
||||
/// 财务相关 API<EFBFBD>。
|
||||
/// </summary>
|
||||
/// 财务相关 API。
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "OMS-Finance")]
|
||||
public class FinanceService : ApplicationService
|
||||
{
|
||||
private const string FeeItemDictType = "fee_item";
|
||||
private const int ExportMaxRows = 50000;
|
||||
|
||||
private IOrderRepository OrderRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IOrderRepository>();
|
||||
|
||||
private ICustomerRepository CustomerRepository =>
|
||||
LazyServiceProvider.GetRequiredService<ICustomerRepository>();
|
||||
|
||||
private IDictRepository DictRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IDictRepository>();
|
||||
|
||||
private EffectiveScopeBuilder DataScopeBuilder =>
|
||||
LazyServiceProvider.GetRequiredService<EffectiveScopeBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询应收应付(订单费用联查订单)<EFBFBD>。
|
||||
/// 分页查询应收应付(订单费用联查订单)。
|
||||
/// </summary>
|
||||
[HttpGet("/finance/receivable-payable/list")]
|
||||
public async Task<OmsPageResult<ReceivablePayablePaginatedOutput>> GetReceivablePayableListAsync(
|
||||
[FromQuery] ReceivablePayablePaginatedInput input)
|
||||
{
|
||||
var customerId = await OmsSessionHelper.ResolveListCustomerIdAsync(
|
||||
CustomerRepository,
|
||||
CurrentUser,
|
||||
input.CustomerId);
|
||||
var filter = BuildFilter(input, customerId);
|
||||
await ApplyInternalOrderDataScopeAsync(filter);
|
||||
|
||||
var filter = await BuildScopedFilterAsync(input);
|
||||
var pageIndex = OmsDocHelper.NormalizePage(input.Page);
|
||||
var pageSize = OmsDocHelper.NormalizePageSize(input.PageSize);
|
||||
var (rows, total) = await OrderRepository.GetReceivablePayablePagedListAsync(
|
||||
@ -48,6 +51,102 @@ public class FinanceService : ApplicationService
|
||||
pageSize,
|
||||
filter);
|
||||
|
||||
var items = await MapReceivablePayableRowsAsync(rows);
|
||||
return new OmsPageResult<ReceivablePayablePaginatedOutput>
|
||||
{
|
||||
Items = items,
|
||||
Total = total
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应收应付汇总(当前筛选条件下全量费用明细)。
|
||||
/// </summary>
|
||||
[HttpGet("/finance/receivable-payable/summary")]
|
||||
public async Task<ReceivablePayableSummaryOutput> GetReceivablePayableSummaryAsync(
|
||||
[FromQuery] ReceivablePayablePaginatedInput input)
|
||||
{
|
||||
var filter = await BuildScopedFilterAsync(input);
|
||||
var rows = await OrderRepository.GetReceivablePayableSummaryAsync(filter);
|
||||
var items = rows
|
||||
.Select(row => new ReceivablePayableSummaryItemOutput
|
||||
{
|
||||
FeeType = row.FeeType,
|
||||
FeeTypeName = GetFeeTypeName(row.FeeType),
|
||||
Currency = row.Currency,
|
||||
TotalAmount = row.TotalAmount,
|
||||
LineCount = row.LineCount
|
||||
})
|
||||
.OrderBy(x => x.FeeType)
|
||||
.ThenBy(x => x.Currency)
|
||||
.ToList();
|
||||
|
||||
return new ReceivablePayableSummaryOutput
|
||||
{
|
||||
TotalLines = items.Sum(x => x.LineCount),
|
||||
Items = items
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出应收应付 Excel。
|
||||
/// </summary>
|
||||
[HttpGet("/finance/receivable-payable/export")]
|
||||
public async Task<FileContentResult> ExportReceivablePayableAsync(
|
||||
[FromQuery] ReceivablePayablePaginatedInput input)
|
||||
{
|
||||
var filter = await BuildScopedFilterAsync(input);
|
||||
var rows = await OrderRepository.GetReceivablePayableExportListAsync(filter, ExportMaxRows);
|
||||
var items = await MapReceivablePayableRowsAsync(rows);
|
||||
var exportRows = items.Select(item => new
|
||||
{
|
||||
运单号 = item.ServiceNo,
|
||||
客户单号 = item.ClientNo,
|
||||
跟踪号 = item.TrackNo,
|
||||
客户编码 = item.CustomerCode,
|
||||
费用类型 = item.FeeTypeName,
|
||||
费用项 = item.CostItemName ?? item.CostItem,
|
||||
金额 = item.Amount,
|
||||
币种 = item.Currency,
|
||||
计费阶段 = item.ChargingStageName,
|
||||
订单状态 = item.OrderStatusName,
|
||||
支付状态 = item.IsPaid == 1 ? "已支付" : "未支付",
|
||||
产品编码 = item.ProductCode,
|
||||
渠道编码 = item.ChannelCode,
|
||||
目的国 = item.ConsigneeCountryName,
|
||||
下游服务商 = item.DownstreamProvider,
|
||||
价格编号 = item.PriceNo,
|
||||
价格生效时间 = item.PriceEffectiveTime,
|
||||
支付时间 = item.PayTime,
|
||||
收货时间 = item.ReceiveTime,
|
||||
发货时间 = item.ShipTime
|
||||
}).ToList();
|
||||
|
||||
await using var stream = new MemoryStream();
|
||||
await MiniExcel.SaveAsAsync(stream, exportRows);
|
||||
stream.Position = 0;
|
||||
return new FileContentResult(stream.ToArray(),
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
FileDownloadName = $"receivable-payable-{DateTime.Now:yyyyMMddHHmmss}.xlsx"
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<OrderReceivablePayableFilter> BuildScopedFilterAsync(
|
||||
ReceivablePayablePaginatedInput input)
|
||||
{
|
||||
var customerId = await OmsSessionHelper.ResolveListCustomerIdAsync(
|
||||
CustomerRepository,
|
||||
CurrentUser,
|
||||
input.CustomerId);
|
||||
var filter = BuildFilter(input, customerId);
|
||||
await ApplyInternalOrderDataScopeAsync(filter);
|
||||
return filter;
|
||||
}
|
||||
|
||||
private async Task<List<ReceivablePayablePaginatedOutput>> MapReceivablePayableRowsAsync(
|
||||
List<OrderReceivablePayableRow> rows)
|
||||
{
|
||||
var customerIds = rows
|
||||
.Select(x => x.Order.CustomerId)
|
||||
.Where(x => x.HasValue)
|
||||
@ -58,8 +157,9 @@ public class FinanceService : ApplicationService
|
||||
? []
|
||||
: await CustomerRepository.GetListAsync(x => customerIds.Contains(x.Id));
|
||||
var customerMap = customers.ToDictionary(x => x.Id);
|
||||
var feeItemNameMap = await BuildFeeItemNameMapAsync();
|
||||
|
||||
var items = rows.Select(row =>
|
||||
return rows.Select(row =>
|
||||
{
|
||||
string? customerCode = null;
|
||||
if (row.Order.CustomerId.HasValue
|
||||
@ -68,8 +168,12 @@ public class FinanceService : ApplicationService
|
||||
customerCode = customer.CustomerCode;
|
||||
}
|
||||
|
||||
var costItem = row.Fee.CostItem;
|
||||
feeItemNameMap.TryGetValue(costItem, out var costItemName);
|
||||
|
||||
return new ReceivablePayablePaginatedOutput
|
||||
{
|
||||
OrderId = row.Order.Id,
|
||||
ServiceNo = row.Order.ServiceNo,
|
||||
ClientNo = row.Order.ClientNo,
|
||||
TrackNo = row.Order.TrackNo,
|
||||
@ -85,7 +189,8 @@ public class FinanceService : ApplicationService
|
||||
ConsigneeCountryName = row.Order.ConsigneeCountryName,
|
||||
FeeType = row.Fee.Type,
|
||||
FeeTypeName = GetFeeTypeName(row.Fee.Type),
|
||||
CostItem = row.Fee.CostItem,
|
||||
CostItem = costItem,
|
||||
CostItemName = costItemName ?? ParcelBillingCalculator.ResolveFeeDisplayName(costItem, null),
|
||||
Amount = row.Fee.Amount,
|
||||
Currency = row.Fee.Currency,
|
||||
DownstreamProvider = row.Fee.DownstreamProvider,
|
||||
@ -95,27 +200,59 @@ public class FinanceService : ApplicationService
|
||||
ChargingStageName = GetChargingStageName(row.Fee.ChargingStage)
|
||||
};
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
return new OmsPageResult<ReceivablePayablePaginatedOutput>
|
||||
{
|
||||
Items = items,
|
||||
Total = total
|
||||
};
|
||||
private async Task<Dictionary<string, string>> BuildFeeItemNameMapAsync()
|
||||
{
|
||||
var dictRows = await DictRepository.GetListAsync(x => x.DictType == FeeItemDictType);
|
||||
return dictRows
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.DictCode))
|
||||
.GroupBy(x => x.DictCode.Trim(), StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(
|
||||
g => g.Key,
|
||||
g => g.First().DictName?.Trim() ?? g.Key,
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static OrderReceivablePayableFilter BuildFilter(
|
||||
ReceivablePayablePaginatedInput input,
|
||||
int? customerId) =>
|
||||
new()
|
||||
int? customerId)
|
||||
{
|
||||
var timeField = NormalizeTimeField(input.TimeField);
|
||||
var useCreateTime = timeField == "createTime";
|
||||
return new()
|
||||
{
|
||||
Keyword = input.Keyword,
|
||||
CustomerId = customerId,
|
||||
CreateTimeStart = input.StartTime,
|
||||
CreateTimeEnd = input.EndTime,
|
||||
CustomerCode = input.CustomerCode,
|
||||
CreateTimeStart = useCreateTime ? input.StartTime : null,
|
||||
CreateTimeEnd = useCreateTime ? input.EndTime : null,
|
||||
TimeField = timeField,
|
||||
TimeStart = input.StartTime,
|
||||
TimeEnd = input.EndTime,
|
||||
FeeType = input.FeeType,
|
||||
CostItem = input.CostItem,
|
||||
ChargingStage = input.ChargingStage
|
||||
ChargingStage = input.ChargingStage,
|
||||
EffectiveStageOnly = input.EffectiveStageOnly,
|
||||
IsPaid = NormalizeIsPaid(input.IsPaid)
|
||||
};
|
||||
}
|
||||
|
||||
private static int? NormalizeIsPaid(int? isPaid)
|
||||
{
|
||||
if (!isPaid.HasValue) return null;
|
||||
return isPaid.Value == 1 ? 1 : isPaid.Value == 0 ? 0 : null;
|
||||
}
|
||||
|
||||
private static string NormalizeTimeField(string? timeField)
|
||||
{
|
||||
var raw = timeField?.Trim();
|
||||
return raw switch
|
||||
{
|
||||
"receiveTime" or "shipTime" or "payTime" => raw,
|
||||
_ => "createTime"
|
||||
};
|
||||
}
|
||||
|
||||
private async Task ApplyInternalOrderDataScopeAsync(OrderReceivablePayableFilter filter)
|
||||
{
|
||||
|
||||
394
src/Oms.Application/Services/Kb/KbArticleService.cs
Normal file
394
src/Oms.Application/Services/Kb/KbArticleService.cs
Normal file
@ -0,0 +1,394 @@
|
||||
using System.Linq.Expressions;
|
||||
using Fake.Application;
|
||||
using Fake.Domain.Exceptions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oms.Application.Dtos.Kb;
|
||||
using Oms.Application.Dtos.Shared;
|
||||
using Oms.Application.Shared;
|
||||
using Oms.Domain.KbAggregate.Entities;
|
||||
using Oms.Domain.KbAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Kb;
|
||||
|
||||
/// <summary>
|
||||
/// 知识库文章:管理端 + 客户门户。
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "OMS-Kb")]
|
||||
public class KbArticleService : ApplicationService
|
||||
{
|
||||
private IKbArticleRepository ArticleRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IKbArticleRepository>();
|
||||
|
||||
private IKbCategoryRepository CategoryRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IKbCategoryRepository>();
|
||||
|
||||
[HttpPost("/kb/admin/article/page")]
|
||||
public async Task<OmsPageResult<KbArticleOutput>> AdminPageAsync(KbArticleListInput input)
|
||||
{
|
||||
var predicate = BuildAdminPredicate(input);
|
||||
var pageIndex = OmsDocHelper.NormalizePage(input.Page);
|
||||
var pageSize = OmsDocHelper.NormalizePageSize(input.PageSize);
|
||||
var entities = await ArticleRepository.GetPagedListAsync(
|
||||
predicate,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
new Dictionary<string, bool>
|
||||
{
|
||||
[nameof(KbArticle.IsPinned)] = false,
|
||||
[nameof(KbArticle.SortOrder)] = true,
|
||||
[nameof(KbArticle.Id)] = false
|
||||
});
|
||||
var total = await ArticleRepository.CountAsync(predicate);
|
||||
var categoryMap = await LoadCategoryNameMapAsync(entities.Select(x => x.CategoryId).Distinct());
|
||||
return new OmsPageResult<KbArticleOutput>
|
||||
{
|
||||
Total = total,
|
||||
Items = entities.Select(x => Map(x, categoryMap, input.IncludeContent)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet("/kb/admin/article/{id:int}")]
|
||||
public async Task<KbArticleOutput> AdminGetAsync(int id)
|
||||
{
|
||||
var entity = await GetArticleOrThrowAsync(id);
|
||||
var categoryMap = await LoadCategoryNameMapAsync([entity.CategoryId]);
|
||||
return Map(entity, categoryMap, includeContent: true);
|
||||
}
|
||||
|
||||
[HttpPost("/kb/admin/article/save")]
|
||||
public async Task<KbArticleOutput> SaveAsync(KbArticleSaveInput input)
|
||||
{
|
||||
ValidateSave(input);
|
||||
await EnsureCategoryExistsAsync(input.CategoryId);
|
||||
|
||||
KbArticle? entity = null;
|
||||
if (input.Id is > 0)
|
||||
{
|
||||
entity = await GetArticleOrThrowAsync(input.Id.Value);
|
||||
}
|
||||
|
||||
entity ??= new KbArticle();
|
||||
ApplySave(input, entity);
|
||||
|
||||
if (string.Equals(entity.Status, KbArticleStatusCodes.Published, StringComparison.OrdinalIgnoreCase)
|
||||
&& entity.PublishTime == null)
|
||||
{
|
||||
entity.PublishTime = DateTime.Now;
|
||||
}
|
||||
|
||||
if (entity.Id > 0)
|
||||
{
|
||||
await ArticleRepository.UpdateAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ArticleRepository.InsertAsync(entity);
|
||||
}
|
||||
|
||||
var categoryMap = await LoadCategoryNameMapAsync([entity.CategoryId]);
|
||||
return Map(entity, categoryMap, includeContent: true);
|
||||
}
|
||||
|
||||
[HttpPost("/kb/admin/article/publish")]
|
||||
public async Task PublishAsync(KbArticleIdInput input)
|
||||
{
|
||||
var entity = await GetArticleOrThrowAsync(input.Id);
|
||||
entity.Status = KbArticleStatusCodes.Published;
|
||||
entity.PublishTime ??= DateTime.Now;
|
||||
await ArticleRepository.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
[HttpPost("/kb/admin/article/offline")]
|
||||
public async Task OfflineAsync(KbArticleIdInput input)
|
||||
{
|
||||
var entity = await GetArticleOrThrowAsync(input.Id);
|
||||
entity.Status = KbArticleStatusCodes.Offline;
|
||||
await ArticleRepository.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
[HttpPost("/kb/admin/article/pin")]
|
||||
public async Task PinAsync(KbArticlePinInput input)
|
||||
{
|
||||
var entity = await GetArticleOrThrowAsync(input.Id);
|
||||
entity.IsPinned = input.IsPinned;
|
||||
await ArticleRepository.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
[HttpPost("/kb/admin/article/delete")]
|
||||
public async Task DeleteAsync(KbArticleIdInput input)
|
||||
{
|
||||
var entity = await GetArticleOrThrowAsync(input.Id);
|
||||
await ArticleRepository.DeleteAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>门户:启用分类列表(需客户登录)。</summary>
|
||||
[HttpGet("/kb/portal/category/list")]
|
||||
public async Task<OmsItemsResult<KbCategoryOutput>> PortalCategoryListAsync()
|
||||
{
|
||||
MarketingPortalSessionHelper.EnsureCustomerLogin(CurrentUser);
|
||||
var items = await CategoryRepository.GetListAsync(x => x.Enabled);
|
||||
var ordered = items.OrderBy(x => x.SortOrder).ThenBy(x => x.Id).ToList();
|
||||
return new OmsItemsResult<KbCategoryOutput>
|
||||
{
|
||||
Items = ordered.Select(x => new KbCategoryOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
Code = x.Code,
|
||||
Name = x.Name,
|
||||
SortOrder = x.SortOrder,
|
||||
Enabled = x.Enabled
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>门户:文章分页(需客户登录)。</summary>
|
||||
[HttpPost("/kb/portal/article/page")]
|
||||
public async Task<OmsPageResult<KbArticleOutput>> PortalPageAsync(KbPortalArticleListInput input)
|
||||
{
|
||||
MarketingPortalSessionHelper.EnsureCustomerLogin(CurrentUser);
|
||||
var predicate = BuildPortalPredicate(input.Keyword, input.CategoryId);
|
||||
var pageIndex = OmsDocHelper.NormalizePage(input.Page);
|
||||
var pageSize = OmsDocHelper.NormalizePageSize(input.PageSize);
|
||||
var entities = await ArticleRepository.GetPagedListAsync(
|
||||
predicate,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
new Dictionary<string, bool>
|
||||
{
|
||||
[nameof(KbArticle.IsPinned)] = false,
|
||||
[nameof(KbArticle.SortOrder)] = true,
|
||||
[nameof(KbArticle.PublishTime)] = false,
|
||||
[nameof(KbArticle.Id)] = false
|
||||
});
|
||||
var total = await ArticleRepository.CountAsync(predicate);
|
||||
var categoryMap = await LoadCategoryNameMapAsync(entities.Select(x => x.CategoryId).Distinct());
|
||||
return new OmsPageResult<KbArticleOutput>
|
||||
{
|
||||
Total = total,
|
||||
Items = entities.Select(x => Map(x, categoryMap, includeContent: false)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>门户:热门(需客户登录)。</summary>
|
||||
[HttpGet("/kb/portal/article/hot")]
|
||||
public async Task<OmsItemsResult<KbArticleOutput>> PortalHotAsync([FromQuery] int top = 10)
|
||||
{
|
||||
MarketingPortalSessionHelper.EnsureCustomerLogin(CurrentUser);
|
||||
top = Math.Clamp(top <= 0 ? 10 : top, 1, 50);
|
||||
var now = DateTime.Now;
|
||||
var all = await ArticleRepository.GetListAsync(x =>
|
||||
x.Status == KbArticleStatusCodes.Published
|
||||
&& x.Audience == KbAudienceCodes.Customer
|
||||
&& (x.ExpireTime == null || x.ExpireTime > now));
|
||||
var ordered = all
|
||||
.OrderByDescending(x => x.IsPinned)
|
||||
.ThenByDescending(x => x.ViewCount)
|
||||
.ThenByDescending(x => x.PublishTime)
|
||||
.ThenByDescending(x => x.Id)
|
||||
.Take(top)
|
||||
.ToList();
|
||||
var categoryMap = await LoadCategoryNameMapAsync(ordered.Select(x => x.CategoryId).Distinct());
|
||||
return new OmsItemsResult<KbArticleOutput>
|
||||
{
|
||||
Items = ordered.Select(x => Map(x, categoryMap, includeContent: false)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>门户:详情(需客户登录;浏览量 +1)。</summary>
|
||||
[HttpGet("/kb/portal/article/{id:int}")]
|
||||
public async Task<KbArticleOutput> PortalGetAsync(int id)
|
||||
{
|
||||
MarketingPortalSessionHelper.EnsureCustomerLogin(CurrentUser);
|
||||
var entity = await GetArticleOrThrowAsync(id);
|
||||
EnsurePortalVisible(entity);
|
||||
entity.ViewCount += 1;
|
||||
await ArticleRepository.UpdateAsync(entity);
|
||||
var categoryMap = await LoadCategoryNameMapAsync([entity.CategoryId]);
|
||||
return Map(entity, categoryMap, includeContent: true);
|
||||
}
|
||||
|
||||
private static Expression<Func<KbArticle, bool>> BuildAdminPredicate(KbArticleListInput input)
|
||||
{
|
||||
var keyword = NormalizeOptional(input.Keyword);
|
||||
var status = NormalizeOptional(input.Status);
|
||||
var audience = NormalizeOptional(input.Audience);
|
||||
var predicate = ExpressionPredicate.True<KbArticle>();
|
||||
|
||||
if (input.CategoryId is int categoryId)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(predicate, x => x.CategoryId == categoryId);
|
||||
}
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(predicate, x => x.Status == status);
|
||||
}
|
||||
|
||||
if (audience != null)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(predicate, x => x.Audience == audience);
|
||||
}
|
||||
|
||||
if (input.IsPinned is bool isPinned)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(predicate, x => x.IsPinned == isPinned);
|
||||
}
|
||||
|
||||
if (keyword != null)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(
|
||||
predicate,
|
||||
x => x.Title.Contains(keyword)
|
||||
|| (x.Summary != null && x.Summary.Contains(keyword))
|
||||
|| (x.Tags != null && x.Tags.Contains(keyword)));
|
||||
}
|
||||
|
||||
return predicate;
|
||||
}
|
||||
|
||||
private static Expression<Func<KbArticle, bool>> BuildPortalPredicate(string? keyword, int? categoryId)
|
||||
{
|
||||
var kw = NormalizeOptional(keyword);
|
||||
var now = DateTime.Now;
|
||||
var predicate = ExpressionPredicate.AndAlso(
|
||||
ExpressionPredicate.True<KbArticle>(),
|
||||
x => x.Status == KbArticleStatusCodes.Published
|
||||
&& x.Audience == KbAudienceCodes.Customer
|
||||
&& (x.ExpireTime == null || x.ExpireTime > now));
|
||||
|
||||
if (categoryId is int cid)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(predicate, x => x.CategoryId == cid);
|
||||
}
|
||||
|
||||
if (kw != null)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(
|
||||
predicate,
|
||||
x => x.Title.Contains(kw)
|
||||
|| (x.Summary != null && x.Summary.Contains(kw))
|
||||
|| (x.Tags != null && x.Tags.Contains(kw)));
|
||||
}
|
||||
|
||||
return predicate;
|
||||
}
|
||||
|
||||
private static void EnsurePortalVisible(KbArticle entity)
|
||||
{
|
||||
if (!string.Equals(entity.Audience, KbAudienceCodes.Customer, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.Equals(entity.Status, KbArticleStatusCodes.Published, StringComparison.OrdinalIgnoreCase)
|
||||
|| (entity.ExpireTime != null && entity.ExpireTime <= DateTime.Now))
|
||||
{
|
||||
throw new BusinessException("文章不存在或未发布");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task EnsureCategoryExistsAsync(int categoryId)
|
||||
{
|
||||
var exists = await CategoryRepository.AnyAsync(x => x.Id == categoryId && x.Enabled);
|
||||
if (!exists)
|
||||
{
|
||||
throw new BusinessException("分类不存在或已停用");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<KbArticle> GetArticleOrThrowAsync(int id)
|
||||
{
|
||||
var entity = await ArticleRepository.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
throw new BusinessException("文章不存在");
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private async Task<Dictionary<int, string>> LoadCategoryNameMapAsync(IEnumerable<int> ids)
|
||||
{
|
||||
var idList = ids.Where(x => x > 0).Distinct().ToList();
|
||||
if (idList.Count == 0)
|
||||
{
|
||||
return new Dictionary<int, string>();
|
||||
}
|
||||
|
||||
var categories = await CategoryRepository.GetListAsync(x => idList.Contains(x.Id));
|
||||
return categories.ToDictionary(x => x.Id, x => x.Name);
|
||||
}
|
||||
|
||||
private static void ValidateSave(KbArticleSaveInput input)
|
||||
{
|
||||
if (input.CategoryId <= 0)
|
||||
{
|
||||
throw new BusinessException("请选择分类");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(input.Title))
|
||||
{
|
||||
throw new BusinessException("标题不能为空");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(input.Content))
|
||||
{
|
||||
throw new BusinessException("正文不能为空");
|
||||
}
|
||||
|
||||
var audience = (input.Audience ?? string.Empty).Trim().ToLowerInvariant();
|
||||
if (audience is not (KbAudienceCodes.Customer or KbAudienceCodes.Internal))
|
||||
{
|
||||
throw new BusinessException("受众仅支持 customer / internal");
|
||||
}
|
||||
|
||||
var status = (input.Status ?? string.Empty).Trim().ToLowerInvariant();
|
||||
if (status is not (KbArticleStatusCodes.Draft or KbArticleStatusCodes.Published or KbArticleStatusCodes.Offline))
|
||||
{
|
||||
throw new BusinessException("状态仅支持 draft / published / offline");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplySave(KbArticleSaveInput input, KbArticle entity)
|
||||
{
|
||||
entity.CategoryId = input.CategoryId;
|
||||
entity.Title = input.Title.Trim();
|
||||
entity.Summary = NormalizeOptional(input.Summary);
|
||||
entity.Content = input.Content ?? string.Empty;
|
||||
entity.Audience = input.Audience.Trim().ToLowerInvariant();
|
||||
entity.Status = input.Status.Trim().ToLowerInvariant();
|
||||
entity.Tags = NormalizeOptional(input.Tags);
|
||||
entity.RelatedPath = NormalizeOptional(input.RelatedPath);
|
||||
entity.RelatedLabel = NormalizeOptional(input.RelatedLabel);
|
||||
entity.IsPinned = input.IsPinned;
|
||||
entity.SortOrder = input.SortOrder;
|
||||
entity.ExpireTime = input.ExpireTime;
|
||||
}
|
||||
|
||||
private static KbArticleOutput Map(
|
||||
KbArticle x,
|
||||
IReadOnlyDictionary<int, string> categoryMap,
|
||||
bool includeContent) =>
|
||||
new()
|
||||
{
|
||||
Id = x.Id,
|
||||
CategoryId = x.CategoryId,
|
||||
CategoryName = categoryMap.TryGetValue(x.CategoryId, out var name) ? name : null,
|
||||
Title = x.Title,
|
||||
Summary = x.Summary,
|
||||
Content = includeContent ? x.Content : null,
|
||||
Audience = x.Audience,
|
||||
Status = x.Status,
|
||||
Tags = x.Tags,
|
||||
RelatedPath = x.RelatedPath,
|
||||
RelatedLabel = x.RelatedLabel,
|
||||
IsPinned = x.IsPinned,
|
||||
SortOrder = x.SortOrder,
|
||||
PublishTime = x.PublishTime,
|
||||
ExpireTime = x.ExpireTime,
|
||||
ViewCount = x.ViewCount,
|
||||
UpdateTime = x.UpdateTime
|
||||
};
|
||||
|
||||
private static string? NormalizeOptional(string? value)
|
||||
{
|
||||
var trimmed = value?.Trim();
|
||||
return string.IsNullOrWhiteSpace(trimmed) ? null : trimmed;
|
||||
}
|
||||
}
|
||||
111
src/Oms.Application/Services/Kb/KbCategoryService.cs
Normal file
111
src/Oms.Application/Services/Kb/KbCategoryService.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using System.Linq.Expressions;
|
||||
using Fake.Application;
|
||||
using Fake.Domain.Exceptions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oms.Application.Dtos.Kb;
|
||||
using Oms.Application.Dtos.Shared;
|
||||
using Oms.Application.Shared;
|
||||
using Oms.Domain.KbAggregate.Entities;
|
||||
using Oms.Domain.KbAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Kb;
|
||||
|
||||
/// <summary>
|
||||
/// 知识库分类管理。
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "OMS-Kb")]
|
||||
public class KbCategoryService : ApplicationService
|
||||
{
|
||||
private IKbCategoryRepository CategoryRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IKbCategoryRepository>();
|
||||
|
||||
private IKbArticleRepository ArticleRepository =>
|
||||
LazyServiceProvider.GetRequiredService<IKbArticleRepository>();
|
||||
|
||||
[HttpGet("/kb/admin/category/list")]
|
||||
public async Task<OmsItemsResult<KbCategoryOutput>> AdminListAsync([FromQuery] bool? enabledOnly = null)
|
||||
{
|
||||
Expression<Func<KbCategory, bool>> predicate = ExpressionPredicate.True<KbCategory>();
|
||||
if (enabledOnly is bool enabled)
|
||||
{
|
||||
predicate = ExpressionPredicate.AndAlso(predicate, x => x.Enabled == enabled);
|
||||
}
|
||||
|
||||
var items = await CategoryRepository.GetListAsync(predicate);
|
||||
var ordered = items.OrderBy(x => x.SortOrder).ThenBy(x => x.Id).ToList();
|
||||
return new OmsItemsResult<KbCategoryOutput>
|
||||
{
|
||||
Items = ordered.Select(Map).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost("/kb/admin/category/save")]
|
||||
public async Task<KbCategoryOutput> SaveAsync(KbCategorySaveInput input)
|
||||
{
|
||||
var code = input.Code.Trim();
|
||||
var name = input.Name.Trim();
|
||||
if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new BusinessException("分类编码 / 名称不能为空");
|
||||
}
|
||||
|
||||
KbCategory? entity = null;
|
||||
if (input.Id is > 0)
|
||||
{
|
||||
entity = await CategoryRepository.FirstOrDefaultAsync(x => x.Id == input.Id.Value);
|
||||
if (entity == null)
|
||||
{
|
||||
throw new BusinessException("分类不存在");
|
||||
}
|
||||
}
|
||||
|
||||
if (await CategoryRepository.ExistsCodeAsync(code, entity?.Id))
|
||||
{
|
||||
throw new BusinessException($"分类编码已存在:{code}");
|
||||
}
|
||||
|
||||
entity ??= new KbCategory();
|
||||
entity.Code = code;
|
||||
entity.Name = name;
|
||||
entity.SortOrder = input.SortOrder;
|
||||
entity.Enabled = input.Enabled;
|
||||
|
||||
if (entity.Id > 0)
|
||||
{
|
||||
await CategoryRepository.UpdateAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
await CategoryRepository.InsertAsync(entity);
|
||||
}
|
||||
|
||||
return Map(entity);
|
||||
}
|
||||
|
||||
[HttpPost("/kb/admin/category/delete")]
|
||||
public async Task DeleteAsync(KbCategoryDeleteInput input)
|
||||
{
|
||||
var entity = await CategoryRepository.FirstOrDefaultAsync(x => x.Id == input.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
throw new BusinessException("分类不存在");
|
||||
}
|
||||
|
||||
var articleCount = await ArticleRepository.CountByCategoryIdAsync(entity.Id);
|
||||
if (articleCount > 0)
|
||||
{
|
||||
throw new BusinessException($"该分类下仍有 {articleCount} 篇文章,无法删除");
|
||||
}
|
||||
|
||||
await CategoryRepository.DeleteAsync(entity);
|
||||
}
|
||||
|
||||
private static KbCategoryOutput Map(KbCategory x) => new()
|
||||
{
|
||||
Id = x.Id,
|
||||
Code = x.Code,
|
||||
Name = x.Name,
|
||||
SortOrder = x.SortOrder,
|
||||
Enabled = x.Enabled
|
||||
};
|
||||
}
|
||||
@ -7,10 +7,10 @@ using Oms.Application.Dtos.Mcp;
|
||||
using Oms.Application.Dtos.Shared;
|
||||
using Oms.Application.Mcp;
|
||||
using Oms.Application.Shared;
|
||||
using Oms.Domain.AiAggregate.Repositories;
|
||||
using Oms.Domain.CustomersAggregate.Repositories;
|
||||
using Oms.Domain.McpAggregate.Entities;
|
||||
using Oms.Domain.McpAggregate.Repositories;
|
||||
using Oms.Domain.XhsAggregate.Repositories;
|
||||
|
||||
namespace Oms.Application.Services.Mcp;
|
||||
|
||||
@ -19,9 +19,9 @@ public class McpToolService : ApplicationService
|
||||
{
|
||||
private IMcpToolRepository McpToolRepository => LazyServiceProvider.GetRequiredService<IMcpToolRepository>();
|
||||
private IMcpToolExecutor ToolExecutor => LazyServiceProvider.GetRequiredService<IMcpToolExecutor>();
|
||||
private IXhsAiProviderRepository AiProviderRepository => LazyServiceProvider.GetRequiredService<IXhsAiProviderRepository>();
|
||||
private IAiProviderRepository AiProviderRepository => LazyServiceProvider.GetRequiredService<IAiProviderRepository>();
|
||||
private ICustomerRepository CustomerRepository => LazyServiceProvider.GetRequiredService<ICustomerRepository>();
|
||||
private XhsLlmClient LlmClient => LazyServiceProvider.GetRequiredService<XhsLlmClient>();
|
||||
private AiLlmClient LlmClient => LazyServiceProvider.GetRequiredService<AiLlmClient>();
|
||||
|
||||
/// <summary>列出 MCP 工具(内置目录 + 库表覆盖)</summary>
|
||||
[HttpPost("/mcp/tool/list")]
|
||||
@ -307,7 +307,7 @@ public class McpToolService : ApplicationService
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private async Task<Oms.Domain.XhsAggregate.Entities.XhsAiProvider> ResolveProviderAsync(
|
||||
private async Task<Oms.Domain.AiAggregate.Entities.AiProvider> ResolveProviderAsync(
|
||||
int customerId,
|
||||
string providerKey)
|
||||
{
|
||||
|
||||
@ -8,6 +8,8 @@ using Oms.Application.Shared;
|
||||
using Oms.Domain.ChannelsAggregate.Repositories;
|
||||
using Oms.Domain.OperationsAggregate.Entities;
|
||||
using Oms.Domain.OperationsAggregate.Repositories;
|
||||
using Oms.Domain.OrdersAggregate.Consts;
|
||||
using Oms.Domain.OrdersAggregate.Entities;
|
||||
using Oms.Domain.OrdersAggregate.Repositories;
|
||||
using Oms.Domain.SystemAggregate.Repositories;
|
||||
|
||||
@ -54,7 +56,8 @@ public class InboundRecordService : ApplicationService
|
||||
ProductCode = order.ProductCode,
|
||||
DestinationCountry = order.ConsigneeCountry,
|
||||
OrderStatus = order.OrderStatus,
|
||||
OrderStatusName = OmsDocHelper.GetOrderStatusName(order.OrderStatus)
|
||||
OrderStatusName = OmsDocHelper.GetOrderStatusName(order.OrderStatus),
|
||||
AllocationPendingReason = order.AllocationPendingReason
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(order.ProductCode))
|
||||
@ -103,6 +106,7 @@ public class InboundRecordService : ApplicationService
|
||||
"收货");
|
||||
|
||||
ParcelBillingValidators.EnsureInboundOrderStatus(order.OrderStatus);
|
||||
await EnsureInboundNotInFlightAsync(order, input.WaybillNo.Trim());
|
||||
|
||||
int? salesProductId = null;
|
||||
string? destinationCountry = order.ConsigneeCountry;
|
||||
@ -137,20 +141,13 @@ public class InboundRecordService : ApplicationService
|
||||
|
||||
var savedEntity = await InboundRecordRepository.InsertAsync(entity);
|
||||
|
||||
try
|
||||
{
|
||||
var refreshed = await OrderRepository.GetByWaybillNoAsync(input.WaybillNo.Trim());
|
||||
if (refreshed != null)
|
||||
{
|
||||
await AutoTriggerRuntimeService.FireAsync(refreshed, AutoTriggerTiming.Inbound, operatorId);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 自动触发失败不影响入库主流程
|
||||
}
|
||||
// 自动触发改异步,避免拉长扫码 RT
|
||||
AutoTriggerRuntimeService.EnqueueFire(order.Id, AutoTriggerTiming.Inbound, operatorId);
|
||||
|
||||
return ObjectMapper.Map<InboundRecord, InboundRecordOutput>(savedEntity);
|
||||
var refreshed = await OrderRepository.GetByWaybillNoAsync(input.WaybillNo.Trim());
|
||||
var output = ObjectMapper.Map<InboundRecord, InboundRecordOutput>(savedEntity);
|
||||
ApplyOrderStatusToInboundOutput(output, refreshed);
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -181,6 +178,14 @@ public class InboundRecordService : ApplicationService
|
||||
var productMap = products.ToDictionary(x => x.Id);
|
||||
var warehouseMap = warehouses.ToDictionary(x => x.Id);
|
||||
|
||||
var waybillNos = entities
|
||||
.Select(x => x.WaybillNo?.Trim())
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Cast<string>()
|
||||
.ToArray();
|
||||
var orderMap = await BuildOrderMapByWaybillNosAsync(waybillNos);
|
||||
|
||||
var items = entities.Select(entity =>
|
||||
{
|
||||
var output = ObjectMapper.Map<InboundRecord, InboundRecordOutput>(entity);
|
||||
@ -191,9 +196,88 @@ public class InboundRecordService : ApplicationService
|
||||
? warehouse.WarehouseName
|
||||
: null;
|
||||
output.OperatorName = entity.OperatorId?.ToString();
|
||||
var key = entity.WaybillNo?.Trim() ?? string.Empty;
|
||||
if (orderMap.TryGetValue(key, out var order))
|
||||
{
|
||||
ApplyOrderStatusToInboundOutput(output, order);
|
||||
}
|
||||
|
||||
return output;
|
||||
}).ToList();
|
||||
|
||||
return new OmsItemsResult<InboundRecordOutput> { Items = items };
|
||||
}
|
||||
|
||||
private async Task<Dictionary<string, Order>> BuildOrderMapByWaybillNosAsync(string[] waybillNos)
|
||||
{
|
||||
var map = new Dictionary<string, Order>(StringComparer.OrdinalIgnoreCase);
|
||||
if (waybillNos.Length == 0)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
var orders = await OrderRepository.GetListAsync(x =>
|
||||
waybillNos.Contains(x.ServiceNo)
|
||||
|| (x.TrackNo != null && waybillNos.Contains(x.TrackNo))
|
||||
|| (x.DownstreamServiceNo != null && waybillNos.Contains(x.DownstreamServiceNo))
|
||||
|| (x.ClientNo != null && waybillNos.Contains(x.ClientNo)));
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
void Put(string? key)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
map[key.Trim()] = order;
|
||||
}
|
||||
|
||||
Put(order.ServiceNo);
|
||||
Put(order.TrackNo);
|
||||
Put(order.DownstreamServiceNo);
|
||||
Put(order.ClientNo);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void ApplyOrderStatusToInboundOutput(InboundRecordOutput output, Order? order)
|
||||
{
|
||||
if (order == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
output.OrderId = order.Id;
|
||||
output.OrderStatus = order.OrderStatus;
|
||||
output.OrderStatusName = OmsDocHelper.GetOrderStatusName(order.OrderStatus);
|
||||
output.AllocationPendingReason = order.AllocationPendingReason;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 短时幂等:处理中重复扫码直接拒绝,避免双写入库记录与双投计费任务。
|
||||
/// </summary>
|
||||
private async Task EnsureInboundNotInFlightAsync(Order order, string waybillNo)
|
||||
{
|
||||
const int windowSeconds = 15;
|
||||
var now = DateTime.Now;
|
||||
|
||||
if (string.Equals(order.OrderStatus, OrderStatusCodes.PendingAllocation, StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(order.AllocationPendingReason?.Trim(), "入库后计费/排货处理中", StringComparison.Ordinal)
|
||||
&& order.ReceiveTime.HasValue
|
||||
&& (now - order.ReceiveTime.Value).TotalSeconds < windowSeconds)
|
||||
{
|
||||
throw new BusinessException("订单入库处理中,请勿重复扫描");
|
||||
}
|
||||
|
||||
var latest = await InboundRecordRepository.GetLatestByWaybillNoAsync(waybillNo);
|
||||
if (latest != null
|
||||
&& (now - latest.OperateTime).TotalSeconds < windowSeconds
|
||||
&& string.Equals(order.OrderStatus, OrderStatusCodes.PendingAllocation, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new BusinessException("订单入库处理中,请勿重复扫描");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,8 @@ public sealed class OrderBatchActionExecutor(
|
||||
OrderBatchActionCodes.Delete => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
OrderBatchActionCodes.Print => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
OrderBatchActionCodes.GenerateLabelPdf => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
OrderBatchActionCodes.InboundBilling => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
OrderBatchActionCodes.Reallocate => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
OrderBatchActionCodes.MarkProblematic => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
OrderBatchActionCodes.MarkClaimed => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
OrderBatchActionCodes.HandleStatusUpdate => await orderActionHandler.ExecuteAsync(message, cancellationToken),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user