-- CREATE TABLE `goblin_sqb_mall_info` (
--                                         `mid`        bigint(20)       NOT NULL AUTO_INCREMENT COMMENT '自增ID',
--                                         `mall_id`    VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '商城唯一ID',
--                                         `mall_sn`    VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧商城编号',
--                                         `mall_name`  VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商城名称',
--                                         `signature`  VARCHAR(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商城密钥',
--                                         `store_id`   VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '关联我方店铺ID',
--                                         `status`     TINYINT      NOT NULL DEFAULT 1 COMMENT '0-禁用 1-启用',
--                                         `created_at`    timestamp NULL  DEFAULT NULL COMMENT '创建时间',
--                                         `updated_at`    timestamp NULL DEFAULT NULL COMMENT '更新时间',
--                                         PRIMARY KEY (`mid`),
--                                         UNIQUE KEY `uk_mall_sn` (`mall_sn`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧商城信息';
--
-- CREATE TABLE `goblin_sqb_goods_ext` (
--                                         `mid`            bigint(20)       NOT NULL AUTO_INCREMENT COMMENT '自增ID',
--                                         `spu_id`         VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联 goblin_goods.spu_id',
--                                         `sku_id`         VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联 goblin_goods_sku.sku_id',
--                                         `mall_sn`        VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属收钱吧商城编号',
--                                         `signature`       VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商城密钥',
--                                         `sqb_spu_id`      VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧SPU ID',
--                                         `sqb_sku_id`     VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL   COMMENT '收钱吧SKU ID',
--                                         `created_at`    timestamp   NULL  DEFAULT NULL COMMENT '创建时间',
--                                         `updated_at`    timestamp   NULL  DEFAULT NULL COMMENT '更新时间',
--                                         PRIMARY KEY (`mid`),
--                                         UNIQUE KEY `uk_spu_sku` (`spu_id`, `sku_id`),
--                                         KEY `idx_mall_sn` (`mall_sn`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧商品扩展信息';
--
-- CREATE TABLE `goblin_sqb_performance_goods` (
--                                                 `mid`             bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '自增ID',
--                                                 `performances_id` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '演出ID',
--                                                 `spu_id`          VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品ID',
--                                                 `sku_id`          VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'SKU ID',
--                                                 `sort`            INT         NOT NULL DEFAULT 0 COMMENT '排序权重',
--                                                 `settlement_price` DECIMAL(10,2) DEFAULT NULL COMMENT '换购价格（不设置则按商品售价售卖）',
--                                                 `status`          TINYINT     NOT NULL DEFAULT 1 COMMENT '0-禁用 1-启用',
--                                                 `created_at`    timestamp        NULL     DEFAULT NULL,
--                                                 `updated_at`    timestamp        NULL     DEFAULT NULL,
--                                                 PRIMARY KEY (`mid`),
--                                                 UNIQUE KEY `uk_perf_sku` (`performances_id`, `sku_id`),
--                                                 KEY `idx_performances_id` (`performances_id`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='演出-收钱吧商品关联';
--
-- CREATE TABLE `goblin_sqb_order` (
--                                     `mid`                   bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '自增ID',
--                                     `order_id`              VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '本地订单ID',
--                                     `user_id`               VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '用户ID',
--                                     `performances_id`       VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '关联演出ID',
--                                     `spu_id`                VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '商品ID',
--                                     `sku_id`                VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT 'SKU ID',
--                                     `quantity`              INT         NOT NULL DEFAULT 1 COMMENT '购买数量',
--                                     `amount`                BIGINT(20)  NOT NULL COMMENT '支付金额（分）',
--                                     `sqb_order_sn`          VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci    NOT NULL       COMMENT '收钱吧订单号',
--                                     `sqb_order_signature`   VARCHAR(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   NOT NULL       COMMENT '收钱吧订单签名',
--                                     `sqb_acquiring_sn`      VARCHAR(64)  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   NOT NULL       COMMENT '收钱吧收单号',
--                                     `sqb_acquiring_sign`      VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   NOT NULL  COMMENT '收钱吧收单密钥',
--                                     `sqb_checkout_items_id` VARCHAR(64)  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL      COMMENT '结算明细ID',
--                                     `coupon_sn`             VARCHAR(64)  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   default ''   COMMENT '券码编号',
--                                     `coupon_qr_code`        VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   default ''     COMMENT '核销二维码',
--                                     `coupon_expire_time`    DATETIME  DEFAULT NULL  COMMENT '券码过期时间',
--                                     `status`                TINYINT      NOT NULL DEFAULT 0 COMMENT '0-待支付 1-已支付 2-已核销 3-已退款 4-退款中 9-失败',
--                                     `refund_reason`         VARCHAR(256)   CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   default ''   COMMENT '退款原因',
--                                     `sqb_refund_sn`         VARCHAR(256)   CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci    default ''    COMMENT '收钱吧-退款号',
--                                     `sqb_refund_signature`  VARCHAR(256)   CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci    default ''   COMMENT '收钱吧-退款号密码',
--                                     `created_at`    timestamp    NULL      DEFAULT NULL,
--                                     `updated_at`    timestamp    NULL     DEFAULT NULL,
--                                     PRIMARY KEY (`mid`),
--                                     UNIQUE KEY `uk_order_id` (`order_id`),
--                                     KEY `idx_user_id` (`user_id`),
--                                     KEY `idx_performances_id` (`performances_id`),
--                                     KEY `idx_sqb_acquiring_sn` (`sqb_acquiring_sn`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧订单';
--
--
-- CREATE TABLE `goblin_sqb_performance_config` (
--                                                  `mid` bigint(20) NOT NULL AUTO_INCREMENT,
--                                                  `performances_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '演出ID',
--                                                  `auto_offline` tinyint(4) DEFAULT '0' COMMENT '演出结束自动下架 0-否 1-是',
--                                                  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
--                                                  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
--                                                  PRIMARY KEY (`mid`),
--                                                  UNIQUE KEY `uk_perf_id` (`performances_id`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧演出级全局配置';
-- -- 2026-03-30 增加逻辑删除及审计建议字段
-- ALTER TABLE `goblin_sqb_goods_ext` ADD COLUMN `updated_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人' AFTER `updated_at`;
-- ALTER TABLE `goblin_sqb_goods_ext` ADD COLUMN `del_flg` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标记[0-未删除|1-删除]' AFTER `updated_by`;
-- ALTER TABLE `goblin_sqb_goods_ext` ADD COLUMN `deleted_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '删除人' AFTER `del_flg`;
-- ALTER TABLE `goblin_sqb_goods_ext` ADD COLUMN `deleted_at` timestamp NULL DEFAULT NULL COMMENT '删除时间' AFTER `deleted_by`;


---------------------------------- !!! 2026-4-3 设置字段排序规则-最新表结构 --------------------------------
CREATE TABLE `goblin_sqb_goods_ext` (
                                        `mid` bigint(20) NOT NULL AUTO_INCREMENT,
                                        `spu_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联 goblin_goods.spu_id',
                                        `sku_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联 goblin_goods_sku.sku_id',
                                        `mall_sn` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属收钱吧商城编号',
                                        `signature` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商城密钥',
                                        `sqb_spu_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧SPU ID',
                                        `sqb_sku_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '收钱吧SKU ID',
                                        `created_at` timestamp NULL DEFAULT NULL,
                                        `updated_at` timestamp NULL DEFAULT NULL,
                                        `updated_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
                                        `del_flg` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标记[0-未删除|1-删除]',
                                        `deleted_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '删除人',
                                        `deleted_at` timestamp NULL DEFAULT NULL COMMENT '删除时间',
                                        PRIMARY KEY (`mid`),
                                        UNIQUE KEY `uk_spu_sku` (`spu_id`,`sku_id`),
                                        KEY `idx_mall_sn` (`mall_sn`)
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧商品扩展信息';

CREATE TABLE `goblin_sqb_performance_goods` (
                                                `mid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
                                                `performances_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '演出ID',
                                                `spu_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品ID',
                                                `sku_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'SKU ID',
                                                `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序权重',
                                                `settlement_price` decimal(10,2) DEFAULT NULL COMMENT '换购价格（不设置则按商品售价售卖）',
                                                `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0-禁用 1-启用',
                                                `created_at` timestamp NULL DEFAULT NULL,
                                                `updated_at` timestamp NULL DEFAULT NULL,
                                                PRIMARY KEY (`mid`),
                                                UNIQUE KEY `uk_perf_sku` (`performances_id`,`sku_id`),
                                                KEY `idx_performances_id` (`performances_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='演出-收钱吧商品关联';

CREATE TABLE `goblin_sqb_performance_config` (
                                                 `mid` bigint(20) NOT NULL AUTO_INCREMENT,
                                                 `performances_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '演出ID',
                                                 `auto_offline` tinyint(4) DEFAULT '0' COMMENT '演出结束自动下架 0-否 1-是',
                                                 `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
                                                 `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                                                 PRIMARY KEY (`mid`),
                                                 UNIQUE KEY `uk_perf_id` (`performances_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧演出级全局配置';

CREATE TABLE `goblin_sqb_mall_info` (
                                        `mid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
                                        `mall_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商城唯一ID',
                                        `mall_sn` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧商城编号',
                                        `mall_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商城名称',
                                        `signature` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商城密钥',
                                        `store_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联我方店铺ID',
                                        `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0-禁用 1-启用',
                                        `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                        `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
                                        PRIMARY KEY (`mid`),
                                        UNIQUE KEY `uk_mall_sn` (`mall_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧商城信息';

CREATE TABLE `goblin_sqb_order` (
                                    `mid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
                                    `order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '本地订单ID',
                                    `user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户ID',
                                    `performances_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关联演出ID',
                                    `spu_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品ID',
                                    `sku_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'SKU ID',
                                    `quantity` int(11) NOT NULL DEFAULT '1' COMMENT '购买数量',
                                    `amount` bigint(20) NOT NULL COMMENT '支付金额（分）',
                                    `sqb_order_sn` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧订单号',
                                    `sqb_order_signature` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧订单签名',
                                    `sqb_acquiring_sn` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧收单号',
                                    `sqb_acquiring_sign` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收钱吧收单密钥',
                                    `sqb_checkout_items_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '结算明细ID',
                                    `coupon_sn` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '券码编号',
                                    `coupon_qr_code` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '核销二维码',
                                    `coupon_expire_time` datetime DEFAULT NULL COMMENT '券码过期时间',
                                    `coupon_used_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0-未核销 1-已核销（订单进度见 goblin_store_order.status）',
                                    `refund_reason` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '退款原因',
                                    `sqb_refund_sn` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '收钱吧-退款号',
                                    `sqb_refund_signature` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '收钱吧-退款号密码',
                                    `created_at` timestamp NULL DEFAULT NULL,
                                    `updated_at` timestamp NULL DEFAULT NULL,
                                    PRIMARY KEY (`mid`),
                                    UNIQUE KEY `uk_order_id` (`order_id`),
                                    KEY `idx_user_id` (`user_id`),
                                    KEY `idx_performances_id` (`performances_id`),
                                    KEY `idx_sqb_acquiring_sn` (`sqb_acquiring_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收钱吧订单';

-- 2026-5-15 增加收钱吧商城名称字段
ALTER TABLE goblin_sqb_goods_ext ADD sqb_mall_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT "" COMMENT '收钱吧商城名称';
