优化店员查询接口:在线店员优先显示

- 在 /wx/clerk/user/queryByPage 接口中添加排序逻辑
- 在线状态(onlineState=1)的店员优先显示在列表前面
- 离线状态(onlineState=0)的店员排在后面
- 正确处理空值情况,将 null 视为离线状态
- 在控制器层实现排序,保持服务层代码简洁
This commit is contained in:
irving
2025-08-30 21:55:27 -04:00
parent d719a047d8
commit 662eb93289
2 changed files with 67403 additions and 18 deletions

67364
backend.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -114,7 +114,7 @@ public class WxClerkController {
* 店员获取个人业绩信息 * 店员获取个人业绩信息
*/ */
@ApiOperation(value = "查询店员业绩", notes = "店员获取个人业绩信息") @ApiOperation(value = "查询店员业绩", notes = "店员获取个人业绩信息")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功")}) @ApiResponses({ @ApiResponse(code = 200, message = "操作成功") })
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/queryPerformanceInfo") @PostMapping("/user/queryPerformanceInfo")
public R queryPerformanceInfo( public R queryPerformanceInfo(
@@ -133,7 +133,7 @@ public class WxClerkController {
* 店员获取个人等级信息 * 店员获取个人等级信息
*/ */
@ApiOperation(value = "查询店员等级", notes = "店员获取个人等级信息") @ApiOperation(value = "查询店员等级", notes = "店员获取个人等级信息")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = PlayClerkLevelInfoReturnVo.class)}) @ApiResponses({ @ApiResponse(code = 200, message = "操作成功", response = PlayClerkLevelInfoReturnVo.class) })
@ClerkUserLogin @ClerkUserLogin
@GetMapping("/user/queryLevelInfo") @GetMapping("/user/queryLevelInfo")
public R queryLevelInfo() { public R queryLevelInfo() {
@@ -158,8 +158,8 @@ public class WxClerkController {
* 店员获取个人信息 * 店员获取个人信息
*/ */
@ApiOperation(value = "查询店员信息", notes = "店员获取个人详细信息") @ApiOperation(value = "查询店员信息", notes = "店员获取个人详细信息")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = PlayClerkUserInfoResultVo.class), @ApiResponses({ @ApiResponse(code = 200, message = "操作成功", response = PlayClerkUserInfoResultVo.class),
@ApiResponse(code = 500, message = "用户不存在")}) @ApiResponse(code = 500, message = "用户不存在") })
@ClerkUserLogin @ClerkUserLogin
@GetMapping("/user/queryById") @GetMapping("/user/queryById")
public R queryById() { public R queryById() {
@@ -172,7 +172,7 @@ public class WxClerkController {
} }
@ApiOperation(value = "发送验证码", notes = "店员绑定手机号发送验证码") @ApiOperation(value = "发送验证码", notes = "店员绑定手机号发送验证码")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = String.class)}) @ApiResponses({ @ApiResponse(code = 200, message = "操作成功", response = String.class) })
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/sendCode") @PostMapping("/user/sendCode")
public R sendCode( public R sendCode(
@@ -186,7 +186,7 @@ public class WxClerkController {
} }
@ApiOperation(value = "绑定手机号", notes = "店员绑定手机号") @ApiOperation(value = "绑定手机号", notes = "店员绑定手机号")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "验证码错误")}) @ApiResponses({ @ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "验证码错误") })
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/bindCode") @PostMapping("/user/bindCode")
public R bindCode( public R bindCode(
@@ -210,8 +210,8 @@ public class WxClerkController {
} }
@ApiOperation(value = "店员申请", notes = "用户申请成为店员") @ApiOperation(value = "店员申请", notes = "用户申请成为店员")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "系统错误,用户不存在"), @ApiResponses({ @ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "系统错误,用户不存在"),
@ApiResponse(code = 500, message = "当前用户已经是店员"), @ApiResponse(code = 500, message = "已有申请未审核")}) @ApiResponse(code = 500, message = "当前用户已经是店员"), @ApiResponse(code = 500, message = "已有申请未审核") })
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/add") @PostMapping("/user/add")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@@ -240,7 +240,7 @@ public class WxClerkController {
} }
@ApiOperation(value = "更新头像", notes = "店员更新头像") @ApiOperation(value = "更新头像", notes = "店员更新头像")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功")}) @ApiResponses({ @ApiResponse(code = 200, message = "操作成功") })
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/updateAvatar") @PostMapping("/user/updateAvatar")
public R updateAvatar(@ApiParam(value = "头像信息", required = true) @Validated @RequestBody PlayClerkUserAvatarVo vo) { public R updateAvatar(@ApiParam(value = "头像信息", required = true) @Validated @RequestBody PlayClerkUserAvatarVo vo) {
@@ -340,13 +340,34 @@ public class WxClerkController {
* 分页获取店员列表 * 分页获取店员列表
* *
* @param vo * @param vo
* PlayClerkUserInfoQueryVo * PlayClerkUserInfoQueryVo
* @return 店员列表 * @return 店员列表
*/ */
@PostMapping("/user/queryByPage") @PostMapping("/user/queryByPage")
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);
} }
@@ -369,7 +390,7 @@ public class WxClerkController {
* 获取店员礼物信息 * 获取店员礼物信息
* *
* @param id * @param id
* 店员ID * 店员ID
* @return 店员礼物 * @return 店员礼物
*/ */
@@ -405,7 +426,7 @@ public class WxClerkController {
* 获取店员价格 * 获取店员价格
* *
* @param id * @param id
* 店员ID * 店员ID
* @return 店员价格 * @return 店员价格
*/ */
@GetMapping("/user/queryPriceById") @GetMapping("/user/queryPriceById")
@@ -417,7 +438,7 @@ public class WxClerkController {
* 店员分页查询本人订单列表 * 店员分页查询本人订单列表
* *
* @param vo * @param vo
* 订单列表分页查询对象 * 订单列表分页查询对象
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -434,7 +455,7 @@ public class WxClerkController {
* 店员查询本人订单详情 * 店员查询本人订单详情
* *
* @param id * @param id
* 订单ID * 订单ID
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -451,7 +472,7 @@ public class WxClerkController {
* 店员-接单 * 店员-接单
* *
* @param id * @param id
* 订单ID * 订单ID
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -468,7 +489,7 @@ public class WxClerkController {
* 店员-开始订单 * 店员-开始订单
* *
* @param id * @param id
* 订单ID * 订单ID
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -484,7 +505,7 @@ public class WxClerkController {
* 店员-取消订单 * 店员-取消订单
* *
* @param vo * @param vo
* 取消订单传参 * 取消订单传参
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -501,7 +522,7 @@ public class WxClerkController {
* 分页获取店员评价(订单评价) * 分页获取店员评价(订单评价)
* *
* @param vo * @param vo
* 店员评价查询对象 * 店员评价查询对象
* @return 店员评价 * @return 店员评价
*/ */
@PostMapping("/user/queryEvaluateByPage") @PostMapping("/user/queryEvaluateByPage")