package com.xhpc.pp.tx;

public class TxException extends Exception {

    /**
     * 缺少参数
     */
    public static final TxException INVALID_PARAMETER = new TxException("1101", "缺少必要参数");
    public static final TxException REGISTER_FAIL = new TxException("0103", "注册失败");
    public static final TxException LOGIN_FAIL = new TxException("0104", "用户名或密码错误");
    public static final TxException LOGIN_FAIL_NON_REG = new TxException("0105", "非APP注册用户，请先注册后再登录");
    public static final TxException LOGIN_FAIL_FREEZE = new TxException("0106", "用户处于冻结状态，暂不可用，请联系系统管理人员");
    public static final TxException LOGIN_FAIL_SMS_CODE = new TxException("0107", "短信验证码不正确");
    public static final TxException USER_NO_EXIST = new TxException("0108", "用户不存在");
    public static final TxException SESSION_INVALID = new TxException("0001", "用户未登录或过期，请重新登录");
    public static final TxException USER_BALANCE_LOCKED = new TxException("3001", "余额锁定，当前有未结束的充电操作。");
    public static final TxException NO_DATA = new TxException("0002", "无数据");
    private static final long serialVersionUID = 1L;
    private String returnCode;

    public TxException(String rtnCode, Throwable reason) {

        super(rtnCode, reason);
        this.returnCode = rtnCode;
    }

    public TxException(String rtnCode, String msg) {

        super(msg);
        this.returnCode = rtnCode;
    }

    public TxException(String rtnCode) {

        this.returnCode = rtnCode;
    }

    public static TxException SERVICE_CALL_FIAL(String code, String error) {

        return new TxException(code, error);
    }

    /**
     * 参数错误
     */
    public static TxException PARAMETER_INVALID(String error) {

        return new TxException("1101", error);
    }

    /**
     * 内部错误
     */
    public static TxException INNER_ERROR(String msg) {

        return new TxException("1111", msg);
    }

    public String getReturnCode() {

        return returnCode;
    }

}
