mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-21 19:50:32 +08:00
crm: 增加基于客户查询商机分页
This commit is contained in:
parent
2d9f5cc4d0
commit
db03b10d24
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.business;
|
package cn.iocoder.yudao.module.crm.controller.admin.business;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
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.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
@ -8,6 +9,7 @@ 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.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;
|
||||||
@ -109,7 +111,32 @@ public class CrmBusinessController {
|
|||||||
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
|
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
|
||||||
// 处理商机状态名称回显
|
// 处理商机状态名称回显
|
||||||
Set<Long> statusIds = pageResult.getList().stream()
|
Set<Long> statusIds = pageResult.getList().stream()
|
||||||
|
.map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
||||||
|
queryVO.setIdList(statusIds);
|
||||||
|
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
||||||
|
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page-by-customer")
|
||||||
|
@Operation(summary = "获得商机分页,基于指定客户")
|
||||||
|
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) {
|
||||||
|
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
|
||||||
|
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO);
|
||||||
|
// 处理客户名称回显
|
||||||
|
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||||
|
Set<Long> customerIds = pageResult.getList().stream()
|
||||||
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
|
||||||
|
// 处理商机状态类型名称回显
|
||||||
|
Set<Long> statusTypeIds = pageResult.getList().stream()
|
||||||
|
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
|
||||||
|
queryStatusTypeVO.setIdList(statusTypeIds);
|
||||||
|
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
|
||||||
|
// 处理商机状态名称回显
|
||||||
|
Set<Long> statusIds = pageResult.getList().stream()
|
||||||
|
.map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
||||||
queryVO.setIdList(statusIds);
|
queryVO.setIdList(statusIds);
|
||||||
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
||||||
@ -128,12 +155,12 @@ public class CrmBusinessController {
|
|||||||
@Operation(summary = "导出商机 Excel")
|
@Operation(summary = "导出商机 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:business:export')")
|
@PreAuthorize("@ss.hasPermission('crm:business:export')")
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO,
|
public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
List<CrmBusinessDO> list = businessService.getBusinessList(exportReqVO);
|
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId());
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
List<CrmBusinessExcelVO> datas = CrmBusinessConvert.INSTANCE.convertList02(list);
|
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class,
|
||||||
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas);
|
CrmBusinessConvert.INSTANCE.convertList02(pageResult.getList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/transfer")
|
@PutMapping("/transfer")
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商机 Excel 导出 Request VO,参数和 CrmBusinessPageReqVO 是一致的")
|
|
||||||
@Data
|
|
||||||
public class CrmBusinessExportReqVO {
|
|
||||||
|
|
||||||
@Schema(description = "商机名称", example = "李四")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Schema(description = "商机状态类型编号", example = "25714")
|
|
||||||
private Long statusTypeId;
|
|
||||||
|
|
||||||
@Schema(description = "商机状态编号", example = "30320")
|
|
||||||
private Long statusId;
|
|
||||||
|
|
||||||
@Schema(description = "下次联系时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] contactNextTime;
|
|
||||||
|
|
||||||
@Schema(description = "客户编号", example = "10299")
|
|
||||||
private Long customerId;
|
|
||||||
|
|
||||||
@Schema(description = "预计成交日期")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] dealTime;
|
|
||||||
|
|
||||||
@Schema(description = "商机金额", example = "12371")
|
|
||||||
private BigDecimal price;
|
|
||||||
|
|
||||||
@Schema(description = "整单折扣")
|
|
||||||
private BigDecimal discountPercent;
|
|
||||||
|
|
||||||
@Schema(description = "产品总金额", example = "12025")
|
|
||||||
private BigDecimal productPrice;
|
|
||||||
|
|
||||||
@Schema(description = "备注", example = "随便")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
@Schema(description = "负责人的用户编号", example = "25562")
|
|
||||||
private Long ownerUserId;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] createTime;
|
|
||||||
|
|
||||||
@Schema(description = "只读权限的用户编号数组")
|
|
||||||
private String roUserIds;
|
|
||||||
|
|
||||||
@Schema(description = "读写权限的用户编号数组")
|
|
||||||
private String rwUserIds;
|
|
||||||
|
|
||||||
@Schema(description = "1赢单2输单3无效", example = "1")
|
|
||||||
private Integer endStatus;
|
|
||||||
|
|
||||||
@Schema(description = "结束时的备注", example = "你说的对")
|
|
||||||
private String endRemark;
|
|
||||||
|
|
||||||
@Schema(description = "最后跟进时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] contactLastTime;
|
|
||||||
|
|
||||||
@Schema(description = "跟进状态", example = "1")
|
|
||||||
private Integer followUpStatus;
|
|
||||||
|
|
||||||
}
|
|
@ -15,4 +15,7 @@ public class CrmBusinessPageReqVO extends PageParam {
|
|||||||
@Schema(description = "商机名称", example = "李四")
|
@Schema(description = "商机名称", example = "李四")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "客户编号", example = "10795")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,6 @@ public class CrmContactBaseVO {
|
|||||||
@ExcelProperty(value = "最后跟进时间",order = 6)
|
@ExcelProperty(value = "最后跟进时间",order = 6)
|
||||||
private LocalDateTime lastTime;
|
private LocalDateTime lastTime;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "负责人用户编号", example = "14334")
|
@Schema(description = "负责人用户编号", example = "14334")
|
||||||
@NotNull(message = "负责人不能为空")
|
@NotNull(message = "负责人不能为空")
|
||||||
private Long ownerUserId;
|
private Long ownerUserId;
|
||||||
|
@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business;
|
|||||||
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.business.vo.business.CrmBusinessExportReqVO;
|
|
||||||
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.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商机 Mapper
|
* 商机 Mapper
|
||||||
@ -26,23 +25,10 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
|
|||||||
.orderByDesc(CrmBusinessDO::getId));
|
.orderByDesc(CrmBusinessDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<CrmBusinessDO> selectList(CrmBusinessExportReqVO reqVO) {
|
default PageResult<CrmBusinessDO> selectPageByCustomer(CrmContractPageReqVO reqVO) {
|
||||||
return selectList(new LambdaQueryWrapperX<CrmBusinessDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessDO>()
|
||||||
|
.eq(CrmBusinessDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
|
||||||
.likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
|
.likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
|
||||||
.eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId())
|
|
||||||
.betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId())
|
|
||||||
.betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark())
|
|
||||||
.betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark())
|
|
||||||
.betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime())
|
|
||||||
.eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus())
|
|
||||||
.orderByDesc(CrmBusinessDO::getId));
|
.orderByDesc(CrmBusinessDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.business;
|
package cn.iocoder.yudao.module.crm.service.business;
|
||||||
|
|
||||||
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.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO;
|
||||||
|
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.CrmBusinessUpdateReqVO;
|
||||||
|
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 javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -57,6 +62,8 @@ public interface CrmBusinessService {
|
|||||||
/**
|
/**
|
||||||
* 获得商机分页
|
* 获得商机分页
|
||||||
*
|
*
|
||||||
|
* 数据权限:基于 {@link CrmBusinessDO}
|
||||||
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @return 商机分页
|
* @return 商机分页
|
||||||
@ -64,12 +71,14 @@ public interface CrmBusinessService {
|
|||||||
PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId);
|
PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得商机列表, 用于 Excel 导出
|
* 获得商机分页,基于指定客户
|
||||||
*
|
*
|
||||||
* @param exportReqVO 查询条件
|
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
||||||
* @return 商机列表
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 联系人分页
|
||||||
*/
|
*/
|
||||||
List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO);
|
PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商机转移
|
* 商机转移
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.collection.ListUtil;
|
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.business.vo.business.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||||
|
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.permission.CrmPermissionDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||||
@ -116,8 +117,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO) {
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
|
||||||
return businessMapper.selectList(exportReqVO);
|
public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO) {
|
||||||
|
return businessMapper.selectPageByCustomer(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,10 +72,10 @@ public interface CrmContactService {
|
|||||||
*
|
*
|
||||||
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
||||||
*
|
*
|
||||||
* @param pageVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 联系人分页
|
* @return 联系人分页
|
||||||
*/
|
*/
|
||||||
PageResult<CrmContactDO> getContactPageByCustomer(CrmContactPageReqVO pageVO);
|
PageResult<CrmContactDO> getContactPageByCustomer(CrmContactPageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有联系人列表
|
* 获取所有联系人列表
|
||||||
|
Loading…
Reference in New Issue
Block a user