package com.mosquito.project.persistence.entity;

import jakarta.persistence.*;
import java.time.OffsetDateTime;

@Entity
@Table(name = "user_rewards", indexes = {
    @Index(name = "idx_user_rewards_user", columnList = "user_id"),
    @Index(name = "idx_user_rewards_activity", columnList = "activity_id"),
    @Index(name = "idx_user_rewards_status", columnList = "status")
})
public class UserRewardEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "activity_id", nullable = false)
    private Long activityId;

    @Column(name = "user_id", nullable = false)
    private Long userId;

    @Column(name = "type", nullable = false, length = 32)
    private String type;

    @Column(name = "points", nullable = false)
    private Integer points;

    @Column(name = "status", nullable = false, length = 32)
    private String status = "PENDING";

    @Column(name = "created_at")
    private OffsetDateTime createdAt;

    @Column(name = "tracking_id", length = 64)
    private String trackingId;

    // 优惠券相关字段
    @Column(name = "coupon_batch_id", length = 64)
    private String couponBatchId;

    @Column(name = "coupon_code", length = 64)
    private String couponCode;

    @Column(name = "coupon_value", length = 64)
    private String couponValue;

    // 数据权限字段：记录奖励发放时的部门ID，用于部门数据范围过滤
    @Column(name = "department_id")
    private Long departmentId;

    // 审批类型：AUTO(自动), RISK(风控), RISK_FINANCE(风控+财务), RISK_FINANCE_DIRECTOR(风控+财务+总监)
    @Column(name = "approval_type", length = 32)
    private String approvalType;

    // 当前审批级别：0-待风控审批，1-待财务审批，2-待总监审批，3-已完成所有审批
    @Column(name = "current_approval_level")
    private Integer currentApprovalLevel = 0;

    // 需要的总审批级别数
    @Column(name = "required_approval_levels")
    private Integer requiredApprovalLevels = 0;

    // 关联的审批记录ID
    @Column(name = "approval_record_id")
    private Long approvalRecordId;

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    public Long getActivityId() { return activityId; }
    public void setActivityId(Long activityId) { this.activityId = activityId; }
    public Long getUserId() { return userId; }
    public void setUserId(Long userId) { this.userId = userId; }
    public String getType() { return type; }
    public void setType(String type) { this.type = type; }
    public Integer getPoints() { return points; }
    public void setPoints(Integer points) { this.points = points; }
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    public OffsetDateTime getCreatedAt() { return createdAt; }
    public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; }
    public String getTrackingId() { return trackingId; }
    public void setTrackingId(String trackingId) { this.trackingId = trackingId; }
    public String getCouponBatchId() { return couponBatchId; }
    public void setCouponBatchId(String couponBatchId) { this.couponBatchId = couponBatchId; }
    public String getCouponCode() { return couponCode; }
    public void setCouponCode(String couponCode) { this.couponCode = couponCode; }
    public String getCouponValue() { return couponValue; }
    public void setCouponValue(String couponValue) { this.couponValue = couponValue; }
    public Long getDepartmentId() { return departmentId; }
    public void setDepartmentId(Long departmentId) { this.departmentId = departmentId; }
    public String getApprovalType() { return approvalType; }
    public void setApprovalType(String approvalType) { this.approvalType = approvalType; }
    public Integer getCurrentApprovalLevel() { return currentApprovalLevel; }
    public void setCurrentApprovalLevel(Integer currentApprovalLevel) { this.currentApprovalLevel = currentApprovalLevel; }
    public Integer getRequiredApprovalLevels() { return requiredApprovalLevels; }
    public void setRequiredApprovalLevels(Integer requiredApprovalLevels) { this.requiredApprovalLevels = requiredApprovalLevels; }
    public Long getApprovalRecordId() { return approvalRecordId; }
    public void setApprovalRecordId(Long approvalRecordId) { this.approvalRecordId = approvalRecordId; }
}

