package com.cool.store.enums.fees;

import com.cool.store.enums.point.ShopSubStageEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static com.cool.store.enums.point.ShopSubStageEnum.SHOP_STAGE_28;

/**
 * <p>
 * 钱包转账费用科目枚举类
 * </p>
 *
 * @author wangff
 * @since 2026/1/30
 */
@Getter
@AllArgsConstructor
public enum WalletFeeItemEnum {
    FRANCHISE_FEE(310, "expense_franchise_fee", "加盟费"),
    MANAGEMENT_FEE(311, "expense_management_fee", "管理费（年）"),
    BRAND_USAGE_FEE(312, "expense_brand_usage_fee", "品牌使用费（年）"),
    DESIGN_FEE_GROUP(313, "expense_design_fee_group", "设计费-集团"),
    SYSTEM_SERVICE_FEE(319,"expense_system_service_money","系统服务费（年）"),
//    DESIGN_FEE_LG(314, "expense_design_fee_lg", "设计费-立规"),
    EARNEST_MONEY(315, "expense_earnest_money", "加盟保证金"),
    DEVICE_EARNEST_MONEY(320, "expense_device_earnest_money", "设备保证金"),
    EXPENSE_DECORATION_MONEY(316, "expense_decoration_money", "装修费"),
    EXPENSE_EQUIPMENT_MONEY(317, "expense_equipment_money", "设备费"),
    ;

    private final Integer feeItemId;

    private final String expenseType;

    private final String desc;

    public static WalletFeeItemEnum getByExpenseType(String expenseType) {
        for (WalletFeeItemEnum value : WalletFeeItemEnum.values()) {
            if (value.expenseType.equals(expenseType)) {
                return value;
            }
        }
        return null;
    }

    public static String getByExpenseTypeName(String expenseType) {
        for (WalletFeeItemEnum value : WalletFeeItemEnum.values()) {
            if (value.expenseType.equals(expenseType)) {
                return value.getDesc();
            }
        }
        return null;
    }

    public static List<WalletFeeItemEnum> getBaseExpenseType(){
        return Arrays.asList(FRANCHISE_FEE,MANAGEMENT_FEE,BRAND_USAGE_FEE,DESIGN_FEE_GROUP,EARNEST_MONEY,SYSTEM_SERVICE_FEE,DEVICE_EARNEST_MONEY);
    }

    public static WalletFeeItemEnum getByFeeItemId(Integer feeItemId) {
        for (WalletFeeItemEnum value : WalletFeeItemEnum.values()) {
            if (value.feeItemId.equals(feeItemId)) {
                return value;
            }
        }
        return null;
    }


    public static List<String> getWalletFeeItemBySubStage(Integer subStage){
        ShopSubStageEnum subStageEnum = ShopSubStageEnum.getByShopSubStage(subStage);
        if (subStageEnum==null){
            return null;
        }
        switch (subStageEnum){
            case SHOP_STAGE_28:
                return Arrays.asList(
                        FRANCHISE_FEE.getExpenseType(),
                        MANAGEMENT_FEE.getExpenseType(),
                        BRAND_USAGE_FEE.getExpenseType(),
                        DESIGN_FEE_GROUP.getExpenseType(),
                        EARNEST_MONEY.getExpenseType(),
                        DEVICE_EARNEST_MONEY.getExpenseType());
            case SHOP_STAGE_27:
                return Arrays.asList(EXPENSE_DECORATION_MONEY.getExpenseType(),
                        EXPENSE_EQUIPMENT_MONEY.getExpenseType());
            default:
                return null;
        }
    }
}
