mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	wip: 待办事项
This commit is contained in:
		| @@ -0,0 +1,41 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.message; | ||||
|  | ||||
| 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.customer.vo.CrmCustomerRespVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.message.vo.CrmTodayCustomerPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| import cn.iocoder.yudao.module.crm.service.message.CrmMessageService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import jakarta.annotation.Resource; | ||||
| import jakarta.validation.Valid; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
| import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||||
|  | ||||
|  | ||||
| @Tag(name = "管理后台 - CRM消息") | ||||
| @RestController | ||||
| @RequestMapping("/crm/message") | ||||
| @Validated | ||||
| public class CrmMessageController { | ||||
|  | ||||
|     @Resource | ||||
|     private CrmMessageService crmMessageService; | ||||
|  | ||||
|     @GetMapping("/todayCustomer") | ||||
|     @Operation(summary = "今日需联系客户") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:message:todayCustomer')") | ||||
|     public CommonResult<PageResult<CrmCustomerRespVO>> getTodayCustomerPage(@Valid CrmTodayCustomerPageReqVO pageReqVO) { | ||||
|         PageResult<CrmCustomerDO> pageResult = crmMessageService.getTodayCustomerPage(pageReqVO, getLoginUserId()); | ||||
|         return success(BeanUtils.toBean(pageResult, CrmCustomerRespVO.class)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,26 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.message.vo; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.validation.InEnum; | ||||
| import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; | ||||
| import cn.iocoder.yudao.module.crm.enums.message.CrmContactStatusEnum; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| @Schema(description = "管理后台 - 今日需联系客户 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class CrmTodayCustomerPageReqVO extends PageParam { | ||||
|  | ||||
|     @Schema(description = "联系状态", example = "1") | ||||
|     @InEnum(CrmContactStatusEnum.class) | ||||
|     private Integer contactStatus; | ||||
|  | ||||
|     @Schema(description = "场景类型", example = "1") | ||||
|     @InEnum(CrmSceneTypeEnum.class) | ||||
|     private Integer sceneType; | ||||
|  | ||||
| } | ||||
| @@ -5,13 +5,17 @@ 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.MPJLambdaWrapperX; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.message.vo.CrmTodayCustomerPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; | ||||
| import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||||
| import cn.iocoder.yudao.module.crm.enums.message.CrmContactStatusEnum; | ||||
| import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils; | ||||
| import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import org.springframework.lang.Nullable; | ||||
|  | ||||
| import java.time.LocalDate; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| @@ -63,4 +67,53 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||||
|         return selectJoinList(CrmCustomerDO.class, query); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 待办事项 - 今日需联系客户 | ||||
|      * | ||||
|      * @param pageReqVO 分页请求参数 | ||||
|      * @param userId    当前用户ID | ||||
|      * @return 分页结果 | ||||
|      */ | ||||
|     default PageResult<CrmCustomerDO> selectTodayCustomerPage(CrmTodayCustomerPageReqVO pageReqVO, Long userId) { | ||||
|         MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); | ||||
|         // 拼接数据权限的查询条件 | ||||
|         CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), | ||||
|                 CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); | ||||
|  | ||||
|         query.selectAll(CrmCustomerDO.class) | ||||
|                 .leftJoin(CrmFollowUpRecordDO.class, CrmFollowUpRecordDO::getBizId, CrmCustomerDO::getId) | ||||
|                 .eq(CrmFollowUpRecordDO::getType, CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||||
|  | ||||
|         // 拼接自身的查询条件 | ||||
|         LocalDate today = LocalDate.now(); | ||||
|         LocalDate tomorrow = today.plusDays(1); | ||||
|         LocalDate yesterday = today.minusDays(1); | ||||
|         if (pageReqVO.getContactStatus().equals(CrmContactStatusEnum.NEEDED_TODAY.getType())) { | ||||
|             // 今天需联系: | ||||
|             // 1.【客户】的【下一次联系时间】 是【今天】 | ||||
|             // 2. 无法找到【今天】创建的【跟进】记录 | ||||
|             query.between(CrmCustomerDO::getContactNextTime, today, tomorrow) | ||||
|                     .between(CrmFollowUpRecordDO::getCreateTime, today, tomorrow) | ||||
|                     .isNull(CrmFollowUpRecordDO::getId); | ||||
|         } else if (pageReqVO.getContactStatus().equals(CrmContactStatusEnum.EXPIRED.getType())) { | ||||
|             // 已逾期: | ||||
|             // 1. 【客户】的【下一次联系时间】 <= 【昨天】 | ||||
|             // 2. 无法找到【今天】创建的【跟进】记录 | ||||
|             query.le(CrmCustomerDO::getContactNextTime, yesterday) | ||||
|                     .between(CrmFollowUpRecordDO::getCreateTime, today, tomorrow) | ||||
|                     .isNull(CrmFollowUpRecordDO::getId); | ||||
|         } else if (pageReqVO.getContactStatus().equals(CrmContactStatusEnum.ALREADY_CONTACT.getType())) { | ||||
|             // 已联系: | ||||
|             // 1.【客户】的【下一次联系时间】 是【今天】 | ||||
|             // 2. 找到【今天】创建的【跟进】记录 | ||||
|             query.between(CrmCustomerDO::getContactNextTime, today, tomorrow) | ||||
|                     .between(CrmFollowUpRecordDO::getCreateTime, today, tomorrow) | ||||
|                     .isNotNull(CrmFollowUpRecordDO::getId); | ||||
|         } else { | ||||
|             // TODO: 参数错误,是不是要兜一下底 | ||||
|         } | ||||
|  | ||||
|         return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,22 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.message; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.message.vo.CrmTodayCustomerPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| import jakarta.validation.Valid; | ||||
|  | ||||
| /** | ||||
|  * CRM 代办消息 Service 接口 | ||||
|  * | ||||
|  * @author dhb52 | ||||
|  */ | ||||
| public interface CrmMessageService { | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      * @param pageReqVO | ||||
|      * @return | ||||
|      */ | ||||
|     PageResult<CrmCustomerDO> getTodayCustomerPage(@Valid CrmTodayCustomerPageReqVO pageReqVO, Long userId); | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,24 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.message; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.message.vo.CrmTodayCustomerPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Component; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
|  | ||||
| @Component | ||||
| @Validated | ||||
| public class CrmMessageServiceImpl implements CrmMessageService { | ||||
|  | ||||
|     @Resource | ||||
|     private CrmCustomerMapper customerMapper; | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<CrmCustomerDO> getTodayCustomerPage(CrmTodayCustomerPageReqVO pageReqVO, Long userId) { | ||||
|         return customerMapper.selectTodayCustomerPage(pageReqVO, userId); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 dhb52
					dhb52