package com.yc.ship.module.otc.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;


@RequiredArgsConstructor
@Getter
public enum TradeModeEnum {

    // 余额
    BALANCE_ADMIN_RECHARGE_1(1, 1, 1, "管理员余额充值", "trade_balance"),
    BALANCE_ADMIN_RECHARGE_2(1, 1, 2, "管理员余额充值", "trade_balance"),
    BALANCE_SELF_RECHARGE(1, 3, 1, "余额自助充值", "trade_balance"),
    BALANCE_PAY(1, 5, 2, "余额购票", "trade_balance"),
    BALANCE_REFUND(1, 7, 1, "余额退款", "trade_balance"),
    BALANCE_ROLLBACK(1, 7, 3, "余额回滚", "trade_balance"),

    // 授信
    CREDIT_ADMIN_RECHARGE_1(2, 2, 1, "管理员授信充值", "trade_credit"),
    CREDIT_ADMIN_RECHARGE_2(2, 2, 2, "管理员授信充值", "trade_credit"),
    CREDIT_SELF_RECHARGE(4, 8, 1, "授信自助充值", "trade_credit"),
    CREDIT_PAY(2, 6, 2, "授信购票", "trade_credit"),
    CREDIT_REFUND(2, 8, 1, "授信退款", "trade_credit"),
    CREDIT_ROLLBACK(2, 8, 3, "授信回滚", "trade_credit"),

    // 变更额度
    QUOTA_1(3, 99, 1, "授信额度变更", "credit"),
    QUOTA_2(3, 99, 2, "授信额度变更", "credit"),

    //平台授信
    PLAT_CREDIT_PAY(4, 9, 2, "平台授信购票", "trade_credit"),
    PLAT_CREDIT_REFUND(4, 10, 1, "平台授信退款", "trade_credit"),
    PLAT_CREDIT_RECHARGE(4, 11, 1, "平台授信账单还款", "trade_credit"),
    PLAT_CREDIT_SHARE(4, 15, 1, "平台授信分配", "trade_credit"),

    //平台预付款
    PLAT_BALANCE_PAY(5, 12, 2, "平台预付款购票", "trade_credit"),
    PLAT_BALANCE_REFUND(5, 13, 1, "平台预付款退款", "trade_credit"),
    PLAT_BALANCE_RECHARGE(5, 14, 1, "平台预付款分配", "trade_credit"),
    PLAT_BALANCE_RECHARGE_BACK(5, 16, 2, "平台预付款回收", "trade_credit"),
    PLAT_CREDIT_SHARE_BACK(4, 18, 2, "平台授信回收", "trade_credit"),
    BALANCE_PAY_CREDIT_BILL(5, 19, 2, "预付款支付授信账单", "trade_credit"),
    BALANCE_PAY_DIRECT_STOCK(5, 20, 2, "定向库存购买", "trade_credit"),
    BALANCE_REFUND_DIRECT_STOCK(5, 21, 1, "定向库存退款", "trade_credit"),
    GUIDE_REFUND_BALANCE_TRANS(5, 22, 2, "导游代退扣预存款", "trade_credit"),
    GUIDE_REFUND_BALANCE_TRANS_CANCEL(5, 23, 1, "导游代退失败回退预存款", "trade_credit")
    ;
    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeModeEnum::getType).toArray();

    /**
     * 1.余额，2.授信充正，3.授信提额
     */
    private final Integer operateType;
    /**
     * 操作类型：1.管理员余额充值、2.管理员授信充值、3.余额自助充值、4.授信自助充值、5.余额购票、6.授信购票、7.余额退款、8.授信退款、9.平台授信购票、10.平台授信退款 99.授信额度变更
     */
    private final Integer type;
    /**
     * 交易类型 0.不变 1.增加、2.减少 3.回滚
     */
    private final Integer mode;
    /**
     * 状态名
     */
    private final String name;
    /**
     * 服务名称
     */
    private final String serviceName;


    public static TradeModeEnum valueOf(Integer operateType, Integer type, Integer mode) {
        return Arrays.stream(TradeModeEnum.values()).filter(item -> item.operateType.equals(operateType) && item.getType().equals(type) && item.getMode().equals(mode)).findFirst().get();
    }

}
