package com.hzs.bonus.base.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.hzs.bonus.base.mapper.BdVertexBonusMapper;
import com.hzs.bonus.base.service.IBdVertexBonusService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.domain.vertex.BdVertexBonus;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 体系奖金配置（记录哪个体系走特殊奖金） 服务实现类
 */
@Service
public class BdVertexBonusServiceImpl extends ServiceImpl<BdVertexBonusMapper, BdVertexBonus> implements IBdVertexBonusService {

    @Override
    public Map<Long, List<Integer>> queryVertexBonus() {
        HashMap<Long, List<Integer>> resultMap = new HashMap<>();

        List<BdVertexBonus> vertexBonusList = this.list();
        if (CollectionUtil.isNotEmpty(vertexBonusList)) {
            for (BdVertexBonus bdVertexBonus : vertexBonusList) {
                if (resultMap.containsKey(bdVertexBonus.getPkVertex())) {
                    resultMap.get(bdVertexBonus.getPkVertex()).add(bdVertexBonus.getBonusItems());
                } else {
                    List<Integer> tmpList = new ArrayList<>();
                    tmpList.add(bdVertexBonus.getBonusItems());
                    resultMap.put(bdVertexBonus.getPkVertex(), tmpList);
                }
            }
        }

        return resultMap;
    }

}
