Commit 72f35ef0 authored by yanghao's avatar yanghao

chore: 客户更新 更新时可更新多条

parent 45923591
package cn.iocoder.yudao.module.customer.service.customerFollowup;
import java.text.MessageFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import javax.annotation.Resource;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.apollo.core.event.OrderNumberLogEvent;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.code.CodeUtils;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.customer.convert.customerFollowup.CustomerFollowupConvert;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerContacts.CustomerContactsDO;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerFollowup.CustomerFollowupDO;
import cn.iocoder.yudao.module.customer.dal.mysql.customer.CustomerMapper;
import cn.iocoder.yudao.module.customer.dal.mysql.customerContacts.CustomerContactsMapper;
import cn.iocoder.yudao.module.customer.dal.mysql.customerFollowup.CustomerFollowupMapper;
import cn.iocoder.yudao.module.customer.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.customer.service.customerOperateLog.CustomerOperateLogService;
import cn.iocoder.yudao.module.customer.vo.customerFollowup.CustomerFollowupCreateReqVO;
import cn.iocoder.yudao.module.customer.vo.customerFollowup.CustomerFollowupQueryVO;
import cn.iocoder.yudao.module.customer.vo.customerFollowup.CustomerFollowupUpdateReqVO;
import cn.iocoder.yudao.module.customer.vo.customerFollowup.CustomerFollowupUpdateStatusReqVO;
import cn.iocoder.yudao.module.customer.vo.customerOperateLog.CustomerOperateLogCreateReqVO;
import cn.iocoder.yudao.module.ecw.enums.CustomerFollowupStatusEnum;
import cn.iocoder.yudao.module.ecw.enums.CustomerOperateTypeEnum;
......@@ -29,15 +32,15 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.customer.vo.customerFollowup.*;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerFollowup.CustomerFollowupDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.customer.convert.customerFollowup.CustomerFollowupConvert;
import cn.iocoder.yudao.module.customer.dal.mysql.customerFollowup.CustomerFollowupMapper;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.customer.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.customer.enums.ErrorCodeConstants.FOLLOWUP_ALREADY_SUBMITTED;
import static cn.iocoder.yudao.module.customer.enums.ErrorCodeConstants.FOLLOWUP_NOT_EXISTS;
/**
* 客户跟进 Service 实现类
......@@ -194,7 +197,19 @@ public class CustomerFollowupServiceImpl extends AbstractService<CustomerFollowu
@Override
public void updateFollowupStatus(CustomerFollowupUpdateStatusReqVO updateStatusReqVO) {
Long id = updateStatusReqVO.getId();
Long updateId = updateStatusReqVO.getId();
List<Long> ids = updateStatusReqVO.getIds();
List<Long> idList = new ArrayList<>();
// id + ids 到idList
if (updateId!= null) {
idList.add(updateId);
}
if (CollectionUtil.isNotEmpty(ids)) {
idList.addAll(ids);
}
for (Long id : idList) {
CustomerFollowupDO customerFollowupDO = followupMapper.selectById(id);
if (customerFollowupDO == null) {
throw exception(FOLLOWUP_NOT_EXISTS);
......@@ -203,12 +218,15 @@ public class CustomerFollowupServiceImpl extends AbstractService<CustomerFollowu
if (CustomerFollowupStatusEnum.Commited.getValue().equals(customerFollowupDO.getStatus())) {
throw exception(FOLLOWUP_ALREADY_SUBMITTED);
}
}
for (Long id : idList) {
CustomerFollowupDO customerFollowupDO = followupMapper.selectById(id);
customerFollowupDO.setStatus(updateStatusReqVO.getStatus());
followupMapper.updateById(customerFollowupDO);
Long customerId = customerFollowupDO.getCustomerId();
if (customerId != null) {
CustomerDO customer = customerMapper.selectById(customerId);
......@@ -233,6 +251,7 @@ public class CustomerFollowupServiceImpl extends AbstractService<CustomerFollowu
}
}
}
}
@Override
public void deleteFollowup(Long id) {
......
......@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.util.List;
@ApiModel("管理后台 - 客户跟进更新状态 Request VO")
@Data
......@@ -17,6 +18,11 @@ public class CustomerFollowupUpdateStatusReqVO {
@NotNull(message = "主键不能为空")
private Long id;
//ids
@ApiModelProperty(value = "主键列表", required = true)
@NotNull(message = "主键列表不能为空")
private List<Long> ids;
@ApiModelProperty(value = "状态 字典customer_followup_status")
private Integer status;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment