package ink.wgink.module.wechat.pay.enums;

/**
 * @ClassName: PayErrorMsgEnum
 * @Description: 支付错误码
 * @Author: wanggeng
 * @Date: 2021/8/19 9:21 上午
 * @Version: 1.0
 */
public enum PayErrorMsgEnum {

    /**
     * 202 错误
     */
    USERPAYING_200(202, "USERPAYING", "用户支付中，需要输入密码", "等待5秒，然后调用被扫订单结果查询API，查询当前订单的不同状态，决定下一步的操作"),

    /**
     * 400 错误
     */
    APPID_MCHID_NOT_MATCH_400(400, "APPID_MCHID_NOT_MATCH", "appid和mch_id不匹配", "请确认appid和mch_id是否匹配"),
    PARAM_ERROR_400(400, "PARAM_ERROR", "业务规则限制", "请根据接口返回的详细信息检查请求参数"),
    ORDER_CLOSED(400, "ORDER_CLOSED", "订单已关闭", "当前订单已关闭，请重新下单"),
    MCH_NOT_EXISTS_400(400, "MCH_NOT_EXISTS", "商户号不存在", "请检查商户号是否正确"),
    INVALID_REQUEST_400(400, "INVALID_REQUEST", "无效请求", "请根据接口返回的详细信息检查"),
    PHONE_NOT_EXIST_400(400, "PHONE_NOT_EXIST", "手机号不存在", "请检查手机号码是否正确"),
    AUTH_CODE_INVALID_400(400, "AUTH_CODE_INVALID", "收银员扫描的不是微信支付的条码", "请扫描微信支付被扫条码/二维码"),
    NO_STATEMENT_EXIST_400(400, "NO_STATEMENT_EXIST", "账单文件不存在", "请检查当前商户号是否在指定日期有交易或退款发生"),
    STATEMENT_CREATING_400(400, "STATEMENT_CREATING", "账单生成中", "请先检查当前商户号在指定日期内是否有成功的交易或退款，若有，则在T+1日上午8点后再重新下载"),
    RESOURCE_ALREADY_EXISTS_400(400, "RESOURCE_ALREADY_EXISTS", "用户已签约该商户，不可重复签约", "请通过查询用户接口获取用户的签约信息"),
    ALREADY_EXISTS_400(400, "ALREADY_EXISTS", "资源已存在", "尝试创建的资源已存在，无需重复创建"),
    USER_NOT_REGISTERED_400(400, "USER_NOT_REGISTERED", "服务未开通或账号未注册", "该用户尚未注册或开通当前服务，请开通后再试"),
    ORDER_PAID_400(400, "ORDER_PAID", "订单已支付", "请确认该订单号是否重复支付，如果是新单，请使用新订单号提交"),
    ORDER_REVERSED_400(400, "ORDER_REVERSED", "订单已撤销", "当前订单状态为“订单已撤销”，请提示用户重新支付"),
    ORDERCLOSED_400(400, "ORDERCLOSED", "订单已关闭", "商户订单号异常，请重新下单支付"),
    ORDERPAID_400(400, "ORDERPAID", "订单已支付", "请确认该订单号是否重复支付，如果是新单，请使用新订单号提交"),
    ORDERREVERSED_400(400, "ORDERREVERSED", "订单已撤销", "当前订单状态为“订单已撤销”，请提示用户重新支付"),

    /**
     * 401 错误
     */
    SIGN_ERROR_401(401, "SIGN_ERROR", "签名错误", "请检查签名参数和方法是否都符合签名算法要求"),

    /**
     * 403 错误
     */
    TRADE_ERROR_403(403, "TRADE_ERROR", "交易错误", "因业务原因交易失败，请查看接口返回的详细信息"),
    OUT_TRADE_NO_USED_403(403, "OUT_TRADE_NO_USED", "商户订单号重复", "请核实商户订单号是否重复提交"),
    ACCOUNT_ERROR_403(403, "ACCOUNT_ERROR", "账号异常", "用户账号异常，无需更多操作"),
    RULE_LIMIT_403(403, "RULE_LIMIT", "业务规则限制", "因业务规则限制请求频率，请查看接口返回的详细信息"),
    NOT_ENOUGH_403(403, "NOT_ENOUGH", "余额不足", "用户账号余额不足，请用户充值或更换支付卡后再支付"),
    NO_AUTH_403(403, "NO_AUTH", "商户无权限", "请商户前往申请此接口相关权限"),
    REQUEST_BLOCKED_403(403, "REQUEST_BLOCKED", "请求受阻", "此状态代表退款申请失败，商户可根据具体的错误提示做相应的处理"),
    CONTRACT_NOT_EXIST_403(403, "CONTRACT_NOT_EXIST", "签约协议不存在", "请检查签约协议号是否正确，是否已解约"),
    CONTRACT_EXISTED_403(403, "CONTRACT_EXISTED", "协议已存在", "已开通自动扣费服务功能，无需重复开通"),
    AUTH_CODE_EXPIRE_403(403, "AUTH_CODE_EXPIRE", "用户的条码已经过期", "请收银员提示用户，请用户在微信上刷新条码，然后请收银员重新扫码。 直接将错误展示给收银员"),
    USER_ACCOUNT_ABNORMAL_403(403, "USER_ACCOUNT_ABNORMAL", "用户账户异常", "该确认用户账号是否正常，商家可联系微信支付或让用户联系微信支付客服处理"),
    CONTRACT_ERROR_403(403, "CONTRACT_ERROR", "当前用户签约状态失效", "请通过查询用户接口核实签约状态"),
    CONTRACT_NOT_CONFIRMED_403(403, "CONTRACT_NOT_CONFIRMED", "二级商户未开启手动提现权限", "二级商户号提现权限已关闭，无法发起提现"),
    ACCOUNT_NOT_VERIFIED_403(403, "ACCOUNT_NOT_VERIFIED", "二级商户下行打款未成功", "二级商户号结算银行卡信息有误，修改后重试"),

    /**
     * 404 错误
     */
    REFUND_NOT_EXISTS_404(404, "REFUND_NOT_EXISTS", "订单号错误或订单状态不正确", "请检查订单号是否有误以及订单状态是否正确，如：未支付、已支付未退款"),
    ORDER_NO_TEXIST_404(404, "ORDER_NO_TEXIST", "订单不存在", "请检查订单是否发起过交易"),
    ORDER_NOT_EXIST_404(404, "ORDER_NOT_EXIST", "请求的资源不存在", "请商户检查需要查询的id或者请求URL是否正确"),
    USER_NOT_EXIST_404(404, "USER_NOT_EXIST", "用户账户注销", "请检查用户账户是否正确"),
    USER_NOT_EXISTS_404(404, "USER_NOT_EXISTS", "openid不正确", "请确认传入的openid是否正确"),
    MCH_NOT_EXISTS_404(404, "MCH_NOT_EXISTS", "商户号不存在", "请确认传入的商户号是否正确"),
    RESOURCE_NOT_EXISTS_404(404, "RESOURCE_NOT_EXISTS", "查询的资源不存在", "请检查查询资源的对应id是否填写正确"),
    NOT_FOUND_404(404, "NOT_FOUND", "请求的资源不存在", "请商户检查需要查询的id或者请求URL是否正确"),

    /**
     * 429 错误
     */
    FREQUENCY_LIMITED_429(429, "FREQUENCY_LIMITED", "频率超限", "请求量不要超过接口调用频率限制"),
    RATELIMIT_EXCEEDED_429(429, "RATELIMIT_EXCEEDED", "频率限制", "请降低频率后重试"),
    FREQUENCY_LIMIT_EXCEED_429(429, "FREQUENCY_LIMIT_EXCEED", "接口限频", "请降低调用频率"),

    /**
     * 500 错误
     */
    ERROR_500(500, "ERROR", "业务错误", "该错误都会返回具体的错误原因，请根据实际返回做相应处理"),
    OPENID_MISMATCH_500(500, "OPENID_MISMATCH", "openid和appid不匹配", "请确认openid和appid是否匹配"),
    BANK_ERROR_500(500, "BANK_ERROR", "银行系统异常", "银行系统异常，请用相同参数重新调用"),
    INVALID_TRANSACTIONID_500(500, "INVALID_TRANSACTIONID", "订单号非法", "请检查微信支付订单号是否正确"),
    BIZ_ERR_NEED_RETRY_500(500, "BIZ_ERR_NEED_RETRY", "退款业务流程错误", "请不要更换商户退款单号，请使用相同参数再次调用API"),
    SYSTEM_ERROR_500(500, "SYSTEM_ERROR", "系统错误", "系统异常，请用相同参数重新调用");

    private int code;
    private String errorCode;
    private String summary;
    private String solution;

    PayErrorMsgEnum(int code, String errorCode, String summary, String solution) {
        this.code = code;
        this.errorCode = errorCode;
        this.summary = summary;
        this.solution = solution;
    }

    public int getCode() {
        return code;
    }

    public String getErrorCode() {
        return errorCode == null ? "" : errorCode.trim();
    }

    public String getSummary() {
        return summary == null ? "" : summary.trim();
    }

    public String getSolution() {
        return solution == null ? "" : solution.trim();
    }
}
