USE mall4cloud_admin;
ALTER TABLE shop_wallet DROP COLUMN zone_num;
ALTER TABLE supplier_wallet DROP COLUMN zone_num;
# 把钱包分片的内容整合到总钱包中
UPDATE shop_wallet sw
    JOIN (SELECT SUM(unsettled_amount) AS unsettled_amount, SUM(settled_amount) AS settled_amount,
                 SUM(total_settled_amount) AS total_settled_amount,shop_id, pay_sys_type
          FROM shop_wallet_zone
          GROUP BY shop_id) zone ON zone.shop_id = sw.`shop_id` AND zone.pay_sys_type = sw.`pay_sys_type`
SET sw.unsettled_amount = zone.unsettled_amount + sw.`unsettled_amount`,
    sw.`settled_amount` = zone.settled_amount + sw.`settled_amount`,
    sw.`total_settled_amount` = zone.total_settled_amount + sw.`total_settled_amount`;
UPDATE supplier_wallet sw
    JOIN (SELECT SUM(unsettled_amount) AS unsettled_amount, SUM(settled_amount) AS settled_amount,
                 SUM(total_settled_amount) AS total_settled_amount,supplier_id, pay_sys_type
          FROM supplier_wallet_zone
          GROUP BY supplier_id) zone ON zone.supplier_id = sw.`supplier_id` AND zone.pay_sys_type = sw.`pay_sys_type`
SET sw.unsettled_amount = zone.unsettled_amount + sw.`unsettled_amount`,
    sw.`settled_amount` = zone.settled_amount + sw.`settled_amount`,
    sw.`total_settled_amount` = zone.total_settled_amount + sw.`total_settled_amount`;
DROP TABLE IF EXISTS `shop_wallet_zone`;
DROP TABLE IF EXISTS `supplier_wallet_zone`;
DROP TABLE IF EXISTS `supplier_wallet_log`;

USE mall4cloud_job;
DELETE FROM xxl_job_info
       WHERE executor_handler IN ('zoneShopWalletToTenIfNecessary', 'zoneSupplierWalletToTenIfNecessary');

# 变更商家端公告位置
USE mall4cloud_auth;
# menu_id = 253, 375都是'公告'
DELETE FROM `menu` WHERE `menu_id` IN (253, 375);
# parent_id = 145 为'店铺管理'
INSERT INTO `menu`(`menu_id`,`create_time`, `update_time`, `parent_id`, `biz_type`, `permission`, `path`, `component`, `redirect`, `always_show`, `hidden`, `name`, `title`, `icon`, `no_cache`, `breadcrumb`, `affix`, `active_menu`, `seq`)
VALUES
    (669, NOW(), NOW(), 145, 1, NULL, 'notice', 'shop/notice', NULL, NULL, 0, '店铺公告', '店铺公告', '', NULL, NULL, NULL, NULL, 1);
