/**
Source Server Version: 8.0.31
Source Database: backendsys
Date: 2024/04/09 11:21:58
*/

DROP TABLE IF EXISTS `sys_user_points_history`;
CREATE TABLE `sys_user_points_history` (
    PRIMARY KEY (`id`),
    `id` BIGINT AUTO_INCREMENT COMMENT 'ID',
    `target_user_id` BIGINT NOT NULL COMMENT '积分生效用户ID',
    `point_adjustment` FLOAT NOT NULL COMMENT '积分变动 (增加|减少) (正|负)',
    `point_balance` FLOAT NOT NULL COMMENT '积分余额',

    `activity_type` VARCHAR(255) NOT NULL COMMENT '触发类型 (枚举值) (后台操作|消耗|购买|赠送)',
    `activity_type_description` VARCHAR(255) NOT NULL COMMENT '触发类型描述',
    `activity_detail` VARCHAR(255) COMMENT '触发事件描述',

    `operator_type` VARCHAR(255) NOT NULL COMMENT '操作人类型 (系统|用户)',
    `operator_user_id` BIGINT COMMENT '操作人用户ID',
    `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='系统用户积分历史记录表';

INSERT INTO sys_user_points_history(target_user_id, point_adjustment, point_balance, activity_type, activity_type_description, activity_detail, operator_type, operator_user_id) VALUES
    (1, -1000, 9000, 'USED', '消耗', 'IVH-生成数智人音视频', 'SYSTEM', null),
    (1, 2000, 11000, 'BACKEND', '后台操作', '手动操作积分', 'USER', 2)
;