package thyyxxk.webserver.entity.outpatient.wxapi;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

@Data
public class RefundParam {
    @NotNull(message = "退款操作时间不能为空。")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date refundOpDatetime;
    // 总金额
    @DecimalMin(value = "0", message = "总金额不能小于等于零。")
    private BigDecimal totalFee;
    @DecimalMin(value = "0", message = "退款金额不能小于等于零。")
    private BigDecimal cashpayAmt;
    @DecimalMin(value = "0", message = "退款金额不能小于等于零。")
    private BigDecimal refundAmt;
    // 交易订单号
    @NotBlank(message = "交易订单号不能为空。")
    private String tradeNo;
    // 退款操作员code
    @NotBlank(message = "退款操作员不能为空。")
    private String refundOpCode;
    // 退款原因
    @NotBlank(message = "退款原因不能为空。")
    private String refundReason;
    // 微信退款id
    private String refundId;

    public @DecimalMin(value = "0", message = "退款金额不能小于等于零。") BigDecimal getRefundAmt() {
        return null == refundAmt ? cashpayAmt : refundAmt;
    }
}
