-- 用户盈亏日志表:每次卖出/领福利时记录实际盈亏金额 CREATE TABLE user_profit_log ( id bigint(20) NOT NULL AUTO_INCREMENT, user_id bigint(20) NOT NULL COMMENT '用户ID', profit_date date NOT NULL COMMENT '盈亏日期(北京时间)', amount decimal(20,8) NOT NULL COMMENT '盈亏金额(正=盈利,负=亏损)', type tinyint(1) NOT NULL COMMENT '类型: 1=交易盈亏 2=福利', coin_code varchar(20) DEFAULT NULL COMMENT '币种代码(交易盈亏时有值)', related_order_no varchar(32) DEFAULT NULL COMMENT '关联订单号', create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), KEY idx_user_date (user_id, profit_date), KEY idx_profit_date (profit_date) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户盈亏日志表';