-- ----------------------------
-- Table structure for qimall_addons_sign_in_award_config
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_sign_in_award_config`;
CREATE TABLE `qimall_addons_sign_in_award_config`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0 COMMENT '商城ID',
  `day` int(11) NOT NULL DEFAULT 1 COMMENT '签到天数，1：每天签到，>1：连续签到',
  `num` int(11) NOT NULL DEFAULT 0 COMMENT '奖励优惠券或积分数量',
  `coupon_id` int(11) NOT NULL DEFAULT 0 COMMENT '赠送优惠券ID',
  `type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1：积分，2：优惠券',
  `status` tinyint(4) 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
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '签到奖励配置表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qimall_addons_user_sign_in_award
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_user_sign_in_award`;
CREATE TABLE `qimall_addons_user_sign_in_award`  (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `score_num` int(11) NOT NULL DEFAULT 0 COMMENT '累计积分奖励数量',
  `coupon_num` int(11) NOT NULL DEFAULT 0 COMMENT '累计优惠券奖励数量',
  `total_sign_in` int(11) NOT NULL COMMENT '累计签到天数',
  `sign_at` int(11) NOT NULL DEFAULT 0 COMMENT '最新签到时间',
  `status` tinyint(4) 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
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户签到奖励表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qimall_addons_user_sign_in_award_record
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_user_sign_in_award_record`;
CREATE TABLE `qimall_addons_user_sign_in_award_record`  (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `sign_id` int(11) NOT NULL DEFAULT 0 COMMENT '签到记录表ID',
  `num` int(11) NOT NULL DEFAULT 0 COMMENT '奖励数量',
  `coupon_id` int(11) NOT NULL DEFAULT 0 COMMENT '赠送优惠券ID',
  `type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '类型，1：积分，2：优惠券',
  `describe` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '说明',
  `sign_at` int(10) NOT NULL DEFAULT 0 COMMENT '签到时间',
  `status` tinyint(4) 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 `sign_id`(`sign_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '签到奖励记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qimall_addons_user_sign_in_record
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_user_sign_in_record`;
CREATE TABLE `qimall_addons_user_sign_in_record`  (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `status` tinyint(4) 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_created`(`created_at`, `user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '签到记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- 插入定时任务表
-- ----------------------------
INSERT INTO `qimall_crontab_task`(`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES 
('清除累计签到天数', 'sign/clean-total-sign-in', 2, '0 0 0 * * *', 0, 1, 1639724931, 1639724931);