更新若干功能

This commit is contained in:
2026-08-19 08:16:49 +08:00
parent 4979bb83d2
commit 72bc6502eb
56 changed files with 3627 additions and 343 deletions

View File

@@ -0,0 +1,49 @@
-- ============================================================
-- 装修模板只留 4 套轻奢:素胚 / 珠贝白 / 胡桃木 / 香槟金
-- 其余软删;经销商与应用绑了已删 code 的回落到空(走品牌默认)
-- 本脚本可重复执行:缺列先补,已处理过的行不再变
-- ============================================================
SET @db := DATABASE();
SET @now := UNIX_TIMESTAMP();
-- 有的库还没跑过 2026-08-14/03cc_wx_user 没有 template_code先补列再纠偏
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_wx_user' AND COLUMN_NAME = 'template_code'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `cc_wx_user` ADD COLUMN `template_code` varchar(50) NOT NULL DEFAULT '''' COMMENT ''经销商专属装修模板 code空=跟随品牌默认'' AFTER `price_number`',
'SELECT ''skip cc_wx_user.template_code'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
UPDATE `cc_wx_template`
SET `deleted_at` = @now, `updated_at` = @now, `is_default` = 0
WHERE `deleted_at` = 0
AND `code` NOT IN ('nature-clay', 'lux-pearl', 'lux-walnut', 'lux-champagne');
UPDATE `cc_wx_template`
SET `name` = '素胚', `style_tag` = '轻奢', `updated_at` = @now
WHERE `code` = 'nature-clay' AND `deleted_at` = 0;
UPDATE `cc_wx_user` u
LEFT JOIN `cc_wx_template` t
ON t.`code` = u.`template_code` AND t.`deleted_at` = 0
SET u.`template_code` = ''
WHERE u.`template_code` <> '' AND t.`id` IS NULL;
-- nl_wx_app 可能尚未建表,没有表就跳过
SET @app_exists := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'nl_wx_app'
);
SET @sql := IF(@app_exists = 0,
'SELECT ''skip nl_wx_app (table missing)'' AS msg',
'UPDATE `nl_wx_app` a
LEFT JOIN `cc_wx_template` t
ON t.`code` = a.`template_code` AND t.`deleted_at` = 0
SET a.`template_code` = ''lux-champagne'', a.`updated_at` = UNIX_TIMESTAMP()
WHERE a.`template_code` <> '''' AND t.`id` IS NULL'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

View File

@@ -0,0 +1,29 @@
-- ============================================================
-- 卡片画布方案表15 套预设由后台 init-presets 灌 layers JSON
-- ============================================================
SET @db := DATABASE();
SET @exists := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_wx_card_scheme'
);
SET @sql := IF(@exists = 0,
'CREATE TABLE `cc_wx_card_scheme` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '''' COMMENT ''方案名'',
`code` varchar(50) NOT NULL DEFAULT '''' COMMENT ''方案标识'',
`preview` varchar(500) NOT NULL DEFAULT '''' COMMENT ''缩略图'',
`layers` mediumtext COMMENT ''图层 JSON'',
`is_preset` tinyint NOT NULL DEFAULT 0 COMMENT ''1=内置预设,不可删'',
`app_code` varchar(20) NOT NULL DEFAULT '''' COMMENT ''品牌,空=通用'',
`sort` int NOT NULL DEFAULT 0,
`status` tinyint NOT NULL DEFAULT 0 COMMENT ''0=启用 1=停用'',
`created_at` int NOT NULL DEFAULT 0,
`updated_at` int NOT NULL DEFAULT 0,
`deleted_at` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_wx_card_scheme_code` (`code`, `app_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT=''小程序卡片画布方案''',
'SELECT ''skip cc_wx_card_scheme'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

View File

@@ -0,0 +1,13 @@
-- ============================================================
-- 七牛种子默认 path_prefix=uploads但本站历史对象都在 Bucket 根目录
-- b_*.jpg。列举再套这层前缀会拉回空列表。
-- 只清掉仍是种子默认值的行;运营自己改过的前缀不动。
-- ============================================================
SET @now := UNIX_TIMESTAMP();
UPDATE `nl_oss_config`
SET `path_prefix` = '', `updated_at` = @now
WHERE `driver` = 'qiniu'
AND `path_prefix` = 'uploads'
AND `deleted_at` = 0;

View File

@@ -0,0 +1,58 @@
-- ============================================================
-- 家具套餐:主表 + 搭配明细(幂等)
-- 金额一律整数分original_amount 由明细自动算package_amount 是独立报价
-- ============================================================
SET @db := DATABASE();
SET @exists := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_package'
);
SET @sql := IF(@exists = 0,
'CREATE TABLE `cc_package` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '''' COMMENT ''套餐名'',
`cover` varchar(500) NOT NULL DEFAULT '''' COMMENT ''封面'',
`subtitle` varchar(200) NOT NULL DEFAULT '''' COMMENT ''副标题'',
`remark` varchar(255) NOT NULL DEFAULT '''' COMMENT ''备注'',
`original_amount` int NOT NULL DEFAULT 0 COMMENT ''原价合计(分,倍率=1'',
`package_amount` int NOT NULL DEFAULT 0 COMMENT ''套餐报价(分,倍率=1'',
`is_hot` tinyint NOT NULL DEFAULT 0 COMMENT ''1=首页热门'',
`sort` int NOT NULL DEFAULT 0,
`status` tinyint NOT NULL DEFAULT 0 COMMENT ''0=上架 1=下架'',
`created_at` int NOT NULL DEFAULT 0,
`updated_at` int NOT NULL DEFAULT 0,
`deleted_at` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `idx_package_hot` (`is_hot`, `sort`, `status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT=''家具套餐''',
'SELECT ''skip cc_package'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @exists := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_package_item'
);
SET @sql := IF(@exists = 0,
'CREATE TABLE `cc_package_item` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`package_id` int NOT NULL DEFAULT 0 COMMENT ''套餐'',
`catalogue_id` int NOT NULL DEFAULT 0 COMMENT ''商品图册'',
`price_sheet_id` int NOT NULL DEFAULT 0 COMMENT ''规格行'',
`material_key` varchar(50) NOT NULL DEFAULT ''routine'' COMMENT ''材质键'',
`quantity` int NOT NULL DEFAULT 1 COMMENT ''数量'',
`unit_price` int NOT NULL DEFAULT 0 COMMENT ''该规格基准单价快照(分)'',
`sort` int NOT NULL DEFAULT 0,
`remark` varchar(255) NOT NULL DEFAULT '''',
`created_at` int NOT NULL DEFAULT 0,
`updated_at` int NOT NULL DEFAULT 0,
`deleted_at` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `idx_package_item_pkg` (`package_id`),
KEY `idx_package_item_cat` (`catalogue_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT=''套餐搭配明细''',
'SELECT ''skip cc_package_item'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

View File

@@ -0,0 +1,66 @@
-- ============================================================
-- 清单绑定套餐快照(幂等)
-- 加入套餐时记下套餐价/原价和每行快照,改规格后用差额补差价
-- ============================================================
SET @db := DATABASE();
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_list' AND COLUMN_NAME = 'package_id'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `cc_list` ADD COLUMN `package_id` int NOT NULL DEFAULT 0 COMMENT ''绑定套餐0=普通清单'' AFTER `status`',
'SELECT ''skip cc_list.package_id'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_list' AND COLUMN_NAME = 'package_amount'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `cc_list` ADD COLUMN `package_amount` int NOT NULL DEFAULT 0 COMMENT ''加入时套餐价快照(分,已乘倍率)'' AFTER `package_id`',
'SELECT ''skip cc_list.package_amount'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_list' AND COLUMN_NAME = 'original_amount'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `cc_list` ADD COLUMN `original_amount` int NOT NULL DEFAULT 0 COMMENT ''加入时原价快照(分,已乘倍率)'' AFTER `package_amount`',
'SELECT ''skip cc_list.original_amount'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_list_item' AND COLUMN_NAME = 'package_item_id'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `cc_list_item` ADD COLUMN `package_item_id` int NOT NULL DEFAULT 0 COMMENT ''来源套餐明细0=散件'' AFTER `remark`',
'SELECT ''skip cc_list_item.package_item_id'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_list_item' AND COLUMN_NAME = 'snapshot_unit_price'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `cc_list_item` ADD COLUMN `snapshot_unit_price` int NOT NULL DEFAULT 0 COMMENT ''加入时单价快照(分,已乘倍率)'' AFTER `package_item_id`',
'SELECT ''skip cc_list_item.snapshot_unit_price'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'cc_list_item' AND COLUMN_NAME = 'snapshot_quantity'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `cc_list_item` ADD COLUMN `snapshot_quantity` int NOT NULL DEFAULT 1 COMMENT ''加入时数量快照'' AFTER `snapshot_unit_price`',
'SELECT ''skip cc_list_item.snapshot_quantity'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

View File

@@ -0,0 +1,14 @@
-- ============================================================
-- 小程序应用:按品牌开关套餐(两品牌共库,不能写 nl_system_config
-- ============================================================
SET @db := DATABASE();
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'nl_wx_app' AND COLUMN_NAME = 'package_enabled'
);
SET @sql := IF(@exists = 0,
'ALTER TABLE `nl_wx_app` ADD COLUMN `package_enabled` tinyint NOT NULL DEFAULT 0 COMMENT ''1=启用套餐(首页热门+底栏)'' AFTER `template_code`',
'SELECT ''skip nl_wx_app.package_enabled'' AS msg'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;