feat(实物商品): 新增预售发货时间 presale_day 字段全链路支持

This commit is contained in:
From-wh 2026-10-22 09:51:55 +08:00 committed by 吴昊天
parent 1b8714b752
commit 000adafb42
8 changed files with 27 additions and 1 deletions

View File

@ -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;

View File

@ -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'])) {

View File

@ -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);

View File

@ -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', []],

View File

@ -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),

View File

@ -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;
}
/**

View File

@ -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'] ?? '';

View File

@ -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时有效)',