package com.yuchen.saas.park.api.enums.property;

import com.yuchen.saas.park.api.vo.property.PropertyFeeItemSubjectVo;
import lombok.AllArgsConstructor;
import lombok.Getter;

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

/**
 * "归属收费科目:1:0001主营业务收入,2:0002营业外收入,3:0003保证金,4:004代收费,5:0005预存款"
 */
@Getter
@AllArgsConstructor
public enum FeeItemTypeEnum {
    MAIN_BUSINESS_INCOME(1, "主营业务收入"),
    NONBUSINESS_INCOME(2, "营业外收入"),
    SECURITY_DEPOSIT(3, "保证金"),
    COLLECTION_FEE(4, "代收费"),
    PREPAID_DEPOSIT(5, "预存款");

    private final Integer value;
    private final String desc;

    public static String getDescByCode(Integer value) {
        if (Objects.isNull(value)) {
            return "";
        }
        FeeItemTypeEnum[] enumArray = FeeItemTypeEnum.values();
        for (FeeItemTypeEnum e : enumArray) {
            if (e.getValue().equals(value)) {
                return e.getDesc();
            }
        }
        return "";
    }
    public static FeeItemTypeEnum matchCode(Integer value) {
        for (FeeItemTypeEnum shareTypeEnum : FeeItemTypeEnum.values()) {
            if (shareTypeEnum.getValue().equals(value)) {
                return shareTypeEnum;
            }
        }
        return null;
    }

    public static List<PropertyFeeItemSubjectVo> list() {
        List<PropertyFeeItemSubjectVo> list=new ArrayList<>();
        for (FeeItemTypeEnum shareTypeEnum : FeeItemTypeEnum.values()) {
            PropertyFeeItemSubjectVo vo=new PropertyFeeItemSubjectVo();
            vo.setValue(shareTypeEnum.getValue());
            vo.setDesc(shareTypeEnum.getDesc());
            list.add(vo);
        }
        return list;
    }

}
