-- ----------------------------
-- Table structure for qimall_addons_score_mall_exchange_record
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_score_mall_exchange_record`;
CREATE TABLE `qimall_addons_score_mall_exchange_record`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品ID',
  `goods_attr_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品属性ID',
  `exchange_price` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '对换价格',
  `goods` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '商品信息',
  `num` int(11) NOT NULL DEFAULT 0 COMMENT '兑换数量',
  `order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `order_id` int(11) NOT NULL DEFAULT 0 COMMENT '订单ID',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `user_mall_id`(`user_id`, `mall_id`) USING BTREE,
  INDEX `goods_id`(`goods_id`) USING BTREE,
  INDEX `order_no`(`order_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '积分商城兑换记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qimall_addons_score_mall_goods
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_score_mall_goods`;
CREATE TABLE `qimall_addons_score_mall_goods`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品ID',
  `cate_id` int(11) NOT NULL DEFAULT 0 COMMENT '分类ID',
  `score` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT 'type=1,2时消耗的积分',
  `money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT 'type=2时，商品价格',
  `price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '商品售价，对应goods表price',
  `type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1：全积分兑换，2：积分加金额，3：积分抵扣',
  `num` int(11) NOT NULL DEFAULT 0 COMMENT '已兑换数量',
  `use_coupon` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否不参加优惠券抵扣，0：参加，1：不参加',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `goods_id`(`goods_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '积分商城商品表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qimall_addons_score_mall_goods_attr
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_score_mall_goods_attr`;
CREATE TABLE `qimall_addons_score_mall_goods_attr`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品ID',
  `goods_attr_id` int(11) NOT NULL DEFAULT 0 COMMENT '规格ID',
  `score` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT 'type=1,2时消耗的积分',
  `money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '商品价格',
  `price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '商品售价，对应goodsAttr表price',
  `deduction_limit` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'type=3时[{最少抵扣积分:score,是否限制抵扣:0or1}]',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `goods_id`(`goods_id`) USING BTREE,
  INDEX `goods_attr_id`(`goods_attr_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '积分商城商品规格表' ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- 链接分类
-- ----------------------------
INSERT INTO `qimall_link_category` ( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES
( 'score_mall', '积分商品', 19, 1, NULL, 1, 1641814024, 1641814024),
( 'score_mall_cate', '积分商品分类', 19, 1, NULL, 1, 1641814039, 1641814039);


-- ----------------------------
-- 装修组件
-- ----------------------------
INSERT INTO `qimall_diy_components` (`code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES
('score-mall', '积分商品', 'marketing', '', 999, 0, '{\"is_drag\":\"true\",\"is_up\":\"true\",\"id_down\":\"true\",\"is_copy\":\"true\"}', 999, 'ScoreMall', 1, 1634538238, 1634538238);

