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 MemberApplyCashVO {

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

    @ApiModelProperty("会员ID")
    private Integer memberId;

    @ApiModelProperty("会员名称")
    private String memberName;

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

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

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

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

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

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

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

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

    @ApiModelProperty("拒绝原因")
    private String refuseReason;

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

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

    @ApiModelProperty("交易流水号")
    private String transactionSn;

    @ApiModelProperty("操作管理员ID")
    private Integer adminId;

    @ApiModelProperty("操作管理员名称")
    private String adminName;

    @ApiModelProperty("会员手机号")
    private String memberMobile;

    public MemberApplyCashVO(MemberApplyCash memberApplyCash) {
        this.cashId = memberApplyCash.getCashId();
        this.memberId = memberApplyCash.getMemberId();
        this.memberName = memberApplyCash.getMemberName();
        this.cashSn = memberApplyCash.getCashSn();
        this.cashAmount = memberApplyCash.getCashAmount();
        this.applyTime = memberApplyCash.getApplyTime();
        this.receiveName = memberApplyCash.getReceiveName();
        this.receiveType = memberApplyCash.getReceiveType();
        this.receiveBank = memberApplyCash.getReceiveBank();
        this.state = memberApplyCash.getState();
        this.stateValue = dealStateValue(memberApplyCash.getState());
        this.refuseReason = memberApplyCash.getRefuseReason();
        this.failReason = memberApplyCash.getFailReason();
        this.serviceFee = memberApplyCash.getServiceFee();
        this.transactionSn = memberApplyCash.getTransactionSn();
        this.adminId = memberApplyCash.getAdminId();
        this.adminName = memberApplyCash.getAdminName();
    }

    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:
                value = "已拒绝";
                break;
            case MemberWithdrawConst.STATE_4:
                value = "提现失败";
                break;
            default:
                return Language.translate("未知");
        }
        //翻译
        value = Language.translate(value);
        return value;
    }
}
