Commit 740e9297fa60d3fd5a2c4070f2f2f6852220568d
1 parent
d9b0c9b4
✨ CRM:完善商机和联系人之间的关联
Showing
10 changed files
with
77 additions
and
53 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| @@ -139,6 +139,14 @@ public class CrmContactController { | @@ -139,6 +139,14 @@ public class CrmContactController { | ||
| 139 | return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); | 139 | return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | + @GetMapping("/page-by-business") | ||
| 143 | + @Operation(summary = "获得联系人分页,基于指定商机") | ||
| 144 | + public CommonResult<PageResult<CrmContactRespVO>> getContactPageByBusiness(@Valid CrmContactPageReqVO pageVO) { | ||
| 145 | + Assert.notNull(pageVO.getBusinessId(), "商机编号不能为空"); | ||
| 146 | + PageResult<CrmContactDO> pageResult = contactService.getContactPageByBusinessId(pageVO); | ||
| 147 | + return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); | ||
| 148 | + } | ||
| 149 | + | ||
| 142 | @GetMapping("/export-excel") | 150 | @GetMapping("/export-excel") |
| 143 | @Operation(summary = "导出联系人 Excel") | 151 | @Operation(summary = "导出联系人 Excel") |
| 144 | @PreAuthorize("@ss.hasPermission('crm:contact:export')") | 152 | @PreAuthorize("@ss.hasPermission('crm:contact:export')") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java
| @@ -39,4 +39,7 @@ public class CrmContactPageReqVO extends PageParam { | @@ -39,4 +39,7 @@ public class CrmContactPageReqVO extends PageParam { | ||
| 39 | @InEnum(CrmSceneTypeEnum.class) | 39 | @InEnum(CrmSceneTypeEnum.class) |
| 40 | private Integer sceneType; // 场景类型,为 null 时则表示全部 | 40 | private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 41 | 41 | ||
| 42 | + @Schema(description = "商机编号", example = "10430") | ||
| 43 | + private Long businessId; | ||
| 44 | + | ||
| 42 | } | 45 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.convert.business; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | ||
| 4 | -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | ||
| 5 | -import org.mapstruct.Mapper; | ||
| 6 | -import org.mapstruct.Mapping; | ||
| 7 | -import org.mapstruct.factory.Mappers; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 商机 Convert | ||
| 11 | - * | ||
| 12 | - * @author ljlleo | ||
| 13 | - */ | ||
| 14 | -@Mapper | ||
| 15 | -public interface CrmBusinessConvert { | ||
| 16 | - | ||
| 17 | - CrmBusinessConvert INSTANCE = Mappers.getMapper(CrmBusinessConvert.class); | ||
| 18 | - | ||
| 19 | - @Mapping(target = "bizId", source = "reqVO.id") | ||
| 20 | - CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId); | ||
| 21 | - | ||
| 22 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java
| @@ -31,4 +31,8 @@ public interface CrmContactBusinessMapper extends BaseMapperX<CrmContactBusiness | @@ -31,4 +31,8 @@ public interface CrmContactBusinessMapper extends BaseMapperX<CrmContactBusiness | ||
| 31 | return selectList(CrmContactBusinessDO::getContactId, contactId); | 31 | return selectList(CrmContactBusinessDO::getContactId, contactId); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | + default List<CrmContactBusinessDO> selectListByBusinessId(Long businessId) { | ||
| 35 | + return selectList(CrmContactBusinessDO::getBusinessId, businessId); | ||
| 36 | + } | ||
| 37 | + | ||
| 34 | } | 38 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| @@ -40,6 +40,18 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | @@ -40,6 +40,18 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | ||
| 40 | .orderByDesc(CrmContactDO::getId)); | 40 | .orderByDesc(CrmContactDO::getId)); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | + default PageResult<CrmContactDO> selectPageByBusinessId(CrmContactPageReqVO pageVO, Collection<Long> ids) { | ||
| 44 | + return selectPage(pageVO, new LambdaQueryWrapperX<CrmContactDO>() | ||
| 45 | + .in(CrmContactDO::getId, ids) // 指定联系人编号 | ||
| 46 | + .likeIfPresent(CrmContactDO::getName, pageVO.getName()) | ||
| 47 | + .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) | ||
| 48 | + .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) | ||
| 49 | + .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail()) | ||
| 50 | + .eqIfPresent(CrmContactDO::getQq, pageVO.getQq()) | ||
| 51 | + .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat()) | ||
| 52 | + .orderByDesc(CrmContactDO::getId)); | ||
| 53 | + } | ||
| 54 | + | ||
| 43 | default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) { | 55 | default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) { |
| 44 | MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); | 56 | MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); |
| 45 | // 拼接数据权限的查询条件 | 57 | // 拼接数据权限的查询条件 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -8,7 +8,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | @@ -8,7 +8,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; |
| 10 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | 10 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 11 | -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; | 11 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; |
| 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; |
| 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; |
| @@ -24,6 +24,7 @@ import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; | @@ -24,6 +24,7 @@ import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; | ||
| 24 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | 24 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 25 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | 25 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 26 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | 26 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 27 | +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | ||
| 27 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | 28 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; |
| 28 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 29 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 29 | import com.mzt.logapi.context.LogRecordContext; | 30 | import com.mzt.logapi.context.LogRecordContext; |
| @@ -38,6 +39,7 @@ import org.springframework.validation.annotation.Validated; | @@ -38,6 +39,7 @@ import org.springframework.validation.annotation.Validated; | ||
| 38 | import java.math.BigDecimal; | 39 | import java.math.BigDecimal; |
| 39 | import java.time.LocalDateTime; | 40 | import java.time.LocalDateTime; |
| 40 | import java.util.Collection; | 41 | import java.util.Collection; |
| 42 | +import java.util.Collections; | ||
| 41 | import java.util.List; | 43 | import java.util.List; |
| 42 | 44 | ||
| 43 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 45 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -100,14 +102,19 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -100,14 +102,19 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 100 | businessProducts.forEach(item -> item.setBusinessId(business.getId())); | 102 | businessProducts.forEach(item -> item.setBusinessId(business.getId())); |
| 101 | businessProductMapper.insertBatch(businessProducts); | 103 | businessProductMapper.insertBatch(businessProducts); |
| 102 | } | 104 | } |
| 103 | - // 在联系人的详情页,如果直接【新建商机】,则需要关联下。 | ||
| 104 | - contactBusinessService.createContactBusiness(createReqVO.getContactId(), business.getId()); | 105 | + |
| 105 | // 3. 创建数据权限 | 106 | // 3. 创建数据权限 |
| 106 | // 设置当前操作的人为负责人 | 107 | // 设置当前操作的人为负责人 |
| 107 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) | 108 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) |
| 108 | .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); | 109 | .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); |
| 109 | 110 | ||
| 110 | - // 4. 记录操作日志上下文 | 111 | + // 4. 在联系人的详情页,如果直接【新建商机】,则需要关联下 |
| 112 | + if (createReqVO.getContactId() != null) { | ||
| 113 | + contactBusinessService.createContactBusinessList(new CrmContactBusinessReqVO().setContactId(createReqVO.getContactId()) | ||
| 114 | + .setBusinessIds(Collections.singletonList(business.getId()))); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + // 5. 记录操作日志上下文 | ||
| 111 | LogRecordContext.putVariable("business", business); | 118 | LogRecordContext.putVariable("business", business); |
| 112 | return business.getId(); | 119 | return business.getId(); |
| 113 | } | 120 | } |
| @@ -262,8 +269,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -262,8 +269,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 262 | CrmBusinessDO business = validateBusinessExists(reqVO.getId()); | 269 | CrmBusinessDO business = validateBusinessExists(reqVO.getId()); |
| 263 | 270 | ||
| 264 | // 2.1 数据权限转移 | 271 | // 2.1 数据权限转移 |
| 265 | - permissionService.transferPermission( | ||
| 266 | - CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); | 272 | + permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_BUSINESS.getType(), |
| 273 | + reqVO.getNewOwnerUserId(), reqVO.getId(), CrmPermissionLevelEnum.OWNER.getLevel())); | ||
| 267 | // 2.2 设置新的负责人 | 274 | // 2.2 设置新的负责人 |
| 268 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | 275 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); |
| 269 | 276 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java
| @@ -14,15 +14,6 @@ import java.util.List; | @@ -14,15 +14,6 @@ import java.util.List; | ||
| 14 | public interface CrmContactBusinessService { | 14 | public interface CrmContactBusinessService { |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | - * 创建联系人人商机关联 | ||
| 18 | - * | ||
| 19 | - * @param contactId 联系人编号 | ||
| 20 | - * @param businessId 商机编号 | ||
| 21 | - */ | ||
| 22 | - void createContactBusiness(Long contactId, Long businessId); | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | * 创建联系人与商机的关联 | 17 | * 创建联系人与商机的关联 |
| 27 | * | 18 | * |
| 28 | * @param createReqVO 创建信息 | 19 | * @param createReqVO 创建信息 |
| @@ -51,4 +42,12 @@ public interface CrmContactBusinessService { | @@ -51,4 +42,12 @@ public interface CrmContactBusinessService { | ||
| 51 | */ | 42 | */ |
| 52 | List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId); | 43 | List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId); |
| 53 | 44 | ||
| 45 | + /** | ||
| 46 | + * 获得联系人与商机的关联列表,基于商机编号 | ||
| 47 | + * | ||
| 48 | + * @param businessId 商机编号 | ||
| 49 | + * @return 联系人商机关联 | ||
| 50 | + */ | ||
| 51 | + List<CrmContactBusinessDO> getContactBusinessListByBusinessId(Long businessId); | ||
| 52 | + | ||
| 54 | } | 53 | } |
| 55 | \ No newline at end of file | 54 | \ 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
| @@ -42,22 +42,6 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | @@ -42,22 +42,6 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | ||
| 42 | private CrmContactService contactService; | 42 | private CrmContactService contactService; |
| 43 | 43 | ||
| 44 | @Override | 44 | @Override |
| 45 | - public void createContactBusiness(Long contactId, Long businessId) { | ||
| 46 | - // 校验存在 | ||
| 47 | - CrmContactDO contact = contactService.getContact(contactId); | ||
| 48 | - if (contact == null) { | ||
| 49 | - throw exception(CONTACT_NOT_EXISTS); | ||
| 50 | - } | ||
| 51 | - CrmBusinessDO business = businessService.getBusiness(businessId); | ||
| 52 | - if (business == null) { | ||
| 53 | - throw exception(BUSINESS_NOT_EXISTS); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - // 插入 | ||
| 57 | - contactBusinessMapper.insert(new CrmContactBusinessDO(null, contactId, businessId)); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - @Override | ||
| 61 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#createReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) | 45 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#createReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) |
| 62 | public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { | 46 | public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { |
| 63 | CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); | 47 | CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); |
| @@ -107,4 +91,10 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | @@ -107,4 +91,10 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | ||
| 107 | return contactBusinessMapper.selectListByContactId(contactId); | 91 | return contactBusinessMapper.selectListByContactId(contactId); |
| 108 | } | 92 | } |
| 109 | 93 | ||
| 94 | + @Override | ||
| 95 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#businessId", level = CrmPermissionLevelEnum.READ) | ||
| 96 | + public List<CrmContactBusinessDO> getContactBusinessListByBusinessId(Long businessId) { | ||
| 97 | + return contactBusinessMapper.selectListByBusinessId(businessId); | ||
| 98 | + } | ||
| 99 | + | ||
| 110 | } | 100 | } |
| 111 | \ No newline at end of file | 101 | \ 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
| @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; | 4 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; |
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; |
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 9 | import jakarta.validation.Valid; | 10 | import jakarta.validation.Valid; |
| @@ -151,6 +152,16 @@ public interface CrmContactService { | @@ -151,6 +152,16 @@ public interface CrmContactService { | ||
| 151 | PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO); | 152 | PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO); |
| 152 | 153 | ||
| 153 | /** | 154 | /** |
| 155 | + * 获得联系人分页 | ||
| 156 | + * | ||
| 157 | + * 数据权限:基于 {@link CrmBusinessDO} | ||
| 158 | + * | ||
| 159 | + * @param pageVO 分页查询 | ||
| 160 | + * @return 联系人分页 | ||
| 161 | + */ | ||
| 162 | + PageResult<CrmContactDO> getContactPageByBusinessId(CrmContactPageReqVO pageVO); | ||
| 163 | + | ||
| 164 | + /** | ||
| 154 | * 获取关联客户的联系人数量 | 165 | * 获取关联客户的联系人数量 |
| 155 | * | 166 | * |
| 156 | * @param customerId 客户编号 | 167 | * @param customerId 客户编号 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusines | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusines | ||
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; |
| 10 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; | 10 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; |
| 11 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | ||
| 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 12 | import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; | 13 | import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; |
| 13 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 14 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| @@ -36,6 +37,7 @@ import java.util.List; | @@ -36,6 +37,7 @@ import java.util.List; | ||
| 36 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 37 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 37 | import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | 38 | import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; |
| 38 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | 39 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| 40 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 39 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | 41 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 40 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; | 42 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; |
| 41 | import static java.util.Collections.singletonList; | 43 | import static java.util.Collections.singletonList; |
| @@ -290,6 +292,16 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -290,6 +292,16 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 290 | } | 292 | } |
| 291 | 293 | ||
| 292 | @Override | 294 | @Override |
| 295 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#pageVO.businessId", level = CrmPermissionLevelEnum.READ) | ||
| 296 | + public PageResult<CrmContactDO> getContactPageByBusinessId(CrmContactPageReqVO pageVO) { | ||
| 297 | + List<CrmContactBusinessDO> contactBusinessList = contactBusinessService.getContactBusinessListByBusinessId(pageVO.getBusinessId()); | ||
| 298 | + if (CollUtil.isEmpty(contactBusinessList)) { | ||
| 299 | + return PageResult.empty(); | ||
| 300 | + } | ||
| 301 | + return contactMapper.selectPageByBusinessId(pageVO, convertSet(contactBusinessList, CrmContactBusinessDO::getContactId)); | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + @Override | ||
| 293 | public Long getContactCountByCustomerId(Long customerId) { | 305 | public Long getContactCountByCustomerId(Long customerId) { |
| 294 | return contactMapper.selectCount(CrmContactDO::getCustomerId, customerId); | 306 | return contactMapper.selectCount(CrmContactDO::getCustomerId, customerId); |
| 295 | } | 307 | } |