SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Records of mall_ad_position
-- ----------------------------

-- ----------------------------
-- Table structure for mall_address
-- ----------------------------
DROP TABLE IF EXISTS `mall_address`;
CREATE TABLE `mall_address`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NULL DEFAULT 0 COMMENT '用户ID',
  `user_name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT '' COMMENT '收货人姓名',
  `is_default` int NULL DEFAULT 0 COMMENT '默认（1是，0否）',
  `tel_number` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT '' COMMENT '手机',
  `province_name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT '0' COMMENT '省',
  `city_name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT '0' COMMENT '市',
  `county_name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT '0' COMMENT '区',
  `detail_info` varchar(120) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT '' COMMENT '详细收货地址信息',
  `label` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT NULL COMMENT '标签',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `user_id`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_unicode_ci ROW_FORMAT = DYNAMIC;



-- ----------------------------
-- Table structure for mall_browsing_history
-- ----------------------------
DROP TABLE IF EXISTS `mall_browsing_history`;
CREATE TABLE `mall_browsing_history`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL COMMENT '用户ID',
  `goods_id` int NOT NULL COMMENT '商品ID',
  `browsed_time` datetime NULL DEFAULT NULL COMMENT '浏览时间',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index`(`user_id` ASC, `goods_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 73 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci ROW_FORMAT = DYNAMIC;



-- ----------------------------
-- Table structure for mall_cart
-- ----------------------------
DROP TABLE IF EXISTS `mall_cart`;
CREATE TABLE `mall_cart`  (
  `id` mediumint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` mediumint UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户Id',
  `goods_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '商品名称',
  `goods_id` mediumint UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品Id',
  `number` smallint UNSIGNED NOT NULL DEFAULT 0 COMMENT '数量',
  `sku_id` int NOT NULL DEFAULT 0 COMMENT 'skuId',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_goods_id`(`goods_id` ASC) USING BTREE,
  INDEX `idx_ski_id`(`sku_id` ASC) USING BTREE,
  INDEX `idx_user_id`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 226 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of mall_cart
-- ----------------------------

-- ----------------------------
-- Table structure for mall_category
-- ----------------------------
DROP TABLE IF EXISTS `mall_category`;
CREATE TABLE `mall_category`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(90) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
  `keywords` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '',
  `front_desc` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '',
  `parent_id` int UNSIGNED NULL DEFAULT 0,
  `sort_order` tinyint UNSIGNED NULL DEFAULT 50,
  `show_index` tinyint(1) NULL DEFAULT 0,
  `is_show` tinyint UNSIGNED NULL DEFAULT 1,
  `banner_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '',
  `icon_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
  `img_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
  `wap_banner_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
  `level` int NULL DEFAULT NULL,
  `type` int NULL DEFAULT 0,
  `front_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `parent_id`(`parent_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1036013 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of mall_category
-- ----------------------------

-- ----------------------------
-- Table structure for mall_coin_config
-- ----------------------------
DROP TABLE IF EXISTS `mall_coin_config`;
CREATE TABLE `mall_coin_config`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `coin_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '名称',
  `exchange_ratio` int NOT NULL COMMENT '兑换比例',
  `is_used` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用：0-禁用，1-启用',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '学豆配置表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of mall_coin_config
-- ----------------------------

-- ----------------------------
-- Table structure for mall_coin_freeze_log
-- ----------------------------
DROP TABLE IF EXISTS `mall_coin_freeze_log`;
CREATE TABLE `mall_coin_freeze_log`  (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint UNSIGNED NOT NULL COMMENT '用户ID',
  `account_id` bigint UNSIGNED NOT NULL COMMENT '账户ID',
  `order_sn` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '关联订单编号',
  `freeze_amount` decimal(18, 2) NOT NULL COMMENT '冻结金额（单位：分）',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态：0-已冻结，1-已解冻，2-已扣除',
  `freeze_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '冻结时间',
  `unfreeze_time` datetime NULL DEFAULT NULL COMMENT '解冻时间',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_order_sn`(`order_sn` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '学豆冻结记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of mall_coin_freeze_log
-- ----------------------------

-- ----------------------------
-- Table structure for mall_coin_recharge
-- ----------------------------
DROP TABLE IF EXISTS `mall_coin_recharge`;
CREATE TABLE `mall_coin_recharge`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL COMMENT '用户ID',
  `recharge_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '充值金额',
  `recharge_sn` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NOT NULL COMMENT '充值订单号',
  `coin_config_id` int NULL DEFAULT NULL COMMENT '学豆配置id',
  `recharge_time` datetime NULL DEFAULT NULL COMMENT '充值时间',
  `pay_status` tinyint NULL DEFAULT NULL COMMENT '支付状态{0-付款中;1-已付款;2-付款失败;3-退款}',
  `pay_success_time` datetime NULL DEFAULT NULL COMMENT '充值时间',
  `transaction_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL,
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_user_id`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for mall_coin_refund
-- ----------------------------
DROP TABLE IF EXISTS `mall_coin_refund`;
CREATE TABLE `mall_coin_refund`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL COMMENT '用户ID',
  `refund_sn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '退款编号',
  `recharge_id` int NOT NULL,
  `refund_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '退款原因',
  `actual_refund_amount` int NULL DEFAULT NULL COMMENT '实际退款金额',
  `refund_success_time` datetime NULL DEFAULT NULL COMMENT '退款成功作时间',
  `status` tinyint(1) NULL DEFAULT NULL COMMENT '状态（0待审核，1审核通过，2审核拒绝，3：待微信退款，4：微信退款成功，5微信退款失败)',
  `refund_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '退款金额',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL,
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_user_id`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for mall_coin_refund_log
-- ----------------------------
DROP TABLE IF EXISTS `mall_coin_refund_log`;
CREATE TABLE `mall_coin_refund_log`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `refund_id` int NOT NULL COMMENT '退款id',
  `operation_name` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '操作名称',
  `operation_time` datetime NULL DEFAULT NULL COMMENT '操作时间',
  `status` tinyint(1) NULL DEFAULT NULL COMMENT '状态（0待审核，1审核通过，2审核拒绝，3：待微信退款，4：微信退款成功，5微信退款失败)',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL,
  `wx_request_json` json NULL COMMENT '微信接口请求json',
  `wx_response_json` json NULL COMMENT '微信接口响应json',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_refund_id`(`refund_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '学豆退款操作日志表' ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for mall_collect
-- ----------------------------
DROP TABLE IF EXISTS `mall_collect`;
CREATE TABLE `mall_collect`  (
  `id` mediumint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` mediumint UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户Id',
  `value_id` mediumint UNSIGNED NOT NULL DEFAULT 0 COMMENT '产品Id',
  `add_time` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '添加时间',
  `is_attention` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否提醒',
  `type_id` int UNSIGNED NOT NULL DEFAULT 0,
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `user_id`(`user_id` ASC) USING BTREE,
  INDEX `goods_id`(`value_id` ASC) USING BTREE,
  INDEX `is_attention`(`is_attention` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 75 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of mall_collect
-- ----------------------------

-- ----------------------------
-- Table structure for mall_goods
-- ----------------------------
DROP TABLE IF EXISTS `mall_goods`;
CREATE TABLE `mall_goods`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '记录唯一标识，自增主键',
  `category_id` int UNSIGNED NULL DEFAULT 0 COMMENT '商品所属分类的 ID，关联分类表',
  `collect_count` int NOT NULL DEFAULT 0 COMMENT '商品收藏数量',
  `goods_sn` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '商品的唯一编号',
  `name` varchar(120) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '商品的名称',
  `brand_id` int UNSIGNED NULL DEFAULT 0 COMMENT '商品所属品牌的 ID，关联品牌表',
  `keywords` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '商品的关键词，用于搜索',
  `goods_brief` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '商品的简要描述',
  `goods_desc` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL COMMENT '商品的详细描述',
  `add_time` datetime NULL DEFAULT NULL COMMENT '商品添加到系统的时间',
  `sort_order` smallint UNSIGNED NULL DEFAULT 100 COMMENT '商品在列表中的排序顺序',
  `price` int NOT NULL DEFAULT -1 COMMENT '商品价格，单位使用：分',
  `market_price` int NULL DEFAULT NULL COMMENT '市场价，单位使用：分',
  `cost_price` int NOT NULL DEFAULT -1 COMMENT '成本价，单位： 分',
  `primary_pic_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '商品的主图片链接',
  `weight` int NULL DEFAULT NULL COMMENT '重量，单位g，用于物流发货 ',
  `spec_type` bit(1) NULL DEFAULT NULL COMMENT '规格类型：0 单规格 1 多规格',
  `stock` int NULL DEFAULT NULL COMMENT '库存',
  `goods_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物品类型（对应订单主表物品类型）: bm000001 文件  bm000002 数码产品  bm000003 生活用品  bm000004 食品  bm000005 服饰  bm000006 其他  bm000007 生鲜类  bm000008 易碎品  bm000009 液体',
  `list_pic_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '商品在列表中展示的图片链接',
  `retail_price` decimal(10, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '商品的零售价格',
  `sales_count` int UNSIGNED NULL DEFAULT 0 COMMENT '商品的销售数量',
  `virtual_sell_volume` int UNSIGNED NULL DEFAULT 0 COMMENT '虚拟销量',
  `browse_count` int UNSIGNED NULL DEFAULT 0 COMMENT '浏览量',
  `app_exclusive_price` decimal(10, 2) UNSIGNED NULL DEFAULT NULL COMMENT 'APP 专享的商品价格',
  `is_on_sale` tinyint UNSIGNED NULL DEFAULT 1 COMMENT '商品是否上架销售，1 表示上架，0 表示下架',
  `on_sale_time` datetime NULL DEFAULT NULL COMMENT '上架时间',
  `off_sale_time` datetime NULL DEFAULT NULL COMMENT '下架时间',
  `is_new` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '商品是否为新品，1 表示是新品，0 表示不是',
  `is_app_exclusive` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '商品是否为 APP 专属，1 表示是，0 表示不是',
  `is_limited` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '商品是否为限量商品，1 表示是，0 表示不是',
  `is_featured_recommend` tinyint NULL DEFAULT 0 COMMENT '是否精品推荐：0-否 1-是',
  `is_special_offer` tinyint NULL DEFAULT 0 COMMENT '是否特价优惠：0-否 1-是',
  `is_hot` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '商品是否为热门商品，1 表示是，0 表示不是',
  `create_user_id` bigint NULL DEFAULT NULL COMMENT '创建商品的用户 ID',
  `update_user_id` bigint NULL DEFAULT NULL COMMENT '最后修改商品信息的用户 ID',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_goods_sn`(`goods_sn` ASC) USING BTREE,
  INDEX `idx_category_id`(`category_id` ASC) USING BTREE,
  INDEX `idx_sort_order`(`sort_order` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for mall_goods_attribute
-- ----------------------------
DROP TABLE IF EXISTS `mall_goods_attribute`;
CREATE TABLE `mall_goods_attribute`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `attribute_name` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '属性名称',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态: 0=禁用 1=启用',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci COMMENT = '商品属性表' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for mall_goods_attribute_value
-- ----------------------------
DROP TABLE IF EXISTS `mall_goods_attribute_value`;
CREATE TABLE `mall_goods_attribute_value`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `attribute_id` int UNSIGNED NOT NULL COMMENT '属性ID',
  `attribute_value` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '属性值',
  `remark` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '备注',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态: 0=禁用 1=启用',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci COMMENT = '商品属性值表' ROW_FORMAT = Dynamic;



-- ----------------------------
-- Table structure for mall_goods_collected
-- ----------------------------
DROP TABLE IF EXISTS `mall_goods_collected`;
CREATE TABLE `mall_goods_collected`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `goods_id` int NULL DEFAULT 0 COMMENT '商品id',
  `is_collected` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除标记(0-未收藏,1-已收藏)',
  `user_id` int NULL DEFAULT NULL COMMENT '用户id',
  `collected_time` datetime NULL DEFAULT NULL COMMENT '收藏时间',
  `sort_order` int NULL DEFAULT 5 COMMENT '排序',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `goods_id`(`goods_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 769 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for mall_goods_comment
-- ----------------------------
DROP TABLE IF EXISTS `mall_goods_comment`;
CREATE TABLE `mall_goods_comment`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论编号，主键自增',
  `user_id` bigint NOT NULL COMMENT '评价人的用户id',
  `user_nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '评价人名称',
  `user_avatar` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '评价人头像',
  `order_id` bigint NULL DEFAULT 0 COMMENT '订单编号',
  `order_item_id` bigint NULL DEFAULT 0 COMMENT '订单项编号',
  `spu_id` bigint NULL DEFAULT NULL COMMENT 'spu编号',
  `spu_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT 'spu名称',
  `sku_id` bigint NULL DEFAULT NULL COMMENT 'sku编号',
  `sku_pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '商品图片url',
  `is_real` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT '0' COMMENT '是否虚拟商品，Y:是 N:否',
  `is_anonymous` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NOT NULL DEFAULT 'N' COMMENT '是否匿名，Y:是 N:否',
  `is_visible` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Y' COMMENT '是否可见，Y:显示 N:隐藏',
  `is_reply` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'N' COMMENT '商家是否回复',
  `scores` tinyint NOT NULL COMMENT '评分星级1-5分',
  `description_scores` tinyint NOT NULL COMMENT '描述星级 1-5 星',
  `benefit_scores` tinyint NOT NULL COMMENT '服务星级 1-5 星',
  `content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '评论内容',
  `pic_urls` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '评论图片地址数组',
  `reply_user_id` bigint NULL DEFAULT NULL COMMENT '回复管理员id',
  `reply_content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商家回复内容',
  `reply_time` datetime NULL DEFAULT NULL COMMENT '商家回复时间',
  `comment_time` datetime NULL DEFAULT NULL COMMENT '评价时间',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_spu_id`(`spu_id` ASC) USING BTREE,
  INDEX `idx_sku_id`(`sku_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci COMMENT = '商品评论' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for mall_goods_specification
-- ----------------------------
DROP TABLE IF EXISTS `mall_goods_specification`;
CREATE TABLE `mall_goods_specification`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `goods_id` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品id',
  `attributes` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '属性数组，JSON 格式 [{propertId: , valueId: }, {propertId: , valueId: }]',
  `pic_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '图片url',
  `price` int NOT NULL DEFAULT -1 COMMENT '商品价格，单位：分',
  `market_price` int NULL DEFAULT NULL COMMENT '市场价，单位：分',
  `cost_price` int NOT NULL DEFAULT -1 COMMENT '成本价，单位： 分',
  `bar_code` varchar(124) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'SKU 的条形码',
  `stock` int NULL DEFAULT NULL COMMENT '库存',
  `weight` double NULL DEFAULT NULL COMMENT '商品重量，单位：kg 千克',
  `volume` double NULL DEFAULT NULL COMMENT '商品体积，单位：m^3 平米',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `goods_id`(`goods_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 92 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '商品对应规格表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for mall_home_layout
-- ----------------------------
DROP TABLE IF EXISTS `mall_home_layout`;
CREATE TABLE `mall_home_layout`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `block_name` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NOT NULL COMMENT '区块名称',
  `block_url` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NOT NULL COMMENT '区块url',
  `block_type` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NOT NULL COMMENT '区块类型',
  `sort_order` int NOT NULL DEFAULT 0 COMMENT '排序权重',
  `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态: 0=禁用 1=启用',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci COMMENT = '首页布局配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of mall_home_layout
-- ----------------------------

-- ----------------------------
-- Table structure for mall_order
-- ----------------------------
DROP TABLE IF EXISTS `mall_order`;
CREATE TABLE `mall_order`  (
  `id` mediumint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '订单唯一标识',
  `order_sn` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '订单编号（唯一）',
  `user_id` mediumint UNSIGNED NULL DEFAULT 0 COMMENT '用户ID',
  `order_status` int UNSIGNED NULL DEFAULT 0 COMMENT '订单状态（0-待付款，1-已付款，2-已发货，3-已完成，4-已取消）',
  `shipping_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '物流状态（0-未发货，1-已发货，2-已签收）',
  `pay_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '支付状态（0-未支付，1-已支付，2-支付失败）',
  `comment_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '评价状态，1：已评价，0：为评价',
  `consignee` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '收货人姓名',
  `country` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '国家',
  `province` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '省份',
  `city` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '城市',
  `district` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '区/县',
  `address` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '详细地址',
  `mobile` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '联系电话',
  `postscript` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '订单备注',
  `pay_id` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '0' COMMENT '支付方式ID',
  `pay_name` varchar(120) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '支付方式名称',
  `actual_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '实际支付金额（已扣除优惠）',
  `integral` int UNSIGNED NULL DEFAULT 0 COMMENT '使用积分数量',
  `integral_money` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '积分抵扣金额',
  `order_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '订单总价（含运费）',
  `goods_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商品总价',
  `add_time` datetime NULL DEFAULT NULL COMMENT '订单创建时间',
  `confirm_time` datetime NULL DEFAULT NULL COMMENT '用户确认收货时间',
  `pay_time` datetime NULL DEFAULT NULL COMMENT '支付成功时间',
  `remark` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '订单备注',
  `delivery_time` datetime NULL DEFAULT NULL COMMENT '发货时间',
  `weight` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '重量，单位kg，范围0.01-30 默认0.02）',
  `logistics_code` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '物流公司编码',
  `shipping_no` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '物流单号',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `order_sn`(`order_sn` ASC) USING BTREE COMMENT '订单编号唯一索引',
  INDEX `user_id`(`user_id` ASC) USING BTREE COMMENT '用户ID索引',
  INDEX `order_status`(`order_status` ASC) USING BTREE COMMENT '订单状态索引',
  INDEX `shipping_status`(`shipping_status` ASC) USING BTREE COMMENT '物流状态索引',
  INDEX `pay_status`(`pay_status` ASC) USING BTREE COMMENT '支付状态索引',
  INDEX `pay_id`(`pay_id` ASC) USING BTREE COMMENT '支付方式ID索引'
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '商城订单主表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of mall_order
-- ----------------------------

-- ----------------------------
-- Table structure for mall_order_goods
-- ----------------------------
DROP TABLE IF EXISTS `mall_order_goods`;
CREATE TABLE `mall_order_goods`  (
  `id` mediumint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `order_id` mediumint UNSIGNED NOT NULL DEFAULT 0 COMMENT '订单Id',
  `goods_id` mediumint UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品id',
  `goods_name` varchar(120) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '商品名称',
  `number` smallint UNSIGNED NOT NULL DEFAULT 1 COMMENT '商品数量',
  `price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '商品价格',
  `sku_id` mediumint UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品sku id',
  `cart_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '购物车项编号',
  `comment_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '评价状态，1：已评价，0：为评价',
  `attributes` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '商品sku 属性',
  `is_real` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '虚拟商品',
  `pic_url` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '图片链接',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `order_id`(`order_id` ASC) USING BTREE,
  INDEX `goods_id`(`goods_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 142 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for mall_search_history
-- ----------------------------
DROP TABLE IF EXISTS `mall_search_history`;
CREATE TABLE `mall_search_history`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `keyword` char(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '关键字',
  `from` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '' COMMENT '搜索来源，如PC、小程序、APP等',
  `add_time` int NOT NULL DEFAULT 0 COMMENT '搜索时间',
  `user_id` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '会员Id',
    `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
    `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
    `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
    `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 48 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of mall_search_history
-- ----------------------------

-- ----------------------------
-- Table structure for mall_sender_config
-- ----------------------------
DROP TABLE IF EXISTS `mall_sender_config`;
CREATE TABLE `mall_sender_config`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '寄件人姓名',
  `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号码',
  `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '固定电话号码',
  `country_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '国家代码（如 CHN）',
  `prov` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '省份名称',
  `city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '城市名称',
  `area` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '区/县名称',
  `address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '详细地址信息',
   `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '寄件人配置表' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for mall_trade_after_sale
-- ----------------------------
DROP TABLE IF EXISTS `mall_trade_after_sale`;
CREATE TABLE `mall_trade_after_sale`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '售后记录ID，唯一标识每条售后记录，自增',
  `no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '售后单号，用于识别每笔售后业务',
  `status` int NOT NULL COMMENT '售后状态，以整数形式表示售后所处的不同阶段',
  `user_id` int NOT NULL COMMENT '发起售后的用户ID，关联用户表中的用户',
  `apply_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '申请售后的原因，用户填写的售后申请理由',
  `apply_description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请售后的详细描述，对售后情况的进一步说明',
  `apply_time` datetime NULL DEFAULT NULL COMMENT '申请售后的时间',
  `apply_pic_urls` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申请售后时上传的图片URL列表，用于辅助说明售后问题',
  `order_id` int NULL DEFAULT NULL COMMENT '关联的订单ID，指向产生售后的原始订单',
  `order_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关联的订单号，方便查询和识别原始订单',
  `order_item_id` int NULL DEFAULT NULL COMMENT '关联的订单项ID，具体指向订单中的某一商品项',
  `spu_id` int NULL DEFAULT NULL COMMENT '关联的商品SPU ID，代表商品的通用属性集合',
  `spu_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关联的商品SPU名称，商品的通用名称',
  `sku_id` int NULL DEFAULT NULL COMMENT '关联的商品SKU ID，代表商品的具体规格',
  `properties` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品的属性信息，如颜色、尺寸等具体规格描述',
  `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品的图片URL，用于展示商品外观',
  `count` int NULL DEFAULT NULL COMMENT '售后商品的数量，申请售后的商品件数',
  `audit_time` datetime NULL DEFAULT NULL COMMENT '审核时间，记录售后申请的审核时间',
  `audit_user_id` int NULL DEFAULT NULL COMMENT '审核人员的用户ID，关联审核该售后的用户',
  `audit_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核不通过的原因，若审核未通过，记录具体理由',
  `refund_price` int NULL DEFAULT NULL COMMENT '退款金额，以整数形式记录应退还的金额',
  `pay_refund_id` int NULL DEFAULT NULL COMMENT '支付退款记录的ID，关联支付系统中的退款记录',
  `refund_time` datetime NULL DEFAULT NULL COMMENT '退款时间，记录实际退款的时间',
  `logistics_id` int NULL DEFAULT NULL COMMENT '物流单号对应的物流记录ID，关联物流信息表',
  `logistics_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物流单号，用于查询商品的物流运输情况',
  `delivery_time` datetime NULL DEFAULT NULL COMMENT '发货时间，记录商品发货的时间',
  `receive_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '收货时间，记录商品被接收的时间',
  `receive_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '收货异常的原因，若收货出现问题，记录具体原因',
  `creator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建记录的人员，记录创建该售后记录的操作人员',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
    `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
    `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
    `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `user_id`(`user_id` ASC) USING BTREE,
  INDEX `order_no`(`order_no` ASC) USING BTREE,
  INDEX `order_id`(`order_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '交易售后表，记录交易售后的相关信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for mall_user_coin_account
-- ----------------------------
DROP TABLE IF EXISTS `mall_user_coin_account`;
CREATE TABLE `mall_user_coin_account`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL COMMENT '用户ID',
  `freeze_balance` decimal(10, 2) NULL DEFAULT NULL COMMENT '冻结余额',
  `available_balance` decimal(10, 2) NULL DEFAULT NULL COMMENT '可用余额',
  `total_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '冻结余额',
  `is_block` tinyint(1) NULL DEFAULT NULL COMMENT '交易状态（0正常，1锁定）',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
    `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
    `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
    `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_user_id`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_german2_ci COMMENT = '用户账户表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for zmall_user_coin_account_trade_log
-- ----------------------------
DROP TABLE IF EXISTS `mall_user_coin_account_trade_log`;
CREATE TABLE `mall_user_coin_account_trade_log`  (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` bigint UNSIGNED NOT NULL COMMENT '用户ID',
  `trade_type` tinyint NOT NULL COMMENT '交易类型: 1-充值，2-微信退款, 3-兑换, 4-购买, 5-退货',
  `trade_name` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '操作名称',
  `trade_time` datetime NULL DEFAULT NULL COMMENT '操作时间',
  `related_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '关联业务ID（如课程ID、订单ID）',
  `before_balance` decimal(10, 2) NOT NULL COMMENT '交易前余额',
  `trade_amount` decimal(10, 2) NOT NULL COMMENT '交易金额',
  `after_balance` decimal(10, 2) NOT NULL COMMENT '交易后余额',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注信息',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
   `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
   `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
   `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 46 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用户账户交易明细表' ROW_FORMAT = Dynamic;


DROP TABLE IF EXISTS `mall_order_log`;
CREATE TABLE `mall_order_log`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '日志主键',
  `user_id` bigint NOT NULL COMMENT '用户编号',
  `operate_type` tinyint NULL DEFAULT NULL COMMENT '操作类型',
  `user_type` tinyint NOT NULL DEFAULT 0 COMMENT '用户类型',
  `order_id` bigint NOT NULL COMMENT '订单号',
  `before_status` tinyint NULL DEFAULT NULL COMMENT '订单变更前状态',
  `after_status` tinyint NULL DEFAULT NULL COMMENT '订单变更后状态',
  `shipping_status` tinyint NULL DEFAULT NULL COMMENT '物流状态',
  `comment_status` int NOT NULL DEFAULT 0 COMMENT '评价状态',
  `content` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作内容',
  `deleted` bit(1) NOT NULL COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default'  COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_order_id`(`order_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8785 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '订单日志' ROW_FORMAT = Dynamic;