
package com.tmerclub.cloud.flow.constant;


import java.util.Objects;

/**
 * 页面操作
 *
 * @author yxf
 */
public enum FlowSpuSortEnum {
    /**
     * 曝光次数
     */
    VISIT(0, "visit"),
    /**
     * 曝光人数
     */
    VISIT_USER(1, "visitUser"),
    /**
     * 加购人数
     */
    PLUS_SHOP_CART_USER(2, "plusShopCartUser"),
    /**
     * 加购件数
     */
    PLUS_SHOP_CART(3, "plusShopCart"),
    /**
     * 下单人数
     */
    PLACE_ORDER_USER(4, "placeOrderUser"),
    /**
     * 支付人数
     */
    PAY_USER(5, "payUser"),
    /**
     * 支付人数
     */
    PLACE_ORDER_NUM(6, "placeOrderNum"),
    /**
     * 支付人数
     */
    PAY_NUM(7, "payNum"),
    /**
     * 下单金额
     */
    PLACE_ORDER_AMOUNT(8, "placeOrderAmount"),
    /**
     * 支付金额
     */
    PAY_AMOUNT(9, "payAmount"),
    /**
     * 申请退款订单数
     */
    APPLY_REFUND_ORDER(10, "applyRefundOrder"),
    /**
     * 申请退款人数
     */
    APPLY_REFUND_USER(11, "applyRefundUser"),
    /**
     * 成功退款订单数
     */
    SUCCESS_REFUND_ORDER(12, "successRefundOrder"),
    /**
     * 成功退款人数
     */
    SUCCESS_REFUND_USER(13, "successRefundUser"),
    /**
     * 成功退款金额
     */
    SUCCESS_REFUND_AMOUNT(14, "successRefundAmount"),
    /**
     * 成功退款率
     */
    success_Refund_Rate(15, "successRefundRate")
    ;

    private final Integer id;
    private final String name;

    public Integer value() {
        return id;
    }

    public String getName() {
        return name;
    }

    FlowSpuSortEnum(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public static FlowSpuSortEnum instance(String value) {
        FlowSpuSortEnum[] enums = values();
        for (FlowSpuSortEnum statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static FlowSpuSortEnum[] allEnum() {
        FlowSpuSortEnum[] enums = values();
        return enums;
    }


    public static Boolean isVisitOrShare(Integer id) {
        return id.equals(VISIT.value());
    }


    public static String getFieldName(Integer id) {
        for (FlowSpuSortEnum value : values()) {
            if (Objects.equals(value.id, id)){
                return value.name;
            }
        }
        return VISIT.name;
    }
}
