feat:评价

This commit is contained in:
dzc committed 2026-01-06 16:05:09 +08:00
1 parent 7bd97ee83d
commit dbb40d0a62
5 files changed
+53 -7

No files matched your search

@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.member.controller.admin.recent.vo;
import cn.iocoder.yudao.module.member.controller.app.recent.vo.AppEvaluateDetailResVo;
import cn.iocoder.yudao.module.member.dal.dataobject.recent.RecentDO;
import cn.iocoder.yudao.module.member.service.photo.BO.MemberPhotoTotalExtBO;
import cn.iocoder.yudao.module.member.service.user.BO.MemberExtBO;
@@ -36,6 +37,9 @@ public class RecentPageResVo extends RecentDO {
@Schema(description = "用户相册")
private List<RecentPageResVo.MemberPhoto> MemberPhotoList;
@Schema(description = "用户评价")
private AppEvaluateDetailResVo evaluateDetail;
@Schema(description = "距离(km)")
private Double distance;
@@ -150,7 +150,7 @@ public class AppRecentController {
@PostMapping("/evaluate-detail")
@Operation(summary = "我的评价总分数详情")
public CommonResult<AppEvaluateDetailResVo> evaluateDetail() {
return success(recentService.evaluateDetail(getLoginUserId()));
return success(recentService.evaluateDetail(getLoginUserId(), null));
}
@GetMapping("/getById")
@@ -37,4 +37,9 @@ public class AppEvaluateDetailResVo {
* 评价数量
*/
private Integer evaluateCount = 0;
/**
* 当前用户是否可以评价
*/
private Boolean canEvaluate = false;
}
@@ -101,7 +101,7 @@ public interface RecentService {
/**
* 我的评价总分数详情
*/
AppEvaluateDetailResVo evaluateDetail(Long userId);
AppEvaluateDetailResVo evaluateDetail(Long userId, Long operateUserId);
/**
* 查询朋友圈用户
@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.member.service.recent;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@@ -60,6 +62,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.recent.RecentMapper;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@@ -605,12 +608,41 @@ public class RecentServiceImpl implements RecentService {
* 我的评价总分数详情
*/
@Override
public AppEvaluateDetailResVo evaluateDetail(Long userid) {
public AppEvaluateDetailResVo evaluateDetail(Long userid, Long operateUserId) {
AppEvaluateDetailResVo total = operationMapper.evaluateDetail(userid);
if (ObjectUtil.isEmpty(total)) return new AppEvaluateDetailResVo();
int allTotal = total.getScoreSc() + total.getScoreNx() + total.getScoreSk() + total.getScoreYq();
int avgScore = new BigDecimal(allTotal).divide(BigDecimal.valueOf(4), 0, RoundingMode.HALF_UP).intValue();
total.setAvgScore(avgScore);
if (ObjectUtil.isNotEmpty(total)) {
int allTotal = total.getScoreSc() + total.getScoreNx() + total.getScoreSk() + total.getScoreYq();
int avgScore = new BigDecimal(allTotal).divide(BigDecimal.valueOf(4), 0, RoundingMode.HALF_UP).intValue();
total.setAvgScore(avgScore);
} else {
total = new AppEvaluateDetailResVo();
}
if (ObjectUtil.isNotEmpty(operateUserId)) {
// 查看是否已评价
Long evaluateCount = operationMapper.selectCount(new LambdaQueryWrapperX<OperationDO>()
.eq(OperationDO::getOperatorMemberId, operateUserId)
.eqIfPresent(OperationDO::getMemberId, userid)
.eq(OperationDO::getBizType, MemberRecentOperateEnum.MEMBER_RATING.getType())
.isNull(OperationDO::getCancelTime)
);
if (evaluateCount > 0) {
total.setCanEvaluate(false);
return total;
}
// 当前用户`operateUserId`是否在3个小时前查看过`userid`的微信
LocalDateTime time = LocalDateTime.now().minusHours(3);
String timeStr = LocalDateTimeUtil.format(time, DatePattern.NORM_DATETIME_PATTERN);
Long count = operationMapper.selectCount(new LambdaQueryWrapperX<OperationDO>()
.eq(OperationDO::getOperatorMemberId, operateUserId)
.eqIfPresent(OperationDO::getMemberId, userid)
.eq(OperationDO::getBizType, MemberRecentOperateEnum.MEMBER_LOOK_WECHAT.getType())
.isNull(OperationDO::getCancelTime)
.le(OperationDO::getTapTime, timeStr)
);
if (count > 0) {
total.setCanEvaluate(true);
}
}
return total;
}
@@ -639,6 +671,11 @@ public class RecentServiceImpl implements RecentService {
if (ObjectUtil.isNotEmpty(operation)) {
result.setUserOperationStatus(operation);
}
// 评价相关
AppEvaluateDetailResVo evaluateDetailResVo = evaluateDetail(userId, operateUserId);
if (ObjectUtil.isNotEmpty(evaluateDetailResVo)) {
result.setEvaluateDetail(evaluateDetailResVo);
}
if (ObjectUtil.isNotEmpty(result.getUserOperationStatus())) {
Boolean isLookWechat = result.getUserOperationStatus().getIsLookWechat();
if (Boolean.TRUE.equals(isLookWechat)) {