文件
xionggeshop/addons/shopro/rename_brand_xiongge.sql

110 行
4.3 KiB
SQL

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

-- 雄戈小酒:将线上数据库「雄哥」统一改为「雄戈」(含演示分类/商品/装修)
-- 执行后:清除 Shopro 缓存 + 小程序重新编译
-- 建议先备份 fa_shopro_category、fa_shopro_goods、fa_shopro_decorate_content
SET @now = UNIX_TIMESTAMP();
-- ========== 1. Shopro 商城配置 ==========
UPDATE `fa_shopro_config`
SET `value` = REPLACE(REPLACE(REPLACE(REPLACE(`value`,
'雄哥小酒', '雄戈小酒'),
'雄哥系列', '雄戈系列'),
'贵州雄哥酒业有限公司', '贵州雄戈酒业有限公司'),
'雄哥酒业', '雄戈酒业')
WHERE `value` LIKE '%雄哥%';
-- ========== 2. FastAdmin 站点名称 ==========
UPDATE `fa_config`
SET `value` = '雄戈小酒'
WHERE `name` = 'name' AND (`value` LIKE '%雄哥%' OR `value` = '雄戈小酒');
-- ========== 3. 商品分类(含首页宫格「雄哥系列」等) ==========
UPDATE `fa_shopro_category`
SET `name` = REPLACE(REPLACE(`name`, '雄哥小酒', '雄戈小酒'), '雄哥系列', '雄戈系列'),
`description` = REPLACE(REPLACE(IFNULL(`description`, ''), '雄哥小酒', '雄戈小酒'), '雄哥', '雄戈'),
`updatetime` = @now
WHERE `name` LIKE '%雄哥%' OR IFNULL(`description`, '') LIKE '%雄哥%';
-- ========== 4. 演示商品及全部含「雄哥」的商品 ==========
UPDATE `fa_shopro_goods`
SET `title` = REPLACE(REPLACE(`title`, '雄哥小酒', '雄戈小酒'), '雄哥', '雄戈'),
`subtitle` = REPLACE(IFNULL(`subtitle`, ''), '雄哥', '雄戈'),
`content` = REPLACE(REPLACE(REPLACE(IFNULL(`content`, ''),
'贵州雄哥酒业有限公司', '贵州雄戈酒业有限公司'),
'雄哥小酒', '雄戈小酒'),
'雄哥', '雄戈'),
`updatetime` = @now
WHERE `title` LIKE '%雄哥%'
OR IFNULL(`subtitle`, '') LIKE '%雄哥%'
OR IFNULL(`content`, '') LIKE '%雄哥%';
-- ========== 5. 富文本 ==========
UPDATE `fa_shopro_richtext`
SET `title` = REPLACE(REPLACE(`title`, '雄哥小酒', '雄戈小酒'), '雄哥', '雄戈'),
`content` = REPLACE(REPLACE(REPLACE(`content`,
'雄哥小酒', '雄戈小酒'),
'贵州雄哥酒业有限公司', '贵州雄戈酒业有限公司'),
'雄哥', '雄戈'),
`updatetime` = @now
WHERE `title` LIKE '%雄哥%' OR `content` LIKE '%雄哥%';
-- ========== 6. 装修模板(轮播 path_name、首页宫格 list 等 JSON) ==========
UPDATE `fa_shopro_decorate`
SET `name` = REPLACE(REPLACE(`name`, '雄哥小酒', '雄戈小酒'), '雄哥', '雄戈'),
`updatetime` = @now
WHERE `name` LIKE '%雄哥%';
UPDATE `fa_shopro_decorate_content`
SET `content` = REPLACE(REPLACE(REPLACE(REPLACE(`content`,
'雄哥小酒礼盒', '雄戈小酒礼盒'),
'雄哥小酒', '雄戈小酒'),
'雄哥系列', '雄戈系列'),
'雄哥', '雄戈')
WHERE `content` LIKE '%雄哥%';
-- ========== 7. 运费模板 ==========
UPDATE `fa_shopro_dispatch`
SET `name` = REPLACE(`name`, '雄哥', '雄戈'),
`updatetime` = @now
WHERE `name` LIKE '%雄哥%';
-- ========== 8. 重建首页分类宫格(从已更新的子分类重新生成 list) ==========
SET @root_id = (
SELECT id FROM `fa_shopro_category`
WHERE `pid` = 0 AND `status` = 'normal'
ORDER BY `weigh` DESC, `id` DESC
LIMIT 1
);
SET @menu_json = (
SELECT CONCAT(
'{"name":"","style":5,"list":[',
IFNULL(GROUP_CONCAT(
JSON_OBJECT(
'name', `name`,
'image', `image`,
'path', CONCAT('/pages/goods/list?id=', `id`),
'path_name', `name`,
'path_type', 1
)
ORDER BY `weigh` DESC, `id` ASC
SEPARATOR ','
), ''),
']}'
)
FROM `fa_shopro_category`
WHERE `pid` = @root_id AND `type` = 'shop' AND `status` = 'normal'
);
UPDATE `fa_shopro_decorate_content`
SET `content` = @menu_json
WHERE `category` = 'home'
AND `type` = 'menu'
AND @menu_json IS NOT NULL
AND @menu_json LIKE '%"list":[{%';
-- 验证:
-- SELECT id, name FROM fa_shopro_category WHERE name LIKE '%雄戈%' OR name LIKE '%雄哥%';
-- SELECT id, title FROM fa_shopro_goods WHERE title LIKE '%演示%' OR title LIKE '%雄哥%' OR title LIKE '%雄戈%';
-- SELECT type, LEFT(content, 400) FROM fa_shopro_decorate_content WHERE category='home' AND type IN ('menu','banner');