CREATE TABLE `cai_prize_info`
(
    `id`              bigint        NOT NULL AUTO_INCREMENT COMMENT '奖品ID',
    `prize_name`      varchar(100)  NOT NULL COMMENT '奖品名称',
    `prize_desc`      varchar(500)           DEFAULT '' COMMENT '奖品描述',
    `prize_img`       varchar(255)           DEFAULT '' COMMENT '奖品图片地址',
    `win_probability` decimal(5, 4) NOT NULL COMMENT '中奖率（0-1，如0.0100表示1%）',
    `guarantee_draws` int           NOT NULL DEFAULT 0 COMMENT '保底抽数（0表示无保底，谢谢惠顾奖无效）',
    `min_win_draws`   int           NOT NULL DEFAULT 0 COMMENT '最低中奖抽数（0表示无限制，谢谢惠顾奖无效）',
    `stock`           int           NOT NULL DEFAULT 0 COMMENT '奖品库存（谢谢惠顾奖填0，不校验）',
    `prize_type`      tinyint       not null comment '奖品类型 1-谢谢惠顾 2-普通奖 3-大奖',
    `prize_price`     bigint(20)    not null default 0 comment '奖品价值估算',
    `auto_give`       tinyint       not null default 0 comment '是否自动兑奖',
    `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`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='奖品基础表';


CREATE TABLE `cai_prize_online`
(
    `id`              bigint        NOT NULL AUTO_INCREMENT COMMENT '奖品ID',
    `prize_id`        bigint        NOT NULL COMMENT '奖品ID',
    `gender`          tinyint(1)    NOT NULL DEFAULT '0' COMMENT '性别 1-女  2-男',
    `prize_name`      varchar(100)  NOT NULL COMMENT '奖品名称',
    `prize_desc`      varchar(500)           DEFAULT '' COMMENT '奖品描述',
    `prize_img`       varchar(255)           DEFAULT '' COMMENT '奖品图片地址',
    `win_probability` decimal(5, 4) NOT NULL COMMENT '中奖率（0-1，如0.0100表示1%）',
    `guarantee_draws` int           NOT NULL DEFAULT 0 COMMENT '保底抽数（0表示无保底，谢谢惠顾奖无效）',
    `min_win_draws`   int           NOT NULL DEFAULT 0 COMMENT '最低中奖抽数（0表示无限制，谢谢惠顾奖无效）',
    `stock`           int           NOT NULL DEFAULT 0 COMMENT '奖品库存（谢谢惠顾奖填0，不校验）',
    `prize_type`      tinyint       not null comment '奖品类型 1-谢谢惠顾 2-普通奖 3-大奖',
    `prize_price`     bigint(20)    not null default 0 comment '奖品价值估算',
    `auto_give`       tinyint       not null default 0 comment '是否自动兑奖',
    `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`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='已发布奖品表';


alter table `cai_point_change_log`
    ADD COLUMN remark varchar(200) null comment '备注';


-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(2003344862891581442, '抽奖奖品', '1738072642014617602', '1', 'prizeInfo', 'cai/prizeInfo/index', 1, 0, 'C', '0', '0', 'cai:prizeInfo:list', '#', 'admin', sysdate(), '', null, '抽奖奖品菜单');

-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(2003344862891581443, '抽奖奖品查询', 2003344862891581442, '1',  '#', '', 1, 0, 'F', '0', '0', 'cai:prizeInfo:query',        '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(2003344862891581444, '抽奖奖品新增', 2003344862891581442, '2',  '#', '', 1, 0, 'F', '0', '0', 'cai:prizeInfo:add',          '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(2003344862891581445, '抽奖奖品修改', 2003344862891581442, '3',  '#', '', 1, 0, 'F', '0', '0', 'cai:prizeInfo:edit',         '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(2003344862891581446, '抽奖奖品删除', 2003344862891581442, '4',  '#', '', 1, 0, 'F', '0', '0', 'cai:prizeInfo:remove',       '#', 'admin', sysdate(), '', null, '');



CREATE TABLE `cai_prize_winning_record`
(
    `id`              bigint        NOT NULL AUTO_INCREMENT COMMENT '奖品ID',
    `user_id`         bigint(20)        NOT NULL COMMENT '用户ID',
    `use_point`         bigint(20)        NOT NULL COMMENT '抽奖消耗',
    `prize_id`        bigint        NOT NULL COMMENT '奖品ID',
    `prize_name`      varchar(100)  NOT NULL COMMENT '奖品名称',
    `prize_desc`      varchar(500)           DEFAULT '' COMMENT '奖品描述',
    `prize_img`       varchar(255)           DEFAULT '' COMMENT '奖品图片地址',
    `win_probability` decimal(5, 4) NOT NULL COMMENT '中奖率（0-1，如0.0100表示1%）',
    `guarantee_draws` int           NOT NULL DEFAULT 0 COMMENT '保底抽数（0表示无保底，谢谢惠顾奖无效）',
    `min_win_draws`   int           NOT NULL DEFAULT 0 COMMENT '最低中奖抽数（0表示无限制，谢谢惠顾奖无效）',
    `stock`           int           NOT NULL DEFAULT 0 COMMENT '奖品库存（谢谢惠顾奖填0，不校验）',
    `prize_type`      tinyint       not null comment '奖品类型 1-谢谢惠顾 2-普通奖 3-大奖',
    `prize_price`     bigint(20)    not null default 0 comment '奖品价值估算',
    `auto_give`       tinyint       not null default 0 comment '是否自动兑奖',
    `give_status`       tinyint       not null default 0 comment '奖品兑换情况 0-未兑换 1-已兑换',
    `give_remark`       varchar(100)       not null default 0 comment '兑奖备注说明',
    `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`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='中奖记录';
