-- 红包信息表
CREATE TABLE webchat_payment.`web_chat_red_packet` (
   `ID` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
   `send_user_id` char(100) NOT NULL COMMENT '红包发送人',
   `receiver_user_id` char(100) NOT NULL COMMENT '接受人',
   `type` int(4) NOT NULL COMMENT '消息类型',
   `count` int(4) NOT NULL COMMENT '红包个数',
   `status` int(4) NOT NULL COMMENT '状态',
   `total_money` DECIMAL(10, 2) default '0.00' COMMENT '金额',
   `CREATE_BY` char(100) DEFAULT NULL COMMENT '创建人',
   `CREATE_DATE` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `expire_date` datetime NOT NULL COMMENT '过期时间',
   `UPDATE_BY` char(100) DEFAULT NULL COMMENT '更新人',
   `UPDATE_DATE` datetime DEFAULT NULL COMMENT '更新时间',
   `VERSION` int DEFAULT '0' COMMENT '版本',
   PRIMARY KEY (`ID`),
   KEY `INDEX_SEND_USER_ID` (`send_user_id`),
   KEY `INDEX_STATUS_EXPIRE_DATE` (`status`, `expire_date`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='红包信息表';

-- 红包拆分记录明细表
CREATE TABLE webchat_payment.`web_chat_red_packet_record` (
      `ID` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
      `red_packet_id` bigint NOT NULL COMMENT '红包id',
      `user_id` char(100) NOT NULL COMMENT '领取人',
      `money` DECIMAL(10, 2) default '0.00' COMMENT '领取金额',
      `CREATE_DATE` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      PRIMARY KEY (`ID`),
      KEY `INDEX_RED_PACKET_ID` (`red_packet_id`),
      KEY `INDEX_USER_ID` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='红包拆分记录明细表';

-- 用户钱包
CREATE TABLE webchat_payment.`web_chat_user_wallet` (
    `ID` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `trans_event` int(4) NOT NULL COMMENT '事件类型',
    `trans_type` int(4) NOT NULL COMMENT '收入/支出',
    `user_id` char(100) NOT NULL COMMENT '用户id',
    `target_user_id` char(100) NOT NULL COMMENT '目标用户',
    `money` DECIMAL(10, 2) default '0.00' COMMENT '流转金额',
    `trans_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '流转时间',
    PRIMARY KEY (`ID`),
    KEY `INDEX_USER_ID` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户钱包';