海外活动管理项目后端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
4.8 KiB

/*
Navicat Premium Dump SQL
Source Server : localhost_3306
Source Server Type : MySQL
Source Server Version : 80042 (8.0.42)
Source Host : localhost:3306
Source Schema : lottery_system
Target Server Type : MySQL
Target Server Version : 80042 (8.0.42)
File Encoding : 65001
Date: 10/07/2025 15:00:53
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for lottery_round
-- ----------------------------
DROP TABLE IF EXISTS `lottery_round`;
CREATE TABLE `lottery_round` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '轮次ID',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '轮次名称',
`start_time` datetime NOT NULL COMMENT '开始时间',
`end_time` datetime NOT NULL COMMENT '结束时间',
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '轮次描述',
`status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0-未开始,1-进行中,2-已结束)',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_time`(`start_time` ASC, `end_time` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '抽奖轮次表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of lottery_round
-- ----------------------------
-- ----------------------------
-- Table structure for prize
-- ----------------------------
DROP TABLE IF EXISTS `prize`;
CREATE TABLE `prize` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '奖品ID',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '奖品名称',
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '奖品描述',
`image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '奖品图片URL',
`stock` int NOT NULL DEFAULT 0 COMMENT '库存数量',
`probability` decimal(5, 4) NOT NULL COMMENT '中奖概率(0.0000-1.0000)',
`prize_type` tinyint NOT NULL COMMENT '奖品类型(1-实物,2-虚拟,3-积分)',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-下架,1-上架)',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '奖品表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of prize
-- ----------------------------
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户名',
`phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
`email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '邮箱',
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态(0-禁用,1-正常)',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `idx_username`(`username` ASC) USING BTREE,
INDEX `idx_phone`(`phone` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '用户表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of user
-- ----------------------------
-- ----------------------------
-- Table structure for winning_record
-- ----------------------------
DROP TABLE IF EXISTS `winning_record`;
CREATE TABLE `winning_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`prize_id` bigint NOT NULL COMMENT '奖品ID',
`round_id` bigint NOT NULL COMMENT '抽奖轮次ID',
`win_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '中奖时间',
`is_claimed` tinyint NOT NULL DEFAULT 0 COMMENT '是否已领取(0-未领取,1-已领取)',
`claim_time` datetime NULL DEFAULT NULL COMMENT '领取时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `idx_user_round`(`user_id` ASC, `round_id` ASC) USING BTREE,
INDEX `idx_round`(`round_id` ASC) USING BTREE,
INDEX `idx_user`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '中奖记录表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of winning_record
-- ----------------------------
SET FOREIGN_KEY_CHECKS = 1;