package com.bonus.canteen.core.account.v3.app.vo;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.account.v3.constants.AccTradeTypeEnum;
import com.bonus.canteen.core.pay.common.constants.PayStateEnum;
import com.bonus.canteen.core.pay.common.constants.PayTypeEnum;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.time.LocalDateTime;

public class AppAccTradePageVO {
   @ApiModelProperty("交易订单号")
   private Long tradeId;
   @ApiModelProperty("钱包交易金额/分")
   private BigDecimal amount;
   @ApiModelProperty("钱包总余额/分")
   private BigDecimal walletBalTotal;
   @ApiModelProperty("交易类型id")
   private Integer tradeType;
   @ApiModelProperty("交易类型名称")
   private String tradeTypeName;
   @ApiModelProperty("交易时间")
   private LocalDateTime tradeTime;
   @ApiModelProperty("支付状态 1-待支付 2-支付中 3-支付成功 4-支付失败 5-支付关闭")
   private Integer payState;
   @ApiModelProperty("支付状态名称")
   private String payStateName;
   @ApiModelProperty("支付方式类型")
   private Integer payType;
   @ApiModelProperty("支付方式名称")
   private String payTypeName;
   @ApiModelProperty("备注")
   private String remark;
   @ApiModelProperty(
      value = "失败原因",
      hidden = true
   )
   private String failReason;
   @ApiModelProperty("补贴有效期")
   private LocalDateTime validityTime;
   @ApiModelProperty("补贴有效期(展示)")
   private String validityTimeTitle;

   public String getTradeTypeName() {
      return AccTradeTypeEnum.getDesc(this.tradeType);
   }

   public String getPayStateName() {
      String payStateName;
      if (PayStateEnum.isPaidState(this.getPayState())) {
         payStateName = "充值成功";
      } else if (PayStateEnum.isFailedState(this.getPayState())) {
         payStateName = "充值失败";
      } else {
         payStateName = "充值超时";
      }

      return payStateName;
   }

   public String getPayTypeName() {
      return PayTypeEnum.getDesc(this.getPayType());
   }

   public String getRemark() {
      return PayStateEnum.isFailedState(this.getPayState()) ? this.failReason : this.remark;
   }

   public String getValidityTimeTitle() {
      if (ObjectUtil.isNotNull(this.getValidityTime())) {
         String format = DateUtil.format(this.getValidityTime(), "yyyy-MM-dd");
         return "有效期至" + format;
      } else {
         return this.validityTimeTitle;
      }
   }

   public Long getTradeId() {
      return this.tradeId;
   }

   public BigDecimal getAmount() {
      return this.amount;
   }

   public BigDecimal getWalletBalTotal() {
      return this.walletBalTotal;
   }

   public Integer getTradeType() {
      return this.tradeType;
   }

   public LocalDateTime getTradeTime() {
      return this.tradeTime;
   }

   public Integer getPayState() {
      return this.payState;
   }

   public Integer getPayType() {
      return this.payType;
   }

   public String getFailReason() {
      return this.failReason;
   }

   public LocalDateTime getValidityTime() {
      return this.validityTime;
   }

   public void setTradeId(final Long tradeId) {
      this.tradeId = tradeId;
   }

   public void setAmount(final BigDecimal amount) {
      this.amount = amount;
   }

   public void setWalletBalTotal(final BigDecimal walletBalTotal) {
      this.walletBalTotal = walletBalTotal;
   }

   public void setTradeType(final Integer tradeType) {
      this.tradeType = tradeType;
   }

   public void setTradeTypeName(final String tradeTypeName) {
      this.tradeTypeName = tradeTypeName;
   }

   public void setTradeTime(final LocalDateTime tradeTime) {
      this.tradeTime = tradeTime;
   }

   public void setPayState(final Integer payState) {
      this.payState = payState;
   }

   public void setPayStateName(final String payStateName) {
      this.payStateName = payStateName;
   }

   public void setPayType(final Integer payType) {
      this.payType = payType;
   }

   public void setPayTypeName(final String payTypeName) {
      this.payTypeName = payTypeName;
   }

   public void setRemark(final String remark) {
      this.remark = remark;
   }

   public void setFailReason(final String failReason) {
      this.failReason = failReason;
   }

   public void setValidityTime(final LocalDateTime validityTime) {
      this.validityTime = validityTime;
   }

   public void setValidityTimeTitle(final String validityTimeTitle) {
      this.validityTimeTitle = validityTimeTitle;
   }
}
