package com.slodon.b2b2c.vo.member;

import com.slodon.b2b2c.core.constant.MemberWithdrawConst;
import com.slodon.b2b2c.core.i18n.Language;
import com.slodon.b2b2c.core.util.StringUtil;
import com.slodon.b2b2c.member.pojo.MemberApplyCash;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 *
 * 封装提现记录VO对象
 * @author wuxy
 * @date 2022.01.27 14:40
 */
@Data
public class FrontMemberApplyCashVO {

    @ApiModelProperty("提现ID")
    private Integer cashId;

    @ApiModelProperty("提现单号")
    private String cashSn;

    @ApiModelProperty("提现金额")
    private BigDecimal cashAmount;

    @ApiModelProperty("申请时间")
    private Date applyTime;

    @ApiModelProperty("完成时间")
    private Date finishTime;

    @ApiModelProperty("收款方式")
    private String receiveBank;

    @ApiModelProperty("收款账号")
    private String receiveAccount;

    @ApiModelProperty("收款人姓名")
    private String receiveName;

    @ApiModelProperty("收款方式：WXPAY-微信、ALIPAY-支付宝")
    private String receiveType;

    @ApiModelProperty("状态：1、待处理；2、提现成功；3、已拒绝；4、提现失败")
    private Integer state;

    @ApiModelProperty("状态：1、待处理；2、提现成功；3、已拒绝；4、提现失败")
    private String stateValue;

    @ApiModelProperty("提现失败原因")
    private String failReason;

    @ApiModelProperty("手续费")
    private BigDecimal serviceFee;

    public FrontMemberApplyCashVO(MemberApplyCash memberApplyCash) {
        this.cashId = memberApplyCash.getCashId();
        this.cashSn = memberApplyCash.getCashSn();
        this.cashAmount = memberApplyCash.getCashAmount();
        this.applyTime = memberApplyCash.getApplyTime();
        this.finishTime = memberApplyCash.getFinishTime();
        this.receiveBank = memberApplyCash.getReceiveBank();
        this.receiveAccount = memberApplyCash.getReceiveAccount();
        this.receiveName = memberApplyCash.getReceiveName();
        this.receiveType = memberApplyCash.getReceiveType();
        this.state = memberApplyCash.getState();
        this.stateValue = dealStateValue(memberApplyCash.getState());
        if (memberApplyCash.getState() == MemberWithdrawConst.STATE_3) {
            this.failReason = memberApplyCash.getRefuseReason();
        } else if (memberApplyCash.getState() == MemberWithdrawConst.STATE_4) {
            this.failReason = memberApplyCash.getFailReason();
        }
        this.serviceFee = memberApplyCash.getServiceFee();
    }

    public static String dealStateValue(Integer state) {
        String value;
        if (StringUtil.isNullOrZero(state)) {
            return Language.translate("未知");
        }
        switch (state) {
            case MemberWithdrawConst.STATE_1:
                value = "提现中";
                break;
            case MemberWithdrawConst.STATE_2:
                value = "提现成功";
                break;
            case MemberWithdrawConst.STATE_3:
            case MemberWithdrawConst.STATE_4:
                value = "提现失败";
                break;
            default:
                return Language.translate("未知");
        }
        //翻译
        value = Language.translate(value);
        return value;
    }
}
