package com.ruoyi.ibs.grid.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ibs.grid.domain.entity.GridUnionCmpmGongsi;
import com.ruoyi.ibs.grid.domain.entity.GridUnionCmpmLingshou;
import com.ruoyi.ibs.grid.domain.entity.GridUnionCustGongsi;
import com.ruoyi.ibs.grid.domain.entity.GridUnionCustLingshou;
import com.ruoyi.ibs.grid.mapper.GridUnionCountMapper;
import com.ruoyi.ibs.grid.service.GridUnionCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class GridUnionCountServiceImpl implements GridUnionCountService {

    @Autowired
    private GridUnionCountMapper mapper;

    @Override
    public List<GridUnionCmpmLingshou> selectLsCountList() {
        HashMap<String, Object> paramMap = new HashMap<>();
        paramMap.put("userRole","head");
        if(SecurityUtils.userRole().equals("branch")){
            paramMap.put("userRole","branch");
            paramMap.put("isBranch",true);
        }
        if(SecurityUtils.userRole().equals("outlet")){
            paramMap.put("userRole","outlet");
            paramMap.put("isOutlet",true);
        }
        if(SecurityUtils.userRole().equals("manager")){
            paramMap.put("userRole","manager");
            paramMap.put("isManager",true);
        }
        paramMap.put("deptId",SecurityUtils.getDeptId());
        paramMap.put("userName",SecurityUtils.getUsername());
        return mapper.selectLsCountList(paramMap);
    }

    @Override
    public List<GridUnionCmpmGongsi> selectGsCountList() {
        HashMap<String, Object> paramMap = new HashMap<>();
        paramMap.put("userRole","head");
        if(SecurityUtils.userRole().equals("branch")){
            paramMap.put("userRole","branch");
            paramMap.put("isBranch",true);
        }
        if(SecurityUtils.userRole().equals("outlet")){
            paramMap.put("userRole","outlet");
            paramMap.put("isOutlet",true);
        }
        if(SecurityUtils.userRole().equals("manager")){
            paramMap.put("userRole","manager");
            paramMap.put("isManager",true);
        }
        paramMap.put("deptId",SecurityUtils.getDeptId());
        paramMap.put("userName",SecurityUtils.getUsername());
        return mapper.selectGsCountList(paramMap);
    }

    @Override
    public List<GridUnionCustLingshou> selectLsCustList(String custName, String custIdc,String dt) {
        HashMap<String, Object> paramMap = new HashMap<>();
        if(SecurityUtils.userRole().equals("branch")){
            paramMap.put("isBranch",true);
        }
        if(SecurityUtils.userRole().equals("outlet")){
            paramMap.put("isOutlet",true);
        }
        if(SecurityUtils.userRole().equals("manager")){
            paramMap.put("isManager",true);
        }
        paramMap.put("custName",custName);
        paramMap.put("custIdc",custIdc);
        paramMap.put("dt",dt);
        paramMap.put("deptId",SecurityUtils.getDeptId());
        paramMap.put("userName",SecurityUtils.getUsername());
        return mapper.selectLsCustList(paramMap);
    }

    @Override
    public List<GridUnionCustGongsi> selectGsCustList(String custName, String socialCreditCode,String dt) {
        HashMap<String, Object> paramMap = new HashMap<>();
        if(SecurityUtils.userRole().equals("branch")){
            paramMap.put("isBranch",true);
        }
        if(SecurityUtils.userRole().equals("outlet")){
            paramMap.put("isOutlet",true);
        }
        if(SecurityUtils.userRole().equals("manager")){
            paramMap.put("isManager",true);
        }
        paramMap.put("custName",custName);
        paramMap.put("socialCreditCode",socialCreditCode);
        paramMap.put("dt",dt);
        paramMap.put("deptId",SecurityUtils.getDeptId());
        paramMap.put("userName",SecurityUtils.getUsername());
        return mapper.selectGsCustList(paramMap);
    }

    @Override
    public List<GridUnionCustLingshou> selectLsCustListLimit(String custName, String custIdc,String dt) {
        HashMap<String, Object> paramMap = new HashMap<>();
        if(SecurityUtils.userRole().equals("branch")){
            paramMap.put("isBranch",true);
        }
        if(SecurityUtils.userRole().equals("outlet")){
            paramMap.put("isOutlet",true);
        }
        if(SecurityUtils.userRole().equals("manager")){
            paramMap.put("isManager",true);
        }
        paramMap.put("custName",custName);
        paramMap.put("custIdc",custIdc);
        paramMap.put("dt",dt);
        paramMap.put("deptId",SecurityUtils.getDeptId());
        paramMap.put("userName",SecurityUtils.getUsername());
        return mapper.selectLsCustListLimit(paramMap);
    }

    @Override
    public List<GridUnionCustGongsi> selectGsCustListLimit(String custName, String socialCreditCode,String dt) {
        HashMap<String, Object> paramMap = new HashMap<>();
        if(SecurityUtils.userRole().equals("branch")){
            paramMap.put("isBranch",true);
        }
        if(SecurityUtils.userRole().equals("outlet")){
            paramMap.put("isOutlet",true);
        }
        if(SecurityUtils.userRole().equals("manager")){
            paramMap.put("isManager",true);
        }
        paramMap.put("custName",custName);
        paramMap.put("socialCreditCode",socialCreditCode);
        paramMap.put("dt",dt);
        paramMap.put("deptId",SecurityUtils.getDeptId());
        paramMap.put("userName",SecurityUtils.getUsername());
        return mapper.selectGsCustListLimit(paramMap);
    }
}
