Commit 7dd35f3295c0226d6eba8cfaf8d461adb5506db1
1 parent
66a34a6d
✨ CRM:完善联系人的编辑、详情
Showing
10 changed files
with
81 additions
and
101 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
| ... | ... | @@ -75,6 +75,8 @@ public interface LogRecordConstants { |
| 75 | 75 | String CRM_CONTACT_DELETE_SUCCESS = "删除了联系人【{{#contactName}}】"; |
| 76 | 76 | String CRM_CONTACT_TRANSFER_SUB_TYPE = "转移联系人"; |
| 77 | 77 | String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; |
| 78 | + String CRM_CONTACT_FOLLOW_UP_SUB_TYPE = "联系人跟进"; | |
| 79 | + String CRM_CONTACT_FOLLOW_UP_SUCCESS = "联系人跟进【{{#contactName}}】"; | |
| 78 | 80 | |
| 79 | 81 | // ======================= CRM_BUSINESS 商机 ======================= |
| 80 | 82 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| ... | ... | @@ -118,7 +118,7 @@ public class CrmContactController { |
| 118 | 118 | @Operation(summary = "获得联系人的精简列表") |
| 119 | 119 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 120 | 120 | public CommonResult<List<CrmContactRespVO>> getSimpleContactList() { |
| 121 | - List<CrmContactDO> list = contactService.getSimpleContactList(getLoginUserId()); | |
| 121 | + List<CrmContactDO> list = contactService.getContactList(getLoginUserId()); | |
| 122 | 122 | return success(convertList(list, contact -> // 只返回 id、name 字段 |
| 123 | 123 | new CrmContactRespVO().setId(contact.getId()).setName(contact.getName()))); |
| 124 | 124 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java
| ... | ... | @@ -27,6 +27,7 @@ public class CrmContactSaveReqVO { |
| 27 | 27 | private String name; |
| 28 | 28 | |
| 29 | 29 | @Schema(description = "客户编号", example = "10795") |
| 30 | + @NotNull(message = "客户编号不能为空") | |
| 30 | 31 | @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) |
| 31 | 32 | private Long customerId; |
| 32 | 33 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/CrmContactConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.convert.contact; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactRespVO; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | |
| 7 | -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO; | |
| 8 | -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | |
| 9 | -import org.mapstruct.Mapper; | |
| 10 | -import org.mapstruct.Mapping; | |
| 11 | -import org.mapstruct.factory.Mappers; | |
| 12 | - | |
| 13 | -import java.util.List; | |
| 14 | - | |
| 15 | -/** | |
| 16 | - * CRM 联系人 Convert | |
| 17 | - * | |
| 18 | - * @author 芋道源码 | |
| 19 | - */ | |
| 20 | -@Mapper | |
| 21 | -public interface CrmContactConvert { | |
| 22 | - | |
| 23 | - CrmContactConvert INSTANCE = Mappers.getMapper(CrmContactConvert.class); | |
| 24 | - | |
| 25 | - @Mapping(target = "bizId", source = "reqVO.id") | |
| 26 | - CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); | |
| 27 | - | |
| 28 | - @Mapping(target = "id", source = "reqBO.bizId") | |
| 29 | - CrmContactDO convert(CrmUpdateFollowUpReqBO reqBO); | |
| 30 | - | |
| 31 | - default List<CrmContactDO> convertList(List<CrmUpdateFollowUpReqBO> list) { | |
| 32 | - return CollectionUtils.convertList(list, INSTANCE::convert); | |
| 33 | - } | |
| 34 | - | |
| 35 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| ... | ... | @@ -22,12 +22,6 @@ import java.util.List; |
| 22 | 22 | @Mapper |
| 23 | 23 | public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { |
| 24 | 24 | |
| 25 | - default int updateOwnerUserIdById(Long id, Long ownerUserId) { | |
| 26 | - return update(new LambdaUpdateWrapper<CrmContactDO>() | |
| 27 | - .eq(CrmContactDO::getId, id) | |
| 28 | - .set(CrmContactDO::getOwnerUserId, ownerUserId)); | |
| 29 | - } | |
| 30 | - | |
| 31 | 25 | default int updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { |
| 32 | 26 | return update(new LambdaUpdateWrapper<CrmContactDO>() |
| 33 | 27 | .eq(CrmContactDO::getCustomerId, customerId) | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
| ... | ... | @@ -6,9 +6,9 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReq |
| 6 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 9 | -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO; | |
| 10 | 9 | import jakarta.validation.Valid; |
| 11 | 10 | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | 12 | import java.util.Collection; |
| 13 | 13 | import java.util.List; |
| 14 | 14 | import java.util.Map; |
| ... | ... | @@ -54,7 +54,7 @@ public interface CrmContactService { |
| 54 | 54 | void transferContact(CrmContactTransferReqVO reqVO, Long userId); |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * 更新客户联系人负责人 | |
| 57 | + * 更新指定客户的联系人的负责人 | |
| 58 | 58 | * |
| 59 | 59 | * @param customerId 客户编号 |
| 60 | 60 | * @param ownerUserId 用户编号 |
| ... | ... | @@ -64,9 +64,20 @@ public interface CrmContactService { |
| 64 | 64 | /** |
| 65 | 65 | * 更新联系人相关跟进信息 |
| 66 | 66 | * |
| 67 | - * @param updateFollowUpReqBOList 跟进信息 | |
| 67 | + * @param id 编号 | |
| 68 | + * @param contactNextTime 下次联系时间 | |
| 69 | + * @param contactLastContent 最后联系内容 | |
| 70 | + */ | |
| 71 | + void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * 更新联系人相关跟进信息 | |
| 75 | + * | |
| 76 | + * @param ids 编号数组 | |
| 77 | + * @param contactNextTime 下次联系时间 | |
| 78 | + * @param contactLastContent 最后联系内容 | |
| 68 | 79 | */ |
| 69 | - void updateContactFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList); | |
| 80 | + void updateContactFollowUpBatch(Collection<Long> ids, LocalDateTime contactNextTime, String contactLastContent); | |
| 70 | 81 | |
| 71 | 82 | /** |
| 72 | 83 | * 获得联系人 |
| ... | ... | @@ -104,19 +115,12 @@ public interface CrmContactService { |
| 104 | 115 | } |
| 105 | 116 | |
| 106 | 117 | /** |
| 107 | - * 获得联系人列表 | |
| 108 | - * | |
| 109 | - * @return 联系人列表 | |
| 110 | - */ | |
| 111 | - List<CrmContactDO> getContactList(); | |
| 112 | - | |
| 113 | - /** | |
| 114 | 118 | * 获取联系人列表(校验权限) |
| 115 | 119 | * |
| 116 | 120 | * @param userId 用户编号 |
| 117 | 121 | * @return 联系人列表 |
| 118 | 122 | */ |
| 119 | - List<CrmContactDO> getSimpleContactList(Long userId); | |
| 123 | + List<CrmContactDO> getContactList(Long userId); | |
| 120 | 124 | |
| 121 | 125 | /** |
| 122 | 126 | * 获得联系人分页 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| ... | ... | @@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusines |
| 8 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; |
| 10 | 10 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; |
| 11 | -import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert; | |
| 12 | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 13 | 12 | import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; |
| 14 | 13 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| ... | ... | @@ -17,9 +16,9 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm |
| 17 | 16 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 18 | 17 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| 19 | 18 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 20 | -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO; | |
| 21 | 19 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 22 | 20 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 21 | +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | |
| 23 | 22 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 24 | 23 | import com.mzt.logapi.context.LogRecordContext; |
| 25 | 24 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| ... | ... | @@ -30,14 +29,15 @@ import org.springframework.stereotype.Service; |
| 30 | 29 | import org.springframework.transaction.annotation.Transactional; |
| 31 | 30 | import org.springframework.validation.annotation.Validated; |
| 32 | 31 | |
| 32 | +import java.time.LocalDateTime; | |
| 33 | 33 | import java.util.Collection; |
| 34 | 34 | import java.util.List; |
| 35 | 35 | |
| 36 | 36 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 37 | 37 | import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; |
| 38 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 38 | 39 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 39 | 40 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; |
| 40 | -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; | |
| 41 | 41 | import static java.util.Collections.singletonList; |
| 42 | 42 | |
| 43 | 43 | /** |
| ... | ... | @@ -73,7 +73,7 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 73 | 73 | success = CRM_CONTACT_CREATE_SUCCESS) |
| 74 | 74 | public Long createContact(CrmContactSaveReqVO createReqVO, Long userId) { |
| 75 | 75 | createReqVO.setId(null); |
| 76 | - // 1. 校验 | |
| 76 | + // 1. 校验关联数据 | |
| 77 | 77 | validateRelationDataExists(createReqVO); |
| 78 | 78 | |
| 79 | 79 | // 2. 插入联系人 |
| ... | ... | @@ -102,8 +102,9 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 102 | 102 | success = CRM_CONTACT_UPDATE_SUCCESS) |
| 103 | 103 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 104 | 104 | public void updateContact(CrmContactSaveReqVO updateReqVO) { |
| 105 | - // 1. 校验存在 | |
| 105 | + // 1.1 校验存在 | |
| 106 | 106 | CrmContactDO oldContact = validateContactExists(updateReqVO.getId()); |
| 107 | + // 1.2 校验关联数据 | |
| 107 | 108 | validateRelationDataExists(updateReqVO); |
| 108 | 109 | |
| 109 | 110 | // 2. 更新联系人 |
| ... | ... | @@ -123,15 +124,15 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 123 | 124 | private void validateRelationDataExists(CrmContactSaveReqVO saveReqVO) { |
| 124 | 125 | // 1. 校验客户 |
| 125 | 126 | if (saveReqVO.getCustomerId() != null && customerService.getCustomer(saveReqVO.getCustomerId()) == null) { |
| 126 | - throw exception(CUSTOMER_NOT_EXISTS); | |
| 127 | + customerService.validateCustomer(saveReqVO.getCustomerId()); | |
| 127 | 128 | } |
| 128 | 129 | // 2. 校验负责人 |
| 129 | - if (saveReqVO.getOwnerUserId() != null && adminUserApi.getUser(saveReqVO.getOwnerUserId()) == null) { | |
| 130 | - throw exception(USER_NOT_EXISTS); | |
| 130 | + if (saveReqVO.getOwnerUserId() != null) { | |
| 131 | + adminUserApi.validateUser(saveReqVO.getOwnerUserId()); | |
| 131 | 132 | } |
| 132 | 133 | // 3. 直属上级 |
| 133 | - if (saveReqVO.getParentId() != null && contactMapper.selectById(saveReqVO.getParentId()) == null) { | |
| 134 | - throw exception(CONTACT_NOT_EXISTS); | |
| 134 | + if (saveReqVO.getParentId() != null) { | |
| 135 | + validateContactExists(saveReqVO.getParentId()); | |
| 135 | 136 | } |
| 136 | 137 | // 4. 如果有关联商机,则需要校验存在 |
| 137 | 138 | if (saveReqVO.getBusinessId() != null && businessService.getBusiness(saveReqVO.getBusinessId()) == null) { |
| ... | ... | @@ -165,11 +166,11 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 165 | 166 | } |
| 166 | 167 | |
| 167 | 168 | private CrmContactDO validateContactExists(Long id) { |
| 168 | - CrmContactDO contactDO = contactMapper.selectById(id); | |
| 169 | - if (contactDO == null) { | |
| 169 | + CrmContactDO contact = contactMapper.selectById(id); | |
| 170 | + if (contact == null) { | |
| 170 | 171 | throw exception(CONTACT_NOT_EXISTS); |
| 171 | 172 | } |
| 172 | - return contactDO; | |
| 173 | + return contact; | |
| 173 | 174 | } |
| 174 | 175 | |
| 175 | 176 | @Override |
| ... | ... | @@ -182,10 +183,10 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 182 | 183 | CrmContactDO contact = validateContactExists(reqVO.getId()); |
| 183 | 184 | |
| 184 | 185 | // 2.1 数据权限转移 |
| 185 | - permissionService.transferPermission( | |
| 186 | - CrmContactConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTACT.getType())); | |
| 186 | + permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(), | |
| 187 | + reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 187 | 188 | // 2.2 设置新的负责人 |
| 188 | - contactMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | |
| 189 | + contactMapper.updateById(new CrmContactDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | |
| 189 | 190 | |
| 190 | 191 | // 3. 记录转移日志 |
| 191 | 192 | LogRecordContext.putVariable("contact", contact); |
| ... | ... | @@ -194,11 +195,30 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 194 | 195 | @Override |
| 195 | 196 | public void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { |
| 196 | 197 | contactMapper.updateOwnerUserIdByCustomerId(customerId, ownerUserId); |
| 198 | + // TODO @puhui999:操作日志、数据权限; | |
| 197 | 199 | } |
| 198 | 200 | |
| 199 | 201 | @Override |
| 200 | - public void updateContactFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList) { | |
| 201 | - contactMapper.updateBatch(CrmContactConvert.INSTANCE.convertList(updateFollowUpReqBOList)); | |
| 202 | + @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", | |
| 203 | + success = CRM_CONTACT_FOLLOW_UP_SUCCESS) | |
| 204 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) | |
| 205 | + public void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { | |
| 206 | + // 1.1 校验存在 | |
| 207 | + CrmContactDO contact = validateContactExists(id); | |
| 208 | + | |
| 209 | + // 2. 更新联系人的跟进信息 | |
| 210 | + contactMapper.updateById(new CrmContactDO().setId(id).setContactNextTime(contactNextTime) | |
| 211 | + .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); | |
| 212 | + | |
| 213 | + // 3. 记录操作日志上下文 | |
| 214 | + LogRecordContext.putVariable("contactName", contact.getName()); | |
| 215 | + } | |
| 216 | + | |
| 217 | + @Override | |
| 218 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#ids", level = CrmPermissionLevelEnum.WRITE) | |
| 219 | + public void updateContactFollowUpBatch(Collection<Long> ids, LocalDateTime contactNextTime, String contactLastContent) { | |
| 220 | + contactMapper.updateBatch(convertList(ids, id -> new CrmContactDO().setId(id).setContactLastTime(LocalDateTime.now()) | |
| 221 | + .setContactNextTime(contactNextTime).setContactLastContent(contactLastContent))); | |
| 202 | 222 | } |
| 203 | 223 | |
| 204 | 224 | //======================= 查询相关 ======================= |
| ... | ... | @@ -226,12 +246,7 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 226 | 246 | } |
| 227 | 247 | |
| 228 | 248 | @Override |
| 229 | - public List<CrmContactDO> getContactList() { | |
| 230 | - return contactMapper.selectList(); | |
| 231 | - } | |
| 232 | - | |
| 233 | - @Override | |
| 234 | - public List<CrmContactDO> getSimpleContactList(Long userId) { | |
| 249 | + public List<CrmContactDO> getContactList(Long userId) { | |
| 235 | 250 | CrmContactPageReqVO reqVO = new CrmContactPageReqVO(); |
| 236 | 251 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 |
| 237 | 252 | return contactMapper.selectPage(reqVO, userId).getList(); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -164,7 +164,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 164 | 164 | |
| 165 | 165 | // 2. 更新客户的跟进信息 |
| 166 | 166 | customerMapper.updateById(new CrmCustomerDO().setId(id).setFollowUpStatus(true).setContactNextTime(contactNextTime) |
| 167 | - .setContactLastTime(LocalDateTime.now())); | |
| 167 | + .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); | |
| 168 | 168 | |
| 169 | 169 | // 3. 记录操作日志上下文 |
| 170 | 170 | LogRecordContext.putVariable("customerName", customer.getName()); |
| ... | ... | @@ -521,11 +521,11 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 521 | 521 | /** |
| 522 | 522 | * 校验客户是否存在 |
| 523 | 523 | * |
| 524 | - * @param customerId 客户 id | |
| 524 | + * @param id 客户 id | |
| 525 | 525 | */ |
| 526 | 526 | @Override |
| 527 | - public void validateCustomer(Long customerId) { | |
| 528 | - validateCustomerExists(customerId); | |
| 527 | + public void validateCustomer(Long id) { | |
| 528 | + validateCustomerExists(id); | |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) { | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java
| ... | ... | @@ -68,41 +68,40 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { |
| 68 | 68 | @Override |
| 69 | 69 | @CrmPermission(bizTypeValue = "#createReqVO.bizType", bizId = "#createReqVO.bizId", level = CrmPermissionLevelEnum.WRITE) |
| 70 | 70 | public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) { |
| 71 | - // 创建更进记录 | |
| 72 | - CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); | |
| 73 | - crmFollowUpRecordMapper.insert(followUpRecord); | |
| 71 | + // 1. 创建更进记录 | |
| 72 | + CrmFollowUpRecordDO record = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); | |
| 73 | + crmFollowUpRecordMapper.insert(record); | |
| 74 | 74 | |
| 75 | - // 2. 更新 bizId 对应的记录; | |
| 76 | - CrmUpdateFollowUpReqBO updateFollowUpReqBO = new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()) | |
| 75 | + // 2. 更新 bizId 对应的记录 | |
| 76 | + CrmUpdateFollowUpReqBO updateFollowUpReqBO = new CrmUpdateFollowUpReqBO().setBizId(record.getBizId()) | |
| 77 | 77 | .setContactLastTime(LocalDateTime.now()) |
| 78 | - .setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()); | |
| 79 | - if (ObjUtil.equal(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) { // 更新商机跟进信息 | |
| 78 | + .setContactNextTime(record.getNextTime()).setContactLastContent(record.getContent()); | |
| 79 | + if (ObjUtil.equal(CrmBizTypeEnum.CRM_BUSINESS.getType(), record.getBizType())) { // 更新商机跟进信息 | |
| 80 | 80 | businessService.updateBusinessFollowUpBatch(Collections.singletonList(updateFollowUpReqBO)); |
| 81 | 81 | } |
| 82 | - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CLUE.getType(), followUpRecord.getBizType())) { // 更新线索跟进信息 | |
| 83 | - clueService.updateClueFollowUp(followUpRecord.getId(), followUpRecord.getNextTime(), followUpRecord.getContent()); | |
| 82 | + if (ObjUtil.equal(CrmBizTypeEnum.CRM_CLUE.getType(), record.getBizType())) { // 更新线索跟进信息 | |
| 83 | + clueService.updateClueFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); | |
| 84 | 84 | } |
| 85 | - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) { // 更新联系人跟进信息 | |
| 86 | - contactService.updateContactFollowUpBatch(Collections.singletonList(updateFollowUpReqBO)); | |
| 85 | + if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTACT.getType(), record.getBizType())) { // 更新联系人跟进信息 | |
| 86 | + contactService.updateContactFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); | |
| 87 | 87 | } |
| 88 | - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) { // 更新合同跟进信息 | |
| 88 | + if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTRACT.getType(), record.getBizType())) { // 更新合同跟进信息 | |
| 89 | 89 | contractService.updateContractFollowUp(updateFollowUpReqBO); |
| 90 | 90 | } |
| 91 | - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) { // 更新客户跟进信息 | |
| 92 | - customerService.updateCustomerFollowUp(followUpRecord.getBizId(), followUpRecord.getNextTime(), followUpRecord.getContent()); | |
| 91 | + if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), record.getBizType())) { // 更新客户跟进信息 | |
| 92 | + customerService.updateCustomerFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // 3.1 更新 contactIds 对应的记录,不更新 lastTime 和 lastContent |
| 96 | 96 | if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { |
| 97 | - contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), | |
| 98 | - contactId -> updateFollowUpReqBO.setBizId(contactId).setContactLastTime(null).setContactLastContent(null))); | |
| 97 | + contactService.updateContactFollowUpBatch(createReqVO.getContactIds(), null, null); | |
| 99 | 98 | } |
| 100 | 99 | // 3.2 需要更新 businessIds 对应的记录,不更新 lastTime 和 lastContent |
| 101 | 100 | if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { |
| 102 | 101 | businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), |
| 103 | 102 | businessId -> updateFollowUpReqBO.setBizId(businessId).setContactLastTime(null).setContactLastContent(null))); |
| 104 | 103 | } |
| 105 | - return followUpRecord.getId(); | |
| 104 | + return record.getId(); | |
| 106 | 105 | } |
| 107 | 106 | |
| 108 | 107 | @Override | ... | ... |