Commit 227a4f126ab2f85b5b8666d3447ff6149fa361f4
1 parent
f366d440
CRM: 完善跟进 TODO
Showing
1 changed file
with
19 additions
and
73 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java
| @@ -66,88 +66,34 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { | @@ -66,88 +66,34 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { | ||
| 66 | crmFollowUpRecordMapper.insert(followUpRecord); | 66 | crmFollowUpRecordMapper.insert(followUpRecord); |
| 67 | 67 | ||
| 68 | LocalDateTime now = LocalDateTime.now(); | 68 | LocalDateTime now = LocalDateTime.now(); |
| 69 | - // TODO @puhui999:感觉可以这里基于 type 做 102 到 104 这种判断;然后,每个类型的调用封装一个小方法,之后调用这些小方法;再之后,74-76、80-82 也是等价的处理; | 69 | + CrmUpdateFollowUpReqBO updateFollowUpReqBO = new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()) |
| 70 | + .setContactLastTime(now).setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()); | ||
| 70 | // 2. 更新 bizId 对应的记录; | 71 | // 2. 更新 bizId 对应的记录; |
| 71 | - updateBizTypeFollowUp(followUpRecord, now); | ||
| 72 | - // 3.1 更新 contactIds 对应的记录 | ||
| 73 | - if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { | ||
| 74 | - contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), contactId -> | ||
| 75 | - new CrmUpdateFollowUpReqBO().setBizId(contactId).setContactNextTime(followUpRecord.getNextTime()) | ||
| 76 | - .setContactLastTime(now).setContactLastContent(followUpRecord.getContent()))); | 72 | + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) { // 更新商机跟进信息 |
| 73 | + businessService.updateBusinessFollowUpBatch(Collections.singletonList(updateFollowUpReqBO)); | ||
| 77 | } | 74 | } |
| 78 | - // 3.2 需要更新 businessIds、contactIds 对应的记录 | ||
| 79 | - if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { | ||
| 80 | - businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), businessId -> | ||
| 81 | - new CrmUpdateFollowUpReqBO().setBizId(businessId).setContactNextTime(followUpRecord.getNextTime()) | ||
| 82 | - .setContactLastTime(now).setContactLastContent(followUpRecord.getContent()))); | 75 | + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_LEADS.getType(), followUpRecord.getBizType())) { // 更新线索跟进信息 |
| 76 | + clueService.updateClueFollowUp(updateFollowUpReqBO); | ||
| 83 | } | 77 | } |
| 84 | - return followUpRecord.getId(); | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - /** | ||
| 88 | - * 执行更新 | ||
| 89 | - * | ||
| 90 | - * @param followUpRecord 跟进记录 | ||
| 91 | - * @param now 跟进时间 | ||
| 92 | - */ | ||
| 93 | - private void updateBizTypeFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { | ||
| 94 | - updateBusinessFollowUp(followUpRecord, now); | ||
| 95 | - updateClueFollowUp(followUpRecord, now); | ||
| 96 | - updateContactFollowUp(followUpRecord, now); | ||
| 97 | - updateContractFollowUp(followUpRecord, now); | ||
| 98 | - updateCustomerFollowUp(followUpRecord, now); | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - private void updateBusinessFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { | ||
| 102 | - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) { | ||
| 103 | - return; | 78 | + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) { // 更新联系人跟进信息 |
| 79 | + contactService.updateContactFollowUpBatch(Collections.singletonList(updateFollowUpReqBO)); | ||
| 104 | } | 80 | } |
| 105 | - | ||
| 106 | - // 更新商机跟进信息 | ||
| 107 | - businessService.updateBusinessFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO() | ||
| 108 | - .setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now) | ||
| 109 | - .setContactLastContent(followUpRecord.getContent()))); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - private void updateClueFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { | ||
| 113 | - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_LEADS.getType(), followUpRecord.getBizType())) { | ||
| 114 | - return; | 81 | + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) { // 更新合同跟进信息 |
| 82 | + contractService.updateContractFollowUp(updateFollowUpReqBO); | ||
| 115 | } | 83 | } |
| 116 | - | ||
| 117 | - // 更新线索跟进信息 | ||
| 118 | - clueService.updateClueFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now) | ||
| 119 | - .setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent())); | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - private void updateContactFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { | ||
| 123 | - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) { | ||
| 124 | - return; | 84 | + if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) { // 更新客户跟进信息 |
| 85 | + customerService.updateCustomerFollowUp(updateFollowUpReqBO); | ||
| 125 | } | 86 | } |
| 126 | 87 | ||
| 127 | - // 更新联系人跟进信息 | ||
| 128 | - contactService.updateContactFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO() | ||
| 129 | - .setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now) | ||
| 130 | - .setContactLastContent(followUpRecord.getContent()))); | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - private void updateContractFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { | ||
| 134 | - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) { | ||
| 135 | - return; | 88 | + // 3.1 更新 contactIds 对应的记录 |
| 89 | + if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { | ||
| 90 | + contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId)); | ||
| 136 | } | 91 | } |
| 137 | - | ||
| 138 | - // 更新合同跟进信息 | ||
| 139 | - contractService.updateContractFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now) | ||
| 140 | - .setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent())); | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - private void updateCustomerFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) { | ||
| 144 | - if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) { | ||
| 145 | - return; | 92 | + // 3.2 需要更新 businessIds、contactIds 对应的记录 |
| 93 | + if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { | ||
| 94 | + businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), updateFollowUpReqBO::setBizId)); | ||
| 146 | } | 95 | } |
| 147 | - | ||
| 148 | - // 更新客户跟进信息 | ||
| 149 | - customerService.updateCustomerFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now) | ||
| 150 | - .setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent())); | 96 | + return followUpRecord.getId(); |
| 151 | } | 97 | } |
| 152 | 98 | ||
| 153 | @Override | 99 | @Override |