-- 添加奖励分级审批相关字段
-- 版本: V46
-- 描述: 添加奖励多级审批所需字段

-- 审批类型：AUTO(自动), RISK(风控), RISK_FINANCE(风控+财务), RISK_FINANCE_DIRECTOR(风控+财务+总监)
ALTER TABLE user_rewards ADD COLUMN approval_type VARCHAR(32) DEFAULT NULL;
COMMENT ON COLUMN user_rewards.approval_type IS '审批类型';

-- 当前审批级别：0-待风控审批，1-待财务审批，2-待总监审批，3-已完成所有审批
ALTER TABLE user_rewards ADD COLUMN current_approval_level INT DEFAULT 0;
COMMENT ON COLUMN user_rewards.current_approval_level IS '当前审批级别';

-- 需要的总审批级别数
ALTER TABLE user_rewards ADD COLUMN required_approval_levels INT DEFAULT 0;
COMMENT ON COLUMN user_rewards.required_approval_levels IS '需要审批的级别数';

-- 关联的审批记录ID
ALTER TABLE user_rewards ADD COLUMN approval_record_id BIGINT DEFAULT NULL;
COMMENT ON COLUMN user_rewards.approval_record_id IS '审批记录ID';

-- 添加索引
CREATE INDEX idx_user_rewards_approval_type ON user_rewards(approval_type);
CREATE INDEX idx_user_rewards_approval_level ON user_rewards(current_approval_level);
CREATE INDEX idx_user_rewards_approval_record ON user_rewards(approval_record_id);
