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


import com.yc.ship.framework.common.core.IntArrayValuable;
import com.yc.ship.framework.common.util.object.ObjectUtils;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 销售渠道,分销、旅行社为平台产品渠道，门市、小程序、自助机、窗口
 *
 */
@RequiredArgsConstructor
@Getter
public enum SellMethodEnum implements IntArrayValuable {
    OTA(0, "分销",0),
    OTC(1, "旅行社",0),
    STORE(2, "门市",1),
    MINI_APP(3, "小程序",1),
    WINDOW(4, "窗口",2),
    AUTO_MACHINE(5, "自助机",2),
    OTA_SYSTEM(6, "分销商系统",0),
    OTC_MOVE_ORDER(7, "旅行社搬单",2),
    OTC_TIMEPAY_ORDER(8, "补票",2);



    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SellMethodEnum::getType).toArray();

    /**
     * 类型值
     */
    private final Integer type;
    /**
     * 状态名
     */
    private final String name;
    /**
     * 分类 0 平台 ，1
     */
    private final Integer cate;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static SellMethodEnum valueOf(Integer type){
        return Arrays.stream(SellMethodEnum.values()).filter(item->item.type.equals(type)).findFirst().get();
    }

    /**
     * 平台的销售渠道
     * @param sellMethod
     * @return
     */
    public static boolean isPlatSellMethod(Integer sellMethod){
        return ObjectUtils.equalsAny(sellMethod,SellMethodEnum.OTA.getType(),SellMethodEnum.OTC.getType()
                ,SellMethodEnum.OTA_SYSTEM.getType(),SellMethodEnum.OTC_MOVE_ORDER.getType());
    }

    /**
     * 内部旅行社的销售渠道
     * @param sellMethod
     * @return
     */
    public static boolean isInnerAgencySellMethod(Integer sellMethod){
        return ObjectUtils.equalsAny(sellMethod,SellMethodEnum.WINDOW.getType(),SellMethodEnum.MINI_APP.getType()
                ,SellMethodEnum.AUTO_MACHINE.getType());
    }
}
