CRM: 完善跟进 TODO

This commit is contained in:
puhui999 2024-01-20 23:07:15 +08:00
parent f366d440d8
commit 227a4f126a
1 changed files with 20 additions and 74 deletions

View File

@ -66,90 +66,36 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
crmFollowUpRecordMapper.insert(followUpRecord); crmFollowUpRecordMapper.insert(followUpRecord);
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// TODO @puhui999感觉可以这里基于 type 102 104 这种判断然后每个类型的调用封装一个小方法之后调用这些小方法再之后74-7680-82 也是等价的处理 CrmUpdateFollowUpReqBO updateFollowUpReqBO = new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId())
.setContactLastTime(now).setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent());
// 2. 更新 bizId 对应的记录 // 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 对应的记录 // 3.1 更新 contactIds 对应的记录
if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { if (CollUtil.isNotEmpty(createReqVO.getContactIds())) {
contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), contactId -> contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId));
new CrmUpdateFollowUpReqBO().setBizId(contactId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent())));
} }
// 3.2 需要更新 businessIdscontactIds 对应的记录 // 3.2 需要更新 businessIdscontactIds 对应的记录
if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) {
businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), businessId -> businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), updateFollowUpReqBO::setBizId));
new CrmUpdateFollowUpReqBO().setBizId(businessId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent())));
} }
return followUpRecord.getId(); 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 @Override
public void deleteFollowUpRecord(Long id, Long userId) { public void deleteFollowUpRecord(Long id, Long userId) {
// 校验存在 // 校验存在