增加在线排序queryByPage
This commit is contained in:
@@ -1,6 +1,18 @@
|
|||||||
package com.starry.admin.modules.clerk.service.impl;
|
package com.starry.admin.modules.clerk.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -11,7 +23,12 @@ import com.starry.admin.common.component.JwtToken;
|
|||||||
import com.starry.admin.common.domain.LoginUser;
|
import com.starry.admin.common.domain.LoginUser;
|
||||||
import com.starry.admin.common.exception.CustomException;
|
import com.starry.admin.common.exception.CustomException;
|
||||||
import com.starry.admin.modules.clerk.mapper.PlayClerkUserInfoMapper;
|
import com.starry.admin.modules.clerk.mapper.PlayClerkUserInfoMapper;
|
||||||
import com.starry.admin.modules.clerk.module.entity.*;
|
import com.starry.admin.modules.clerk.module.entity.PlayClerkCommodityEntity;
|
||||||
|
import com.starry.admin.modules.clerk.module.entity.PlayClerkLevelInfoEntity;
|
||||||
|
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
|
||||||
|
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserQueryVo;
|
||||||
|
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserReturnVo;
|
||||||
|
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserReviewInfoEntity;
|
||||||
import com.starry.admin.modules.clerk.module.vo.PlayClerkCommodityQueryVo;
|
import com.starry.admin.modules.clerk.module.vo.PlayClerkCommodityQueryVo;
|
||||||
import com.starry.admin.modules.clerk.module.vo.PlayClerkUnsettledWagesInfoQueryVo;
|
import com.starry.admin.modules.clerk.module.vo.PlayClerkUnsettledWagesInfoQueryVo;
|
||||||
import com.starry.admin.modules.clerk.module.vo.PlayClerkUnsettledWagesInfoReturnVo;
|
import com.starry.admin.modules.clerk.module.vo.PlayClerkUnsettledWagesInfoReturnVo;
|
||||||
@@ -38,11 +55,8 @@ import com.starry.admin.utils.SecurityUtils;
|
|||||||
import com.starry.common.utils.ConvertUtil;
|
import com.starry.common.utils.ConvertUtil;
|
||||||
import com.starry.common.utils.IdUtils;
|
import com.starry.common.utils.IdUtils;
|
||||||
import com.starry.common.utils.StringUtils;
|
import com.starry.common.utils.StringUtils;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.*;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 店员Service业务层处理
|
* 店员Service业务层处理
|
||||||
@@ -263,6 +277,12 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
|
|||||||
if (StrUtil.isNotBlank(vo.getOnboardingState())) {
|
if (StrUtil.isNotBlank(vo.getOnboardingState())) {
|
||||||
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getOnboardingState, vo.getOnboardingState());
|
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getOnboardingState, vo.getOnboardingState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 排序:置顶状态优先,在线用户其次,最后按创建时间倒序
|
||||||
|
lambdaQueryWrapper.orderByDesc(PlayClerkUserInfoEntity::getPinToTopState)
|
||||||
|
.orderByDesc(PlayClerkUserInfoEntity::getOnlineState)
|
||||||
|
.orderByDesc(PlayClerkUserInfoEntity::getCreatedTime);
|
||||||
|
|
||||||
return this.baseMapper.selectJoinPage(page, PlayClerkUserInfoResultVo.class, lambdaQueryWrapper);
|
return this.baseMapper.selectJoinPage(page, PlayClerkUserInfoResultVo.class, lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +409,12 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
|
|||||||
// 加入组员的筛选
|
// 加入组员的筛选
|
||||||
List<String> clerkIdList = playClerkGroupInfoService.getValidClerkIdList(SecurityUtils.getLoginUser(), null);
|
List<String> clerkIdList = playClerkGroupInfoService.getValidClerkIdList(SecurityUtils.getLoginUser(), null);
|
||||||
lambdaQueryWrapper.in(PlayClerkUserInfoEntity::getId, clerkIdList);
|
lambdaQueryWrapper.in(PlayClerkUserInfoEntity::getId, clerkIdList);
|
||||||
lambdaQueryWrapper.orderByDesc(PlayClerkUserInfoEntity::getCreatedTime);
|
|
||||||
|
// 排序:置顶状态优先,在线用户其次,最后按创建时间倒序
|
||||||
|
lambdaQueryWrapper.orderByDesc(PlayClerkUserInfoEntity::getPinToTopState)
|
||||||
|
.orderByDesc(PlayClerkUserInfoEntity::getOnlineState)
|
||||||
|
.orderByDesc(PlayClerkUserInfoEntity::getCreatedTime);
|
||||||
|
|
||||||
IPage<PlayClerkUserReturnVo> page = this.baseMapper.selectJoinPage(
|
IPage<PlayClerkUserReturnVo> page = this.baseMapper.selectJoinPage(
|
||||||
new Page<>(vo.getPageNum(), vo.getPageSize()), PlayClerkUserReturnVo.class, lambdaQueryWrapper);
|
new Page<>(vo.getPageNum(), vo.getPageSize()), PlayClerkUserReturnVo.class, lambdaQueryWrapper);
|
||||||
|
|
||||||
|
|||||||
@@ -347,27 +347,6 @@ public class WxClerkController {
|
|||||||
public R queryByPage(@RequestBody PlayClerkUserInfoQueryVo vo) {
|
public R queryByPage(@RequestBody PlayClerkUserInfoQueryVo vo) {
|
||||||
IPage<PlayClerkUserInfoResultVo> page = playClerkUserInfoService.selectByPage(vo,
|
IPage<PlayClerkUserInfoResultVo> page = playClerkUserInfoService.selectByPage(vo,
|
||||||
customUserService.getLoginUserId());
|
customUserService.getLoginUserId());
|
||||||
// 对记录进行排序,优先显示在线店员
|
|
||||||
if (page.getRecords() != null && !page.getRecords().isEmpty()) {
|
|
||||||
page.getRecords().sort((clerk1, clerk2) -> {
|
|
||||||
// 在线状态优先级:"1"(在线)排在"0"(离线)之前
|
|
||||||
String onlineState1 = clerk1.getOnlineState();
|
|
||||||
String onlineState2 = clerk2.getOnlineState();
|
|
||||||
// 如果两者在线状态相同,保持原有顺序
|
|
||||||
if (onlineState1 != null && onlineState2 != null) {
|
|
||||||
// 反向比较,使"1"排在"0"之前
|
|
||||||
return onlineState2.compareTo(onlineState1);
|
|
||||||
}
|
|
||||||
// 处理空值情况:将null视为离线状态("0")
|
|
||||||
if (onlineState1 == null && onlineState2 == null)
|
|
||||||
return 0;
|
|
||||||
if (onlineState1 == null)
|
|
||||||
return 1; // null视为离线,排在在线之后
|
|
||||||
if (onlineState2 == null)
|
|
||||||
return -1; // null视为离线,排在在线之后
|
|
||||||
return onlineState2.compareTo(onlineState1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return R.ok(page);
|
return R.ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user