Commit 9e3055ee1ee2ef043bbb24314a87df11002c09d6
1 parent
2d053738
📖 CRM:code review 商机模块
Showing
31 changed files
with
312 additions
and
505 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -24,7 +24,7 @@ public interface ErrorCodeConstants { | @@ -24,7 +24,7 @@ public interface ErrorCodeConstants { | ||
| 24 | // ========== 联系人管理 1-020-003-000 ========== | 24 | // ========== 联系人管理 1-020-003-000 ========== |
| 25 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); | 25 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); |
| 26 | ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在"); | 26 | ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在"); |
| 27 | - ErrorCode CONTACT_BUSINESS_LINK_CREATE_EMPTY = new ErrorCode( 1_020_003_002, "联系人商机关联参数为空"); | 27 | + |
| 28 | // ========== 回款 1-020-004-000 ========== | 28 | // ========== 回款 1-020-004-000 ========== |
| 29 | ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); | 29 | ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); |
| 30 | 30 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| @@ -4,14 +4,9 @@ import cn.hutool.core.collection.CollUtil; | @@ -4,14 +4,9 @@ import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.hutool.core.lang.Assert; | 4 | import cn.hutool.core.lang.Assert; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 7 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 8 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 10 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; |
| 11 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; | ||
| 12 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; | ||
| 13 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO; | ||
| 14 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | ||
| 15 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; | 10 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; |
| 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 17 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| @@ -33,13 +28,10 @@ import org.springframework.web.bind.annotation.*; | @@ -33,13 +28,10 @@ import org.springframework.web.bind.annotation.*; | ||
| 33 | 28 | ||
| 34 | import java.io.IOException; | 29 | import java.io.IOException; |
| 35 | import java.util.List; | 30 | import java.util.List; |
| 36 | -import java.util.Map; | ||
| 37 | -import java.util.Objects; | ||
| 38 | -import java.util.Set; | ||
| 39 | -import java.util.stream.Collectors; | ||
| 40 | 31 | ||
| 41 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 32 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 42 | import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | 33 | import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; |
| 34 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 43 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 35 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 44 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 36 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 45 | 37 | ||
| @@ -51,13 +43,10 @@ public class CrmBusinessController { | @@ -51,13 +43,10 @@ public class CrmBusinessController { | ||
| 51 | 43 | ||
| 52 | @Resource | 44 | @Resource |
| 53 | private CrmBusinessService businessService; | 45 | private CrmBusinessService businessService; |
| 54 | - | ||
| 55 | @Resource | 46 | @Resource |
| 56 | private CrmCustomerService customerService; | 47 | private CrmCustomerService customerService; |
| 57 | - | ||
| 58 | @Resource | 48 | @Resource |
| 59 | private CrmBusinessStatusTypeService businessStatusTypeService; | 49 | private CrmBusinessStatusTypeService businessStatusTypeService; |
| 60 | - | ||
| 61 | @Resource | 50 | @Resource |
| 62 | private CrmBusinessStatusService businessStatusService; | 51 | private CrmBusinessStatusService businessStatusService; |
| 63 | 52 | ||
| @@ -99,27 +88,7 @@ public class CrmBusinessController { | @@ -99,27 +88,7 @@ public class CrmBusinessController { | ||
| 99 | @PreAuthorize("@ss.hasPermission('crm:business:query')") | 88 | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| 100 | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { | 89 | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { |
| 101 | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); | 90 | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); |
| 102 | - if (CollUtil.isEmpty(pageResult.getList())) { | ||
| 103 | - return success(PageResult.empty(pageResult.getTotal())); | ||
| 104 | - } | ||
| 105 | - // 处理客户名称回显 | ||
| 106 | - // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; | ||
| 107 | - Set<Long> customerIds = pageResult.getList().stream() | ||
| 108 | - .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 109 | - List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds, getLoginUserId()); | ||
| 110 | - // 处理商机状态类型名称回显 | ||
| 111 | - Set<Long> statusTypeIds = pageResult.getList().stream() | ||
| 112 | - .map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 113 | - CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO(); | ||
| 114 | - queryStatusTypeVO.setIdList(statusTypeIds); | ||
| 115 | - List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO); | ||
| 116 | - // 处理商机状态名称回显 | ||
| 117 | - Set<Long> statusIds = pageResult.getList().stream() | ||
| 118 | - .map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 119 | - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); | ||
| 120 | - queryVO.setIdList(statusIds); | ||
| 121 | - List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO); | ||
| 122 | - return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList)); | 91 | + return success(buildBusinessDetailPageResult(pageResult)); |
| 123 | } | 92 | } |
| 124 | 93 | ||
| 125 | @GetMapping("/page-by-customer") | 94 | @GetMapping("/page-by-customer") |
| @@ -127,24 +96,16 @@ public class CrmBusinessController { | @@ -127,24 +96,16 @@ public class CrmBusinessController { | ||
| 127 | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) { | 96 | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) { |
| 128 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); | 97 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); |
| 129 | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomerId(pageReqVO); | 98 | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomerId(pageReqVO); |
| 130 | - // 处理客户名称回显 | ||
| 131 | - // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; | ||
| 132 | - Set<Long> customerIds = pageResult.getList().stream() | ||
| 133 | - .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 134 | - List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds, getLoginUserId()); | ||
| 135 | - // 处理商机状态类型名称回显 | ||
| 136 | - Set<Long> statusTypeIds = pageResult.getList().stream() | ||
| 137 | - .map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 138 | - CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO(); | ||
| 139 | - queryStatusTypeVO.setIdList(statusTypeIds); | ||
| 140 | - List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO); | ||
| 141 | - // 处理商机状态名称回显 | ||
| 142 | - Set<Long> statusIds = pageResult.getList().stream() | ||
| 143 | - .map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 144 | - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); | ||
| 145 | - queryVO.setIdList(statusIds); | ||
| 146 | - List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO); | ||
| 147 | - return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList)); | 99 | + return success(buildBusinessDetailPageResult(pageResult)); |
| 100 | + } | ||
| 101 | + | ||
| 102 | + | ||
| 103 | + @GetMapping("/page-by-contact") | ||
| 104 | + @Operation(summary = "获得联系人的商机分页") | ||
| 105 | + @PreAuthorize("@ss.hasPermission('crm:business:query')") | ||
| 106 | + public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessContactPage(@Valid CrmBusinessPageReqVO pageReqVO) { | ||
| 107 | + PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByContact(pageReqVO); | ||
| 108 | + return success(buildBusinessDetailPageResult(pageResult)); | ||
| 148 | } | 109 | } |
| 149 | 110 | ||
| 150 | @GetMapping("/export-excel") | 111 | @GetMapping("/export-excel") |
| @@ -156,8 +117,21 @@ public class CrmBusinessController { | @@ -156,8 +117,21 @@ public class CrmBusinessController { | ||
| 156 | exportReqVO.setPageSize(PAGE_SIZE_NONE); | 117 | exportReqVO.setPageSize(PAGE_SIZE_NONE); |
| 157 | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId()); | 118 | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId()); |
| 158 | // 导出 Excel | 119 | // 导出 Excel |
| 159 | - ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, | ||
| 160 | - CrmBusinessConvert.INSTANCE.convertList02(pageResult.getList())); | 120 | + ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessRespVO.class, |
| 121 | + buildBusinessDetailPageResult(pageResult).getList()); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + private PageResult<CrmBusinessRespVO> buildBusinessDetailPageResult(PageResult<CrmBusinessDO> pageResult) { | ||
| 125 | + if (CollUtil.isEmpty(pageResult.getList())) { | ||
| 126 | + return PageResult.empty(pageResult.getTotal()); | ||
| 127 | + } | ||
| 128 | + List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.getBusinessStatusTypeList( | ||
| 129 | + convertSet(pageResult.getList(), CrmBusinessDO::getStatusTypeId)); | ||
| 130 | + List<CrmBusinessStatusDO> statusList = businessStatusService.getBusinessStatusList( | ||
| 131 | + convertSet(pageResult.getList(), CrmBusinessDO::getStatusId)); | ||
| 132 | + List<CrmCustomerDO> customerList = customerService.getCustomerList( | ||
| 133 | + convertSet(pageResult.getList(), CrmBusinessDO::getCustomerId)); | ||
| 134 | + return CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList); | ||
| 161 | } | 135 | } |
| 162 | 136 | ||
| 163 | @PutMapping("/transfer") | 137 | @PutMapping("/transfer") |
| @@ -167,34 +141,5 @@ public class CrmBusinessController { | @@ -167,34 +141,5 @@ public class CrmBusinessController { | ||
| 167 | businessService.transferBusiness(reqVO, getLoginUserId()); | 141 | businessService.transferBusiness(reqVO, getLoginUserId()); |
| 168 | return success(true); | 142 | return success(true); |
| 169 | } | 143 | } |
| 170 | - @GetMapping("/page-by-contact") | ||
| 171 | - @Operation(summary = "获得联系人的商机分页") | ||
| 172 | - @PreAuthorize("@ss.hasPermission('crm:business:query')") | ||
| 173 | - public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessContactPage(@Valid CrmContactBusinessLinkPageReqVO pageVO) { | ||
| 174 | - PageResult<CrmBusinessRespVO> pageResult = businessService.getBusinessPageByContact(pageVO); | ||
| 175 | - // 处理商机状态类型名称回显 | ||
| 176 | - Set<Long> statusTypeIds = pageResult.getList().stream() | ||
| 177 | - .map(CrmBusinessRespVO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 178 | - CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO(); | ||
| 179 | - queryStatusTypeVO.setIdList(statusTypeIds); | ||
| 180 | - List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO); | ||
| 181 | - Map<Long,String> statusTypeMap = CollectionUtils.convertMap(statusTypeList,CrmBusinessStatusTypeDO::getId,CrmBusinessStatusTypeDO::getName); | ||
| 182 | - // 处理商机状态名称回显 | ||
| 183 | - Set<Long> statusIds = pageResult.getList().stream() | ||
| 184 | - .map(CrmBusinessRespVO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet()); | ||
| 185 | - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); | ||
| 186 | - queryVO.setIdList(statusIds); | ||
| 187 | - List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO); | ||
| 188 | - Map<Long,String> statusMap = CollectionUtils.convertMap(statusList,CrmBusinessStatusDO::getId,CrmBusinessStatusDO::getName); | ||
| 189 | - // 处理客户名称回显 | ||
| 190 | - Set<Long> customerIds = CollectionUtils.convertSet(pageResult.getList(),CrmBusinessRespVO::getCustomerId); | ||
| 191 | - List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds); | ||
| 192 | - Map<Long,String> customerMap = CollectionUtils.convertMap(customerList,CrmCustomerDO::getId,CrmCustomerDO::getName); | ||
| 193 | - pageResult.getList().forEach(item -> { | ||
| 194 | - item.setStatusTypeName(statusTypeMap.get(item.getStatusTypeId())); | ||
| 195 | - item.setStatusName(statusMap.get(item.getStatusId())); | ||
| 196 | - item.setCustomerName(customerMap.get(item.getCustomerId())); | ||
| 197 | - }); | ||
| 198 | - return success(pageResult); | ||
| 199 | - } | 144 | + |
| 200 | } | 145 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java
| @@ -20,6 +20,9 @@ public class CrmBusinessPageReqVO extends PageParam { | @@ -20,6 +20,9 @@ public class CrmBusinessPageReqVO extends PageParam { | ||
| 20 | @Schema(description = "客户编号", example = "10795") | 20 | @Schema(description = "客户编号", example = "10795") |
| 21 | private Long customerId; | 21 | private Long customerId; |
| 22 | 22 | ||
| 23 | + @Schema(description = "联系人编号", example = "10795") | ||
| 24 | + private Long contactId; | ||
| 25 | + | ||
| 23 | @Schema(description = "场景类型", example = "1") | 26 | @Schema(description = "场景类型", example = "1") |
| 24 | @InEnum(CrmSceneTypeEnum.class) | 27 | @InEnum(CrmSceneTypeEnum.class) |
| 25 | private Integer sceneType; // 场景类型,为 null 时则表示全部 | 28 | private Integer sceneType; // 场景类型,为 null 时则表示全部 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java
| @@ -25,6 +25,4 @@ public class CrmBusinessRespVO extends CrmBusinessBaseVO { | @@ -25,6 +25,4 @@ public class CrmBusinessRespVO extends CrmBusinessBaseVO { | ||
| 25 | @Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中") | 25 | @Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中") |
| 26 | private String statusName; | 26 | private String statusName; |
| 27 | 27 | ||
| 28 | - @Schema(description = "联系人商机关联ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") | ||
| 29 | - private Long businessContactId; | ||
| 30 | } | 28 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| @@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert; | @@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert; | ||
| 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 15 | import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants; | 15 | import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants; |
| 16 | -import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessLinkService; | 16 | +import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; |
| 17 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; | 17 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| 18 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | 18 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 19 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 19 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| @@ -30,10 +30,6 @@ import org.springframework.security.access.prepost.PreAuthorize; | @@ -30,10 +30,6 @@ import org.springframework.security.access.prepost.PreAuthorize; | ||
| 30 | import org.springframework.validation.annotation.Validated; | 30 | import org.springframework.validation.annotation.Validated; |
| 31 | import org.springframework.web.bind.annotation.*; | 31 | import org.springframework.web.bind.annotation.*; |
| 32 | 32 | ||
| 33 | -import javax.annotation.Resource; | ||
| 34 | -import javax.servlet.http.HttpServletResponse; | ||
| 35 | -import javax.validation.Valid; | ||
| 36 | -import javax.validation.constraints.NotEmpty; | ||
| 37 | import java.io.IOException; | 33 | import java.io.IOException; |
| 38 | import java.util.Collections; | 34 | import java.util.Collections; |
| 39 | import java.util.List; | 35 | import java.util.List; |
| @@ -63,7 +59,7 @@ public class CrmContactController { | @@ -63,7 +59,7 @@ public class CrmContactController { | ||
| 63 | private AdminUserApi adminUserApi; | 59 | private AdminUserApi adminUserApi; |
| 64 | 60 | ||
| 65 | @Resource | 61 | @Resource |
| 66 | - private CrmContactBusinessLinkService contactBusinessLinkService; | 62 | + private CrmContactBusinessService contactBusinessLinkService; |
| 67 | 63 | ||
| 68 | @PostMapping("/create") | 64 | @PostMapping("/create") |
| 69 | @Operation(summary = "创建联系人") | 65 | @Operation(summary = "创建联系人") |
| @@ -103,7 +99,7 @@ public class CrmContactController { | @@ -103,7 +99,7 @@ public class CrmContactController { | ||
| 103 | NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | 99 | NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |
| 104 | // 2. 获取客户信息 | 100 | // 2. 获取客户信息 |
| 105 | List<CrmCustomerDO> customerList = customerService.getCustomerList( | 101 | List<CrmCustomerDO> customerList = customerService.getCustomerList( |
| 106 | - Collections.singletonList(contact.getCustomerId()), getLoginUserId()); | 102 | + Collections.singletonList(contact.getCustomerId())); |
| 107 | // 3. 直属上级 | 103 | // 3. 直属上级 |
| 108 | List<CrmContactDO> parentContactList = contactService.getContactList( | 104 | List<CrmContactDO> parentContactList = contactService.getContactList( |
| 109 | Collections.singletonList(contact.getParentId()), getLoginUserId()); | 105 | Collections.singletonList(contact.getParentId()), getLoginUserId()); |
| @@ -148,23 +144,6 @@ public class CrmContactController { | @@ -148,23 +144,6 @@ public class CrmContactController { | ||
| 148 | convertDetailContactPage(pageResult).getList()); | 144 | convertDetailContactPage(pageResult).getList()); |
| 149 | } | 145 | } |
| 150 | 146 | ||
| 151 | - @DeleteMapping("/delete-batch-business") | ||
| 152 | - @Operation(summary = "批量删除联系人商机关联") | ||
| 153 | - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')") | ||
| 154 | - public CommonResult<Boolean> deleteContactBusinessLinkBatch(@Valid @RequestBody List<Long> businessContactIds) { | ||
| 155 | - contactBusinessLinkService.deleteContactBusinessLink(businessContactIds); | ||
| 156 | - return success(true); | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - @PostMapping("/create-batch-business") | ||
| 160 | - @Operation(summary = "创建联系人商机关联") | ||
| 161 | - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')") | ||
| 162 | - public CommonResult<Boolean> createContactBusinessLinkBatch( | ||
| 163 | - @Valid @NotEmpty @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) { | ||
| 164 | - contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO); | ||
| 165 | - return success(true); | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | /** | 147 | /** |
| 169 | * 转换成详细的联系人分页,即读取关联信息 | 148 | * 转换成详细的联系人分页,即读取关联信息 |
| 170 | * | 149 | * |
| @@ -178,7 +157,7 @@ public class CrmContactController { | @@ -178,7 +157,7 @@ public class CrmContactController { | ||
| 178 | } | 157 | } |
| 179 | // 1. 获取客户列表 | 158 | // 1. 获取客户列表 |
| 180 | List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList( | 159 | List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList( |
| 181 | - convertSet(contactList, CrmContactDO::getCustomerId), getLoginUserId()); | 160 | + convertSet(contactList, CrmContactDO::getCustomerId)); |
| 182 | // 2. 获取创建人、负责人列表 | 161 | // 2. 获取创建人、负责人列表 |
| 183 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, | 162 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, |
| 184 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | 163 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |
| @@ -196,4 +175,22 @@ public class CrmContactController { | @@ -196,4 +175,22 @@ public class CrmContactController { | ||
| 196 | return success(true); | 175 | return success(true); |
| 197 | } | 176 | } |
| 198 | 177 | ||
| 178 | + // ================== 关联/取关商机 =================== | ||
| 179 | + | ||
| 180 | + @PostMapping("/create-business-list") | ||
| 181 | + @Operation(summary = "创建联系人与商机的关联") | ||
| 182 | + @PreAuthorize("@ss.hasPermission('crm:contact:create-business')") | ||
| 183 | + public CommonResult<Boolean> createContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO createReqVO) { | ||
| 184 | + contactBusinessLinkService.createContactBusinessList(createReqVO); | ||
| 185 | + return success(true); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + @DeleteMapping("/delete-business-list") | ||
| 189 | + @Operation(summary = "删除联系人与商机的关联") | ||
| 190 | + @PreAuthorize("@ss.hasPermission('crm:contact:delete-business')") | ||
| 191 | + public CommonResult<Boolean> deleteContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO deleteReqVO) { | ||
| 192 | + contactBusinessLinkService.deleteContactBusinessList(deleteReqVO); | ||
| 193 | + return success(true); | ||
| 194 | + } | ||
| 195 | + | ||
| 199 | } | 196 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessLinkPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.EqualsAndHashCode; | ||
| 7 | -import lombok.ToString; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import java.time.LocalDateTime; | ||
| 11 | - | ||
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | - | ||
| 14 | -@Schema(description = "管理后台 - CRM 联系人商机关联分页 Request VO") | ||
| 15 | -@Data | ||
| 16 | -@EqualsAndHashCode(callSuper = true) | ||
| 17 | -@ToString(callSuper = true) | ||
| 18 | -public class CrmContactBusinessLinkPageReqVO extends PageParam { | ||
| 19 | - | ||
| 20 | - @Schema(description = "联系人编号", example = "20878") | ||
| 21 | - private Long contactId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "商机编号", example = "7638") | ||
| 24 | - private Long businessId; | ||
| 25 | - | ||
| 26 | - @Schema(description = "创建时间") | ||
| 27 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 28 | - private LocalDateTime[] createTime; | ||
| 29 | - | ||
| 30 | -} | ||
| 31 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessLinkRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||
| 2 | - | ||
| 3 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | - | ||
| 7 | -import java.time.LocalDateTime; | ||
| 8 | - | ||
| 9 | -@Schema(description = "管理后台 - CRM 联系人商机关联 Response VO") | ||
| 10 | -@Data | ||
| 11 | -public class CrmContactBusinessLinkRespVO { | ||
| 12 | - | ||
| 13 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220") | ||
| 14 | - @ExcelProperty("主键") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") | ||
| 18 | - private Long contactId; | ||
| 19 | - | ||
| 20 | - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") | ||
| 21 | - private Long businessId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 24 | - private LocalDateTime createTime; | ||
| 25 | - | ||
| 26 | -} | ||
| 27 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessLinkSaveReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessReqVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 4 | import lombok.Data; | 6 | import lombok.Data; |
| 5 | 7 | ||
| 6 | -import jakarta.validation.constraints.NotNull; | 8 | +import java.util.List; |
| 7 | 9 | ||
| 8 | -@Schema(description = "管理后台 - CRM 联系人商机关联新增/修改 Request VO") | 10 | +@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 用于关联,取消关联的操作 |
| 9 | @Data | 11 | @Data |
| 10 | -public class CrmContactBusinessLinkSaveReqVO { | ||
| 11 | - | ||
| 12 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220") | ||
| 13 | - private Long id; | 12 | +public class CrmContactBusinessReqVO { |
| 14 | 13 | ||
| 15 | @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") | 14 | @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") |
| 16 | @NotNull(message="联系人不能为空") | 15 | @NotNull(message="联系人不能为空") |
| 17 | private Long contactId; | 16 | private Long contactId; |
| 18 | 17 | ||
| 19 | - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") | ||
| 20 | - @NotNull(message="商机不能为空") | ||
| 21 | - private Long businessId; | 18 | + @Schema(description = "商机编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") |
| 19 | + @NotEmpty(message="商机不能为空") | ||
| 20 | + private List<Long> businessIds; | ||
| 22 | 21 | ||
| 23 | } | 22 | } |
| 24 | \ No newline at end of file | 23 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/CrmContactBusinessLinkController.java deleted
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| @@ -124,7 +124,7 @@ public class CrmContractController { | @@ -124,7 +124,7 @@ public class CrmContractController { | ||
| 124 | } | 124 | } |
| 125 | // 1. 获取客户列表 | 125 | // 1. 获取客户列表 |
| 126 | List<CrmCustomerDO> customerList = customerService.getCustomerList( | 126 | List<CrmCustomerDO> customerList = customerService.getCustomerList( |
| 127 | - convertSet(contactList, CrmContractDO::getCustomerId), getLoginUserId()); | 127 | + convertSet(contactList, CrmContractDO::getCustomerId)); |
| 128 | // 2. 获取创建人、负责人列表 | 128 | // 2. 获取创建人、负责人列表 |
| 129 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, | 129 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, |
| 130 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | 130 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java
| @@ -131,7 +131,7 @@ public class CrmReceivableController { | @@ -131,7 +131,7 @@ public class CrmReceivableController { | ||
| 131 | } | 131 | } |
| 132 | // 1. 获取客户列表 | 132 | // 1. 获取客户列表 |
| 133 | List<CrmCustomerDO> customerList = customerService.getCustomerList( | 133 | List<CrmCustomerDO> customerList = customerService.getCustomerList( |
| 134 | - convertSet(receivableList, CrmReceivableDO::getCustomerId), getLoginUserId()); | 134 | + convertSet(receivableList, CrmReceivableDO::getCustomerId)); |
| 135 | // 2. 获取创建人、负责人列表 | 135 | // 2. 获取创建人、负责人列表 |
| 136 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList, | 136 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList, |
| 137 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | 137 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java
| @@ -135,7 +135,7 @@ public class CrmReceivablePlanController { | @@ -135,7 +135,7 @@ public class CrmReceivablePlanController { | ||
| 135 | } | 135 | } |
| 136 | // 1. 获取客户列表 | 136 | // 1. 获取客户列表 |
| 137 | List<CrmCustomerDO> customerList = customerService.getCustomerList( | 137 | List<CrmCustomerDO> customerList = customerService.getCustomerList( |
| 138 | - convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId), getLoginUserId()); | 138 | + convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId)); |
| 139 | // 2. 获取创建人、负责人列表 | 139 | // 2. 获取创建人、负责人列表 |
| 140 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList, | 140 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList, |
| 141 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | 141 | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/CrmContactConvert.java
| 1 | package cn.iocoder.yudao.module.crm.convert.contact; | 1 | package cn.iocoder.yudao.module.crm.convert.contact; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 4 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | 5 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; |
| 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| @@ -13,7 +14,6 @@ import org.mapstruct.factory.Mappers; | @@ -13,7 +14,6 @@ import org.mapstruct.factory.Mappers; | ||
| 13 | 14 | ||
| 14 | import java.util.List; | 15 | import java.util.List; |
| 15 | import java.util.Map; | 16 | import java.util.Map; |
| 16 | -import java.util.stream.Collectors; | ||
| 17 | 17 | ||
| 18 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | 18 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 19 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | 19 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| @@ -55,16 +55,16 @@ public interface CrmContactConvert { | @@ -55,16 +55,16 @@ public interface CrmContactConvert { | ||
| 55 | * | 55 | * |
| 56 | * @param contactDO 联系人 | 56 | * @param contactDO 联系人 |
| 57 | * @param userMap 用户列表 | 57 | * @param userMap 用户列表 |
| 58 | - * @param crmCustomerDOList 客户 | 58 | + * @param customerDOList 客户 |
| 59 | * @return ContactRespVO | 59 | * @return ContactRespVO |
| 60 | */ | 60 | */ |
| 61 | - default CrmContactRespVO convert(CrmContactDO contactDO, Map<Long, AdminUserRespDTO> userMap, List<CrmCustomerDO> crmCustomerDOList, | ||
| 62 | - List<CrmContactDO> contactList) { | 61 | + default CrmContactRespVO convert(CrmContactDO contactDO, Map<Long, AdminUserRespDTO> userMap, |
| 62 | + List<CrmCustomerDO> customerDOList, List<CrmContactDO> contactList) { | ||
| 63 | CrmContactRespVO contactVO = convert(contactDO); | 63 | CrmContactRespVO contactVO = convert(contactDO); |
| 64 | setUserInfo(contactVO, userMap); | 64 | setUserInfo(contactVO, userMap); |
| 65 | - Map<Long, CrmCustomerDO> ustomerMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId, v -> v)); | ||
| 66 | - Map<Long, CrmContactDO> contactMap = contactList.stream().collect(Collectors.toMap(CrmContactDO::getId, v -> v)); | ||
| 67 | - findAndThen(ustomerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName())); | 65 | + Map<Long, CrmCustomerDO> customerMap = CollectionUtils.convertMap(customerDOList, CrmCustomerDO::getId); |
| 66 | + Map<Long, CrmContactDO> contactMap = CollectionUtils.convertMap(contactList, CrmContactDO::getId); | ||
| 67 | + findAndThen(customerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName())); | ||
| 68 | findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName())); | 68 | findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName())); |
| 69 | return contactVO; | 69 | return contactVO; |
| 70 | } | 70 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessLinkDO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessDO.java
| @@ -2,14 +2,13 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contact; | @@ -2,14 +2,13 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contact; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | ||
| 6 | import com.baomidou.mybatisplus.annotation.KeySequence; | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 7 | import com.baomidou.mybatisplus.annotation.TableId; | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 8 | import com.baomidou.mybatisplus.annotation.TableName; | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| 9 | import lombok.*; | 8 | import lombok.*; |
| 10 | 9 | ||
| 11 | /** | 10 | /** |
| 12 | - * CRM 联系人商机关联 DO | 11 | + * CRM 联系人与商机的关联 DO |
| 13 | * | 12 | * |
| 14 | * @author 芋道源码 | 13 | * @author 芋道源码 |
| 15 | */ | 14 | */ |
| @@ -21,7 +20,7 @@ import lombok.*; | @@ -21,7 +20,7 @@ import lombok.*; | ||
| 21 | @Builder | 20 | @Builder |
| 22 | @NoArgsConstructor | 21 | @NoArgsConstructor |
| 23 | @AllArgsConstructor | 22 | @AllArgsConstructor |
| 24 | -public class CrmContactBusinessLinkDO extends BaseDO { | 23 | +public class CrmContactBusinessDO extends BaseDO { |
| 25 | 24 | ||
| 26 | /** | 25 | /** |
| 27 | * 主键 | 26 | * 主键 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| @@ -30,7 +30,14 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | @@ -30,7 +30,14 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | ||
| 30 | 30 | ||
| 31 | default PageResult<CrmBusinessDO> selectPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { | 31 | default PageResult<CrmBusinessDO> selectPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { |
| 32 | return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmBusinessDO>() | 32 | return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmBusinessDO>() |
| 33 | - .eq(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | 33 | + .eq(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 |
| 34 | + .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) | ||
| 35 | + .orderByDesc(CrmBusinessDO::getId)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + default PageResult<CrmBusinessDO> selectPageByContactId(CrmBusinessPageReqVO pageReqVO, Collection<Long> businessIds) { | ||
| 39 | + return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmBusinessDO>() | ||
| 40 | + .in(CrmBusinessDO::getId, businessIds) // 指定商机编号 | ||
| 34 | .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) | 41 | .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) |
| 35 | .orderByDesc(CrmBusinessDO::getId)); | 42 | .orderByDesc(CrmBusinessDO::getId)); |
| 36 | } | 43 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contactbusinesslink/CrmContactBusinessLinkMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO; | ||
| 8 | -import org.apache.ibatis.annotations.Mapper; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * CRM 联系人商机关联 Mapper | ||
| 12 | - * | ||
| 13 | - * @author 芋道源码 | ||
| 14 | - */ | ||
| 15 | -@Mapper | ||
| 16 | -public interface CrmContactBusinessLinkMapper extends BaseMapperX<CrmContactBusinessLinkDO> { | ||
| 17 | - | ||
| 18 | - default PageResult<CrmContactBusinessLinkDO> selectPage(CrmContactBusinessLinkPageReqVO reqVO) { | ||
| 19 | - return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>() | ||
| 20 | - .eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId()) | ||
| 21 | - .eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId()) | ||
| 22 | - .betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime()) | ||
| 23 | - .orderByDesc(CrmContactBusinessLinkDO::getId)); | ||
| 24 | - } | ||
| 25 | - default PageResult<CrmContactBusinessLinkDO> selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) { | ||
| 26 | - return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>() | ||
| 27 | - .eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId()) | ||
| 28 | - .orderByDesc(CrmContactBusinessLinkDO::getId)); | ||
| 29 | - } | ||
| 30 | -} | ||
| 31 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contactbusinesslink/CrmContactBusinessMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | ||
| 5 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | + | ||
| 8 | +import java.util.Collection; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * CRM 联系人与商机的关联 Mapper | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@Mapper | ||
| 17 | +public interface CrmContactBusinessMapper extends BaseMapperX<CrmContactBusinessDO> { | ||
| 18 | + | ||
| 19 | + default CrmContactBusinessDO selectByContactIdAndBusinessId(Long contactId, Long businessId) { | ||
| 20 | + return selectOne(CrmContactBusinessDO::getContactId, contactId, | ||
| 21 | + CrmContactBusinessDO::getBusinessId, businessId); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + default void deleteByContactIdAndBusinessId(Long contactId, Collection<Long> businessIds) { | ||
| 25 | + delete(new LambdaQueryWrapper<CrmContactBusinessDO>() | ||
| 26 | + .eq(CrmContactBusinessDO::getContactId, contactId) | ||
| 27 | + .in(CrmContactBusinessDO::getBusinessId, businessIds)); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + default List<CrmContactBusinessDO> selectListByContactId(Long contactId) { | ||
| 31 | + return selectList(CrmContactBusinessDO::getContactId, contactId); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | +} | ||
| 0 | \ No newline at end of file | 35 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| @@ -5,10 +5,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi | @@ -5,10 +5,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi | ||
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; | ||
| 9 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | ||
| 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | ||
| 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 13 | import jakarta.validation.Valid; | 11 | import jakarta.validation.Valid; |
| 14 | 12 | ||
| @@ -78,11 +76,21 @@ public interface CrmBusinessService { | @@ -78,11 +76,21 @@ public interface CrmBusinessService { | ||
| 78 | * 数据权限:基于 {@link CrmCustomerDO} 读取 | 76 | * 数据权限:基于 {@link CrmCustomerDO} 读取 |
| 79 | * | 77 | * |
| 80 | * @param pageReqVO 分页查询 | 78 | * @param pageReqVO 分页查询 |
| 81 | - * @return 联系人分页 | 79 | + * @return 商机分页 |
| 82 | */ | 80 | */ |
| 83 | PageResult<CrmBusinessDO> getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO); | 81 | PageResult<CrmBusinessDO> getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO); |
| 84 | 82 | ||
| 85 | /** | 83 | /** |
| 84 | + * 获得商机分页,基于指定联系人 | ||
| 85 | + * | ||
| 86 | + * 数据权限:基于 {@link CrmContactDO} 读取 | ||
| 87 | + * | ||
| 88 | + * @param pageReqVO 分页参数 | ||
| 89 | + * @return 商机分页 | ||
| 90 | + */ | ||
| 91 | + PageResult<CrmBusinessDO> getBusinessPageByContact(CrmBusinessPageReqVO pageReqVO); | ||
| 92 | + | ||
| 93 | + /** | ||
| 86 | * 商机转移 | 94 | * 商机转移 |
| 87 | * | 95 | * |
| 88 | * @param reqVO 请求 | 96 | * @param reqVO 请求 |
| @@ -90,10 +98,4 @@ public interface CrmBusinessService { | @@ -90,10 +98,4 @@ public interface CrmBusinessService { | ||
| 90 | */ | 98 | */ |
| 91 | void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId); | 99 | void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId); |
| 92 | 100 | ||
| 93 | - /** | ||
| 94 | - * 获取联系人商机列表 | ||
| 95 | - * @param pageReqVO 分页参数 | ||
| 96 | - * @return 联系人商机 | ||
| 97 | - */ | ||
| 98 | - PageResult<CrmBusinessRespVO> getBusinessPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO); | ||
| 99 | } | 101 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -7,20 +7,14 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi | @@ -7,20 +7,14 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi | ||
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; |
| 10 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 11 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 12 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; | ||
| 13 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO; | ||
| 14 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | ||
| 15 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; | 10 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; |
| 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 17 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO; | ||
| 18 | -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | 12 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; |
| 19 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; | 13 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; |
| 20 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 14 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 21 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | 15 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 22 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; | 16 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| 23 | -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | 17 | +import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; |
| 24 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; | 18 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| 25 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | 19 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 26 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | 20 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| @@ -31,10 +25,9 @@ import org.springframework.validation.annotation.Validated; | @@ -31,10 +25,9 @@ import org.springframework.validation.annotation.Validated; | ||
| 31 | 25 | ||
| 32 | import java.util.Collection; | 26 | import java.util.Collection; |
| 33 | import java.util.List; | 27 | import java.util.List; |
| 34 | -import java.util.Map; | ||
| 35 | -import java.util.Set; | ||
| 36 | 28 | ||
| 37 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 38 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | 31 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; |
| 39 | 32 | ||
| 40 | /** | 33 | /** |
| @@ -48,14 +41,13 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -48,14 +41,13 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 48 | 41 | ||
| 49 | @Resource | 42 | @Resource |
| 50 | private CrmBusinessMapper businessMapper; | 43 | private CrmBusinessMapper businessMapper; |
| 51 | - @Resource | ||
| 52 | - private CrmCustomerService customerService; | ||
| 53 | 44 | ||
| 54 | @Resource | 45 | @Resource |
| 55 | - private CrmPermissionService crmPermissionService; | ||
| 56 | - | 46 | + private CrmPermissionService permissionService; |
| 57 | @Resource | 47 | @Resource |
| 58 | - private CrmContactService crmContactService; | 48 | + private CrmContactService contactService; |
| 49 | + @Resource | ||
| 50 | + private CrmContactBusinessService contactBusinessService; | ||
| 59 | 51 | ||
| 60 | @Override | 52 | @Override |
| 61 | @Transactional(rollbackFor = Exception.class) | 53 | @Transactional(rollbackFor = Exception.class) |
| @@ -65,7 +57,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -65,7 +57,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 65 | businessMapper.insert(business); | 57 | businessMapper.insert(business); |
| 66 | 58 | ||
| 67 | // 创建数据权限 | 59 | // 创建数据权限 |
| 68 | - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) | 60 | + permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) |
| 69 | .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 | 61 | .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 |
| 70 | 62 | ||
| 71 | // 返回 | 63 | // 返回 |
| @@ -93,7 +85,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -93,7 +85,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 93 | // 删除 | 85 | // 删除 |
| 94 | businessMapper.deleteById(id); | 86 | businessMapper.deleteById(id); |
| 95 | // 删除数据权限 | 87 | // 删除数据权限 |
| 96 | - crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_BUSINESS.getType(), id); | 88 | + permissionService.deletePermission(CrmBizTypeEnum.CRM_BUSINESS.getType(), id); |
| 97 | } | 89 | } |
| 98 | 90 | ||
| 99 | private CrmBusinessDO validateBusinessExists(Long id) { | 91 | private CrmBusinessDO validateBusinessExists(Long id) { |
| @@ -130,42 +122,32 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -130,42 +122,32 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 130 | } | 122 | } |
| 131 | 123 | ||
| 132 | @Override | 124 | @Override |
| 125 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#pageReqVO.contactId", level = CrmPermissionLevelEnum.READ) | ||
| 126 | + public PageResult<CrmBusinessDO> getBusinessPageByContact(CrmBusinessPageReqVO pageReqVO) { | ||
| 127 | + // 1. 查询关联的商机编号 | ||
| 128 | + List<CrmContactBusinessDO> contactBusinessList = contactBusinessService.getContactBusinessListByContactId( | ||
| 129 | + pageReqVO.getContactId()); | ||
| 130 | + if (CollUtil.isEmpty(contactBusinessList)) { | ||
| 131 | + return PageResult.empty(); | ||
| 132 | + } | ||
| 133 | + // 2. 查询商机分页 | ||
| 134 | + return businessMapper.selectPageByContactId(pageReqVO, | ||
| 135 | + convertSet(contactBusinessList, CrmContactBusinessDO::getBusinessId)); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + @Override | ||
| 133 | @Transactional(rollbackFor = Exception.class) | 139 | @Transactional(rollbackFor = Exception.class) |
| 134 | public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { | 140 | public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { |
| 135 | // 1 校验商机是否存在 | 141 | // 1 校验商机是否存在 |
| 136 | validateBusinessExists(reqVO.getId()); | 142 | validateBusinessExists(reqVO.getId()); |
| 137 | 143 | ||
| 138 | // 2.1 数据权限转移 | 144 | // 2.1 数据权限转移 |
| 139 | - crmPermissionService.transferPermission( | 145 | + permissionService.transferPermission( |
| 140 | CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); | 146 | CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); |
| 141 | // 2.2 设置新的负责人 | 147 | // 2.2 设置新的负责人 |
| 142 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | 148 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); |
| 143 | 149 | ||
| 144 | // 3. TODO 记录转移日志 | 150 | // 3. TODO 记录转移日志 |
| 145 | } | 151 | } |
| 146 | - @Override | ||
| 147 | - public PageResult<CrmBusinessRespVO> getBusinessPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 148 | - CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO(); | ||
| 149 | - crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId()); | ||
| 150 | - PageResult<CrmContactBusinessLinkDO> businessLinkDOS = crmContactService.selectBusinessPageByContact(crmContactBusinessLinkPageReqVO); | ||
| 151 | - if (CollUtil.isEmpty(businessLinkDOS.getList())){ | ||
| 152 | - return PageResult.empty(); | ||
| 153 | - } | ||
| 154 | - List<CrmBusinessDO> businessList = this.getBusinessList(CollectionUtils.convertList(businessLinkDOS.getList(), | ||
| 155 | - CrmContactBusinessLinkDO::getBusinessId)); | ||
| 156 | - if (CollUtil.isEmpty(businessList)){ | ||
| 157 | - return PageResult.empty(); | ||
| 158 | - } | ||
| 159 | - PageResult<CrmBusinessRespVO> pageResult = new PageResult<CrmBusinessRespVO>(); | ||
| 160 | - List<CrmBusinessRespVO> respVOList = BeanUtils.toBean(businessList,CrmBusinessRespVO.class); | ||
| 161 | - Map<Long,Long> businessContactMap = CollectionUtils.convertMap(businessLinkDOS.getList(), | ||
| 162 | - CrmContactBusinessLinkDO::getBusinessId,CrmContactBusinessLinkDO::getId); | ||
| 163 | - respVOList.forEach(item -> { | ||
| 164 | - item.setBusinessContactId(businessContactMap.get(item.getId())); | ||
| 165 | - }); | ||
| 166 | - pageResult.setList(respVOList); | ||
| 167 | - pageResult.setTotal(businessLinkDOS.getTotal()); | ||
| 168 | - return pageResult; | ||
| 169 | 152 | ||
| 170 | - } | ||
| 171 | } | 153 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java
| @@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusine | @@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusine | ||
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| 8 | 8 | ||
| 9 | import jakarta.validation.Valid; | 9 | import jakarta.validation.Valid; |
| 10 | + | ||
| 11 | +import java.util.Collection; | ||
| 10 | import java.util.List; | 12 | import java.util.List; |
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| @@ -64,4 +66,12 @@ public interface CrmBusinessStatusService { | @@ -64,4 +66,12 @@ public interface CrmBusinessStatusService { | ||
| 64 | */ | 66 | */ |
| 65 | List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO); | 67 | List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO); |
| 66 | 68 | ||
| 69 | + /** | ||
| 70 | + * 获得商机状态列表 | ||
| 71 | + * | ||
| 72 | + * @param ids 编号数组 | ||
| 73 | + * @return 商机状态列表 | ||
| 74 | + */ | ||
| 75 | + List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids); | ||
| 76 | + | ||
| 67 | } | 77 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java
| @@ -12,6 +12,7 @@ import org.springframework.validation.annotation.Validated; | @@ -12,6 +12,7 @@ import org.springframework.validation.annotation.Validated; | ||
| 12 | 12 | ||
| 13 | import jakarta.annotation.Resource; | 13 | import jakarta.annotation.Resource; |
| 14 | 14 | ||
| 15 | +import java.util.Collection; | ||
| 15 | import java.util.List; | 16 | import java.util.List; |
| 16 | 17 | ||
| 17 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -77,4 +78,9 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { | @@ -77,4 +78,9 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { | ||
| 77 | return businessStatusMapper.selectList(queryVO); | 78 | return businessStatusMapper.selectList(queryVO); |
| 78 | } | 79 | } |
| 79 | 80 | ||
| 81 | + @Override | ||
| 82 | + public List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids) { | ||
| 83 | + return businessStatusMapper.selectBatchIds(ids); | ||
| 84 | + } | ||
| 85 | + | ||
| 80 | } | 86 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java
| @@ -5,8 +5,9 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusiness | @@ -5,8 +5,9 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusiness | ||
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; |
| 8 | - | ||
| 9 | import jakarta.validation.Valid; | 8 | import jakarta.validation.Valid; |
| 9 | + | ||
| 10 | +import java.util.Collection; | ||
| 10 | import java.util.List; | 11 | import java.util.List; |
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| @@ -63,4 +64,12 @@ public interface CrmBusinessStatusTypeService { | @@ -63,4 +64,12 @@ public interface CrmBusinessStatusTypeService { | ||
| 63 | */ | 64 | */ |
| 64 | List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO); | 65 | List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO); |
| 65 | 66 | ||
| 67 | + /** | ||
| 68 | + * 获得商机状态类型列表 | ||
| 69 | + * | ||
| 70 | + * @param ids 编号数组 | ||
| 71 | + * @return 商机状态类型列表 | ||
| 72 | + */ | ||
| 73 | + List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids); | ||
| 74 | + | ||
| 66 | } | 75 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java
| @@ -17,6 +17,8 @@ import org.springframework.transaction.annotation.Transactional; | @@ -17,6 +17,8 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 17 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 18 | 18 | ||
| 19 | import jakarta.annotation.Resource; | 19 | import jakarta.annotation.Resource; |
| 20 | + | ||
| 21 | +import java.util.Collection; | ||
| 20 | import java.util.List; | 22 | import java.util.List; |
| 21 | 23 | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 24 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -118,4 +120,9 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe | @@ -118,4 +120,9 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe | ||
| 118 | return businessStatusTypeMapper.selectList(queryVO); | 120 | return businessStatusTypeMapper.selectList(queryVO); |
| 119 | } | 121 | } |
| 120 | 122 | ||
| 123 | + @Override | ||
| 124 | + public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids) { | ||
| 125 | + return businessStatusTypeMapper.selectBatchIds(ids); | ||
| 126 | + } | ||
| 127 | + | ||
| 121 | } | 128 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessLinkService.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.contact; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkSaveReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO; | ||
| 8 | - | ||
| 9 | -import jakarta.validation.Valid; | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * CRM 联系人商机关联 Service 接口 | ||
| 14 | - * | ||
| 15 | - * @author 芋道源码 | ||
| 16 | - */ | ||
| 17 | -public interface CrmContactBusinessLinkService { | ||
| 18 | - | ||
| 19 | - /** | ||
| 20 | - * 创建联系人商机关联 | ||
| 21 | - * | ||
| 22 | - * @param createReqVO 创建信息 | ||
| 23 | - * @return 编号 | ||
| 24 | - */ | ||
| 25 | - Long createContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO createReqVO); | ||
| 26 | - | ||
| 27 | - /** | ||
| 28 | - * 创建联系人商机关联 | ||
| 29 | - * | ||
| 30 | - * @param createReqVO 创建信息 | ||
| 31 | - */ | ||
| 32 | - void createContactBusinessLinkBatch(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO); | ||
| 33 | - | ||
| 34 | - /** | ||
| 35 | - * 更新联系人商机关联 | ||
| 36 | - * | ||
| 37 | - * @param updateReqVO 更新信息 | ||
| 38 | - */ | ||
| 39 | - void updateContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO updateReqVO); | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * 删除联系人商机关联 | ||
| 43 | - * | ||
| 44 | - * @param businessContactIds 删除列表 | ||
| 45 | - */ | ||
| 46 | - void deleteContactBusinessLink(@Valid List<Long> businessContactIds); | ||
| 47 | - | ||
| 48 | - /** | ||
| 49 | - * 获得联系人商机关联 | ||
| 50 | - * | ||
| 51 | - * @param id 编号 | ||
| 52 | - * @return 联系人商机关联 | ||
| 53 | - */ | ||
| 54 | - CrmContactBusinessLinkDO getContactBusinessLink(Long id); | ||
| 55 | - | ||
| 56 | - /** | ||
| 57 | - * 获得联系人商机关联分页 | ||
| 58 | - * | ||
| 59 | - * @param pageReqVO 编号 | ||
| 60 | - * @return 联系人商机关联 | ||
| 61 | - */ | ||
| 62 | - PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO); | ||
| 63 | - | ||
| 64 | - /** | ||
| 65 | - * 获得联系人商机关联分页 | ||
| 66 | - * | ||
| 67 | - * @param pageReqVO 分页查询 | ||
| 68 | - * @return 联系人商机关联分页 | ||
| 69 | - */ | ||
| 70 | - PageResult<CrmContactBusinessLinkDO> getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO); | ||
| 71 | - | ||
| 72 | -} | ||
| 73 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessLinkServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.contact; | ||
| 2 | - | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | -import cn.hutool.core.lang.Assert; | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 7 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 8 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 9 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | ||
| 10 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO; | ||
| 11 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkSaveReqVO; | ||
| 12 | -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; | ||
| 13 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||
| 14 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO; | ||
| 15 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | ||
| 16 | -import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper; | ||
| 17 | -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 18 | -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | ||
| 19 | -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | ||
| 20 | -import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants; | ||
| 21 | -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; | ||
| 22 | -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; | ||
| 23 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 24 | -import org.springframework.stereotype.Service; | ||
| 25 | -import org.springframework.validation.annotation.Validated; | ||
| 26 | - | ||
| 27 | -import javax.annotation.Resource; | ||
| 28 | -import java.util.ArrayList; | ||
| 29 | -import java.util.List; | ||
| 30 | - | ||
| 31 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 32 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 33 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | ||
| 34 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_BUSINESS_LINK_NOT_EXISTS; | ||
| 35 | - | ||
| 36 | -// TODO @puhui999:数据权限的校验;每个操作; | ||
| 37 | -/** | ||
| 38 | - * 联系人商机关联 Service 实现类 | ||
| 39 | - * | ||
| 40 | - * @author 芋道源码 | ||
| 41 | - */ | ||
| 42 | -@Service | ||
| 43 | -@Validated | ||
| 44 | -public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLinkService { | ||
| 45 | - | ||
| 46 | - @Resource | ||
| 47 | - private CrmContactBusinessLinkMapper contactBusinessLinkMapper; | ||
| 48 | - @Resource | ||
| 49 | - private CrmBusinessService crmBusinessService; | ||
| 50 | - | ||
| 51 | - @Resource | ||
| 52 | - private CrmContactService crmContactService; | ||
| 53 | - | ||
| 54 | - @Override | ||
| 55 | - public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) { | ||
| 56 | - CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class); | ||
| 57 | - contactBusinessLinkMapper.insert(contactBusinessLink); | ||
| 58 | - return contactBusinessLink.getId(); | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - @Override | ||
| 62 | - public void createContactBusinessLinkBatch(List<CrmContactBusinessLinkSaveReqVO> createReqVOList) { | ||
| 63 | - // 插入 | ||
| 64 | - CrmContactDO contactDO = crmContactService.getContact(createReqVOList.stream().findFirst().get().getContactId()); | ||
| 65 | - Assert.notNull(contactDO,ErrorCodeConstants.CONTACT_NOT_EXISTS.getMsg()); | ||
| 66 | - List<CrmContactBusinessLinkDO> saveDoList = new ArrayList<CrmContactBusinessLinkDO>(); | ||
| 67 | - createReqVOList.forEach(item -> { | ||
| 68 | - CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId()); | ||
| 69 | - if(crmBusinessDO == null){ | ||
| 70 | - throw exception(BUSINESS_NOT_EXISTS); | ||
| 71 | - } | ||
| 72 | - // 判重 | ||
| 73 | - CrmContactBusinessLinkDO crmContactBusinessLinkDO = contactBusinessLinkMapper.selectOne(new LambdaQueryWrapper<CrmContactBusinessLinkDO>() | ||
| 74 | - .eq(CrmContactBusinessLinkDO::getBusinessId,item.getBusinessId()) | ||
| 75 | - .eq(CrmContactBusinessLinkDO::getContactId,item.getContactId())); | ||
| 76 | - if(crmContactBusinessLinkDO == null){ | ||
| 77 | - saveDoList.add(BeanUtils.toBean(item,CrmContactBusinessLinkDO.class)); | ||
| 78 | - } | ||
| 79 | - }); | ||
| 80 | - contactBusinessLinkMapper.insertBatch(saveDoList); | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - @Override | ||
| 84 | - public void updateContactBusinessLink(CrmContactBusinessLinkSaveReqVO updateReqVO) { | ||
| 85 | - // 校验存在 | ||
| 86 | - validateContactBusinessLinkExists(updateReqVO.getId()); | ||
| 87 | - // 更新 | ||
| 88 | - CrmContactBusinessLinkDO updateObj = BeanUtils.toBean(updateReqVO, CrmContactBusinessLinkDO.class); | ||
| 89 | - contactBusinessLinkMapper.updateById(updateObj); | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - @Override | ||
| 93 | - public void deleteContactBusinessLink(List<Long> businessContactIds) { | ||
| 94 | - // 删除 | ||
| 95 | - contactBusinessLinkMapper.deleteBatchIds(businessContactIds); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - private void validateContactBusinessLinkExists(Long id) { | ||
| 99 | - if (contactBusinessLinkMapper.selectById(id) == null) { | ||
| 100 | - throw exception(CONTACT_BUSINESS_LINK_NOT_EXISTS); | ||
| 101 | - } | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - @Override | ||
| 105 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.READ) | ||
| 106 | - public CrmContactBusinessLinkDO getContactBusinessLink(Long id) { | ||
| 107 | - return contactBusinessLinkMapper.selectById(id); | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - @Override | ||
| 111 | - public PageResult<CrmBusinessRespVO> getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 112 | - CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO(); | ||
| 113 | - crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId()); | ||
| 114 | - PageResult<CrmContactBusinessLinkDO> businessLinkDOS = contactBusinessLinkMapper.selectPageByContact(crmContactBusinessLinkPageReqVO); | ||
| 115 | - List<CrmBusinessDO> businessDOS = crmBusinessService.getBusinessList(CollectionUtils.convertList(businessLinkDOS.getList(), | ||
| 116 | - CrmContactBusinessLinkDO::getBusinessId), getLoginUserId()); | ||
| 117 | - PageResult<CrmBusinessRespVO> pageResult = new PageResult<CrmBusinessRespVO>(); | ||
| 118 | - pageResult.setList(CrmBusinessConvert.INSTANCE.convert(businessDOS)); | ||
| 119 | - pageResult.setTotal(businessLinkDOS.getTotal()); | ||
| 120 | - return pageResult; | ||
| 121 | - | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - @Override | ||
| 125 | - public PageResult<CrmContactBusinessLinkDO> getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 126 | - return contactBusinessLinkMapper.selectPage(pageReqVO); | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | -} | ||
| 130 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.contact; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; | ||
| 4 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | ||
| 5 | +import jakarta.validation.Valid; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * CRM 联系人与商机的关联 Service 接口 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +public interface CrmContactBusinessService { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 创建联系人与商机的关联 | ||
| 18 | + * | ||
| 19 | + * @param createReqVO 创建信息 | ||
| 20 | + */ | ||
| 21 | + void createContactBusinessList(@Valid CrmContactBusinessReqVO createReqVO); | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 删除联系人与商机的关联 | ||
| 25 | + * | ||
| 26 | + * @param deleteReqVO 删除信息 | ||
| 27 | + */ | ||
| 28 | + void deleteContactBusinessList(@Valid CrmContactBusinessReqVO deleteReqVO); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 获得联系人与商机的关联列表,基于联系人编号 | ||
| 32 | + * | ||
| 33 | + * @param contactId 联系人编号 | ||
| 34 | + * @return 联系人商机关联 | ||
| 35 | + */ | ||
| 36 | + List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId); | ||
| 37 | + | ||
| 38 | +} | ||
| 0 | \ No newline at end of file | 39 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.contact; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||
| 6 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | ||
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | ||
| 8 | +import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessMapper; | ||
| 9 | +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; | ||
| 10 | +import jakarta.annotation.Resource; | ||
| 11 | +import org.springframework.context.annotation.Lazy; | ||
| 12 | +import org.springframework.stereotype.Service; | ||
| 13 | +import org.springframework.validation.annotation.Validated; | ||
| 14 | + | ||
| 15 | +import java.util.ArrayList; | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | ||
| 20 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; | ||
| 21 | + | ||
| 22 | +// TODO @puhui999:数据权限的校验;每个操作; | ||
| 23 | +/** | ||
| 24 | + * 联系人与商机的关联 Service 实现类 | ||
| 25 | + * | ||
| 26 | + * @author 芋道源码 | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Validated | ||
| 30 | +public class CrmContactBusinessServiceImpl implements CrmContactBusinessService { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private CrmContactBusinessMapper contactBusinessMapper; | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + @Lazy // 延迟加载,为了解决延迟加载 | ||
| 37 | + private CrmBusinessService businessService; | ||
| 38 | + @Resource | ||
| 39 | + @Lazy // 延迟加载,为了解决延迟加载 | ||
| 40 | + private CrmContactService contactService; | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { | ||
| 44 | + CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); | ||
| 45 | + if (contact == null) { | ||
| 46 | + throw exception(CONTACT_NOT_EXISTS); | ||
| 47 | + } | ||
| 48 | + // 遍历处理,考虑到一般数量不会太多,代码处理简单 | ||
| 49 | + List<CrmContactBusinessDO> saveDOList = new ArrayList<>(); | ||
| 50 | + createReqVO.getBusinessIds().forEach(businessId -> { | ||
| 51 | + CrmBusinessDO business = businessService.getBusiness(businessId); | ||
| 52 | + if (business == null) { | ||
| 53 | + throw exception(BUSINESS_NOT_EXISTS); | ||
| 54 | + } | ||
| 55 | + // 关联判重 | ||
| 56 | + if (contactBusinessMapper.selectByContactIdAndBusinessId(createReqVO.getContactId(), businessId) != null) { | ||
| 57 | + return; | ||
| 58 | + } | ||
| 59 | + saveDOList.add(new CrmContactBusinessDO(null, createReqVO.getContactId(), businessId)); | ||
| 60 | + }); | ||
| 61 | + // 批量插入 | ||
| 62 | + if (CollUtil.isNotEmpty(saveDOList)) { | ||
| 63 | + contactBusinessMapper.insertBatch(saveDOList); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public void deleteContactBusinessList(CrmContactBusinessReqVO deleteReqVO) { | ||
| 69 | + CrmContactDO contact = contactService.getContact(deleteReqVO.getContactId()); | ||
| 70 | + if (contact == null) { | ||
| 71 | + throw exception(CONTACT_NOT_EXISTS); | ||
| 72 | + } | ||
| 73 | + // 直接删除 | ||
| 74 | + contactBusinessMapper.deleteByContactIdAndBusinessId( | ||
| 75 | + deleteReqVO.getContactId(), deleteReqVO.getBusinessIds()); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Override | ||
| 79 | + public List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId) { | ||
| 80 | + return contactBusinessMapper.selectListByContactId(contactId); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | +} | ||
| 0 | \ No newline at end of file | 84 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
| 1 | package cn.iocoder.yudao.module.crm.service.contact; | 1 | package cn.iocoder.yudao.module.crm.service.contact; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO; | ||
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO; | 4 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; |
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO; |
| 9 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO; | ||
| 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 12 | import jakarta.validation.Valid; | 10 | import jakarta.validation.Valid; |
| @@ -90,12 +88,4 @@ public interface CrmContactService { | @@ -90,12 +88,4 @@ public interface CrmContactService { | ||
| 90 | */ | 88 | */ |
| 91 | void transferContact(CrmContactTransferReqVO reqVO, Long userId); | 89 | void transferContact(CrmContactTransferReqVO reqVO, Long userId); |
| 92 | 90 | ||
| 93 | - | ||
| 94 | - /** | ||
| 95 | - * 获取联系人商机关联分页列表 | ||
| 96 | - * @param reqVO 联系人 | ||
| 97 | - * @return 商机联系人关联列表 | ||
| 98 | - */ | ||
| 99 | - PageResult<CrmContactBusinessLinkDO> selectBusinessPageByContact(CrmContactBusinessLinkPageReqVO reqVO); | ||
| 100 | - | ||
| 101 | } | 91 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| @@ -5,17 +5,9 @@ import cn.hutool.core.collection.ListUtil; | @@ -5,17 +5,9 @@ import cn.hutool.core.collection.ListUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; |
| 7 | import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert; | 7 | import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert; |
| 8 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 9 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | ||
| 10 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||
| 11 | -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; | ||
| 12 | -import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; | ||
| 13 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||
| 14 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO; | ||
| 15 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 16 | import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; |
| 17 | -import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper; | ||
| 18 | -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | 10 | +import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessMapper; |
| 19 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 11 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 20 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | 12 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 21 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; | 13 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| @@ -56,7 +48,7 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -56,7 +48,7 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 56 | private AdminUserApi adminUserApi; | 48 | private AdminUserApi adminUserApi; |
| 57 | 49 | ||
| 58 | @Resource | 50 | @Resource |
| 59 | - private CrmContactBusinessLinkMapper contactBusinessLinkMapper; | 51 | + private CrmContactBusinessMapper contactBusinessLinkMapper; |
| 60 | 52 | ||
| 61 | @Override | 53 | @Override |
| 62 | @Transactional(rollbackFor = Exception.class) | 54 | @Transactional(rollbackFor = Exception.class) |
| @@ -161,11 +153,4 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -161,11 +153,4 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 161 | // 3. TODO 记录转移日志 | 153 | // 3. TODO 记录转移日志 |
| 162 | } | 154 | } |
| 163 | 155 | ||
| 164 | - @Override | ||
| 165 | - public PageResult<CrmContactBusinessLinkDO> selectBusinessPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) { | ||
| 166 | - CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO(); | ||
| 167 | - crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId()); | ||
| 168 | - return contactBusinessLinkMapper.selectPageByContact(crmContactBusinessLinkPageReqVO); | ||
| 169 | - | ||
| 170 | - } | ||
| 171 | -} | 156 | +} |
| 172 | \ No newline at end of file | 157 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
| @@ -56,7 +56,7 @@ public interface CrmCustomerService { | @@ -56,7 +56,7 @@ public interface CrmCustomerService { | ||
| 56 | * @return 客户列表 | 56 | * @return 客户列表 |
| 57 | * @author ljlleo | 57 | * @author ljlleo |
| 58 | */ | 58 | */ |
| 59 | - List<CrmCustomerDO> getCustomerList(Collection<Long> ids, Long userId); | 59 | + List<CrmCustomerDO> getCustomerList(Collection<Long> ids); |
| 60 | 60 | ||
| 61 | /** | 61 | /** |
| 62 | * 获得客户分页 | 62 | * 获得客户分页 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| @@ -116,11 +116,11 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -116,11 +116,11 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | @Override | 118 | @Override |
| 119 | - public List<CrmCustomerDO> getCustomerList(Collection<Long> ids, Long userId) { | 119 | + public List<CrmCustomerDO> getCustomerList(Collection<Long> ids) { |
| 120 | if (CollUtil.isEmpty(ids)) { | 120 | if (CollUtil.isEmpty(ids)) { |
| 121 | return Collections.emptyList(); | 121 | return Collections.emptyList(); |
| 122 | } | 122 | } |
| 123 | - return customerMapper.selectBatchIds(ids, userId); | 123 | + return customerMapper.selectBatchIds(ids); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | @Override | 126 | @Override |