mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
refactor: TodayCustomer利用CrmCustomerController#getCustomerPage
This commit is contained in:
parent
72113bbbc6
commit
a5d33692c1
@ -1,41 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.backlog;
|
|
||||||
|
|
||||||
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.backlog.vo.CrmTodayCustomerPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
|
||||||
import cn.iocoder.yudao.module.crm.service.message.CrmBacklogService;
|
|
||||||
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/backlog")
|
|
||||||
@Validated
|
|
||||||
public class CrmBacklogController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CrmBacklogService crmMessageService;
|
|
||||||
|
|
||||||
// TODO 芋艿:未来可能合并到 CrmCustomerController
|
|
||||||
@GetMapping("/today-customer-page")
|
|
||||||
@Operation(summary = "今日需联系客户")
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
|
||||||
public CommonResult<PageResult<CrmCustomerRespVO>> getTodayCustomerPage(@Valid CrmTodayCustomerPageReqVO pageReqVO) {
|
|
||||||
PageResult<CrmCustomerDO> pageResult = crmMessageService.getTodayCustomerPage(pageReqVO, getLoginUserId());
|
|
||||||
return success(BeanUtils.toBean(pageResult, CrmCustomerRespVO.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.backlog.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 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 {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 联系状态 - 今日需联系
|
|
||||||
*/
|
|
||||||
public static final int CONTACT_TODAY = 1;
|
|
||||||
/**
|
|
||||||
* 联系状态 - 已逾期
|
|
||||||
*/
|
|
||||||
public static final int CONTACT_EXPIRED = 2;
|
|
||||||
/**
|
|
||||||
* 联系状态 - 已联系
|
|
||||||
*/
|
|
||||||
public static final int CONTACT_ALREADY = 3;
|
|
||||||
|
|
||||||
@Schema(description = "联系状态", example = "1")
|
|
||||||
private Integer contactStatus;
|
|
||||||
|
|
||||||
@Schema(description = "场景类型", example = "1")
|
|
||||||
@InEnum(CrmSceneTypeEnum.class)
|
|
||||||
private Integer sceneType;
|
|
||||||
|
|
||||||
}
|
|
@ -130,8 +130,7 @@ public class CrmCustomerController {
|
|||||||
CrmCustomerPoolConfigDO poolConfigDO = customerPoolConfigService.getCustomerPoolConfig();
|
CrmCustomerPoolConfigDO poolConfigDO = customerPoolConfigService.getCustomerPoolConfig();
|
||||||
if (ObjUtil.isNull(poolConfigDO)
|
if (ObjUtil.isNull(poolConfigDO)
|
||||||
|| Boolean.FALSE.equals(poolConfigDO.getEnabled())
|
|| Boolean.FALSE.equals(poolConfigDO.getEnabled())
|
||||||
|| Boolean.FALSE.equals(poolConfigDO.getNotifyEnabled())
|
|| Boolean.FALSE.equals(poolConfigDO.getNotifyEnabled())) {
|
||||||
) { // TODO @dbh52:这个括号,一般不换行,在 java 这里;
|
|
||||||
throw exception(CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED);
|
throw exception(CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,19 @@ import lombok.ToString;
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class CrmCustomerPageReqVO extends PageParam {
|
public class CrmCustomerPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系状态 - 今日需联系
|
||||||
|
*/
|
||||||
|
public static final int CONTACT_TODAY = 1;
|
||||||
|
/**
|
||||||
|
* 联系状态 - 已逾期
|
||||||
|
*/
|
||||||
|
public static final int CONTACT_EXPIRED = 2;
|
||||||
|
/**
|
||||||
|
* 联系状态 - 已联系
|
||||||
|
*/
|
||||||
|
public static final int CONTACT_ALREADY = 3;
|
||||||
|
|
||||||
@Schema(description = "客户名称", example = "赵六")
|
@Schema(description = "客户名称", example = "赵六")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ -36,4 +49,10 @@ public class CrmCustomerPageReqVO extends PageParam {
|
|||||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||||
private Boolean pool; // null 则表示为不是公海数据
|
private Boolean pool; // null 则表示为不是公海数据
|
||||||
|
|
||||||
|
@Schema(description = "联系状态", example = "1")
|
||||||
|
private Integer contactStatus; // backlog查询条件, null 则表示为不做查询
|
||||||
|
|
||||||
|
@Schema(description = "跟进状态", example = "true")
|
||||||
|
private Boolean followUpStatus; // backlog查询条件, null 则表示为不做查询
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.crm.dal.mysql.customer;
|
package cn.iocoder.yudao.module.crm.dal.mysql.customer;
|
||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
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.framework.mybatis.core.query.MPJLambdaWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.backlog.vo.CrmTodayCustomerPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||||
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.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
||||||
@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -58,6 +59,24 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
.eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId())
|
.eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId())
|
||||||
.eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel())
|
.eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel())
|
||||||
.eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource());
|
.eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource());
|
||||||
|
|
||||||
|
// backlog 查询
|
||||||
|
if (ObjUtil.isNotNull(pageReqVO.getContactStatus())) {
|
||||||
|
Assert.isNull(pageReqVO.getPool(), "[是否为公海数据]必须是null");
|
||||||
|
|
||||||
|
LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
|
||||||
|
LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now());
|
||||||
|
if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_TODAY)) { // 今天需联系
|
||||||
|
query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday);
|
||||||
|
} else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_EXPIRED)) { // 已逾期
|
||||||
|
query.lt(CrmCustomerDO::getContactNextTime, beginOfToday);
|
||||||
|
} else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_ALREADY)) { // 已联系
|
||||||
|
query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("未知联系状态:" + pageReqVO.getContactStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return selectJoinPage(pageReqVO, CrmCustomerDO.class, query);
|
return selectJoinPage(pageReqVO, CrmCustomerDO.class, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,37 +89,6 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
return selectJoinList(CrmCustomerDO.class, query);
|
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);
|
|
||||||
if (pageReqVO.getContactStatus() != null) {
|
|
||||||
LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
|
|
||||||
LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now());
|
|
||||||
if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_TODAY)) { // 今天需联系
|
|
||||||
query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday);
|
|
||||||
} else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_EXPIRED)) { // 已逾期
|
|
||||||
query.lt(CrmCustomerDO::getContactNextTime, beginOfToday);
|
|
||||||
} else if (pageReqVO.getContactStatus().equals(CrmTodayCustomerPageReqVO.CONTACT_ALREADY)) { // 已联系
|
|
||||||
query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("未知联系状态:" + pageReqVO.getContactStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return selectJoinPage(pageReqVO, CrmCustomerDO.class, query);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<CrmCustomerDO> selectListByLockAndNotPool(Boolean lockStatus) {
|
default List<CrmCustomerDO> selectListByLockAndNotPool(Boolean lockStatus) {
|
||||||
return selectList(new LambdaQueryWrapper<CrmCustomerDO>()
|
return selectList(new LambdaQueryWrapper<CrmCustomerDO>()
|
||||||
.eq(CrmCustomerDO::getLockStatus, lockStatus)
|
.eq(CrmCustomerDO::getLockStatus, lockStatus)
|
||||||
@ -118,7 +106,9 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
||||||
CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null);
|
CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null);
|
||||||
// TODO @dhb52:lock 的情况,不需要提醒哈;
|
|
||||||
|
// 锁定状态不需要提醒
|
||||||
|
query.ne(CrmCustomerDO::getLockStatus, true);
|
||||||
|
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmCustomerDO.class);
|
query.selectAll(CrmCustomerDO.class);
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.message;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.backlog.vo.CrmTodayCustomerPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CRM 待办消息 Service 接口
|
|
||||||
*
|
|
||||||
* @author dhb52
|
|
||||||
*/
|
|
||||||
public interface CrmBacklogService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据【联系状态】、【场景类型】筛选客户分页
|
|
||||||
*
|
|
||||||
* @param pageReqVO 分页查询
|
|
||||||
* @return 分页数据
|
|
||||||
*/
|
|
||||||
PageResult<CrmCustomerDO> getTodayCustomerPage(@Valid CrmTodayCustomerPageReqVO pageReqVO, Long userId);
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.message;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.backlog.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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 待办消息 Service 实现类
|
|
||||||
*
|
|
||||||
* @author dhb52
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Validated
|
|
||||||
public class CrmBacklogServiceImpl implements CrmBacklogService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CrmCustomerMapper customerMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<CrmCustomerDO> getTodayCustomerPage(CrmTodayCustomerPageReqVO pageReqVO, Long userId) {
|
|
||||||
return customerMapper.selectTodayCustomerPage(pageReqVO, userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user