package com.tmerclub.cloud.user.constant;

import org.springframework.data.domain.Sort;

/**
 * 客户列表的订单排序
 *
 * @author: zsm
 * @date: 2023/2/22 9:42
 */
public enum OrderSortEnum {

    /**
     * 消费金额正序
     */
    CONS_AMOUNT_ASC(1, "consAmount", Sort.Direction.ASC),

    /**
     * 消费金额倒序
     */
    CONS_AMOUNT_DESC(2, "consAmount", Sort.Direction.DESC),

    /**
     * 实付金额正序
     */
    ACTUAL_AMOUNT_ASC(3, "actualAmount", Sort.Direction.ASC),

    /**
     * 实付金额倒序
     */
    ACTUAL_AMOUNT_DESC(4, "actualAmount", Sort.Direction.DESC),
    /**
     * 消费次数正序
     */
    CONS_TIMES_ASC(5, "consTimes", Sort.Direction.ASC),

    /**
     * 消费次数倒序
     */
    CONS_TIMES_DESC(6, "consTimes", Sort.Direction.DESC),

    /**
     * 下单次数正序
     */
    ALL_COUNT_ASC(7, "allCount", Sort.Direction.ASC),

    /**
     * 消下单次数倒序
     */
    ALL_COUNTC_DESC(8, "allCount", Sort.Direction.DESC),

    /**
     * 平均折扣正序
     */
    AVER_DISCOUNT_ASC(9, "averDiscount", Sort.Direction.ASC),

    /**
     * 平均折扣倒序
     */
    AVER_DISCOUNT_DESC(10, "averDiscount", Sort.Direction.DESC),

    /**
     * 退款次数正序
     */
    AFTER_SALE_TIMES_ASC(11, "afterSaleTimes", Sort.Direction.ASC),

    /**
     * 退款次数倒序
     */
    AFTER_SALE_TIMES_DESC(12, "afterSaleTimes", Sort.Direction.DESC),

    /**
     * 退款金额正序
     */
    AFTER_SALE_AMOUNT_ASC(13, "afterSaleAmount", Sort.Direction.ASC),

    /**
     * 退款金额倒序
     */
    AFTER_SALE_AMOUNT_DESC(14, "afterSaleAmount", Sort.Direction.DESC);

    private final Integer value;

    private final String srotName;

    private final Sort.Direction order;

    public Integer value() {
        return value;
    }

    public String param() {
        return srotName;
    }

    public Sort.Direction order() {
        return order;
    }

    OrderSortEnum(Integer value, String srotName, Sort.Direction order) {
        this.value = value;
        this.srotName = srotName;
        this.order = order;

    }

    public static String getSortName(Integer value) {
        OrderSortEnum[] enums = values();
        for (OrderSortEnum orderSortEnum : enums) {
            if (!orderSortEnum.value().equals(value)) {
                return orderSortEnum.srotName;
            }
        }
        return null;
    }


    public static OrderSortEnum instance(Integer value) {
        OrderSortEnum[] enums = values();
        for (OrderSortEnum orderSortEnum : enums) {
            if (orderSortEnum.value().equals(value)) {
                return orderSortEnum;
            }
        }
        return null;
    }

}
