Compare commits

..

2 Commits

Author SHA1 Message Date
irving
7771b30366 修复:微信端评价列表自动过滤隐藏评价
Some checks failed
Build and Push Backend / docker (push) Failing after 8s
- 在微信店员评价查询接口中强制设置hidden=0
- 确保顾客端只能看到管理员未隐藏的评价
- 优化日志配置,减少SQL日志输出
2025-10-21 22:41:32 -04:00
irving
ef88ec7134 feat: 店员昵称及性别修改纳入资料审核 2025-10-20 23:10:44 -04:00
15 changed files with 223 additions and 23 deletions

View File

@@ -1,7 +1,9 @@
package com.starry.admin.modules.clerk.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.common.exception.CustomException;
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;
@@ -216,6 +218,9 @@ public class PlayClerkUserInfoController {
@PostMapping(value = "/update")
public R update(@ApiParam(value = "店员信息", required = true) @Validated @RequestBody PlayClerkUserEditVo vo) {
PlayClerkUserInfoEntity entity = ConvertUtil.entityToVo(vo, PlayClerkUserInfoEntity.class);
if (StrUtil.isNotBlank(vo.getSex())) {
throw new CustomException("性别修改需要提交资料审核");
}
boolean success = playClerkUserInfoService.update(entity);
if (success) {
return R.ok();
@@ -233,6 +238,9 @@ public class PlayClerkUserInfoController {
@PostMapping(value = "/updateState")
public R updateState(
@ApiParam(value = "店员状态信息", required = true) @Validated @RequestBody PlayClerkUserStateEditVo vo) {
if (StrUtil.isNotBlank(vo.getSex())) {
throw new CustomException("性别修改需要提交资料审核");
}
PlayClerkUserInfoEntity entity = ConvertUtil.entityToVo(vo, PlayClerkUserInfoEntity.class);
boolean success = playClerkUserInfoService.update(entity);
if (success) {

View File

@@ -36,7 +36,7 @@ public class PlayClerkDataReviewInfoEntity extends BaseEntity<PlayClerkDataRevie
private String clerkId;
/**
* 资料类型[0:昵称;1:头像;2:相册;3:录音]
* 资料类型[0:昵称;1:头像;2:相册;3:录音;4:性别]
*/
private String dataType;

View File

@@ -16,7 +16,8 @@ public enum ClerkDataType {
NICKNAME("0", "昵称"),
AVATAR("1", "头像"),
PHOTO_ALBUM("2", "相册"),
RECORDING("3", "录音");
RECORDING("3", "录音"),
GENDER("4", "性别");
private final String code;
private final String description;

View File

@@ -25,9 +25,9 @@ public class PlayClerkDataReviewQueryVo extends BasePageEntity {
private String clerkId;
/**
* 资料类型[0:昵称;1:头像;2:相册;3:录音]
* 资料类型[0:昵称;1:头像;2:相册;3:录音;4:性别]
*/
@ApiModelProperty(value = "资料类型", example = "1", notes = "0:昵称;1:头像;2:相册;3:录音")
@ApiModelProperty(value = "资料类型", example = "1", notes = "0:昵称;1:头像;2:相册;3:录音;4:性别")
private String dataType;
/**

View File

@@ -43,15 +43,15 @@ public class PlayClerkDataReviewReturnVo {
private String clerkAvatar;
/**
* 资料类型[0:昵称;1:头像;2:相册;3:录音]
* 资料类型[0:昵称;1:头像;2:相册;3:录音;4:性别]
*/
@ApiModelProperty(value = "资料类型", example = "1", notes = "0:昵称;1:头像;2:相册;3:录音")
@ApiModelProperty(value = "资料类型", example = "1", notes = "0:昵称;1:头像;2:相册;3:录音;4:性别")
private String dataType;
/**
* 资料类型枚举(新增字段,用于类型安全)
*/
@ApiModelProperty(value = "资料类型枚举", example = "AVATAR", notes = "NICKNAME:昵称, AVATAR:头像, PHOTO_ALBUM:相册, RECORDING:录音")
@ApiModelProperty(value = "资料类型枚举", example = "AVATAR", notes = "NICKNAME:昵称, AVATAR:头像, PHOTO_ALBUM:相册, RECORDING:录音, GENDER:性别")
private ClerkDataType dataTypeEnum;
/**

View File

@@ -140,6 +140,9 @@ public class PlayClerkDataReviewInfoServiceImpl
if (ClerkReviewState.APPROVED.equals(reviewState)) {
PlayClerkUserInfoEntity userInfo = new PlayClerkUserInfoEntity();
userInfo.setId(entity.getClerkId());
if ("0".equals(entity.getDataType())) {
userInfo.setNickname(entity.getDataContent().isEmpty() ? null : entity.getDataContent().get(0));
}
if ("1".equals(entity.getDataType())) {
userInfo.setAvatar(entity.getDataContent().get(0));
}
@@ -149,6 +152,9 @@ public class PlayClerkDataReviewInfoServiceImpl
if ("3".equals(entity.getDataType())) {
userInfo.setAudio(entity.getDataContent().get(0));
}
if ("4".equals(entity.getDataType())) {
userInfo.setSex(entity.getDataContent().isEmpty() ? null : entity.getDataContent().get(0));
}
playClerkUserInfoService.update(userInfo);
}
}

View File

@@ -12,6 +12,7 @@ import com.starry.admin.common.domain.LoginUser;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.clerk.mapper.PlayClerkUserInfoMapper;
import com.starry.admin.modules.clerk.module.entity.PlayClerkCommodityEntity;
import com.starry.admin.modules.clerk.module.entity.PlayClerkDataReviewInfoEntity;
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;
@@ -21,6 +22,7 @@ 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.PlayClerkUnsettledWagesInfoReturnVo;
import com.starry.admin.modules.clerk.service.IPlayClerkCommodityService;
import com.starry.admin.modules.clerk.service.IPlayClerkDataReviewInfoService;
import com.starry.admin.modules.clerk.service.IPlayClerkLevelInfoService;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.custom.entity.PlayCustomFollowInfoEntity;
@@ -50,6 +52,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -71,6 +74,8 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
@Resource
private IPlayClerkCommodityService playClerkCommodityService;
@Resource
private IPlayClerkDataReviewInfoService playClerkDataReviewInfoService;
@Resource
private IPlayCustomFollowInfoService customFollowInfoService;
@Resource
private IPlayBalanceDetailsInfoService playBalanceDetailsInfoService;
@@ -150,21 +155,29 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
@Override
public PlayClerkUserLoginResponseVo getVo(PlayClerkUserInfoEntity userInfo) {
PlayClerkUserLoginResponseVo result = ConvertUtil.entityToVo(userInfo, PlayClerkUserLoginResponseVo.class);
// List<PlayClerkDataReviewInfoEntity> list =
// playClerkDataReviewInfoService.queryByClerkId(userInfo.getId(),"0");
// // 判断头像、音频、相册是否可以编辑,如果存在未审核的数据,则不允许编辑
// Map<String, PlayClerkDataReviewInfoEntity> map =
// list.stream().collect(Collectors.toMap(PlayClerkDataReviewInfoEntity::getDataType,
// account -> account, (entity1, entity2) -> entity1));
// if (map.containsKey("1")) {
// result.setAvatarAllowEdit(false);
// }
// if (map.containsKey("2")) {
// result.setAlbumAllowEdit(false);
// }
// if (map.containsKey("3")) {
// result.setAudioAllowEdit(false);
// }
List<PlayClerkDataReviewInfoEntity> pendingReviews = playClerkDataReviewInfoService
.queryByClerkId(userInfo.getId(), "0");
if (pendingReviews != null && !pendingReviews.isEmpty()) {
Set<String> pendingTypes = pendingReviews.stream()
.map(PlayClerkDataReviewInfoEntity::getDataType)
.filter(StrUtil::isNotBlank)
.collect(Collectors.toSet());
if (pendingTypes.contains("0")) {
result.setNicknameAllowEdit(false);
}
if (pendingTypes.contains("1")) {
result.setAvatarAllowEdit(false);
}
if (pendingTypes.contains("2")) {
result.setAlbumAllowEdit(false);
}
if (pendingTypes.contains("3")) {
result.setAudioAllowEdit(false);
}
if (pendingTypes.contains("4")) {
result.setSexAllowEdit(false);
}
}
// 是店员之后,判断是否可以登录
if ("1".equals(result.getClerkState())) {
// 设置店员是否运行登录

View File

@@ -2,6 +2,7 @@ package com.starry.admin.modules.order.module.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.starry.common.domain.BaseEntity;
import com.starry.common.enums.EvaluateHiddenState;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -74,6 +75,7 @@ public class PlayOrderEvaluateInfoEntity extends BaseEntity<PlayOrderEvaluateInf
/**
* 数据是否隐藏0:显示1:隐藏)
* @see EvaluateHiddenState
*/
private String hidden;

View File

@@ -1,5 +1,6 @@
package com.starry.admin.modules.order.module.vo;
import com.starry.common.enums.EvaluateHiddenState;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotBlank;
@@ -24,9 +25,10 @@ public class PlayOrderEvaluateEditStateVo {
/**
* 数据是否隐藏0:显示1:隐藏)
* @see EvaluateHiddenState
*/
@NotBlank(message = "是否隐藏不能为空")
@Pattern(regexp = "[01]", message = "是否隐藏数据错误,只能位0或者1")
@ApiModelProperty(value = "是否隐藏", required = true, example = "1", notes = "数据是否隐藏0:显示1:隐藏")
@ApiModelProperty(value = "是否隐藏", required = true, example = "1", notes = "数据是否隐藏0:显示1:隐藏。使用 EvaluateHiddenState 枚举值")
private String hidden;
}

View File

@@ -17,6 +17,7 @@ import com.starry.admin.modules.order.module.vo.PlayOrderEvaluateReturnVo;
import com.starry.admin.modules.order.service.IPlayOrderEvaluateInfoService;
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
import com.starry.admin.utils.SecurityUtils;
import com.starry.common.enums.EvaluateHiddenState;
import com.starry.common.utils.IdUtils;
import com.starry.common.utils.StringUtils;
import java.util.Arrays;

View File

@@ -46,6 +46,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -242,6 +243,36 @@ public class WxClerkController {
return R.ok("申请成功");
}
@ApiOperation(value = "更新昵称", notes = "店员更新昵称")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
@ClerkUserLogin
@PostMapping("/user/updateNickname")
public R updateNickname(@ApiParam(value = "昵称信息", required = true) @Validated @RequestBody PlayClerkUserNicknameVo vo) {
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
PlayClerkDataReviewInfoEntity entity = new PlayClerkDataReviewInfoEntity();
entity.setClerkId(userInfo.getId());
entity.setDataType("0");
entity.setReviewState("0");
entity.setDataContent(Collections.singletonList(vo.getNickname()));
playClerkDataReviewInfoService.create(entity);
return R.ok("提交成功,等待审核~");
}
@ApiOperation(value = "更新性别", notes = "店员更新性别")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
@ClerkUserLogin
@PostMapping("/user/updateSex")
public R updateSex(@ApiParam(value = "性别信息", required = true) @Validated @RequestBody PlayClerkUserSexVo vo) {
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
PlayClerkDataReviewInfoEntity entity = new PlayClerkDataReviewInfoEntity();
entity.setClerkId(userInfo.getId());
entity.setDataType("4");
entity.setReviewState("0");
entity.setDataContent(Collections.singletonList(String.valueOf(vo.getSex())));
playClerkDataReviewInfoService.create(entity);
return R.ok("提交成功,等待审核~");
}
@ApiOperation(value = "更新头像", notes = "店员更新头像")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
@ClerkUserLogin
@@ -324,6 +355,10 @@ public class WxClerkController {
@ClerkUserLogin
@PostMapping("/user/updateOther")
public R updateOther(@Validated @RequestBody PlayClerkUserOtherVo vo) {
if (vo.getSex() != null) {
throw new CustomException("性别修改需要提交资料审核");
}
vo.setSex(null);
PlayClerkUserInfoEntity userInfo = ConvertUtil.entityToVo(vo, PlayClerkUserInfoEntity.class);
userInfo.setId(ThreadLocalRequestDetail.getClerkUserInfo().getId());
playClerkUserInfoService.update(userInfo);
@@ -518,6 +553,8 @@ public class WxClerkController {
@PostMapping("/user/queryEvaluateByPage")
public R queryEvaluateById(@Validated @RequestBody PlayOrderEvaluateQueryVo vo) {
clerkUserInfoService.selectById(vo.getClerkId());
// Force filter to show only visible evaluations (hidden = "0") for WeChat client
vo.setHidden(com.starry.common.enums.EvaluateHiddenState.VISIBLE.getCode());
return R.ok(playOrderEvaluateInfoService.selectByPage(vo));
}

View File

@@ -35,6 +35,11 @@ public class PlayClerkUserLoginResponseVo {
*/
private boolean avatarAllowEdit = true;
/**
* 昵称是否可编辑
*/
private boolean nicknameAllowEdit = true;
/**
* 相册
*/
@@ -55,6 +60,11 @@ public class PlayClerkUserLoginResponseVo {
*/
private boolean audioAllowEdit = true;
/**
* 性别是否可编辑
*/
private boolean sexAllowEdit = true;
/**
* 店员性别0:未知;1:男;2:女)
*/

View File

@@ -0,0 +1,17 @@
package com.starry.admin.modules.weichat.entity;
import javax.validation.constraints.NotBlank;
import lombok.Data;
/**
* 店员昵称修改请求
*/
@Data
public class PlayClerkUserNicknameVo {
/**
* 店员昵称
*/
@NotBlank(message = "昵称不能为空")
private String nickname;
}

View File

@@ -0,0 +1,21 @@
package com.starry.admin.modules.weichat.entity;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import lombok.Data;
/**
* 店员性别修改请求
*/
@Data
public class PlayClerkUserSexVo {
/**
* 店员性别0:未知;1:男;2:女)
*/
@NotNull(message = "性别不能为空")
@Min(value = 0, message = "性别参数错误")
@Max(value = 2, message = "性别参数错误")
private Integer sex;
}

View File

@@ -0,0 +1,82 @@
package com.starry.common.enums;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
/**
* 评价隐藏状态枚举,集中维护状态代码及含义。
* 用于订单评价、打赏等记录的显示/隐藏控制。
*/
@ApiModel(value = "评价隐藏状态", description = "评价隐藏状态枚举,避免魔法值")
public enum EvaluateHiddenState {
VISIBLE("0", "显示"),
HIDDEN("1", "隐藏");
private final String code;
private final String description;
EvaluateHiddenState(String code, String description) {
this.code = code;
this.description = description;
}
@JsonValue
public String getCode() {
return code;
}
public String getDescription() {
return description;
}
/**
* 从代码获取枚举实例
*
* @param code 状态代码
* @return 对应的枚举实例
*/
@JsonCreator
public static EvaluateHiddenState fromCode(String code) {
if (code == null) {
return null;
}
for (EvaluateHiddenState state : EvaluateHiddenState.values()) {
if (state.code.equals(code)) {
return state;
}
}
throw new IllegalArgumentException("Unknown EvaluateHiddenState code: " + code);
}
/**
* 判断是否为显示状态
*
* @param code 状态代码
* @return true: 显示, false: 隐藏或未知
*/
public static boolean isVisible(String code) {
return VISIBLE.code.equals(code);
}
/**
* 判断是否为隐藏状态
*
* @param code 状态代码
* @return true: 隐藏, false: 显示或未知
*/
public static boolean isHidden(String code) {
return HIDDEN.code.equals(code);
}
/**
* 切换显示/隐藏状态
*
* @param currentCode 当前状态代码
* @return 切换后的状态代码
*/
public static String toggle(String currentCode) {
return isHidden(currentCode) ? VISIBLE.code : HIDDEN.code;
}
}