package com.bonus.canteen.core.pay.api.vo;

import cn.hutool.core.bean.BeanUtil;
import com.bonus.canteen.core.pay.common.constants.PayStateEnum;
import com.bonus.canteen.core.pay.common.model.TradeRecord;

import java.math.BigDecimal;

public class UnifyPaySelectVO {
   private Integer code;
   private String msg;
   private Long tradeId;
   private String outTradeNo;
   private BigDecimal amount;
   private BigDecimal realAmount;
   private Integer payType;
   private Integer payChannel;
   private Long custId;

   public static UnifyPaySelectVO of(TradeRecord tradeRecord) {
      UnifyPaySelectVO androidPayVO = (UnifyPaySelectVO)BeanUtil.copyProperties(tradeRecord, UnifyPaySelectVO.class, new String[0]);
      androidPayVO.setTradeId(tradeRecord.getId());
      androidPayVO.setCode(tradeRecord.getTradeState());
      androidPayVO.setMsg(tradeRecord.getTradeResult());
      androidPayVO.setTradeId(tradeRecord.getId());
      androidPayVO.setRealAmount(PayStateEnum.isPaidState(tradeRecord.getTradeState()) ? tradeRecord.getAmount() : BigDecimal.ZERO);
      return androidPayVO;
   }

   public static UnifyPaySelectVO of(UnifyPayVO unifyPayVO) {
      return (UnifyPaySelectVO)BeanUtil.copyProperties(unifyPayVO, UnifyPaySelectVO.class, new String[0]);
   }

   public static UnifyPaySelectVO of(Integer code, String msg) {
      return (new UnifyPaySelectVO()).setCode(code).setMsg(msg);
   }

   public Integer getCode() {
      return this.code;
   }

   public String getMsg() {
      return this.msg;
   }

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

   public String getOutTradeNo() {
      return this.outTradeNo;
   }

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

   public BigDecimal getRealAmount() {
      return this.realAmount;
   }

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

   public Integer getPayChannel() {
      return this.payChannel;
   }

   public Long getCustId() {
      return this.custId;
   }

   public UnifyPaySelectVO setCode(final Integer code) {
      this.code = code;
      return this;
   }

   public UnifyPaySelectVO setMsg(final String msg) {
      this.msg = msg;
      return this;
   }

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

   public UnifyPaySelectVO setOutTradeNo(final String outTradeNo) {
      this.outTradeNo = outTradeNo;
      return this;
   }

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

   public UnifyPaySelectVO setRealAmount(final BigDecimal realAmount) {
      this.realAmount = realAmount;
      return this;
   }

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

   public UnifyPaySelectVO setPayChannel(final Integer payChannel) {
      this.payChannel = payChannel;
      return this;
   }

   public UnifyPaySelectVO setCustId(final Long custId) {
      this.custId = custId;
      return this;
   }
}
