Commit a5d33692c1d6967ee6d9dd34fa0d84b4339d18df
1 parent
72113bbb
refactor: TodayCustomer利用CrmCustomerController#getCustomerPage
Showing
7 changed files
with
41 additions
and
162 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/backlog/CrmBacklogController.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.backlog; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.backlog.vo.CrmTodayCustomerPageReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||
| 9 | -import cn.iocoder.yudao.module.crm.service.message.CrmBacklogService; | ||
| 10 | -import io.swagger.v3.oas.annotations.Operation; | ||
| 11 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 12 | -import jakarta.annotation.Resource; | ||
| 13 | -import jakarta.validation.Valid; | ||
| 14 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 15 | -import org.springframework.validation.annotation.Validated; | ||
| 16 | -import org.springframework.web.bind.annotation.GetMapping; | ||
| 17 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 18 | -import org.springframework.web.bind.annotation.RestController; | ||
| 19 | - | ||
| 20 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 21 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 22 | - | ||
| 23 | -@Tag(name = "管理后台 - CRM待办消息") | ||
| 24 | -@RestController | ||
| 25 | -@RequestMapping("/crm/backlog") | ||
| 26 | -@Validated | ||
| 27 | -public class CrmBacklogController { | ||
| 28 | - | ||
| 29 | - @Resource | ||
| 30 | - private CrmBacklogService crmMessageService; | ||
| 31 | - | ||
| 32 | - // TODO 芋艿:未来可能合并到 CrmCustomerController | ||
| 33 | - @GetMapping("/today-customer-page") | ||
| 34 | - @Operation(summary = "今日需联系客户") | ||
| 35 | - @PreAuthorize("@ss.hasPermission('crm:customer:query')") | ||
| 36 | - public CommonResult<PageResult<CrmCustomerRespVO>> getTodayCustomerPage(@Valid CrmTodayCustomerPageReqVO pageReqVO) { | ||
| 37 | - PageResult<CrmCustomerDO> pageResult = crmMessageService.getTodayCustomerPage(pageReqVO, getLoginUserId()); | ||
| 38 | - return success(BeanUtils.toBean(pageResult, CrmCustomerRespVO.class)); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | -} | ||
| 42 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/backlog/vo/CrmTodayCustomerPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.backlog.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; | ||
| 6 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 7 | -import lombok.Data; | ||
| 8 | -import lombok.EqualsAndHashCode; | ||
| 9 | -import lombok.ToString; | ||
| 10 | - | ||
| 11 | -@Schema(description = "管理后台 - 今日需联系客户 Request VO") | ||
| 12 | -@Data | ||
| 13 | -@EqualsAndHashCode(callSuper = true) | ||
| 14 | -@ToString(callSuper = true) | ||
| 15 | -public class CrmTodayCustomerPageReqVO extends PageParam { | ||
| 16 | - | ||
| 17 | - /** | ||
| 18 | - * 联系状态 - 今日需联系 | ||
| 19 | - */ | ||
| 20 | - public static final int CONTACT_TODAY = 1; | ||
| 21 | - /** | ||
| 22 | - * 联系状态 - 已逾期 | ||
| 23 | - */ | ||
| 24 | - public static final int CONTACT_EXPIRED = 2; | ||
| 25 | - /** | ||
| 26 | - * 联系状态 - 已联系 | ||
| 27 | - */ | ||
| 28 | - public static final int CONTACT_ALREADY = 3; | ||
| 29 | - | ||
| 30 | - @Schema(description = "联系状态", example = "1") | ||
| 31 | - private Integer contactStatus; | ||
| 32 | - | ||
| 33 | - @Schema(description = "场景类型", example = "1") | ||
| 34 | - @InEnum(CrmSceneTypeEnum.class) | ||
| 35 | - private Integer sceneType; | ||
| 36 | - | ||
| 37 | -} | ||
| 38 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| @@ -130,8 +130,7 @@ public class CrmCustomerController { | @@ -130,8 +130,7 @@ public class CrmCustomerController { | ||
| 130 | CrmCustomerPoolConfigDO poolConfigDO = customerPoolConfigService.getCustomerPoolConfig(); | 130 | CrmCustomerPoolConfigDO poolConfigDO = customerPoolConfigService.getCustomerPoolConfig(); |
| 131 | if (ObjUtil.isNull(poolConfigDO) | 131 | if (ObjUtil.isNull(poolConfigDO) |
| 132 | || Boolean.FALSE.equals(poolConfigDO.getEnabled()) | 132 | || Boolean.FALSE.equals(poolConfigDO.getEnabled()) |
| 133 | - || Boolean.FALSE.equals(poolConfigDO.getNotifyEnabled()) | ||
| 134 | - ) { // TODO @dbh52:这个括号,一般不换行,在 java 这里; | 133 | + || Boolean.FALSE.equals(poolConfigDO.getNotifyEnabled())) { |
| 135 | throw exception(CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED); | 134 | throw exception(CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED); |
| 136 | } | 135 | } |
| 137 | 136 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java
| @@ -14,6 +14,19 @@ import lombok.ToString; | @@ -14,6 +14,19 @@ import lombok.ToString; | ||
| 14 | @ToString(callSuper = true) | 14 | @ToString(callSuper = true) |
| 15 | public class CrmCustomerPageReqVO extends PageParam { | 15 | public class CrmCustomerPageReqVO extends PageParam { |
| 16 | 16 | ||
| 17 | + /** | ||
| 18 | + * 联系状态 - 今日需联系 | ||
| 19 | + */ | ||
| 20 | + public static final int CONTACT_TODAY = 1; | ||
| 21 | + /** | ||
| 22 | + * 联系状态 - 已逾期 | ||
| 23 | + */ | ||
| 24 | + public static final int CONTACT_EXPIRED = 2; | ||
| 25 | + /** | ||
| 26 | + * 联系状态 - 已联系 | ||
| 27 | + */ | ||
| 28 | + public static final int CONTACT_ALREADY = 3; | ||
| 29 | + | ||
| 17 | @Schema(description = "客户名称", example = "赵六") | 30 | @Schema(description = "客户名称", example = "赵六") |
| 18 | private String name; | 31 | private String name; |
| 19 | 32 | ||
| @@ -36,4 +49,10 @@ public class CrmCustomerPageReqVO extends PageParam { | @@ -36,4 +49,10 @@ public class CrmCustomerPageReqVO extends PageParam { | ||
| 36 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 49 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 37 | private Boolean pool; // null 则表示为不是公海数据 | 50 | private Boolean pool; // null 则表示为不是公海数据 |
| 38 | 51 | ||
| 52 | + @Schema(description = "联系状态", example = "1") | ||
| 53 | + private Integer contactStatus; // backlog查询条件, null 则表示为不做查询 | ||
| 54 | + | ||
| 55 | + @Schema(description = "跟进状态", example = "true") | ||
| 56 | + private Boolean followUpStatus; // backlog查询条件, null 则表示为不做查询 | ||
| 57 | + | ||
| 39 | } | 58 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
| 1 | package cn.iocoder.yudao.module.crm.dal.mysql.customer; | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.customer; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.date.LocalDateTimeUtil; | 3 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | +import cn.hutool.core.util.ObjUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 7 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.backlog.vo.CrmTodayCustomerPageReqVO; | ||
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; |
| 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; |
| @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 15 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 15 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 16 | import org.apache.ibatis.annotations.Mapper; | 16 | import org.apache.ibatis.annotations.Mapper; |
| 17 | import org.springframework.lang.Nullable; | 17 | import org.springframework.lang.Nullable; |
| 18 | +import org.springframework.util.Assert; | ||
| 18 | 19 | ||
| 19 | import java.time.LocalDateTime; | 20 | import java.time.LocalDateTime; |
| 20 | import java.util.Collection; | 21 | import java.util.Collection; |
| @@ -58,49 +59,36 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | @@ -58,49 +59,36 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||
| 58 | .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) | 59 | .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) |
| 59 | .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) | 60 | .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) |
| 60 | .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()); | 61 | .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()); |
| 61 | - return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long userId) { | ||
| 65 | - MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); | ||
| 66 | - // 拼接数据权限的查询条件 | ||
| 67 | - CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); | ||
| 68 | - // 拼接自身的查询条件 | ||
| 69 | - query.selectAll(CrmCustomerDO.class).in(CrmCustomerDO::getId, ids).orderByDesc(CrmCustomerDO::getId); | ||
| 70 | - return selectJoinList(CrmCustomerDO.class, query); | ||
| 71 | - } | ||
| 72 | 62 | ||
| 73 | - /** | ||
| 74 | - * 待办事项 - 今日需联系客户 | ||
| 75 | - * | ||
| 76 | - * @param pageReqVO 分页请求参数 | ||
| 77 | - * @param userId 当前用户ID | ||
| 78 | - * @return 分页结果 | ||
| 79 | - */ | ||
| 80 | - default PageResult<CrmCustomerDO> selectTodayCustomerPage(CrmTodayCustomerPageReqVO pageReqVO, Long userId) { | ||
| 81 | - MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); | ||
| 82 | - // 拼接数据权限的查询条件 | ||
| 83 | - CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), | ||
| 84 | - CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); | 63 | + // backlog 查询 |
| 64 | + if (ObjUtil.isNotNull(pageReqVO.getContactStatus())) { | ||
| 65 | + Assert.isNull(pageReqVO.getPool(), "[是否为公海数据]必须是null"); | ||
| 85 | 66 | ||
| 86 | - // 拼接自身的查询条件 | ||
| 87 | - query.selectAll(CrmCustomerDO.class); | ||
| 88 | - if (pageReqVO.getContactStatus() != null) { | ||
| 89 | LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); | 67 | LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); |
| 90 | LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); | 68 | LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); |
| 91 | - if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_TODAY)) { // 今天需联系 | 69 | + if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_TODAY)) { // 今天需联系 |
| 92 | query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday); | 70 | query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday); |
| 93 | - } else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_EXPIRED)) { // 已逾期 | 71 | + } else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_EXPIRED)) { // 已逾期 |
| 94 | query.lt(CrmCustomerDO::getContactNextTime, beginOfToday); | 72 | query.lt(CrmCustomerDO::getContactNextTime, beginOfToday); |
| 95 | - } else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_ALREADY)) { // 已联系 | 73 | + } else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_ALREADY)) { // 已联系 |
| 96 | query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday); | 74 | query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday); |
| 97 | } else { | 75 | } else { |
| 98 | throw new IllegalArgumentException("未知联系状态:" + pageReqVO.getContactStatus()); | 76 | throw new IllegalArgumentException("未知联系状态:" + pageReqVO.getContactStatus()); |
| 99 | } | 77 | } |
| 100 | } | 78 | } |
| 79 | + | ||
| 101 | return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); | 80 | return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); |
| 102 | } | 81 | } |
| 103 | 82 | ||
| 83 | + default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long userId) { | ||
| 84 | + MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); | ||
| 85 | + // 拼接数据权限的查询条件 | ||
| 86 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); | ||
| 87 | + // 拼接自身的查询条件 | ||
| 88 | + query.selectAll(CrmCustomerDO.class).in(CrmCustomerDO::getId, ids).orderByDesc(CrmCustomerDO::getId); | ||
| 89 | + return selectJoinList(CrmCustomerDO.class, query); | ||
| 90 | + } | ||
| 91 | + | ||
| 104 | default List<CrmCustomerDO> selectListByLockAndNotPool(Boolean lockStatus) { | 92 | default List<CrmCustomerDO> selectListByLockAndNotPool(Boolean lockStatus) { |
| 105 | return selectList(new LambdaQueryWrapper<CrmCustomerDO>() | 93 | return selectList(new LambdaQueryWrapper<CrmCustomerDO>() |
| 106 | .eq(CrmCustomerDO::getLockStatus, lockStatus) | 94 | .eq(CrmCustomerDO::getLockStatus, lockStatus) |
| @@ -118,7 +106,9 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | @@ -118,7 +106,9 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||
| 118 | // 拼接数据权限的查询条件 | 106 | // 拼接数据权限的查询条件 |
| 119 | CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), | 107 | CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), |
| 120 | CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); | 108 | CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); |
| 121 | - // TODO @dhb52:lock 的情况,不需要提醒哈; | 109 | + |
| 110 | + // 锁定状态不需要提醒 | ||
| 111 | + query.ne(CrmCustomerDO::getLockStatus, true); | ||
| 122 | 112 | ||
| 123 | // 拼接自身的查询条件 | 113 | // 拼接自身的查询条件 |
| 124 | query.selectAll(CrmCustomerDO.class); | 114 | query.selectAll(CrmCustomerDO.class); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/message/CrmBacklogService.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.message; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.backlog.vo.CrmTodayCustomerPageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||
| 6 | -import jakarta.validation.Valid; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * CRM 待办消息 Service 接口 | ||
| 10 | - * | ||
| 11 | - * @author dhb52 | ||
| 12 | - */ | ||
| 13 | -public interface CrmBacklogService { | ||
| 14 | - | ||
| 15 | - /** | ||
| 16 | - * 根据【联系状态】、【场景类型】筛选客户分页 | ||
| 17 | - * | ||
| 18 | - * @param pageReqVO 分页查询 | ||
| 19 | - * @return 分页数据 | ||
| 20 | - */ | ||
| 21 | - PageResult<CrmCustomerDO> getTodayCustomerPage(@Valid CrmTodayCustomerPageReqVO pageReqVO, Long userId); | ||
| 22 | - | ||
| 23 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/message/CrmBacklogServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.message; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.backlog.vo.CrmTodayCustomerPageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | ||
| 7 | -import jakarta.annotation.Resource; | ||
| 8 | -import org.springframework.stereotype.Component; | ||
| 9 | -import org.springframework.validation.annotation.Validated; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 待办消息 Service 实现类 | ||
| 13 | - * | ||
| 14 | - * @author dhb52 | ||
| 15 | - */ | ||
| 16 | -@Component | ||
| 17 | -@Validated | ||
| 18 | -public class CrmBacklogServiceImpl implements CrmBacklogService { | ||
| 19 | - | ||
| 20 | - @Resource | ||
| 21 | - private CrmCustomerMapper customerMapper; | ||
| 22 | - | ||
| 23 | - @Override | ||
| 24 | - public PageResult<CrmCustomerDO> getTodayCustomerPage(CrmTodayCustomerPageReqVO pageReqVO, Long userId) { | ||
| 25 | - return customerMapper.selectTodayCustomerPage(pageReqVO, userId); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | -} |