USE yami_bbc;
# 商品审核配置与签约审核配置合并
update tz_sys_config set `param_value` = '{\"prodAudit\":false,\"signingAudit\":false}' where `param_key` = 'PROD_SWITCH_CONFIG';
delete from tz_sys_config where `param_key` = 'SIGNING_SWITCH_CONFIG';
# 电子面单
CREATE TABLE `tz_outlet_config` (
    `outlet_config_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '网点配置id',
    `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `shop_id` BIGINT DEFAULT NULL COMMENT '店铺id',
    `delivery_company_type` TINYINT NOT NULL COMMENT '快递公司类型',
    `shipper` VARCHAR(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货人',
    `mobile` VARCHAR(20) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货人电话',
    `partner_id` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '电子面单客户账户或月结账号',
    `partner_key` VARCHAR(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '电子面单密码',
    `net` VARCHAR(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收件网点名称',
    `paper_size` TINYINT DEFAULT '1' COMMENT '纸张规格 1.一联面单 2.二联面单',
    `is_default` TINYINT NOT NULL DEFAULT '0' COMMENT '是否默认 0否1是',
    `print_addr` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货地址',
    PRIMARY KEY (`outlet_config_id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网点配置';

CREATE TABLE `tz_printer` (
    `printer_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '打印机id',
    `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `shop_id` BIGINT DEFAULT NULL COMMENT '店铺id',
    `printer_name` VARCHAR(50) COLLATE utf8mb4_general_ci NOT NULL COMMENT '打印机名称',
    `siid` VARCHAR(50) COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备码',
    `printer_remark` VARCHAR(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '打印机备注',
    `is_default` TINYINT DEFAULT '0' COMMENT '是否默认 0否1是',
    PRIMARY KEY (`printer_id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='打印机';

UPDATE tz_sys_config SET param_value =
                             REPLACE(param_value,'","key":','","secret":"","isPrint":false,"mock":false,"printReqUrl":"https://api.kuaidi100.com/label/order","key":')
WHERE param_key = 'QUICK100_CONFIG';

# 菜单权限
# menu_id=20为原退货地址的菜单id
update tz_shop_menu_lang set name = '商家地址库' where menu_id = 20 and lang = 0;
update tz_shop_menu_lang set name = 'Shop Address' where menu_id = 20 and lang = 1;
INSERT  INTO `tz_shop_menu`(`menu_id`,`parent_id`,`url`,`perms`,`type`,`icon`,`order_num`,`hidden`) VALUES
(702,32,'','delivery:outletConfig:list',2,'',0,0),
(703,32,'','delivery:printer:list',2,'',0,0),
(704,5,'','',0,'',4,0),
(705,704,'order/delivery/outlet-config/index','',1,'',0,0),
(706,704,'order/delivery/printer/index','',1,'',1,0),
(707,705,'','delivery:outletConfig:page',2,'',0,0),
(708,705,'','delivery:outletConfig:get',2,'',0,0),
(709,705,'','delivery:outletConfig:save',2,'',0,0),
(710,705,'','delivery:outletConfig:update',2,'',0,0),
(711,705,'','delivery:outletConfig:delete',2,'',0,0),
(712,705,'','delivery:outletConfig:setDefault',2,'',0,0),
(713,706,'','delivery:printer:page',2,'',0,0),
(714,706,'','delivery:printer:get',2,'',0,0),
(715,706,'','delivery:printer:save',2,'',0,0),
(716,706,'','delivery:printer:update',2,'',0,0),
(717,706,'','delivery:printer:delete',2,'',0,0),
(718,706,'','delivery:printer:setDefault',2,'',0,0),
(719,705,'','delivery:outletConfig:paperSize',2,'',0,0),
(720,10,'','admin:brand:page',2,'',0,0);

INSERT  INTO `tz_shop_menu_lang`(`menu_id`,`lang`,`name`) VALUES
(702,0,'获取网点配置列表'),
(703,0,'获取打印机列表'),
(704,0,'电子面单'),
(705,0,'网点配置'),
(706,0,'硬件设备'),
(707,0,'列表'),
(708,0,'查看'),
(709,0,'新增'),
(710,0,'编辑'),
(711,0,'删除'),
(712,0,'设为/取消默认'),
(713,0,'列表'),
(714,0,'查看'),
(715,0,'新增'),
(716,0,'编辑'),
(717,0,'删除'),
(718,0,'设为/取消默认'),
(719,0,'纸张规格'),
(720,0,'品牌列表');

insert  into `tz_sys_menu`(`menu_id`,`parent_id`,`url`,`perms`,`type`,`icon`,`order_num`,`hidden`) values
(1119,125,'','',0,'',3,0),
(1120,1119,'member/delivery/outlet-config/index','',1,'',0,0),
(1121,1119,'member/delivery/printer/index','',1,'',1,0),
(1122,1120,'','delivery:outletConfig:get',2,'',0,0),
(1123,1120,'','delivery:outletConfig:page',2,'',0,0),
(1124,1120,'','delivery:outletConfig:save',2,'',0,0),
(1125,1120,'','delivery:outletConfig:update',2,'',0,0),
(1126,1120,'','delivery:outletConfig:delete',2,'',0,0),
(1127,1120,'','delivery:outletConfig:setDefault',2,'',0,0),
(1128,577,'','delivery:outletConfig:list',2,'',0,0),
(1129,1121,'','delivery:printer:page',2,'',0,0),
(1130,1121,'','delivery:printer:get',2,'',0,0),
(1131,1121,'','delivery:printer:save',2,'',0,0),
(1132,1120,'','delivery:outletConfig:paperSize',2,'',0,0),
(1133,1121,'','delivery:printer:update',2,'',0,0),
(1134,1121,'','delivery:printer:delete',2,'',0,0),
(1135,1121,'','delivery:printer:setDefault',2,'',0,0),
(1136,577,'','delivery:printer:list',2,'',0,0),
(1138,577,'','platform:orderDelivery:update',2,'',0,0);

insert  into `tz_sys_menu_lang`(`menu_id`,`lang`,`name`) values
(1119,0,'电子面单'),
(1120,0,'网点管理'),
(1121,0,'硬件设备'),
(1122,0,'查看'),
(1123,0,'列表'),
(1124,0,'新增'),
(1125,0,'编辑'),
(1126,0,'删除'),
(1127,0,'设为/取消默认'),
(1128,0,'获取网点配置列表'),
(1129,0,'列表'),
(1130,0,'查看'),
(1131,0,'新增'),
(1132,0,'纸张规格'),
(1133,0,'编辑'),
(1134,0,'删除'),
(1135,0,'设为/取消默认'),
(1136,0,'获取打印机列表'),
(1138,0,'修改物流');


# 修改权限
UPDATE
    tz_sys_menu
SET
    `hidden` = 0
WHERE
    menu_id = 1017;


# 删除旧的微信小程序发货配置
DELETE FROM tz_sys_config where param_key = 'WECHAT_SHIPPING_CONFIG';
# 将发货配置添加到微信小程序参数配置里面
UPDATE tz_sys_config set param_value =
                          REPLACE(param_value,'}',',\"wechatShippingAudit\":false}') where param_key = 'MA_CONFIG';





