package com.sckw.core.common.enums.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author lfdc
 * @description 枚举字典
 * @date 2023-07-07 14:07:23
 */
@Getter
@AllArgsConstructor
public enum DictEnum {
    /**
     *
     */
    SYSTEM_MSG("msg_category", "SYSTEM", "系统消息"),
    BUSINESS_MSG("msg_category", "BUSINESS", "业务消息"),
    SMS_REGISTER("send_sms_type", "register", "短信注册"),
    SMS_LOGIN("send_sms_type", "login", "短信登录"),
    SMS_UPDATE_PASSWORD("send_sms_type", "updatePassword", "短信修改密码"),
    PRICE_TYPE_0("price_type", "0", "元/吨"),
    PRICE_TYPE_1("price_type", "1", "元/车"),
    WEIGHT_CAR_0("weight_car", "0", "吨/车"),
    WEIGHT_CAR_1("weight_car", "1", "公斤/车"),
    TRANSPORT_TYPE_0("transport_type", "0", "公斤/车"),
    TRANSPORT_TYPE_1("transport_type", "1", "吨/车"),
    UNIT_TYPE_0("unit_type","0", "吨"),
    UNIT_TYPE_1("unit_type","1", "方"),
    UNIT_TYPE_2("unit_type","2", "箱"),
    UNIT_TYPE_3("unit_type","3", "件"),
    UNIT_TYPE_4("unit_type","4", "其他"),
    TAX_RATE_0("tax_rate","13", "13%"),
    TAX_RATE_1("tax_rate","11", "11%"),
    TAX_RATE_2("tax_rate","10", "10%"),
    TRADE_TYPE_01("trade_type", "11", "预付款-汇付"),
    TRADE_TYPE_02("trade_type", "12", "预付款-新生"),
    TRADE_TYPE_03("trade_type", "13", "预付款-中信"),
    TRADE_TYPE_1("trade_type", "2", "货到付款"),
    TRADE_TYPE_2("trade_type", "3", "线下付款"),
    PICKUP_TYPE_0("pickup_type", "0", "供应配送"),
    PICKUP_TYPE_1("pickup_type", "1", "采方自提"),
    DELIVERY_TYPE_0("delivery_type", "0", "签发交付"),
    DELIVERY_TYPE_1("delivery_type", "1", "签收交付"),
    TORDER_SOURCE_1("tOrder_source", "1", "采购下单"),
    TORDER_SOURCE_2("tOrder_source", "2", "代客下单"),
    TORDER_STATUS_0("tOrder_status", "0", "已保存"),
    TORDER_STATUS_1("tOrder_status", "1", "待受理"),
    TORDER_STATUS_2("tOrder_status", "2", "已退回"),
    TORDER_STATUS_3("tOrder_status", "3", "待签约"),
    TORDER_STATUS_4("tOrder_status", "4", "执行中"),
    TORDER_STATUS_5("tOrder_status", "5", "已完结"),
    TORDER_STATUS_6("tOrder_status", "6", "已对账"),
    TORDER_STATUS_7("tOrder_status", "7", "已结算"),
    CONTRACT_STATUS_0("contract_status", "1", "待签约"),
    CONTRACT_STATUS_1("contract_status", "0", "已签约"),
    SETTLEMENT_CYCLE_0("settlement_cycle", "0", "周结"),
    SETTLEMENT_CYCLE_1("settlement_cycle", "1", "月结"),
    SETTLEMENT_CYCLE_2("settlement_cycle", "2", "季结"),
    SIGNING_TYPE_1("signing_type", "1", "线上签约"),
    SIGNING_TYPE_2("signing_type", "2", "线下签约"),
    TORDER_ADDRESS_TYPE_1("tOrder_address_type", "1", "装货地址"),
    TORDER_ADDRESS_TYPE_2("tOrder_address_type", "2", "卸货地址"),
    TORDER_UNIT_TYPE_1("tOrder_unit_type", "1", "采购单位"),
    TORDER_UNIT_TYPE_2("tOrder_unit_type", "2", "销售单位"),
    ADDRESS_TYPE_0("address_type", "0", "矿山"),
    INDUSTRY_TYPE_0("industry_type", "0", "砂石"),
    CLASSIFICATION_TYPE_0("classification_type", "0", "石料"),
    CATEGORY_TYPE_0("category_type", "0", "山砂"),
    PRODUCT_NAME_TYPE_0("product_name_type", "0", "毛石"),
    GOODS_STATUS_0("goods_status", "0", "已保存"),
    GOODS_STATUS_1("goods_status", "1", "上架中"),
    GOODS_STATUS_2("goods_status", "2", "已下架"),
    CHARGING_TYPE_1("charging_type", "1", "按装货量") ,
    CHARGING_TYPE_2("charging_type", "2", "按卸货量") ,
    CHARGING_TYPE_3("charging_type", "3", "按车次"),
    SIGNING_WAY_1("signing_way", "1", "线上签约"),
    SIGNING_WAY_2("signing_way", "2", "线下签约"),
    TRANSPORT_DEMAND_STATUS_0("transport_demand_status", "0","已保存"),
    TRANSPORT_DEMAND_STATUS_1("transport_demand_status", "1","上架中"),
    TRANSPORT_DEMAND_STATUS_2("transport_demand_status", "2","已下架"),
    WANT_BUY_STATUS_0("want_buy_status", "0","已保存"),
    WANT_BUY_STATUS_1("want_buy_status", "1","上架中"),
    WANT_BUY_STATUS_2("want_buy_status", "2","已下架"),
    PREPAID_LIMIT_NO("prepaid_limit", "0","否"),
    PREPAID_LIMIT_YES("prepaid_limit", "1","是"),
    ;

    private final String type;
    private final String value;
    private final String label;

    public static String getLabel(String type, String value) {
        for (DictEnum dict : DictEnum.values()) {
            if (dict.getType().equals(type) && dict.getValue().equals(value)) {
                return dict.getLabel();
            }
        }
        return null;
    }
    public static List<DictEnum> getEnumsByType(String type) {
        List<DictEnum> list = new ArrayList<>();
        for (DictEnum dict : DictEnum.values()) {
            if (dict.getType().equals(type) ) {
                list.add(dict);
            }
        }
        return list.stream().sorted(Comparator.comparing(DictEnum::getValue)).collect(Collectors.toList());
    }

}
