From 000adafb422d629523f74452634977e9a46aeecb Mon Sep 17 00:00:00 2001 From: From-wh Date: Thu, 22 Oct 2026 09:51:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AE=9E=E7=89=A9=E5=95=86=E5=93=81):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A2=84=E5=94=AE=E5=8F=91=E8=B4=A7=E6=97=B6?= =?UTF-8?q?=E9=97=B4=20presale=5Fday=20=E5=AD=97=E6=AE=B5=E5=85=A8?= =?UTF-8?q?=E9=93=BE=E8=B7=AF=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/services/product/CenterProductServices.php | 6 ++++++ .../product/product/OutCenterProductServices.php | 6 ++++++ backend/modules/product/normal/Installer.php | 2 ++ .../normal/controller/admin/ProductController.php | 1 + .../product/normal/mcp/NormalProductUpdateTool.php | 1 + .../product/normal/service/ProductSaveServices.php | 9 ++++++++- .../modules/product/normal/service/ProductServices.php | 2 ++ backend/public/install/crmeb_table.sql | 1 + 8 files changed, 27 insertions(+), 1 deletion(-) diff --git a/backend/app/services/product/CenterProductServices.php b/backend/app/services/product/CenterProductServices.php index 14f266a12..5881a6a47 100644 --- a/backend/app/services/product/CenterProductServices.php +++ b/backend/app/services/product/CenterProductServices.php @@ -1326,6 +1326,12 @@ class CenterProductServices extends BaseService $data['presale'] = intval($data['presale']); $data['presale_start_time'] = $data['presale'] ? strtotime($data['presale_time'][0]) : 0; $data['presale_end_time'] = $data['presale'] ? strtotime($data['presale_time'][1]) : 0; + // 预售发货时间(预售活动结束后N天内发货):>0 才覆盖写入,未传时新增走列默认值1、编辑保持原值 + if (isset($data['presale_day']) && intval($data['presale_day']) > 0) { + $data['presale_day'] = intval($data['presale_day']); + } else { + unset($data['presale_day']); + } $data['is_limit'] = intval($data['is_limit']); if (!$data['is_limit']) { $data['limit_type'] = 0; diff --git a/backend/app/services/product/product/OutCenterProductServices.php b/backend/app/services/product/product/OutCenterProductServices.php index d8f76123a..732ecaa74 100644 --- a/backend/app/services/product/product/OutCenterProductServices.php +++ b/backend/app/services/product/product/OutCenterProductServices.php @@ -109,6 +109,12 @@ class OutCenterProductServices extends BaseService $data['presale'] = intval($data['presale']); $data['presale_start_time'] = $data['presale'] ? strtotime($data['presale_time'][0]) : 0; $data['presale_end_time'] = $data['presale'] ? strtotime($data['presale_time'][1]) : 0; + // 预售发货时间(预售活动结束后N天内发货):>0 才覆盖写入,未传时新增走列默认值1、编辑保持原值 + if (isset($data['presale_day']) && intval($data['presale_day']) > 0) { + $data['presale_day'] = intval($data['presale_day']); + } else { + unset($data['presale_day']); + } foreach ($detail as &$item) { if (isset($item['stock'])) { diff --git a/backend/modules/product/normal/Installer.php b/backend/modules/product/normal/Installer.php index ffeadb810..e6a6852a2 100644 --- a/backend/modules/product/normal/Installer.php +++ b/backend/modules/product/normal/Installer.php @@ -167,6 +167,7 @@ class Installer extends BaseModuleInstaller `presale` tinyint NOT NULL DEFAULT '0' COMMENT '是否预售(0否/1是)', `presale_start_time` int NOT NULL DEFAULT '0' COMMENT '预售开始时间', `presale_end_time` int NOT NULL DEFAULT '0' COMMENT '预售结束时间', + `presale_day` int NOT NULL DEFAULT '1' COMMENT '预售发货时间(预售活动结束后N天内发货)', `valid_type` tinyint NOT NULL DEFAULT '0' COMMENT '有效期类型(0长期/1固定时段/2购买后N天)', `valid_start_time` int NOT NULL DEFAULT '0' COMMENT '有效期开始时间', `valid_end_time` int NOT NULL DEFAULT '0' COMMENT '有效期结束时间', @@ -256,6 +257,7 @@ class Installer extends BaseModuleInstaller 'is_sub' => "tinyint NOT NULL DEFAULT '0' COMMENT '是否开启分销(0否/1是)'", 'is_vip' => "tinyint NOT NULL DEFAULT '0' COMMENT '是否开启会员价(0否/1是)'", 'vip_product' => "tinyint NOT NULL DEFAULT '0' COMMENT '会员专属(0不限制/1仅会员可见可买/2所有人可见仅会员可买)'", + 'presale_day' => "int NOT NULL DEFAULT '1' COMMENT '预售发货时间(预售活动结束后N天内发货)'", ]; foreach ($columns as $column => $definition) { $this->ensureColumn($tableName, $column, $definition); diff --git a/backend/modules/product/normal/controller/admin/ProductController.php b/backend/modules/product/normal/controller/admin/ProductController.php index 7795ebb7e..ad710d31a 100644 --- a/backend/modules/product/normal/controller/admin/ProductController.php +++ b/backend/modules/product/normal/controller/admin/ProductController.php @@ -269,6 +269,7 @@ class ProductController extends AuthController ['vip_product', 0], ['presale', 0], ['presale_time', []], + ['presale_day', 1], ['product_type', 'normal'], ['custom_form', []], ['params_list', []], diff --git a/backend/modules/product/normal/mcp/NormalProductUpdateTool.php b/backend/modules/product/normal/mcp/NormalProductUpdateTool.php index f37ea2b4b..e6e4b83ce 100644 --- a/backend/modules/product/normal/mcp/NormalProductUpdateTool.php +++ b/backend/modules/product/normal/mcp/NormalProductUpdateTool.php @@ -280,6 +280,7 @@ class NormalProductUpdateTool implements McpToolInterface 'vip_product' => (int)($current['vip_product'] ?? 0), 'presale' => (int)($current['presale'] ?? 0), 'presale_time' => (array)($current['presale_time'] ?? []), + 'presale_day' => max(1, (int)($current['presale_day'] ?? 1)), 'is_limit' => (int)($current['is_limit'] ?? 0), 'min_qty' => (int)($current['min_qty'] ?? 1), 'limit_type' => (int)($current['limit_type'] ?? 0), diff --git a/backend/modules/product/normal/service/ProductSaveServices.php b/backend/modules/product/normal/service/ProductSaveServices.php index cd34f7867..e1c29dec1 100644 --- a/backend/modules/product/normal/service/ProductSaveServices.php +++ b/backend/modules/product/normal/service/ProductSaveServices.php @@ -428,7 +428,7 @@ class ProductSaveServices extends BaseService $presaleStartTime = $presale && !empty($data['presale_time']) ? strtotime($data['presale_time'][0]) : 0; $presaleEndTime = $presale && !empty($data['presale_time']) ? strtotime($data['presale_time'][1]) : 0; - return [ + $centerData = [ 'product_type' => $productType, 'name' => $data['store_name'] ?? '', 'intro' => $intro, @@ -480,6 +480,13 @@ class ProductSaveServices extends BaseService 'give_integral' => floatval($data['give_integral'] ?? 0), 'give_coupon_ids' => !empty($data['coupon_ids']) && is_array($data['coupon_ids']) ? implode(',', $data['coupon_ids']) : '', ]; + // 预售发货时间(预售活动结束后N天内发货):仅调用方显式提供时才写入(最小1天), + // 未提供时新增走列默认值1、编辑保持库中原值,避免不带该字段的保存把已配置值重置 + if (isset($data['presale_day'])) { + $centerData['presale_day'] = max(1, intval($data['presale_day'])); + } + + return $centerData; } /** diff --git a/backend/modules/product/normal/service/ProductServices.php b/backend/modules/product/normal/service/ProductServices.php index 7c769ca6e..b82df9160 100644 --- a/backend/modules/product/normal/service/ProductServices.php +++ b/backend/modules/product/normal/service/ProductServices.php @@ -145,6 +145,8 @@ class ProductServices $pst = $product['presale_start_time'] ?? 0; $pet = $product['presale_end_time'] ?? 0; $product['presale_time'] = $pst == 0 ? [] : [date('Y-m-d H:i:s', $pst), date('Y-m-d H:i:s', $pet)]; + // 预售发货时间(预售活动结束后N天内发货),历史数据无值时回退默认1天 + $product['presale_day'] = max(1, (int)($product['presale_day'] ?? 1)); // ============ 视频 ============ $vl = $product['video_link'] ?? ''; diff --git a/backend/public/install/crmeb_table.sql b/backend/public/install/crmeb_table.sql index 46e8f8436..dfffc4764 100755 --- a/backend/public/install/crmeb_table.sql +++ b/backend/public/install/crmeb_table.sql @@ -1072,6 +1072,7 @@ CREATE TABLE IF NOT EXISTS `eb_product_center` ( `presale` tinyint NOT NULL DEFAULT '0' COMMENT '是否预售(0否/1是)', `presale_start_time` int NOT NULL DEFAULT '0' COMMENT '预售开始时间', `presale_end_time` int NOT NULL DEFAULT '0' COMMENT '预售结束时间', + `presale_day` int NOT NULL DEFAULT '1' COMMENT '预售发货时间(预售活动结束后N天内发货)', `valid_type` tinyint NOT NULL DEFAULT '0' COMMENT '有效期类型(0长期有效/1固定时段/2购买后N天)', `valid_start_time` int NOT NULL DEFAULT '0' COMMENT '有效期开始时间(valid_type=1时有效)', `valid_end_time` int NOT NULL DEFAULT '0' COMMENT '有效期结束时间(valid_type=1时有效)',