package com.dsk.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.domain.customer.vo.CustomerAnalyzeVo;
import com.dsk.system.mapper.CustomerMapper;
import com.dsk.system.service.ICustomerOverviewService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 客户概览相关
 * @author lcl
 * @create 2023/8/15
 */
@Service
public class CustomerOverviewServiceImpl implements ICustomerOverviewService {

    @Resource
    private CustomerMapper customerMapper;

    @Override
    public Map<String, Object> statistics(CustomerSearchDto dto) {
        Map<String, Object> resultMap = new HashMap<>();
        dto.setUserId(SecurityUtils.getUserId());
        //总
        resultMap.put("totalCount",customerMapper.selectCustomerCount(dto));
        //国企
        dto.setCompanyNature("国有企业");
        resultMap.put("nationCount",customerMapper.selectCustomerCount(dto));
        //央企
        dto.setCompanyNature("央企");
        resultMap.put("centreCount",customerMapper.selectCustomerCount(dto));
        //事业
        dto.setCompanyNature("事业单位");
        resultMap.put("undertakingCount",customerMapper.selectCustomerCount(dto));
        return resultMap;
    }

    @Override
    public List<CustomerAnalyzeVo> cooperationTop(CustomerSearchDto dto) {
        dto.setUserId(SecurityUtils.getUserId());
        return customerMapper.selectCooperationTop(dto);
    }

}
