From 17cea8fe652d1566e856e168d528a1af628e2140 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 14 Jul 2025 10:22:00 +0800
Subject: [PATCH] feat(mall): 添加订单角标数量接口并优化相关功能
---
src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 107 insertions(+), 3 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java
index 6e9ee3b..c9166ad 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java
@@ -27,9 +27,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@@ -62,6 +60,7 @@
private final ClothesTypeArtMapper clothesTypeArtMapper;
private final ClothesLocationRemarkMapper clothesLocationRemarkMapper;
private final ClothesPatternRemarkMapper clothesPatternRemarkMapper;
+ private final ClothesSocialCommentMapper clothesSocialCommentMapper;
@Override
@@ -114,8 +113,36 @@
// 调用Mapper方法获取活动分页数据
Page<ApiAllSocialVo> voPage = clothesSocialMapper.selectPageInSocial(page, dto);
+ List<ApiAllSocialVo> vos = voPage.getRecords();
+ if (CollUtil.isNotEmpty(vos)) {
+ Set<Long> socialIds = vos.stream()
+ .map(ApiAllSocialVo::getId)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+
+ if (CollUtil.isNotEmpty(socialIds)) {
+ List<ClothesSocialFollow> clothesSocialFollows = clothesSocialFollowMapper.selectList(
+ Wrappers.lambdaQuery(ClothesSocialFollow.class)
+ .select(ClothesSocialFollow::getId, ClothesSocialFollow::getSourceId)
+ .in(ClothesSocialFollow::getSourceId, socialIds)
+ .eq(ClothesSocialFollow::getType, SocialTypeEnum.LIKE.getValue())
+ );
+
+ Map<Long, Long> likeCountBySocialIdMap = new HashMap<>();
+ if (CollUtil.isNotEmpty(clothesSocialFollows)) {
+ likeCountBySocialIdMap = clothesSocialFollows.stream()
+ .collect(Collectors.groupingBy(ClothesSocialFollow::getSourceId, Collectors.counting()));
+ }
+
+ for (ApiAllSocialVo item : vos){
+ item.setLikeCnt(likeCountBySocialIdMap.getOrDefault(item.getId(), 0L).intValue());
+ }
+ }
+ }
+
return new FebsResponse().success().data(voPage);
}
+
@Override
public FebsResponse socialInfo(ApiSocialInfoDto dto) {
@@ -130,6 +157,7 @@
apiSocialInfoVo.setName(clothesSocial.getName());
apiSocialInfoVo.setContent(clothesSocial.getContent());
apiSocialInfoVo.setCreatedTime(clothesSocial.getCreatedTime());
+ apiSocialInfoVo.setCommentState(clothesSocial.getCommentState());
List<ClothesSocialFile> clothesSocialFiles = clothesSocialFileMapper.selectList(
Wrappers.lambdaQuery(ClothesSocialFile.class)
@@ -211,6 +239,29 @@
apiSocialMuseVo.setLocationRemarkList(locationRemarkList);
}
apiSocialMuseVo.setTotalAmount(totalAmount.setScale(2, RoundingMode.DOWN));
+
+ List<ClothesSocialFollow> clothesSocialFollows = clothesSocialFollowMapper.selectList(
+ Wrappers.lambdaQuery(ClothesSocialFollow.class)
+ .select(ClothesSocialFollow::getType)
+ .eq(ClothesSocialFollow::getSourceId, socialId)
+ );
+ if (CollUtil.isNotEmpty(clothesSocialFollows)){
+
+ Map<Integer, Long> collect = clothesSocialFollows.stream()
+ .collect(Collectors.groupingBy(ClothesSocialFollow::getType, Collectors.counting()));
+ apiSocialInfoVo.setLikeCnt(collect.getOrDefault(SocialTypeEnum.LIKE.getValue(), 0L).intValue());
+ apiSocialInfoVo.setCollectCnt(collect.getOrDefault(SocialTypeEnum.COLLECT.getValue(), 0L).intValue());
+ }
+
+ List<ClothesSocialComment> clothesSocialComments = clothesSocialCommentMapper.selectList(
+ Wrappers.lambdaQuery(ClothesSocialComment.class)
+ .eq(ClothesSocialComment::getSocialId, socialId)
+ .eq(ClothesSocialComment::getShowState, ClothesEnum.UP.getCode())
+ .isNull(ClothesSocialComment::getParentId)
+ );
+ if (CollUtil.isNotEmpty(clothesSocialComments)){
+ apiSocialInfoVo.setCommentCnt(clothesSocialComments.size());
+ }
}
}
@@ -496,6 +547,59 @@
return new FebsResponse().success().data(record);
}
+ @Override
+ public FebsResponse comment(ApiClothesSocialCommentDto dto) {
+
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ Long socialId = dto.getSocialId();
+ Long commentId = dto.getCommentId();
+ ClothesSocial clothesSocial = clothesSocialMapper.selectById(socialId);
+ if (ObjectUtil.isNull(clothesSocial)){
+ return new FebsResponse().fail().message("社区不存在");
+ }
+ if (ClothesEnum.DOWN.getCode() == clothesSocial.getCommentState()){
+ return new FebsResponse().fail().message("禁止评论");
+ }
+ ClothesSocialComment entity = new ClothesSocialComment();
+ entity.setMemberId(memberId);
+ entity.setSocialId(socialId);
+ entity.setComment(dto.getComment());
+ ClothesSocialComment clothesSocialComment = clothesSocialCommentMapper.selectById(commentId);
+ if(ObjectUtil.isNotNull(clothesSocialComment)){
+ entity.setParentId(clothesSocialComment.getParentId());
+ entity.setCommentId(clothesSocialComment.getId());
+ }
+ clothesSocialCommentMapper.insert(entity);
+
+ return new FebsResponse().success().message("操作成功");
+ }
+
+ @Override
+ public FebsResponse allComment(ApiAllCommentDto dto) {
+ // 创建分页对象,传入当前页和每页大小
+ Page<ApiAllCommentVo> page = new Page<>(dto.getPageNow(), dto.getPageSize());
+ // 调用Mapper方法获取活动分页数据
+ Page<ApiAllCommentVo> voPage = clothesSocialCommentMapper.selectPageInComment(page, dto);
+ List<ApiAllCommentVo> records = voPage.getRecords();
+ if (CollUtil.isNotEmpty(records)){
+ Set<Long> collect = records.stream().map(ApiAllCommentVo::getCommentId).collect(Collectors.toSet());
+ List<ClothesSocialComment> clothesSocialComments = clothesSocialCommentMapper.selectList(
+ Wrappers.lambdaQuery(ClothesSocialComment.class)
+ .select(ClothesSocialComment::getParentId)
+ .in(ClothesSocialComment::getParentId, collect)
+ .eq(ClothesSocialComment::getShowState, ClothesEnum.UP.getCode())
+ );
+ if (CollUtil.isNotEmpty(clothesSocialComments)){
+ Map<Long, Long> collect1 = clothesSocialComments.stream()
+ .collect(Collectors.groupingBy(ClothesSocialComment::getParentId, Collectors.counting()));
+ for (ApiAllCommentVo vo : records){
+ vo.setCommentCnt(collect1.getOrDefault(vo.getCommentId(), 0L).intValue());
+ }
+ }
+ }
+ return new FebsResponse().success().data(voPage);
+ }
+
public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
jsonObject.putByPath("text", "123");
--
Gitblit v1.9.1