ALTER TABLE cai_point_record_log
    ADD COLUMN one_join tinyint default 1 not null comment '是否参与分销';


ALTER TABLE cai_point_record_log
    ADD COLUMN trace_id varchar(100) default null comment '链路ID';

CREATE TABLE `cai_point_change_log`
(
    `id`              bigint unsigned  NOT NULL AUTO_INCREMENT COMMENT '子账户ID',
    `user_id`         bigint(20)       NOT NULL COMMENT '用户ID',
    `usercode`        varchar(100)     NOT NULL COMMENT '用户',
    `message`         varchar(100)     NOT NULL COMMENT '账户明细说明',
    `action_type`     varchar(36)               DEFAULT NULL COMMENT '触发来源 1-充值 2-分销 3-抽奖',
    `tar_user_id`     bigint                    DEFAULT NULL COMMENT '目标ID，用户、抽奖ID',
    `tar_usercode`    varchar(20)               DEFAULT NULL COMMENT '目标用户Code，有用户才有用',
    `tar_name`        varchar(255)              DEFAULT NULL COMMENT '目标名称，用户名称，抽奖名称',
    `tar_price`       bigint                    DEFAULT NULL COMMENT '礼物价值',
    `tar_img`         varchar(255)              DEFAULT NULL COMMENT '目标提前缓存的',
    `tar_json`        JSON                      DEFAULT NULL COMMENT '目标额外字段',
    `change_value`    bigint           NOT NULL DEFAULT '0.00' COMMENT '变化值，为正 或者为负',
    `operate_ip`      varchar(15)               DEFAULT '' COMMENT '操作IP',
    `is_admin`        tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否为后台用户手动调整',
    `trace_link_type` varchar(36)               DEFAULT NULL COMMENT '跟踪类型 1-充值 2-分销 3-抽奖',
    `trace_id`        varchar(50)               DEFAULT NULL COMMENT '跟踪ID 订单号-礼物ID',
    `give_flag`       tinyint          NOT NULL DEFAULT '0' COMMENT '是否兑换',
    `give_time`       datetime comment '兑换时间',
    `create_time`     datetime         NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `user_id` (`user_id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC 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 (1998592326494093313, '积分记录', '1738084052270563330', '1', 'pointChangeLog', 'cai/pointChangeLog/index', 1, 0,
        'C', '0', '0', 'cai:pointChangeLog: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 (1998592326494093314, '积分记录查询', 1998592326494093313, '1', '#', '', 1, 0, 'F', '0', '0',
        'cai:pointChangeLog: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 (1998592326494093316, '积分记录修改', 1998592326494093313, '3', '#', '', 1, 0, 'F', '0', '0',
        'cai:pointChangeLog:edit', '#', 'admin', sysdate(), '', null, '');

