package com.ruoyi.sales.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.security.LoginUser; import com.ruoyi.sales.mapper.AreaMapper; import com.ruoyi.sales.mapper.BusinessOpportunityMapper; import com.ruoyi.sales.pojo.Area; import com.ruoyi.sales.pojo.BusinessOpportunity; import com.ruoyi.sales.service.BusinessOpportunityService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.List; /** * @author :yys * @date : 2025/12/12 9:28 */ @Service @Slf4j public class BusinessOpportunityServiceImpl extends ServiceImpl implements BusinessOpportunityService { @Autowired private BusinessOpportunityMapper businessOpportunityMapper; @Autowired private AreaMapper areaMapper; @Override public IPage listPage(Page page, BusinessOpportunity businessOpportunity) { LoginUser loginUser = SecurityUtils.getLoginUser(); LambdaQueryWrapper businessOpportunityLambdaQueryWrapper = new LambdaQueryWrapper<>(); if(businessOpportunity != null){ if(StringUtils.isNotEmpty(businessOpportunity.getCustomerName())){ businessOpportunityLambdaQueryWrapper.like(BusinessOpportunity::getCustomerName,businessOpportunity.getCustomerName()); } if(StringUtils.isNotEmpty(businessOpportunity.getCity())){ businessOpportunityLambdaQueryWrapper.like(BusinessOpportunity::getCity,businessOpportunity.getCity()); } if(StringUtils.isNotEmpty(businessOpportunity.getEntryDateStart()) && StringUtils.isNotEmpty(businessOpportunity.getEntryDateEnd())){ businessOpportunityLambdaQueryWrapper.ge(BusinessOpportunity::getEntryDate,businessOpportunity.getEntryDateStart()) .le(BusinessOpportunity::getEntryDate,businessOpportunity.getEntryDateEnd()); } if(StringUtils.isNotEmpty(businessOpportunity.getEntryPerson())){ businessOpportunityLambdaQueryWrapper.like(BusinessOpportunity::getEntryPerson,businessOpportunity.getEntryPerson()); } if(StringUtils.isNotEmpty(businessOpportunity.getStatus())){ businessOpportunityLambdaQueryWrapper.eq(BusinessOpportunity::getStatus,businessOpportunity.getStatus()); } } List userNameList = Arrays.asList("王超楠","房添姝","缪海庆","管理员"); if(!userNameList.contains(loginUser.getUsername())){ businessOpportunityLambdaQueryWrapper.eq(BusinessOpportunity::getEntryPerson,loginUser.getNickName()); } businessOpportunityLambdaQueryWrapper.orderByDesc(BusinessOpportunity::getEntryDate); return businessOpportunityMapper.selectPage(page,businessOpportunityLambdaQueryWrapper); } @Override public List getProvinceList() { return areaMapper.selectList(new LambdaQueryWrapper().eq(Area::getLevel,1).eq(Area::getParentId,0)); } @Override public List getCityList(Integer provinceId) { return areaMapper.selectList(new LambdaQueryWrapper().eq(Area::getLevel,2).eq(Area::getParentId,provinceId)); } }