127 lines
4.7 KiB
Java
127 lines
4.7 KiB
Java
|
|
package com.klp.service.impl;
|
||
|
|
|
||
|
|
import cn.hutool.core.bean.BeanUtil;
|
||
|
|
import com.klp.common.core.page.TableDataInfo;
|
||
|
|
import com.klp.common.core.domain.PageQuery;
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||
|
|
import com.klp.common.utils.StringUtils;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
import com.klp.domain.bo.WmsCustomerBo;
|
||
|
|
import com.klp.domain.vo.WmsCustomerVo;
|
||
|
|
import com.klp.domain.WmsCustomer;
|
||
|
|
import com.klp.mapper.WmsCustomerMapper;
|
||
|
|
import com.klp.service.IWmsCustomerService;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
import java.util.Collection;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* CRM 客户Service业务层处理
|
||
|
|
*
|
||
|
|
* @author Joshi
|
||
|
|
* @date 2025-08-12
|
||
|
|
*/
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
@Service
|
||
|
|
public class WmsCustomerServiceImpl implements IWmsCustomerService {
|
||
|
|
|
||
|
|
private final WmsCustomerMapper baseMapper;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询CRM 客户
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public WmsCustomerVo queryById(Long customerId){
|
||
|
|
return baseMapper.selectVoById(customerId);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询CRM 客户列表
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public TableDataInfo<WmsCustomerVo> queryPageList(WmsCustomerBo bo, PageQuery pageQuery) {
|
||
|
|
LambdaQueryWrapper<WmsCustomer> lqw = buildQueryWrapper(bo);
|
||
|
|
Page<WmsCustomerVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||
|
|
return TableDataInfo.build(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询CRM 客户列表
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public List<WmsCustomerVo> queryList(WmsCustomerBo bo) {
|
||
|
|
LambdaQueryWrapper<WmsCustomer> lqw = buildQueryWrapper(bo);
|
||
|
|
return baseMapper.selectVoList(lqw);
|
||
|
|
}
|
||
|
|
|
||
|
|
private LambdaQueryWrapper<WmsCustomer> buildQueryWrapper(WmsCustomerBo bo) {
|
||
|
|
Map<String, Object> params = bo.getParams();
|
||
|
|
LambdaQueryWrapper<WmsCustomer> lqw = Wrappers.lambdaQuery();
|
||
|
|
lqw.like(StringUtils.isNotBlank(bo.getName()), WmsCustomer::getName, bo.getName());
|
||
|
|
lqw.eq(bo.getFollowUpStatus() != null, WmsCustomer::getFollowUpStatus, bo.getFollowUpStatus());
|
||
|
|
lqw.eq(bo.getContactLastTime() != null, WmsCustomer::getContactLastTime, bo.getContactLastTime());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getContactLastContent()), WmsCustomer::getContactLastContent, bo.getContactLastContent());
|
||
|
|
lqw.eq(bo.getContactNextTime() != null, WmsCustomer::getContactNextTime, bo.getContactNextTime());
|
||
|
|
lqw.eq(bo.getOwnerUserId() != null, WmsCustomer::getOwnerUserId, bo.getOwnerUserId());
|
||
|
|
lqw.eq(bo.getOwnerTime() != null, WmsCustomer::getOwnerTime, bo.getOwnerTime());
|
||
|
|
lqw.eq(bo.getDealStatus() != null, WmsCustomer::getDealStatus, bo.getDealStatus());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getMobile()), WmsCustomer::getMobile, bo.getMobile());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTelephone()), WmsCustomer::getTelephone, bo.getTelephone());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getQq()), WmsCustomer::getQq, bo.getQq());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getWechat()), WmsCustomer::getWechat, bo.getWechat());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getEmail()), WmsCustomer::getEmail, bo.getEmail());
|
||
|
|
lqw.eq(bo.getAreaId() != null, WmsCustomer::getAreaId, bo.getAreaId());
|
||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getDetailAddress()), WmsCustomer::getDetailAddress, bo.getDetailAddress());
|
||
|
|
lqw.eq(bo.getIndustryId() != null, WmsCustomer::getIndustryId, bo.getIndustryId());
|
||
|
|
lqw.eq(bo.getLevel() != null, WmsCustomer::getLevel, bo.getLevel());
|
||
|
|
lqw.eq(bo.getSource() != null, WmsCustomer::getSource, bo.getSource());
|
||
|
|
return lqw;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 新增CRM 客户
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean insertByBo(WmsCustomerBo bo) {
|
||
|
|
WmsCustomer add = BeanUtil.toBean(bo, WmsCustomer.class);
|
||
|
|
validEntityBeforeSave(add);
|
||
|
|
boolean flag = baseMapper.insert(add) > 0;
|
||
|
|
if (flag) {
|
||
|
|
bo.setCustomerId(add.getCustomerId());
|
||
|
|
}
|
||
|
|
return flag;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 修改CRM 客户
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean updateByBo(WmsCustomerBo bo) {
|
||
|
|
WmsCustomer update = BeanUtil.toBean(bo, WmsCustomer.class);
|
||
|
|
validEntityBeforeSave(update);
|
||
|
|
return baseMapper.updateById(update) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 保存前的数据校验
|
||
|
|
*/
|
||
|
|
private void validEntityBeforeSave(WmsCustomer entity){
|
||
|
|
//TODO 做一些数据校验,如唯一约束
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 批量删除CRM 客户
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||
|
|
if(isValid){
|
||
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||
|
|
}
|
||
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||
|
|
}
|
||
|
|
}
|