|
@@ -21,16 +21,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
-import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
|
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -178,7 +172,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|
|
}
|
|
|
|
|
|
private void transferCustomerOwner(List <Long> cIds, Long ownerId){
|
|
|
- //先一次性校验完成客户是否可用
|
|
|
+ // 先一次性校验完成客户是否可用
|
|
|
+ // TODO @xiaqing:批量一次性加载客户列表,然后去逐个校验;
|
|
|
for (Long cId : cIds) {
|
|
|
//校验是否存在
|
|
|
validateCustomerExists(cId);
|
|
@@ -189,13 +184,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|
|
//todo 校验成交状态
|
|
|
validCustomerDeal(cId);
|
|
|
}
|
|
|
+ // TODO @xiaqing:每个客户更新的时候,where 条件,加上 owner_user_id is null,防止并发问题;
|
|
|
List<CrmCustomerDO> updateDos = new ArrayList <>();
|
|
|
for (Long cId : cIds){
|
|
|
CrmCustomerDO customerDO = new CrmCustomerDO();
|
|
|
customerDO.setId(cId);
|
|
|
customerDO.setOwnerUserId(SecurityFrameworkUtils.getLoginUserId());
|
|
|
}
|
|
|
- //统一修改状态
|
|
|
+ // 统一修改状态
|
|
|
customerMapper.updateBatch(updateDos);
|
|
|
}
|
|
|
|
|
@@ -213,9 +209,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|
|
|
|
|
private void validCustomerDeal(Long id) {
|
|
|
if (customerMapper.selectById(id).getDealStatus() ==true) {
|
|
|
- throw exception(CUSTOMER_DEALED);
|
|
|
+ throw exception(CUSTOMER_ALREADY_DEAL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|