CRM-客户: 完善客户导入
This commit is contained in:
parent
4605e93105
commit
a877bb4731
@ -198,7 +198,7 @@ public class CrmCustomerController {
|
||||
public CommonResult<CrmCustomerImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<CrmCustomerImportExcelVO> list = ExcelUtils.read(file, CrmCustomerImportExcelVO.class);
|
||||
return success(customerService.importCustomerList(list, updateSupport));
|
||||
return success(customerService.importCustomerList(list, updateSupport, getLoginUserId()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,9 +110,10 @@ public interface CrmCustomerService {
|
||||
*
|
||||
* @param importCustomers 导入客户列表
|
||||
* @param isUpdateSupport 是否支持更新
|
||||
* @param userId 用户编号
|
||||
* @return 导入结果
|
||||
*/
|
||||
CrmCustomerImportRespVO importCustomerList(List<CrmCustomerImportExcelVO> importCustomers, Boolean isUpdateSupport);
|
||||
CrmCustomerImportRespVO importCustomerList(List<CrmCustomerImportExcelVO> importCustomers, Boolean isUpdateSupport, Long userId);
|
||||
|
||||
// ==================== 公海相关操作 ====================
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
validateCustomerExceedOwnerLimit(createReqVO.getOwnerUserId(), 1);
|
||||
|
||||
// 2. 插入客户
|
||||
CrmCustomerDO customer = BeanUtils.toBean(createReqVO, CrmCustomerDO.class)
|
||||
CrmCustomerDO customer = BeanUtils.toBean(createReqVO, CrmCustomerDO.class).setOwnerUserId(userId)
|
||||
.setLockStatus(false).setDealStatus(false).setContactLastTime(LocalDateTime.now());
|
||||
customerMapper.insert(customer);
|
||||
|
||||
@ -233,7 +233,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrmCustomerImportRespVO importCustomerList(List<CrmCustomerImportExcelVO> importCustomers, Boolean isUpdateSupport) {
|
||||
public CrmCustomerImportRespVO importCustomerList(List<CrmCustomerImportExcelVO> importCustomers, Boolean isUpdateSupport, Long userId) {
|
||||
if (CollUtil.isEmpty(importCustomers)) {
|
||||
throw exception(CUSTOMER_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
@ -250,8 +250,13 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
// 判断如果不存在,在进行插入
|
||||
CrmCustomerDO existCustomer = customerMapper.selectByCustomerName(importCustomer.getName());
|
||||
if (existCustomer == null) {
|
||||
customerMapper.insert(BeanUtils.toBean(importCustomer, CrmCustomerDO.class));
|
||||
CrmCustomerDO customer = BeanUtils.toBean(importCustomer, CrmCustomerDO.class).setOwnerUserId(userId)
|
||||
.setLockStatus(false).setDealStatus(false).setContactLastTime(LocalDateTime.now());
|
||||
customerMapper.insert(customer);
|
||||
respVO.getCreateCustomerNames().add(importCustomer.getName());
|
||||
// 创建数据权限
|
||||
permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType())
|
||||
.setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人
|
||||
return;
|
||||
}
|
||||
// 如果存在,判断是否允许更新
|
||||
|
Loading…
Reference in New Issue
Block a user