From b2621c889145239b45e2a8b8381a577779bb830d Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 5 Dec 2023 11:04:40 +0800 Subject: [PATCH] =?UTF-8?q?CRM-=E5=AE=A2=E6=88=B7:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E5=92=8C=E5=8F=96=E6=B6=88=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/customer/CrmCustomerController.java | 21 ++++++++++- .../service/customer/CrmCustomerService.java | 18 +++++++++ .../customer/CrmCustomerServiceImpl.java | 37 ++++++++++++++++++- .../CrmCrmReceivableServiceImplTest.java | 4 -- 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index 61489f7e6..d735f8f7b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -36,7 +36,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; @Tag(name = "管理后台 - CRM 客户") @RestController @@ -140,6 +139,24 @@ public class CrmCustomerController { return success(true); } + @PutMapping("/concern") + @Operation(summary = "关注客户") + @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") + @PreAuthorize("@ss.hasPermission('crm:customer:update')") + public CommonResult concernCustomer(@RequestParam("ids") List ids) { + customerService.concernCustomer(ids, getLoginUserId()); + return success(true); + } + + @PutMapping("/cancel-concern") + @Operation(summary = "取消关注客户") + @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") + @PreAuthorize("@ss.hasPermission('crm:customer:update')") + public CommonResult cancelConcernCustomer(@RequestParam("ids") List ids) { + customerService.cancelConcernCustomer(ids, getLoginUserId()); + return success(true); + } + // ==================== 公海相关操作 ==================== @PutMapping("/put-pool") @@ -178,7 +195,7 @@ public class CrmCustomerController { @GetMapping("/query-all-list") @Operation(summary = "查询客户列表") @PreAuthorize("@ss.hasPermission('crm:customer:all')") - public CommonResult> queryAll(){ + public CommonResult> queryAll() { List crmCustomerDOList = customerService.getCustomerList(); List data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList); return success(data); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java index 1834f9031..19ba2aef4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -90,6 +90,22 @@ public interface CrmCustomerService { */ void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); + /** + * 关注客户 + * + * @param ids 客户编号 + * @param userId 用户编号 + */ + void concernCustomer(List ids, Long userId); + + /** + * 取消关注客户 + * + * @param ids 客户编号 + * @param userId 用户编号 + */ + void cancelConcernCustomer(List ids, Long userId); + // ==================== 公海相关操作 ==================== /** @@ -109,8 +125,10 @@ public interface CrmCustomerService { /** * 获取客户列表 + * * @return 客户列表 * @author zyna */ List getCustomerList(); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 98a0b352b..6a1fcfbff 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.crm.service.customer; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; @@ -9,9 +11,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdat import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; +import cn.iocoder.yudao.module.crm.service.concerned.CrmConcernedService; +import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO; import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; @@ -23,6 +27,7 @@ import javax.annotation.Resource; import java.util.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; import static java.util.Collections.singletonList; @@ -41,6 +46,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Resource private CrmPermissionService crmPermissionService; + @Resource + private CrmConcernedService crmConcernedService; + @Resource private AdminUserApi adminUserApi; @@ -151,6 +159,33 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { customerMapper.updateById(updateObj); } + @Override + public void concernCustomer(List ids, Long userId) { + // 1. 校验客户是否存在 + validateCustomerExists(ids); + + // 2. 创建关注 + List createReqBOs = BeanUtils.toBean(convertList(ids, id -> new CrmConcernedCreateReqBO() + .setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(id).setUserId(userId)), CrmConcernedCreateReqBO.class); + crmConcernedService.createConcernedBatch(createReqBOs); + } + + @Override + public void cancelConcernCustomer(List ids, Long userId) { + // 1. 校验客户是否存在 + validateCustomerExists(ids); + + // 2. 取消关注 + crmConcernedService.deleteConcerned(CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); + } + + private void validateCustomerExists(List ids) { + List customerList = customerMapper.selectBatchIds(ids); + if (ObjUtil.notEqual(ids.size(), customerList.size())) { + throw exception(CUSTOMER_NOT_EXISTS); + } + } + @Override @Transactional(rollbackFor = Exception.class) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java index b3db63c07..ffea946ae 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java @@ -108,16 +108,12 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { o.setPlanId(null); o.setCustomerId(null); o.setContractId(null); - o.setCheckStatus(null); o.setProcessInstanceId(null); o.setReturnTime(null); o.setReturnType(null); o.setPrice(null); o.setOwnerUserId(null); - o.setBatchId(null); o.setSort(null); - o.setDataScope(null); - o.setDataScopeDeptIds(null); o.setAuditStatus(null); o.setRemark(null); o.setCreateTime(null);