mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-30 03:01:53 +08:00
Merge branch 'develop' of https://gitee.com/zyna/ruoyi-vue-pro into develop
# Conflicts: # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessLinkServiceImpl.java
This commit is contained in:
commit
2d0537387b
@ -1,6 +1,6 @@
|
|||||||
-- `ruoyi-vue-pro`.crm_contact_business_link definition
|
-- `ruoyi-vue-pro`.crm_contact_business_link definition
|
||||||
|
|
||||||
CREATE TABLE `crm_contact_business_link` (
|
CREATE TABLE `crm_contact_business` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
`contact_id` int(11) DEFAULT NULL COMMENT '联系人id',
|
`contact_id` int(11) DEFAULT NULL COMMENT '联系人id',
|
||||||
`business_id` int(11) DEFAULT NULL COMMENT '商机id',
|
`business_id` int(11) DEFAULT NULL COMMENT '商机id',
|
||||||
@ -10,6 +10,5 @@ CREATE TABLE `crm_contact_business_link` (
|
|||||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||||
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
|
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`)
|
||||||
UNIQUE KEY `crm_contact_business_link_un` (`contact_id`,`business_id`,`deleted`,`tenant_id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='联系人商机关联表';
|
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='联系人商机关联表';
|
@ -24,7 +24,7 @@ public interface ErrorCodeConstants {
|
|||||||
// ========== 联系人管理 1-020-003-000 ==========
|
// ========== 联系人管理 1-020-003-000 ==========
|
||||||
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
|
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
|
||||||
ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在");
|
ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在");
|
||||||
|
ErrorCode CONTACT_BUSINESS_LINK_CREATE_EMPTY = new ErrorCode( 1_020_003_002, "联系人商机关联参数为空");
|
||||||
// ========== 回款 1-020-004-000 ==========
|
// ========== 回款 1-020-004-000 ==========
|
||||||
ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在");
|
ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在");
|
||||||
|
|
||||||
|
@ -4,11 +4,14 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
||||||
@ -30,6 +33,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -163,5 +167,34 @@ public class CrmBusinessController {
|
|||||||
businessService.transferBusiness(reqVO, getLoginUserId());
|
businessService.transferBusiness(reqVO, getLoginUserId());
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
@GetMapping("/page-by-contact")
|
||||||
|
@Operation(summary = "获得联系人的商机分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:business:query')")
|
||||||
|
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessContactPage(@Valid CrmContactBusinessLinkPageReqVO pageVO) {
|
||||||
|
PageResult<CrmBusinessRespVO> pageResult = businessService.getBusinessPageByContact(pageVO);
|
||||||
|
// 处理商机状态类型名称回显
|
||||||
|
Set<Long> statusTypeIds = pageResult.getList().stream()
|
||||||
|
.map(CrmBusinessRespVO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
|
||||||
|
queryStatusTypeVO.setIdList(statusTypeIds);
|
||||||
|
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
|
||||||
|
Map<Long,String> statusTypeMap = CollectionUtils.convertMap(statusTypeList,CrmBusinessStatusTypeDO::getId,CrmBusinessStatusTypeDO::getName);
|
||||||
|
// 处理商机状态名称回显
|
||||||
|
Set<Long> statusIds = pageResult.getList().stream()
|
||||||
|
.map(CrmBusinessRespVO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
||||||
|
queryVO.setIdList(statusIds);
|
||||||
|
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
||||||
|
Map<Long,String> statusMap = CollectionUtils.convertMap(statusList,CrmBusinessStatusDO::getId,CrmBusinessStatusDO::getName);
|
||||||
|
// 处理客户名称回显
|
||||||
|
Set<Long> customerIds = CollectionUtils.convertSet(pageResult.getList(),CrmBusinessRespVO::getCustomerId);
|
||||||
|
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
|
||||||
|
Map<Long,String> customerMap = CollectionUtils.convertMap(customerList,CrmCustomerDO::getId,CrmCustomerDO::getName);
|
||||||
|
pageResult.getList().forEach(item -> {
|
||||||
|
item.setStatusTypeName(statusTypeMap.get(item.getStatusTypeId()));
|
||||||
|
item.setStatusName(statusMap.get(item.getStatusId()));
|
||||||
|
item.setCustomerName(customerMap.get(item.getCustomerId()));
|
||||||
|
});
|
||||||
|
return success(pageResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,6 @@ public class CrmBusinessRespVO extends CrmBusinessBaseVO {
|
|||||||
@Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中")
|
@Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中")
|
||||||
private String statusName;
|
private String statusName;
|
||||||
|
|
||||||
|
@Schema(description = "联系人商机关联ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
|
||||||
|
private Long businessContactId;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert;
|
|||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants;
|
import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessLinkService;
|
||||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
@ -29,6 +30,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -54,10 +59,12 @@ public class CrmContactController {
|
|||||||
private CrmContactService contactService;
|
private CrmContactService contactService;
|
||||||
@Resource
|
@Resource
|
||||||
private CrmCustomerService customerService;
|
private CrmCustomerService customerService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmContactBusinessLinkService contactBusinessLinkService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建联系人")
|
@Operation(summary = "创建联系人")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact:create')")
|
@PreAuthorize("@ss.hasPermission('crm:contact:create')")
|
||||||
@ -141,6 +148,23 @@ public class CrmContactController {
|
|||||||
convertDetailContactPage(pageResult).getList());
|
convertDetailContactPage(pageResult).getList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-batch-business")
|
||||||
|
@Operation(summary = "批量删除联系人商机关联")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')")
|
||||||
|
public CommonResult<Boolean> deleteContactBusinessLinkBatch(@Valid @RequestBody List<Long> businessContactIds) {
|
||||||
|
contactBusinessLinkService.deleteContactBusinessLink(businessContactIds);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/create-batch-business")
|
||||||
|
@Operation(summary = "创建联系人商机关联")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
||||||
|
public CommonResult<Boolean> createContactBusinessLinkBatch(
|
||||||
|
@Valid @NotEmpty @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
||||||
|
contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换成详细的联系人分页,即读取关联信息
|
* 转换成详细的联系人分页,即读取关联信息
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,115 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
||||||
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.business.vo.business.CrmBusinessRespVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkRespVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
|
||||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
|
||||||
import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - CRM 联系人商机关联")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/crm/contact-business-link")
|
|
||||||
@Validated
|
|
||||||
public class CrmContactBusinessLinkController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CrmContactBusinessLinkService contactBusinessLinkService;
|
|
||||||
@Resource
|
|
||||||
private CrmBusinessService crmBusinessService;
|
|
||||||
|
|
||||||
// TODO @zyna:createContactBusinessLink 和 createContactBusinessLinkBatch 是不是合并成一个接口?contactId、List<businessId>
|
|
||||||
@PostMapping("/create")
|
|
||||||
@Operation(summary = "创建联系人商机关联")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
|
||||||
public CommonResult<Long> createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) {
|
|
||||||
return success(contactBusinessLinkService.createContactBusinessLink(createReqVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/create-batch")
|
|
||||||
@Operation(summary = "创建联系人商机关联")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public CommonResult<Boolean> createContactBusinessLinkBatch(
|
|
||||||
@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
|
||||||
createReqVO.stream().forEach(item -> {
|
|
||||||
CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId());
|
|
||||||
if(crmBusinessDO == null){
|
|
||||||
throw exception(BUSINESS_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在更新。
|
|
||||||
@PutMapping("/update")
|
|
||||||
@Operation(summary = "更新联系人商机关联")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')")
|
|
||||||
public CommonResult<Boolean> updateContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO updateReqVO) {
|
|
||||||
contactBusinessLinkService.updateContactBusinessLink(updateReqVO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO @zyna:删除,是不是传递 ids?
|
|
||||||
@DeleteMapping("/delete-batch")
|
|
||||||
@Operation(summary = "批量删除联系人商机关联")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')")
|
|
||||||
public CommonResult<Boolean> deleteContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> deleteList) {
|
|
||||||
contactBusinessLinkService.deleteContactBusinessLink(deleteList);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在单个读取;
|
|
||||||
@GetMapping("/get")
|
|
||||||
@Operation(summary = "获得联系人商机关联")
|
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
|
||||||
public CommonResult<CrmContactBusinessLinkRespVO> getContactBusinessLink(@RequestParam("id") Long id) {
|
|
||||||
CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id);
|
|
||||||
return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO @zyna:这个可以转化下,使用客户编号去查询,就是使用 CrmBusinessController 的 getBusinessPageByCustomer 接口;目的是:复用
|
|
||||||
@GetMapping("/page-by-contact")
|
|
||||||
@Operation(summary = "获得联系人商机关联")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
|
||||||
public CommonResult<PageResult<CrmBusinessRespVO>> getContactBusinessLinkByContact(
|
|
||||||
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
|
||||||
PageResult<CrmBusinessRespVO> contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO);
|
|
||||||
return success(contactBusinessLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO @zyna:这个优化下,搞到 CrmBusinessController 里去,加一个 CrmBusinessController 的 getBusinessPageByContact 接口;目的是:
|
|
||||||
@GetMapping("/page")
|
|
||||||
@Operation(summary = "获得联系人商机关联分页")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
|
||||||
public CommonResult<PageResult<CrmContactBusinessLinkRespVO>> getContactBusinessLinkPage(
|
|
||||||
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
|
||||||
PageResult<CrmContactBusinessLinkDO> pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO);
|
|
||||||
return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO @zyna:最终梳理完后,应该就 2 个接口,要不直接合并到 CrmContactController 中,不作为独立模块,就关联、接触关联。其实和 user 设置它有哪些岗位、部门是类似的。
|
|
||||||
|
|
||||||
}
|
|
@ -76,12 +76,12 @@ public interface CrmContactConvert {
|
|||||||
Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
|
Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
|
||||||
result.forEach(item -> {
|
result.forEach(item -> {
|
||||||
setUserInfo(item, userMap);
|
setUserInfo(item, userMap);
|
||||||
findAndThen(customerMap, item.getCustomerId(), customer -> { // TODO @zyna:这里的 { 可以去掉
|
findAndThen(customerMap, item.getCustomerId(), customer ->
|
||||||
item.setCustomerName(customer.getName());
|
item.setCustomerName(customer.getName())
|
||||||
});
|
);
|
||||||
findAndThen(parentContactMap, item.getParentId(), contactDO -> { // TODO @zyna:这里的 { 可以去掉
|
findAndThen(parentContactMap, item.getParentId(), contactDO ->
|
||||||
item.setParentName(contactDO.getName());
|
item.setParentName(contactDO.getName())
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.convert.contactbusinessslink;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
// TODO @zyna:使用 BeanUtils 慢慢替代现有的 mapstruct 哈
|
|
||||||
@Mapper
|
|
||||||
public interface CrmContactBusinessLinkConvert {
|
|
||||||
CrmContactBusinessLinkConvert INSTANCE = Mappers.getMapper(CrmContactBusinessLinkConvert.class);
|
|
||||||
CrmContactBusinessLinkDO convert(CrmContactBusinessLinkSaveReqVO bean);
|
|
||||||
List<CrmContactBusinessLinkDO> convert(List<CrmContactBusinessLinkSaveReqVO> bean);
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink;
|
package cn.iocoder.yudao.module.crm.dal.dataobject.contact;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
@ -8,14 +8,13 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
// TODO @zyna:可以放到 contact 包下
|
|
||||||
/**
|
/**
|
||||||
* CRM 联系人商机关联 DO
|
* CRM 联系人商机关联 DO
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@TableName("crm_contact_business_link")
|
@TableName("crm_contact_business")
|
||||||
@KeySequence("crm_contact_business_link_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
@KeySequence("crm_contact_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,7 +21,7 @@ public interface CrmContactBusinessLinkMapper extends BaseMapperX<CrmContactBusi
|
|||||||
.eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId())
|
.eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId())
|
||||||
.betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(CrmContactBusinessLinkDO::getId));
|
.orderByDesc(CrmContactBusinessLinkDO::getId));
|
||||||
} // TODO @zyna:方法和方法之间要有空行
|
}
|
||||||
default PageResult<CrmContactBusinessLinkDO> selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) {
|
default PageResult<CrmContactBusinessLinkDO> selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
||||||
.eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId())
|
.eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId())
|
||||||
|
@ -5,6 +5,9 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@ -87,4 +90,10 @@ public interface CrmBusinessService {
|
|||||||
*/
|
*/
|
||||||
void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId);
|
void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取联系人商机列表
|
||||||
|
* @param pageReqVO 分页参数
|
||||||
|
* @return 联系人商机
|
||||||
|
*/
|
||||||
|
PageResult<CrmBusinessRespVO> getBusinessPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO);
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,21 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -23,6 +31,8 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
||||||
@ -44,6 +54,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CrmPermissionService crmPermissionService;
|
private CrmPermissionService crmPermissionService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmContactService crmContactService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) {
|
public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) {
|
||||||
@ -130,5 +143,29 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
|
|
||||||
// 3. TODO 记录转移日志
|
// 3. TODO 记录转移日志
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public PageResult<CrmBusinessRespVO> getBusinessPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||||
|
CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO();
|
||||||
|
crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId());
|
||||||
|
PageResult<CrmContactBusinessLinkDO> businessLinkDOS = crmContactService.selectBusinessPageByContact(crmContactBusinessLinkPageReqVO);
|
||||||
|
if (CollUtil.isEmpty(businessLinkDOS.getList())){
|
||||||
|
return PageResult.empty();
|
||||||
|
}
|
||||||
|
List<CrmBusinessDO> businessList = this.getBusinessList(CollectionUtils.convertList(businessLinkDOS.getList(),
|
||||||
|
CrmContactBusinessLinkDO::getBusinessId));
|
||||||
|
if (CollUtil.isEmpty(businessList)){
|
||||||
|
return PageResult.empty();
|
||||||
|
}
|
||||||
|
PageResult<CrmBusinessRespVO> pageResult = new PageResult<CrmBusinessRespVO>();
|
||||||
|
List<CrmBusinessRespVO> respVOList = BeanUtils.toBean(businessList,CrmBusinessRespVO.class);
|
||||||
|
Map<Long,Long> businessContactMap = CollectionUtils.convertMap(businessLinkDOS.getList(),
|
||||||
|
CrmContactBusinessLinkDO::getBusinessId,CrmContactBusinessLinkDO::getId);
|
||||||
|
respVOList.forEach(item -> {
|
||||||
|
item.setBusinessContactId(businessContactMap.get(item.getId()));
|
||||||
|
});
|
||||||
|
pageResult.setList(respVOList);
|
||||||
|
pageResult.setTotal(businessLinkDOS.getTotal());
|
||||||
|
return pageResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.contactbusinesslink;
|
package cn.iocoder.yudao.module.crm.service.contact;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,9 +41,9 @@ public interface CrmContactBusinessLinkService {
|
|||||||
/**
|
/**
|
||||||
* 删除联系人商机关联
|
* 删除联系人商机关联
|
||||||
*
|
*
|
||||||
* @param createReqVO 删除列表
|
* @param businessContactIds 删除列表
|
||||||
*/
|
*/
|
||||||
void deleteContactBusinessLink(@Valid List<CrmContactBusinessLinkSaveReqVO> createReqVO);
|
void deleteContactBusinessLink(@Valid List<Long> businessContactIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得联系人商机关联
|
* 获得联系人商机关联
|
@ -1,29 +1,36 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.contactbusinesslink;
|
package cn.iocoder.yudao.module.crm.service.contact;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||||
import cn.iocoder.yudao.module.crm.convert.contactbusinessslink.CrmContactBusinessLinkConvert;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
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.enums.ErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||||
import jakarta.annotation.Resource;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_BUSINESS_LINK_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_BUSINESS_LINK_NOT_EXISTS;
|
||||||
|
|
||||||
// TODO @puhui999:数据权限的校验;每个操作;
|
// TODO @puhui999:数据权限的校验;每个操作;
|
||||||
@ -41,6 +48,9 @@ public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLink
|
|||||||
@Resource
|
@Resource
|
||||||
private CrmBusinessService crmBusinessService;
|
private CrmBusinessService crmBusinessService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmContactService crmContactService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) {
|
public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) {
|
||||||
CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class);
|
CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class);
|
||||||
@ -51,14 +61,26 @@ public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLink
|
|||||||
@Override
|
@Override
|
||||||
public void createContactBusinessLinkBatch(List<CrmContactBusinessLinkSaveReqVO> createReqVOList) {
|
public void createContactBusinessLinkBatch(List<CrmContactBusinessLinkSaveReqVO> createReqVOList) {
|
||||||
// 插入
|
// 插入
|
||||||
// TODO @zyna:如果已经关联过,不用重复插入;
|
CrmContactDO contactDO = crmContactService.getContact(createReqVOList.stream().findFirst().get().getContactId());
|
||||||
// TODO @zyna:contact 和 business 存在校验,挪到这里,Controller 不用 @Transactional 注解,添加到这里哈。尽量业务都在 Service;
|
Assert.notNull(contactDO,ErrorCodeConstants.CONTACT_NOT_EXISTS.getMsg());
|
||||||
List<CrmContactBusinessLinkDO> saveDoList = CrmContactBusinessLinkConvert.INSTANCE.convert(createReqVOList);
|
List<CrmContactBusinessLinkDO> saveDoList = new ArrayList<CrmContactBusinessLinkDO>();
|
||||||
|
createReqVOList.forEach(item -> {
|
||||||
|
CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId());
|
||||||
|
if(crmBusinessDO == null){
|
||||||
|
throw exception(BUSINESS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
// 判重
|
||||||
|
CrmContactBusinessLinkDO crmContactBusinessLinkDO = contactBusinessLinkMapper.selectOne(new LambdaQueryWrapper<CrmContactBusinessLinkDO>()
|
||||||
|
.eq(CrmContactBusinessLinkDO::getBusinessId,item.getBusinessId())
|
||||||
|
.eq(CrmContactBusinessLinkDO::getContactId,item.getContactId()));
|
||||||
|
if(crmContactBusinessLinkDO == null){
|
||||||
|
saveDoList.add(BeanUtils.toBean(item,CrmContactBusinessLinkDO.class));
|
||||||
|
}
|
||||||
|
});
|
||||||
contactBusinessLinkMapper.insertBatch(saveDoList);
|
contactBusinessLinkMapper.insertBatch(saveDoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
|
||||||
public void updateContactBusinessLink(CrmContactBusinessLinkSaveReqVO updateReqVO) {
|
public void updateContactBusinessLink(CrmContactBusinessLinkSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateContactBusinessLinkExists(updateReqVO.getId());
|
validateContactBusinessLinkExists(updateReqVO.getId());
|
||||||
@ -68,14 +90,9 @@ public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLink
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteContactBusinessLink(List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
public void deleteContactBusinessLink(List<Long> businessContactIds) {
|
||||||
// 删除
|
// 删除
|
||||||
createReqVO.forEach(item -> {
|
contactBusinessLinkMapper.deleteBatchIds(businessContactIds);
|
||||||
contactBusinessLinkMapper.delete(new LambdaQueryWrapperX<CrmContactBusinessLinkDO>()
|
|
||||||
.eq(CrmContactBusinessLinkDO::getBusinessId,item.getBusinessId())
|
|
||||||
.eq(CrmContactBusinessLinkDO::getContactId,item.getContactId())
|
|
||||||
.eq(CrmContactBusinessLinkDO::getDeleted,0));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateContactBusinessLinkExists(Long id) {
|
private void validateContactBusinessLinkExists(Long id) {
|
@ -1,10 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.contact;
|
package cn.iocoder.yudao.module.crm.service.contact;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessLinkPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@ -88,4 +90,12 @@ public interface CrmContactService {
|
|||||||
*/
|
*/
|
||||||
void transferContact(CrmContactTransferReqVO reqVO, Long userId);
|
void transferContact(CrmContactTransferReqVO reqVO, Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取联系人商机关联分页列表
|
||||||
|
* @param reqVO 联系人
|
||||||
|
* @return 商机联系人关联列表
|
||||||
|
*/
|
||||||
|
PageResult<CrmContactBusinessLinkDO> selectBusinessPageByContact(CrmContactBusinessLinkPageReqVO reqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,17 @@ import cn.hutool.core.collection.ListUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||||
import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert;
|
import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||||
|
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessLinkDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper;
|
||||||
|
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.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||||
@ -43,10 +52,12 @@ public class CrmContactServiceImpl implements CrmContactService {
|
|||||||
private CrmCustomerService customerService;
|
private CrmCustomerService customerService;
|
||||||
@Resource
|
@Resource
|
||||||
private CrmPermissionService crmPermissionService;
|
private CrmPermissionService crmPermissionService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmContactBusinessLinkMapper contactBusinessLinkMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) {
|
public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) {
|
||||||
@ -150,4 +161,11 @@ public class CrmContactServiceImpl implements CrmContactService {
|
|||||||
// 3. TODO 记录转移日志
|
// 3. TODO 记录转移日志
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<CrmContactBusinessLinkDO> selectBusinessPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||||
|
CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO();
|
||||||
|
crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId());
|
||||||
|
return contactBusinessLinkMapper.selectPageByContact(crmContactBusinessLinkPageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user