package cn.pluss.platform.vo;

import cn.pluss.platform.entity.Account;
import cn.pluss.platform.entity.SubMerchantApplyOrder;
import lombok.Data;

/**
 * 微信认证信息VO
 *
 * @author djh
 */
@Data
public class WxCertInfoVO {

    /**
     * M800商编
     */
    private String merchantCode;

    /**
     * 通道商编
     */
    private String merchantId;

    /**
     * 通道id
     */
    private String channelId;

    /**
     * 通道名称
     */
    private String channelName;

    /**
     * 通道类型
     */
    private String channelType;

    public void setChannelType(String channelType) {
        this.channelType = channelType;
        if (channelType.equals(Account.CHANNEL_TYPE_D0)) {
            channelTypeDesc = "实时到账";
        }

        if (channelType.equals(Account.CHANNEL_TYPE_D1)) {
            channelTypeDesc = "次日到账";
        }
    }

    /**
     * 通道类型描述
     */
    private String channelTypeDesc;

    /**
     * 状态
     */
    private String status;

    public void setStatus(String status) {
        this.status = status;

        if (status == null) {
            return;
        }

        switch (status) {
            case SubMerchantApplyOrder.STATUS_NO_AUDIT:
                statusDesc = "暂未进件";
                break;
            case SubMerchantApplyOrder.RES_STATUS_REVIEW:
                statusDesc = "认证中";
                break;
            case SubMerchantApplyOrder.RES_STATUS_SUCCESS:
                statusDesc = "待授权";
                break;
            case SubMerchantApplyOrder.RES_STATUS_COMPLETE:
                statusDesc = "认证完成";
                break;
            case SubMerchantApplyOrder.RES_STATUS_COMMIT_ERROR:
                statusDesc = "认证异常";
                break;
            default:
                this.status = SubMerchantApplyOrder.STATUS_NO_WX_AUDIT;
                statusDesc = "未认证";
                break;
        }
    }

    /**
     * 状态描述
     */
    private String statusDesc;

    /**
     * 微信子商户号
     */
    private String wxSubMerchantId;

    /**
     * 微信认证状态备注
     */
    private String remark;

    /**
     * 认证码图片链接
     */
    private String infoQrcode;

    /**
     * 手动认证码连接
     */
    private String altImgUrl;

    public static WxCertInfoVO empty(String channelType) {
        WxCertInfoVO wxCertInfoVO = new WxCertInfoVO();
        wxCertInfoVO.setChannelType(channelType);
        wxCertInfoVO.setStatus(SubMerchantApplyOrder.STATUS_NO_AUDIT);

        return wxCertInfoVO;
    }
}
