| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; |
| | |
| | | * @return 客户信息 DO |
| | | */ |
| | | private static CrmCustomerDO initCustomer(Object customer, Long ownerUserId) { |
| | | return BeanUtils.toBean(customer, CrmCustomerDO.class).setOwnerUserId(ownerUserId) |
| | | CrmCustomerDO result = BeanUtils.toBean(customer, CrmCustomerDO.class).setOwnerUserId(ownerUserId) |
| | | .setOwnerTime(LocalDateTime.now()); |
| | | if (result.getAutoPoolEnabled() == null) { |
| | | result.setAutoPoolEnabled(true); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_IMPORT_SUB_TYPE, bizNo = "0", |
| | | success = CRM_CUSTOMER_IMPORT_SUCCESS) |
| | | public CrmCustomerImportRespVO importCustomerList(List<CrmCustomerImportExcelVO> importCustomers, |
| | | CrmCustomerImportReqVO importReqVO) { |
| | | // 校验非空 |
| | |
| | | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) |
| | | .setBizId(customer.getId()).setUserId(importReqVO.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); |
| | | } |
| | | // 1.3 记录操作日志 |
| | | getSelf().importCustomerLog(customer, false); |
| | | return; |
| | | } |
| | | |
| | |
| | | .setId(existCustomer.getId()); |
| | | customerMapper.updateById(updateCustomer); |
| | | respVO.getUpdateCustomerNames().add(importCustomer.getName()); |
| | | // 2.2 记录操作日志 |
| | | getSelf().importCustomerLog(updateCustomer, true); |
| | | }); |
| | | // 记录导入结果汇总,供 @LogRecord 的 success 文案引用 |
| | | OperateLogUtils.putImportSummary(respVO.getCreateCustomerNames(), respVO.getUpdateCustomerNames(), |
| | | respVO.getFailureCustomerNames()); |
| | | return respVO; |
| | | } |
| | | |
| | | /** |
| | | * 记录导入客户时的操作日志 |
| | | * |
| | | * @param customer 客户信息 |
| | | * @param isUpdate 是否更新;true - 更新,false - 新增 |
| | | */ |
| | | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_IMPORT_SUB_TYPE, bizNo = "{{#customer.id}}", |
| | | success = CRM_CUSTOMER_IMPORT_SUCCESS) |
| | | public void importCustomerLog(CrmCustomerDO customer, boolean isUpdate) { |
| | | LogRecordContext.putVariable("customer", customer); |
| | | LogRecordContext.putVariable("isUpdate", isUpdate); |
| | | } |
| | | |
| | | // ==================== 公海相关操作 ==================== |
| | |
| | | adminUserApi.validateUserList(singletonList(ownerUserId)); |
| | | // 1.3 校验状态 |
| | | customers.forEach(customer -> { |
| | | // 关闭公海可见度的客户不能通过编号直接领取或分配。 |
| | | if (Boolean.FALSE.equals(customer.getAutoPoolEnabled())) { |
| | | throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.CRM_CUSTOMER.getName()); |
| | | } |
| | | // 校验是否已有负责人 |
| | | validateCustomerOwnerExists(customer, false); |
| | | // 校验是否锁定 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<CrmCustomerDO> getCustomerList() { |
| | | return customerMapper.selectList(); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) { |
| | | return customerMapper.selectPage(pageReqVO, userId); |
| | | } |