package com.haha.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@TableName("t_refund")
public class Refund implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long orderId;

    private String orderNo;

    private String refundNo;

    private BigDecimal refundAmount;

    private BigDecimal totalAmount;

    private String status;

    private String reason;

    private String remark;

    private String transactionId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime refundTime;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long reviewerId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime reviewTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime updateTime;

    /** 退款后是否恢复库存：1=恢复，0=不恢复（默认1）。用于区分"识别多扣退库存"和"质量问题不退库存"场景 */
    private Integer restoreStock;

    public boolean isPending() {
        return "PENDING".equals(status);
    }

    public boolean isRefunded() {
        return "REFUNDED".equals(status);
    }

    public boolean isRejected() {
        return "REJECTED".equals(status);
    }
}
