-- ----------------------------
-- Table structure for qimall_addons_recharge_active
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_recharge_active`;
CREATE TABLE `qimall_addons_recharge_active`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT 0,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '活动名称',
  `start_at` int(11) NOT NULL DEFAULT 0 COMMENT '开始时间',
  `end_at` int(11) NOT NULL DEFAULT 0 COMMENT '结束时间',
  `already_give` int(11) NULL DEFAULT 0 COMMENT '已赠送人数',
  `give_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '赠送说明',
  `give_cond` int(11) NOT NULL COMMENT '赠送条件 0/单次充值 1/累计充值(活动时间内)',
  `give_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '赠送具体信息',
  `active_status` tinyint(5) NOT NULL DEFAULT 0 COMMENT '0/未开始 1/进行中 2/已过期 3/已停用',
  `status` tinyint(2) NOT NULL DEFAULT 0 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(11) NOT NULL DEFAULT 0,
  `updated_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_mall`(`mall_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '充值有礼活动' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for qimall_addons_recharge_log
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_recharge_log`;
CREATE TABLE `qimall_addons_recharge_log`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `recharge_active_id` int(11) NOT NULL COMMENT '充值活动id',
  `recharge_order_id` int(11) NOT NULL DEFAULT 0 COMMENT '充值订单id',
  `recharge_num` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '充值金额',
  `give_score` int(11) NOT NULL DEFAULT 0 COMMENT '赠送积分',
  `give_balance` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '赠送余额',
  `give_coupons` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '赠送优惠券',
  `give_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '赠送内容文字描述',
  `created_at` int(11) NOT NULL DEFAULT 0,
  `updated_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_mall_user`(`mall_id`, `user_id`) USING BTREE,
  INDEX `idx_order`(`recharge_order_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 
('充值有礼活动定时开启/结束', 'recharge-balance-activity/do-job', 2, '0 */1 * * * *', 0, -1, 1640760567, 1640836085),
('充值有礼活动定时开启/结束', 'recharge-balance-activity/do-job', 2, '0 */1 * * * *', 0, 1, 1640836138, 1640836138);