Commit 29f1eb2c184bf7485734d8f869a236bab337fe25
1 parent
3f8fa6b1
✨ CRM:优化 CRM 跟进记录的实现
Showing
12 changed files
with
50 additions
and
84 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| ... | ... | @@ -126,15 +126,6 @@ public class CrmBusinessController { |
| 126 | 126 | return businessVO; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - // TODO 芋艿:处理下 | |
| 130 | - @GetMapping("/list-by-ids") | |
| 131 | - @Operation(summary = "获得商机列表") | |
| 132 | - @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") | |
| 133 | - @PreAuthorize("@ss.hasPermission('crm:business:query')") | |
| 134 | - public CommonResult<List<CrmBusinessRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) { | |
| 135 | - return success(BeanUtils.toBean(businessService.getBusinessList(ids, getLoginUserId()), CrmBusinessRespVO.class)); | |
| 136 | - } | |
| 137 | - | |
| 138 | 129 | @GetMapping("/simple-all-list") |
| 139 | 130 | @Operation(summary = "获得联系人的精简列表") |
| 140 | 131 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| ... | ... | @@ -105,15 +105,6 @@ public class CrmContactController { |
| 105 | 105 | return buildContactDetailList(singletonList(contact)).get(0); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - @GetMapping("/list-by-ids") | |
| 109 | - @Operation(summary = "获得联系人列表") | |
| 110 | - @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") | |
| 111 | - @PreAuthorize("@ss.hasPermission('crm:contact:query')") | |
| 112 | - public CommonResult<List<CrmContactRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) { | |
| 113 | - List<CrmContactDO> list = contactService.getContactListByIds(ids, getLoginUserId()); | |
| 114 | - return success(BeanUtils.toBean(list, CrmContactRespVO.class)); | |
| 115 | - } | |
| 116 | - | |
| 117 | 108 | @GetMapping("/simple-all-list") |
| 118 | 109 | @Operation(summary = "获得联系人的精简列表") |
| 119 | 110 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| ... | ... | @@ -187,8 +187,8 @@ public class CrmContractController { |
| 187 | 187 | Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(convertSet(contractList, |
| 188 | 188 | CrmContractDO::getSignContactId)), CrmContactDO::getId); |
| 189 | 189 | // 1.4 获取商机 |
| 190 | - Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(convertSet(contractList, | |
| 191 | - CrmContractDO::getBusinessId)), CrmBusinessDO::getId); | |
| 190 | + Map<Long, CrmBusinessDO> businessMap = businessService.getBusinessMap( | |
| 191 | + convertSet(contractList, CrmContractDO::getBusinessId)); | |
| 192 | 192 | // 2. 拼接数据 |
| 193 | 193 | return BeanUtils.toBean(contractList, CrmContractRespVO.class, contractVO -> { |
| 194 | 194 | // 2.1 设置客户信息 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java
| ... | ... | @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | |
| 7 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; |
| 8 | 9 | import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordRespVO; |
| 9 | 10 | import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; |
| ... | ... | @@ -13,6 +14,8 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; |
| 13 | 14 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 14 | 15 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| 15 | 16 | import cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService; |
| 17 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 18 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 16 | 19 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | 20 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | 21 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -26,7 +29,7 @@ import java.util.ArrayList; |
| 26 | 29 | import java.util.Map; |
| 27 | 30 | |
| 28 | 31 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 29 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 32 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 30 | 33 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; |
| 31 | 34 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 32 | 35 | |
| ... | ... | @@ -44,6 +47,9 @@ public class CrmFollowUpRecordController { |
| 44 | 47 | @Resource |
| 45 | 48 | private CrmBusinessService businessService; |
| 46 | 49 | |
| 50 | + @Resource | |
| 51 | + private AdminUserApi adminUserApi; | |
| 52 | + | |
| 47 | 53 | @PostMapping("/create") |
| 48 | 54 | @Operation(summary = "创建跟进记录") |
| 49 | 55 | @PreAuthorize("@ss.hasPermission('crm:follow-up-record:create')") |
| ... | ... | @@ -74,17 +80,24 @@ public class CrmFollowUpRecordController { |
| 74 | 80 | @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')") |
| 75 | 81 | public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { |
| 76 | 82 | PageResult<CrmFollowUpRecordDO> pageResult = followUpRecordService.getFollowUpRecordPage(pageReqVO); |
| 77 | - /// 拼接数据 | |
| 78 | - Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList( | |
| 79 | - convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId); | |
| 80 | - Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList( | |
| 81 | - convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId); | |
| 83 | + // 1.1 查询联系人和商机 | |
| 84 | + Map<Long, CrmContactDO> contactMap = contactService.getContactMap( | |
| 85 | + convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())); | |
| 86 | + Map<Long, CrmBusinessDO> businessMap = businessService.getBusinessMap( | |
| 87 | + convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())); | |
| 88 | + // 1.2 查询用户 | |
| 89 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | |
| 90 | + convertSet(pageResult.getList(), item -> Long.valueOf(item.getCreator()))); | |
| 91 | + // 2. 拼接数据 | |
| 82 | 92 | PageResult<CrmFollowUpRecordRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class, record -> { |
| 83 | - record.setContactNames(new ArrayList<>()).setBusinessNames(new ArrayList<>()); | |
| 84 | - record.getContactIds().forEach(id -> MapUtils.findAndThen(contactMap, id, | |
| 85 | - contact -> record.getContactNames().add(contact.getName()))); | |
| 86 | - record.getContactIds().forEach(id -> MapUtils.findAndThen(businessMap, id, | |
| 87 | - business -> record.getBusinessNames().add(business.getName()))); | |
| 93 | + // 2.1 设置联系人和商机信息 | |
| 94 | + record.setBusinesses(new ArrayList<>()).setContacts(new ArrayList<>()); | |
| 95 | + record.getContactIds().forEach(id -> MapUtils.findAndThen(contactMap, id, contact -> | |
| 96 | + record.getContacts().add(new CrmBusinessRespVO().setId(contact.getId()).setName(contact.getName())))); | |
| 97 | + record.getContactIds().forEach(id -> MapUtils.findAndThen(businessMap, id, business -> | |
| 98 | + record.getBusinesses().add(new CrmBusinessRespVO().setId(business.getId()).setName(business.getName())))); | |
| 99 | + // 2.2 设置用户信息 | |
| 100 | + MapUtils.findAndThen(userMap, Long.valueOf(record.getCreator()), user -> record.setCreatorName(user.getNickname())); | |
| 88 | 101 | }); |
| 89 | 102 | return success(voPageResult); |
| 90 | 103 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | |
| 4 | 5 | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| 6 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 5 | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 8 | import lombok.Data; |
| 7 | 9 | |
| ... | ... | @@ -36,19 +38,26 @@ public class CrmFollowUpRecordRespVO { |
| 36 | 38 | |
| 37 | 39 | @Schema(description = "关联的商机编号数组") |
| 38 | 40 | private List<Long> businessIds; |
| 39 | - @Schema(description = "关联的商机名称数组") | |
| 40 | - private List<String> businessNames; | |
| 41 | + @Schema(description = "关联的商机数组") | |
| 42 | + private List<CrmBusinessRespVO> businesses; | |
| 41 | 43 | |
| 42 | 44 | @Schema(description = "关联的联系人编号数组") |
| 43 | 45 | private List<Long> contactIds; |
| 44 | 46 | @Schema(description = "关联的联系人名称数组") |
| 45 | - private List<String> contactNames; | |
| 47 | + private List<CrmBusinessRespVO> contacts; | |
| 46 | 48 | |
| 47 | 49 | @Schema(description = "图片") |
| 48 | 50 | private List<String> picUrls; |
| 49 | 51 | @Schema(description = "附件") |
| 50 | 52 | private List<String> fileUrls; |
| 51 | 53 | |
| 54 | + @Schema(description = "创建人", example = "1024") | |
| 55 | + @ExcelProperty("创建人") | |
| 56 | + private String creator; | |
| 57 | + @Schema(description = "创建人名字", example = "芋道源码") | |
| 58 | + @ExcelProperty("创建人名字") | |
| 59 | + private String creatorName; | |
| 60 | + | |
| 52 | 61 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 53 | 62 | private LocalDateTime createTime; |
| 54 | 63 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| ... | ... | @@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 12 | 12 | import org.apache.ibatis.annotations.Mapper; |
| 13 | 13 | |
| 14 | 14 | import java.util.Collection; |
| 15 | -import java.util.List; | |
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * 商机 Mapper |
| ... | ... | @@ -54,15 +53,6 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { |
| 54 | 53 | return selectJoinPage(pageReqVO, CrmBusinessDO.class, query); |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | - default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) { | |
| 58 | - MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); | |
| 59 | - // 拼接数据权限的查询条件 | |
| 60 | - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId); | |
| 61 | - // 拼接自身的查询条件 | |
| 62 | - query.selectAll(CrmBusinessDO.class).in(CrmBusinessDO::getId, ids).orderByDesc(CrmBusinessDO::getId); | |
| 63 | - return selectJoinList(CrmBusinessDO.class, query); | |
| 64 | - } | |
| 65 | - | |
| 66 | 56 | default Long selectCountByStatusTypeId(Long statusTypeId) { |
| 67 | 57 | return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId); |
| 68 | 58 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| ... | ... | @@ -69,14 +69,6 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { |
| 69 | 69 | return selectJoinPage(pageReqVO, CrmContactDO.class, query); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long ownerUserId) { | |
| 73 | - MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); | |
| 74 | - // 拼接数据权限的查询条件 | |
| 75 | - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, ownerUserId); | |
| 76 | - query.selectAll(CrmContactDO.class).in(CrmContactDO::getId, ids).orderByDesc(CrmContactDO::getId); | |
| 77 | - return selectJoinList(CrmContactDO.class, query); | |
| 78 | - } | |
| 79 | - | |
| 80 | 72 | default List<CrmContactDO> selectListByCustomerId(Long customerId) { |
| 81 | 73 | return selectList(CrmContactDO::getCustomerId, customerId); |
| 82 | 74 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| ... | ... | @@ -16,6 +16,9 @@ import jakarta.validation.Valid; |
| 16 | 16 | import java.time.LocalDateTime; |
| 17 | 17 | import java.util.Collection; |
| 18 | 18 | import java.util.List; |
| 19 | +import java.util.Map; | |
| 20 | + | |
| 21 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 19 | 22 | |
| 20 | 23 | /** |
| 21 | 24 | * 商机 Service 接口 |
| ... | ... | @@ -101,15 +104,17 @@ public interface CrmBusinessService { |
| 101 | 104 | * @param ids 编号 |
| 102 | 105 | * @return 商机列表 |
| 103 | 106 | */ |
| 104 | - List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId); | |
| 107 | + List<CrmBusinessDO> getBusinessList(Collection<Long> ids); | |
| 105 | 108 | |
| 106 | 109 | /** |
| 107 | - * 获得商机列表 | |
| 110 | + * 获得商机 Map | |
| 108 | 111 | * |
| 109 | 112 | * @param ids 编号 |
| 110 | - * @return 商机列表 | |
| 113 | + * @return 商机 Map | |
| 111 | 114 | */ |
| 112 | - List<CrmBusinessDO> getBusinessList(Collection<Long> ids); | |
| 115 | + default Map<Long, CrmBusinessDO> getBusinessMap(Collection<Long> ids) { | |
| 116 | + return convertMap(getBusinessList(ids), CrmBusinessDO::getId); | |
| 117 | + } | |
| 113 | 118 | |
| 114 | 119 | /** |
| 115 | 120 | * 获得指定商机编号的产品列表 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -323,14 +323,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | @Override |
| 326 | - public List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId) { | |
| 327 | - if (CollUtil.isEmpty(ids)) { | |
| 328 | - return ListUtil.empty(); | |
| 329 | - } | |
| 330 | - return businessMapper.selectBatchIds(ids, userId); | |
| 331 | - } | |
| 332 | - | |
| 333 | - @Override | |
| 334 | 326 | public List<CrmBusinessDO> getBusinessList(Collection<Long> ids) { |
| 335 | 327 | if (CollUtil.isEmpty(ids)) { |
| 336 | 328 | return ListUtil.empty(); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
| ... | ... | @@ -98,15 +98,6 @@ public interface CrmContactService { |
| 98 | 98 | /** |
| 99 | 99 | * 获得联系人列表 |
| 100 | 100 | * |
| 101 | - * @param ids 编号 | |
| 102 | - * @param userId 用户编号 | |
| 103 | - * @return 联系人列表 | |
| 104 | - */ | |
| 105 | - List<CrmContactDO> getContactListByIds(Collection<Long> ids, Long userId); | |
| 106 | - | |
| 107 | - /** | |
| 108 | - * 获得联系人列表 | |
| 109 | - * | |
| 110 | 101 | * @param ids 编号 |
| 111 | 102 | * @return 联系人列表 |
| 112 | 103 | */ | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| ... | ... | @@ -258,14 +258,6 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | @Override |
| 261 | - public List<CrmContactDO> getContactListByIds(Collection<Long> ids, Long userId) { | |
| 262 | - if (CollUtil.isEmpty(ids)) { | |
| 263 | - return ListUtil.empty(); | |
| 264 | - } | |
| 265 | - return contactMapper.selectBatchIds(ids, userId); | |
| 266 | - } | |
| 267 | - | |
| 268 | - @Override | |
| 269 | 261 | public List<CrmContactDO> getContactList(Collection<Long> ids) { |
| 270 | 262 | if (CollUtil.isEmpty(ids)) { |
| 271 | 263 | return ListUtil.empty(); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java
| ... | ... | @@ -69,6 +69,9 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { |
| 69 | 69 | crmFollowUpRecordMapper.insert(record); |
| 70 | 70 | |
| 71 | 71 | // 2. 更新 bizId 对应的记录 |
| 72 | + if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), record.getBizType())) { // 更新客户跟进信息 | |
| 73 | + customerService.updateCustomerFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); | |
| 74 | + } | |
| 72 | 75 | if (ObjUtil.equal(CrmBizTypeEnum.CRM_BUSINESS.getType(), record.getBizType())) { // 更新商机跟进信息 |
| 73 | 76 | businessService.updateBusinessFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); |
| 74 | 77 | } |
| ... | ... | @@ -81,9 +84,6 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { |
| 81 | 84 | if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTRACT.getType(), record.getBizType())) { // 更新合同跟进信息 |
| 82 | 85 | contractService.updateContractFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); |
| 83 | 86 | } |
| 84 | - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), record.getBizType())) { // 更新客户跟进信息 | |
| 85 | - customerService.updateCustomerFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); | |
| 86 | - } | |
| 87 | 87 | |
| 88 | 88 | // 3.1 更新 contactIds 对应的记录,只更新 nextTime |
| 89 | 89 | if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { | ... | ... |