ALTER TABLE `shop_goods` 
ADD COLUMN `belong_type` TINYINT NOT NULL DEFAULT 0 COMMENT '归属类型（0-借还柜 1-固资通）' 
AFTER `category_id`;

ALTER TABLE `shop_goods` 
ADD COLUMN `external_goods_id` BIGINT NULL COMMENT '外部归属类型的商品ID' 
AFTER `category_id`;

-- 添加缺失字段
ALTER TABLE `return_approval`
ADD COLUMN `external_goods_id` bigint DEFAULT NULL COMMENT '外部归属类型的商品ID' AFTER `order_goods_id`,
ADD COLUMN `apply_quantity` int DEFAULT NULL COMMENT '申请数量' AFTER `external_goods_id`,
ADD COLUMN `approval_type` TINYINT NOT NULL DEFAULT 0 COMMENT '审批类型（0为借还柜 1为固资通）' AFTER `order_goods_id`,
ADD COLUMN `apply_remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '申请说明' AFTER `return_remark`;

-- 添加索引
ALTER TABLE `return_approval`
ADD INDEX `idx_external_goods_id` (`external_goods_id`),
ADD INDEX `idx_approval_type` (`approval_type`);

ALTER TABLE `shop_goods` 
ADD COLUMN `corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id'
AFTER `external_goods_id`;

ALTER TABLE `return_approval` 
ADD COLUMN `corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id'
AFTER `external_goods_id`;


ALTER TABLE `return_approval` 
ADD COLUMN `external_approval_id` bigint DEFAULT NULL COMMENT '外部归属类型的审批ID'
AFTER `external_goods_id`;
ALTER TABLE `return_approval`
ADD INDEX `idx_external_approval_id` (`external_approval_id`);