package com.crm.pay.constant;

import com.crm.rely.backend.core.dto.base.BaseResultDto;

/**
 * @Author houn
 * @Date 2025/12/20 19:09
 * @PackageName:com.crm.pay.constant
 * @ClassName: MerchantFailEnum
 * @Description: TODO
 */

public enum MerchantFailEnum {
    /**
     * public static final int MERCHANT_IS_NOT_EXIST = 13001;
     * public static final int MERCHANT_PAY_TYPE_IS_NOT_EXIST = 13002;
     * public static final int MERCHANT_PAY_TYPE_IS_NOT_EXIST = 13002;
     */
    //实现错误码枚举
    MERCHANT_IS_NOT_EXIST(13001, "Merchant does not exist"),
    MERCHANT_PAY_TYPE_IS_NOT_EXIST(13002, "Merchant channel does not exist."),
    MERCHANT_SIGN_ERROR(13003, "Merchant signature error"),
    MERCHANT_CHANNEL_ERROR(13004, "Channel error"),
    MERCHANT_CHANNEL_IS_NOT_EXIST_ERROR(13005, "The channel does not exist."),
    MERCHANT_CHANNEL_SEP_IS_EXIST_ERROR(13006, "Order already exists"),
    MERCHANT_REQUEST_TIME_OUT_ERROR(13007, "Time out"),
    MERCHANT_REQUEST_GA_CODE_ERROR(13008, "CAPTCHA error"),
    MERCHANT_IP_ERROR(130089, "IP restriction, no permission"),
    MERCHANT_PAY_SUCCESS_ERROR(130010, "Pay Repeated"),
    ;

    private int code;
    private String message;

    private MerchantFailEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static MerchantFailEnum getByCode(int code) {
        for (MerchantFailEnum value : values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }

    public static BaseResultDto getBaseResultDto(MerchantFailEnum merchantFailEnum) {

        return BaseResultDto.error(merchantFailEnum.code, merchantFailEnum.message);
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
