package com.dsk.biz.service.impl;


import com.dsk.biz.domain.bo.CustomerSearchDto;
import com.dsk.biz.domain.vo.CustomerAnalyzeVo;
import com.dsk.biz.mapper.CustomerMapper;
import com.dsk.biz.service.ICustomerOverviewService;
import com.dsk.common.helper.LoginHelper;
import com.google.api.client.util.SecurityUtils;
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(LoginHelper.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(LoginHelper.getUserId());
        return customerMapper.selectCooperationTop(dto);
    }

    @Override
    public List<Map<String, Object>> creditLevel(CustomerSearchDto dto) {
        dto.setUserId(LoginHelper.getUserId());
        return customerMapper.selectCreditLevelGroup(dto);
    }

}
