package com.ruoyi.ss.bonus.domain.enums;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.enums.UserType;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wjh
 * 2024/8/21
 */
@Getter
@AllArgsConstructor
public enum BonusArrivalType {

    PLATFORM("1", "平台"),
    AGENT("2", "代理商"),
    MCH("3", "商户"),
    STAFF("4", "员工");

    private final String type;
    private final String msg;

    public static BonusArrivalType parseByUserType(String type) {
        if (UserType.AGENT.equalsType(type)) {
            return AGENT;
        }
        return MCH;
    }

    public static BonusArrivalType parseByDept(SysDept dept) {
        if (dept == null) {
            return null;
        }
        if (Constants.ROOT_DEPT == dept.getDeptId()) {
            return PLATFORM;
        }
        return null;
    }

    public static List<String> asList(BonusArrivalType ...types) {
        return Arrays.stream(types).map(BonusArrivalType::getType).collect(Collectors.toList());
    }

    /**
     * 用户表
     */
    public static List<String> userList() {
        return asList(AGENT, MCH, STAFF);
    }

    /**
     * 部门表
     */
    public static List<String> deptList() {
        return asList(PLATFORM);
    }
}
