package com.doumee.service.business.impl;
|
|
import com.doumee.biz.zbom.ZbomCRMService;
|
import com.doumee.core.constants.ResponseStatus;
|
import com.doumee.core.exception.BusinessException;
|
import com.doumee.core.model.PageData;
|
import com.doumee.core.model.PageWrap;
|
import com.doumee.core.utils.Constants;
|
import com.doumee.core.utils.Utils;
|
import com.doumee.dao.business.CustomerLogMapper;
|
import com.doumee.dao.business.model.*;
|
import com.doumee.service.business.CustomerLogService;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 客户留资记录信息表Service实现
|
* @author 江蹄蹄
|
* @date 2024/07/04 14:40
|
*/
|
@Service
|
public class CustomerLogServiceImpl implements CustomerLogService {
|
|
@Autowired
|
private CustomerLogMapper customerLogMapper;
|
@Autowired
|
private ZbomCRMService zbomCRMService;
|
|
@Override
|
public Long create(CustomerLog customerLog) {
|
customerLogMapper.insert(customerLog);
|
return customerLog.getId();
|
}
|
|
@Override
|
public void deleteById(Long id) {
|
customerLogMapper.deleteById(id);
|
}
|
|
@Override
|
public void delete(CustomerLog customerLog) {
|
UpdateWrapper<CustomerLog> deleteWrapper = new UpdateWrapper<>(customerLog);
|
customerLogMapper.delete(deleteWrapper);
|
}
|
|
@Override
|
public void deleteByIdInBatch(List<Long> ids) {
|
if (CollectionUtils.isEmpty(ids)) {
|
return;
|
}
|
customerLogMapper.deleteBatchIds(ids);
|
}
|
|
@Override
|
public void updateById(CustomerLog customerLog) {
|
customerLogMapper.updateById(customerLog);
|
}
|
|
@Override
|
public void reSubmit(CustomerLog customerLog){
|
CustomerLog log = customerLogMapper.selectById(customerLog.getId());
|
if(log ==null || Constants.equalsInteger(log.getIsdeleted(),Constants.ONE)){
|
throw new BusinessException(ResponseStatus.DATA_EMPTY);
|
}
|
if(Constants.equalsInteger(log.getCrmStatus(),Constants.ONE)){
|
//如果已经提交成功过
|
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该留资数据已提交,无需重新提交!");
|
}
|
zbomCRMService.dealCustomerLogData(log);
|
}
|
@Override
|
public void reSubmitAll(CustomerLog log){
|
List<CustomerLog> logList = customerLogMapper.selectList(new QueryWrapper<CustomerLog>()
|
.lambda()
|
.eq(CustomerLog::getIsdeleted,Constants.ZERO)
|
.eq(log.getCrmStatus()!=null,CustomerLog::getCrmStatus,log.getCrmStatus())
|
.ne(CustomerLog::getCrmStatus,Constants.ONE));
|
if(logList ==null || logList.size() ==0){
|
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,不存在待处理数据");
|
}
|
if(Constants.equalsInteger(log.getCrmStatus(),Constants.ONE)){
|
//如果已经提交成功过
|
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该留资数据已提交,无需重新提交!");
|
}
|
for(CustomerLog model :logList){
|
zbomCRMService.dealCustomerLogData(model);
|
}
|
}
|
|
@Override
|
public void updateByIdInBatch(List<CustomerLog> customerLogs) {
|
if (CollectionUtils.isEmpty(customerLogs)) {
|
return;
|
}
|
for (CustomerLog customerLog: customerLogs) {
|
this.updateById(customerLog);
|
}
|
}
|
|
@Override
|
public CustomerLog findById(Long id) {
|
return customerLogMapper.selectById(id);
|
}
|
|
@Override
|
public CustomerLog findOne(CustomerLog customerLog) {
|
QueryWrapper<CustomerLog> wrapper = new QueryWrapper<>(customerLog);
|
return customerLogMapper.selectOne(wrapper);
|
}
|
|
@Override
|
public List<CustomerLog> findList(CustomerLog customerLog) {
|
QueryWrapper<CustomerLog> wrapper = new QueryWrapper<>(customerLog);
|
return customerLogMapper.selectList(wrapper);
|
}
|
|
@Override
|
public PageData<CustomerLog> findPage(PageWrap<CustomerLog> pageWrap) {
|
IPage<CustomerLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
|
MPJLambdaWrapper<CustomerLog> queryWrapper = new MPJLambdaWrapper<>();
|
Utils.MP.blankToNull(pageWrap.getModel());
|
queryWrapper.selectAll(CustomerLog.class)
|
.leftJoin(Customer.class,Customer::getId,CustomerLog::getCostomerId)
|
.eq(CustomerLog::getIsdeleted, Constants.ZERO)
|
.eq(Objects.nonNull(pageWrap.getModel().getType()),CustomerLog::getType, pageWrap.getModel().getType())
|
.eq(Objects.nonNull(pageWrap.getModel().getMemberId()),Customer::getMemberId, pageWrap.getModel().getMemberId());
|
queryWrapper.orderByDesc(CustomerLog::getCreateDate);
|
PageData<CustomerLog> pageData = PageData.from(customerLogMapper.selectJoinPage(page,CustomerLog.class, queryWrapper));
|
for (CustomerLog customerLog:pageData.getRecords()) {
|
customerLog.setPhone(
|
customerLog.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2")
|
);
|
}
|
return pageData;
|
}
|
|
@Override
|
public long count(CustomerLog customerLog) {
|
QueryWrapper<CustomerLog> wrapper = new QueryWrapper<>(customerLog);
|
return customerLogMapper.selectCount(wrapper);
|
}
|
}
|