Commit b2621c889145239b45e2a8b8381a577779bb830d
1 parent
9c1687dc
CRM-客户: 新增关注和取消关注客户接口
Showing
4 changed files
with
73 additions
and
7 deletions
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. |
| 36 | 36 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; |
| 37 | 37 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 38 | 38 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 39 | -import static java.util.Collections.singletonList; | |
| 40 | 39 | |
| 41 | 40 | @Tag(name = "管理后台 - CRM 客户") |
| 42 | 41 | @RestController |
| ... | ... | @@ -140,6 +139,24 @@ public class CrmCustomerController { |
| 140 | 139 | return success(true); |
| 141 | 140 | } |
| 142 | 141 | |
| 142 | + @PutMapping("/concern") | |
| 143 | + @Operation(summary = "关注客户") | |
| 144 | + @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") | |
| 145 | + @PreAuthorize("@ss.hasPermission('crm:customer:update')") | |
| 146 | + public CommonResult<Boolean> concernCustomer(@RequestParam("ids") List<Long> ids) { | |
| 147 | + customerService.concernCustomer(ids, getLoginUserId()); | |
| 148 | + return success(true); | |
| 149 | + } | |
| 150 | + | |
| 151 | + @PutMapping("/cancel-concern") | |
| 152 | + @Operation(summary = "取消关注客户") | |
| 153 | + @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") | |
| 154 | + @PreAuthorize("@ss.hasPermission('crm:customer:update')") | |
| 155 | + public CommonResult<Boolean> cancelConcernCustomer(@RequestParam("ids") List<Long> ids) { | |
| 156 | + customerService.cancelConcernCustomer(ids, getLoginUserId()); | |
| 157 | + return success(true); | |
| 158 | + } | |
| 159 | + | |
| 143 | 160 | // ==================== 公海相关操作 ==================== |
| 144 | 161 | |
| 145 | 162 | @PutMapping("/put-pool") |
| ... | ... | @@ -178,7 +195,7 @@ public class CrmCustomerController { |
| 178 | 195 | @GetMapping("/query-all-list") |
| 179 | 196 | @Operation(summary = "查询客户列表") |
| 180 | 197 | @PreAuthorize("@ss.hasPermission('crm:customer:all')") |
| 181 | - public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll(){ | |
| 198 | + public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll() { | |
| 182 | 199 | List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList(); |
| 183 | 200 | List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList); |
| 184 | 201 | return success(data); | ... | ... |
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 { |
| 90 | 90 | */ |
| 91 | 91 | void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); |
| 92 | 92 | |
| 93 | + /** | |
| 94 | + * 关注客户 | |
| 95 | + * | |
| 96 | + * @param ids 客户编号 | |
| 97 | + * @param userId 用户编号 | |
| 98 | + */ | |
| 99 | + void concernCustomer(List<Long> ids, Long userId); | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * 取消关注客户 | |
| 103 | + * | |
| 104 | + * @param ids 客户编号 | |
| 105 | + * @param userId 用户编号 | |
| 106 | + */ | |
| 107 | + void cancelConcernCustomer(List<Long> ids, Long userId); | |
| 108 | + | |
| 93 | 109 | // ==================== 公海相关操作 ==================== |
| 94 | 110 | |
| 95 | 111 | /** |
| ... | ... | @@ -109,8 +125,10 @@ public interface CrmCustomerService { |
| 109 | 125 | |
| 110 | 126 | /** |
| 111 | 127 | * 获取客户列表 |
| 128 | + * | |
| 112 | 129 | * @return 客户列表 |
| 113 | 130 | * @author zyna |
| 114 | 131 | */ |
| 115 | 132 | List<CrmCustomerDO> getCustomerList(); |
| 133 | + | |
| 116 | 134 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.util.ObjUtil; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; |
| 6 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; |
| 7 | 9 | 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 |
| 9 | 11 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| 10 | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 11 | 13 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; |
| 12 | -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | |
| 13 | 14 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 14 | 15 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 16 | +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | |
| 17 | +import cn.iocoder.yudao.module.crm.service.concerned.CrmConcernedService; | |
| 18 | +import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO; | |
| 15 | 19 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 16 | 20 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 17 | 21 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| ... | ... | @@ -23,6 +27,7 @@ import javax.annotation.Resource; |
| 23 | 27 | import java.util.*; |
| 24 | 28 | |
| 25 | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 26 | 31 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 27 | 32 | import static java.util.Collections.singletonList; |
| 28 | 33 | |
| ... | ... | @@ -42,6 +47,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 42 | 47 | private CrmPermissionService crmPermissionService; |
| 43 | 48 | |
| 44 | 49 | @Resource |
| 50 | + private CrmConcernedService crmConcernedService; | |
| 51 | + | |
| 52 | + @Resource | |
| 45 | 53 | private AdminUserApi adminUserApi; |
| 46 | 54 | |
| 47 | 55 | @Override |
| ... | ... | @@ -152,6 +160,33 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 152 | 160 | } |
| 153 | 161 | |
| 154 | 162 | @Override |
| 163 | + public void concernCustomer(List<Long> ids, Long userId) { | |
| 164 | + // 1. 校验客户是否存在 | |
| 165 | + validateCustomerExists(ids); | |
| 166 | + | |
| 167 | + // 2. 创建关注 | |
| 168 | + List<CrmConcernedCreateReqBO> createReqBOs = BeanUtils.toBean(convertList(ids, id -> new CrmConcernedCreateReqBO() | |
| 169 | + .setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(id).setUserId(userId)), CrmConcernedCreateReqBO.class); | |
| 170 | + crmConcernedService.createConcernedBatch(createReqBOs); | |
| 171 | + } | |
| 172 | + | |
| 173 | + @Override | |
| 174 | + public void cancelConcernCustomer(List<Long> ids, Long userId) { | |
| 175 | + // 1. 校验客户是否存在 | |
| 176 | + validateCustomerExists(ids); | |
| 177 | + | |
| 178 | + // 2. 取消关注 | |
| 179 | + crmConcernedService.deleteConcerned(CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); | |
| 180 | + } | |
| 181 | + | |
| 182 | + private void validateCustomerExists(List<Long> ids) { | |
| 183 | + List<CrmCustomerDO> customerList = customerMapper.selectBatchIds(ids); | |
| 184 | + if (ObjUtil.notEqual(ids.size(), customerList.size())) { | |
| 185 | + throw exception(CUSTOMER_NOT_EXISTS); | |
| 186 | + } | |
| 187 | + } | |
| 188 | + | |
| 189 | + @Override | |
| 155 | 190 | @Transactional(rollbackFor = Exception.class) |
| 156 | 191 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) |
| 157 | 192 | public void putCustomerPool(Long id) { | ... | ... |
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 { |
| 108 | 108 | o.setPlanId(null); |
| 109 | 109 | o.setCustomerId(null); |
| 110 | 110 | o.setContractId(null); |
| 111 | - o.setCheckStatus(null); | |
| 112 | 111 | o.setProcessInstanceId(null); |
| 113 | 112 | o.setReturnTime(null); |
| 114 | 113 | o.setReturnType(null); |
| 115 | 114 | o.setPrice(null); |
| 116 | 115 | o.setOwnerUserId(null); |
| 117 | - o.setBatchId(null); | |
| 118 | 116 | o.setSort(null); |
| 119 | - o.setDataScope(null); | |
| 120 | - o.setDataScopeDeptIds(null); | |
| 121 | 117 | o.setAuditStatus(null); |
| 122 | 118 | o.setRemark(null); |
| 123 | 119 | o.setCreateTime(null); | ... | ... |