package com.cool.store.enums.point;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author zhangchenbiao
 * @FileName: ShopStageEnum
 * @Description:店铺阶段
 * @date 2024-04-10 17:34
 */
public enum ShopSubStageEnum {

    SHOP_STAGE_1(ShopStageEnum.SHOP_STAGE_1, 10, "选址", 12),
    SHOP_STAGE_2(ShopStageEnum.SHOP_STAGE_1, 20, "上传租赁合同", 14),
    SHOP_STAGE_3(ShopStageEnum.SHOP_STAGE_2, 30, "营业执照办理", 23),
    SHOP_STAGE_4(ShopStageEnum.SHOP_STAGE_2, 40, "食安许可证", 55),
    SHOP_STAGE_5(ShopStageEnum.SHOP_STAGE_2, 50, "员工招聘", 23),
    SHOP_STAGE_7(ShopStageEnum.SHOP_STAGE_2, 70, "缴纳加盟费/保证金", 1),
    SHOP_STAGE_8(ShopStageEnum.SHOP_STAGE_2, 80, "加盟合同签约", 4),
    SHOP_STAGE_9(ShopStageEnum.SHOP_STAGE_2, 90, "设计阶段", 14),
    SHOP_STAGE_11(ShopStageEnum.SHOP_STAGE_2, 110, "施工阶段", 25),
    SHOP_STAGE_12(ShopStageEnum.SHOP_STAGE_2, 120, "装修验收", 27),
    SHOP_STAGE_14(ShopStageEnum.SHOP_STAGE_2, 140, "开业运营方案", 28),

    SHOP_STAGE_15(ShopStageEnum.SHOP_STAGE_2, 150, "建店资料收集", 9),
    SHOP_STAGE_16(ShopStageEnum.SHOP_STAGE_2, 160, "POS开通", 10),
    SHOP_STAGE_17(ShopStageEnum.SHOP_STAGE_2, 170, "订货系统开通", 10),
    SHOP_STAGE_23(ShopStageEnum.SHOP_STAGE_2, 230, "信发系统开通", 10),
    SHOP_STAGE_24(ShopStageEnum.SHOP_STAGE_2, 240, "营帐通开通", 10),



    SHOP_STAGE_18(ShopStageEnum.SHOP_STAGE_3, 180, "抖音", null),
    SHOP_STAGE_19(ShopStageEnum.SHOP_STAGE_3, 190, "美团外卖", null),
    SHOP_STAGE_20(ShopStageEnum.SHOP_STAGE_3, 200, "美团团购", null),
    SHOP_STAGE_21(ShopStageEnum.SHOP_STAGE_3, 210, "饿了么", null),
    SHOP_STAGE_22(ShopStageEnum.SHOP_STAGE_3, 220, "快手", null),



    ;

    //阶段
    private ShopStageEnum shopStageEnum;

    //子阶段
    private Integer shopSubStage;

    //子阶段名称
    private String shopSubStageName;

    //计划完成天数
    private Integer planCompleteDays;

    ShopSubStageEnum(ShopStageEnum shopStageEnum, Integer shopSubStage, String shopSubStageName, Integer planCompleteDays) {
        this.shopStageEnum = shopStageEnum;
        this.shopSubStage = shopSubStage;
        this.shopSubStageName = shopSubStageName;
        this.planCompleteDays = planCompleteDays;
    }

    public static List<ShopSubStageEnum> getShopStageEnum(Integer shopStage) {
        List<ShopSubStageEnum> resultList = new ArrayList<>();
        for (ShopSubStageEnum shopStageEnum : ShopSubStageEnum.values()) {
            if (shopStageEnum.getShopStageEnum().getShopStage().equals(shopStage)) {
                resultList.add(shopStageEnum);
            }
        }
        return resultList;
    }

    public ShopStageEnum getShopStageEnum() {
        return shopStageEnum;
    }

    public Integer getShopSubStage() {
        return shopSubStage;
    }

    public String getShopSubStageName() {
        return shopSubStageName;
    }

    public Integer getPlanCompleteDays() {
        return planCompleteDays;
    }

    /**
     * 获取各阶段的初始状态
     *
     * @return
     */
    public ShopSubStageStatusEnum getInitStatus() {
        switch (this) {
            case SHOP_STAGE_1:
                return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_10;
            case SHOP_STAGE_5:
                return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_50;
            case SHOP_STAGE_7:
                return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_70;
            case SHOP_STAGE_2:
            case SHOP_STAGE_3:
            case SHOP_STAGE_4:
            case SHOP_STAGE_8:
            case SHOP_STAGE_9:
            case SHOP_STAGE_11:
            case SHOP_STAGE_12:
            case SHOP_STAGE_14:
            case SHOP_STAGE_15:
            case SHOP_STAGE_16:
            case SHOP_STAGE_17:
            case SHOP_STAGE_18:
            case SHOP_STAGE_19:
            case SHOP_STAGE_20:
            case SHOP_STAGE_21:
            case SHOP_STAGE_22:
            case SHOP_STAGE_23:
            case SHOP_STAGE_24:
                return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_00;
            default:
                return null;
        }
    }

    public static Integer getSelectStageMaxDays() {
        return Math.max(ShopSubStageEnum.SHOP_STAGE_1.getPlanCompleteDays(), ShopSubStageEnum.SHOP_STAGE_2.getPlanCompleteDays());

    }

    public String getPlanCompleteTime(LocalDate planCompleteTime) {
        switch (this) {
            case SHOP_STAGE_18:
            case SHOP_STAGE_19:
            case SHOP_STAGE_20:
            case SHOP_STAGE_21:
            case SHOP_STAGE_22:
                return null;
            default:
                return planCompleteTime.plusDays(getPlanCompleteDays()).toString();
        }
    }

    public static ShopSubStageEnum getByShopSubStage(Integer shopSubStage) {
        if (Objects.isNull(shopSubStage)) {
            return null;
        }
        for (ShopSubStageEnum value : ShopSubStageEnum.values()) {
            if (value.getShopSubStage().equals(shopSubStage)) {
                return value;
            }
        }
        return null;
    }

}
