package com.freemud.application.sdk.api.ordercenter.enums.orderv1;

import org.apache.commons.lang.StringUtils;

public enum  OrderSourceV1 {


    WE_CHAT("we_chat", "自营微信小程序", 1),
    SAAS("saas", "saas 点餐", 2),
    ALIPAY("alipay", "支付宝", 3),
    HTML5("html5", "自营H5", 4),
    ANDROID("android", "自营安卓APP", 5),
    IOS("ios", "自营苹果APP", 6),
    PC_WEB("pcweb", "自营PC-WEB", 7),
    ELEME("eleme", "饿了么外卖", 8),
    EBAI("ebwm", "饿百外卖", 9),
    JDWM("jdwm", "京东到家", 10),
    MTWM("mtwm", "美团外卖", 11),
    APP("app", "APP", 12),
    I_MEMBER("imember", "i 会员订单", 13),
    I_CARGO("icargo", "i应用订货", 14),
    POS("pos", "线下 POS", 15),
    BDWM("bdwm", "百度外卖", 16),
    IPINTUAN("ipintuan", "i拼团", 18),
    MEAL("meal", "i围餐", 19),
    JUBAOPEN("mtjbp", "美团服务商", 20),
    DIANPING("dp", "美团点评", 21),
    KOUBEI("koubeiwaimai", "口碑外卖", 22),
    //    MALL("mall", "非码Mall", 23),
    SAASMALL("saasmall", "微商城", 23),
    DPZHCT("dpzhct", "美团点评智慧餐厅", 24),
    FMWD("fmwd", "非码微店", 25),
    Y_POS("ypos", "非码云POS", 26),
    TIKTOKPAY("tiktokpay","抖音支付", 27),
    BEAUTIFUL("beautiful","美业", 28),
    ASSISTANT("assistant","非码小助手", 29),
    SHERPAS("sherpas","食派士", 30),
    parkingmanual("parkingmanual", "农工商停车手工录单", 98),
    PARKING("parking", "农工商停车", 99),
    SDG("sdg", "闪电购", 1000);
    private String code;
    private String desc;
    private Integer clientType;

    OrderSourceV1(String code, String desc, Integer clientType) {
        this.code = code;
        this.desc = desc;
        this.clientType = clientType;
    }

    /**
     * 字符串渠道码转对应数字类型渠道码
     *
     * @param code
     * @return
     */
    public static Integer getClientByCode(String code) {
        Integer client = OrderSourceV1.SAAS.getClientType();
        if (StringUtils.isBlank(code)) return client;
        for (OrderSourceV1 value : OrderSourceV1.values()) {
            if (value.getCode().equals(code.toLowerCase())) {
                client = value.getClientType();
                break;
            }
        }
        return client;
    }

    /**
     * 数字类型渠道码转字符类型渠道码
     *
     * @param clientType
     * @return
     */
    public static String getCodeByClientType(Integer clientType) {
        String name = "";
        for (OrderSourceV1 value : OrderSourceV1.values()) {
            if (value.getClientType().equals(clientType)) {
                name = value.getCode();
                break;
            }
        }
        if (StringUtils.isBlank(name)) name = clientType.toString();
        return name;
    }

    /**
     * 数字类型渠道码转字符类型渠道码注释
     *
     * @param clientType
     * @return
     */
    public static String getDescByClientType(Integer clientType) {
        String name = "";
        for (OrderSourceV1 value : OrderSourceV1.values()) {
            if (value.getClientType().equals(clientType)) {
                name = value.getDesc();
                break;
            }
        }
        if (StringUtils.isBlank(name)) name = clientType.toString();
        return name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Integer getClientType() {
        return clientType;
    }

    public void setClientType(Integer clientType) {
        this.clientType = clientType;
    }
}
