From 227a4f126ab2f85b5b8666d3447ff6149fa361f4 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sat, 20 Jan 2024 23:07:15 +0800 Subject: [PATCH] =?UTF-8?q?CRM:=20=E5=AE=8C=E5=96=84=E8=B7=9F=E8=BF=9B=20T?= =?UTF-8?q?ODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmFollowUpRecordServiceImpl.java | 94 ++++--------------- 1 file changed, 20 insertions(+), 74 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java index a2da1ee3e..612772a1d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java @@ -66,90 +66,36 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { crmFollowUpRecordMapper.insert(followUpRecord); LocalDateTime now = LocalDateTime.now(); - // TODO @puhui999:感觉可以这里基于 type 做 102 到 104 这种判断;然后,每个类型的调用封装一个小方法,之后调用这些小方法;再之后,74-76、80-82 也是等价的处理; + CrmUpdateFollowUpReqBO updateFollowUpReqBO = new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()) + .setContactLastTime(now).setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()); // 2. 更新 bizId 对应的记录; - updateBizTypeFollowUp(followUpRecord, now); + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) { // 更新商机跟进信息 + businessService.updateBusinessFollowUpBatch(Collections.singletonList(updateFollowUpReqBO)); + } + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_LEADS.getType(), followUpRecord.getBizType())) { // 更新线索跟进信息 + clueService.updateClueFollowUp(updateFollowUpReqBO); + } + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) { // 更新联系人跟进信息 + contactService.updateContactFollowUpBatch(Collections.singletonList(updateFollowUpReqBO)); + } + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) { // 更新合同跟进信息 + contractService.updateContractFollowUp(updateFollowUpReqBO); + } + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) { // 更新客户跟进信息 + customerService.updateCustomerFollowUp(updateFollowUpReqBO); + } + // 3.1 更新 contactIds 对应的记录 if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { - contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), contactId -> - new CrmUpdateFollowUpReqBO().setBizId(contactId).setContactNextTime(followUpRecord.getNextTime()) - .setContactLastTime(now).setContactLastContent(followUpRecord.getContent()))); + contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId)); } // 3.2 需要更新 businessIds、contactIds 对应的记录 if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { - businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), businessId -> - new CrmUpdateFollowUpReqBO().setBizId(businessId).setContactNextTime(followUpRecord.getNextTime()) - .setContactLastTime(now).setContactLastContent(followUpRecord.getContent()))); + businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), updateFollowUpReqBO::setBizId)); } return followUpRecord.getId(); } - /** - * 执行更新 - * - * @param followUpRecord 跟进记录 - * @param now 跟进时间 - */ - private void updateBizTypeFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { - updateBusinessFollowUp(followUpRecord, now); - updateClueFollowUp(followUpRecord, now); - updateContactFollowUp(followUpRecord, now); - updateContractFollowUp(followUpRecord, now); - updateCustomerFollowUp(followUpRecord, now); - } - - private void updateBusinessFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) { - return; - } - - // 更新商机跟进信息 - businessService.updateBusinessFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO() - .setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now) - .setContactLastContent(followUpRecord.getContent()))); - } - - private void updateClueFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_LEADS.getType(), followUpRecord.getBizType())) { - return; - } - - // 更新线索跟进信息 - clueService.updateClueFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now) - .setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent())); - } - - private void updateContactFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) { - return; - } - - // 更新联系人跟进信息 - contactService.updateContactFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO() - .setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now) - .setContactLastContent(followUpRecord.getContent()))); - } - - private void updateContractFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) { - return; - } - - // 更新合同跟进信息 - contractService.updateContractFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now) - .setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent())); - } - - private void updateCustomerFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) { - return; - } - - // 更新客户跟进信息 - customerService.updateCustomerFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now) - .setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent())); - } - @Override public void deleteFollowUpRecord(Long id, Long userId) { // 校验存在