|
|
@@ -54,6 +54,8 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
|
|
|
private final CommonCommentMapper commonCommentMapper;
|
|
|
|
|
|
+ private final CommonRatingService commonRatingService;
|
|
|
+
|
|
|
public int addLiulanCount(String id) {
|
|
|
LambdaUpdateWrapper<LifeUserDynamics> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
lambdaUpdateWrapper.eq(LifeUserDynamics::getId, id);
|
|
|
@@ -157,13 +159,38 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
// 查询动态数据并按类型过滤
|
|
|
List<LifeUserDynamicsVo> lifeUserDynamicsVoList = lifeUserDynamicsMapper.getLifeUserDynamicsList();
|
|
|
|
|
|
+ // 店铺id
|
|
|
+ // TODO 可以优化小驴:优化方案直接sql分组查询评价数量,避免循环查询
|
|
|
+ List<String> storeUserIdList = new ArrayList<>();
|
|
|
+ Map<String, Integer> commitCountMap = new HashMap<>();
|
|
|
//对lifeUserDynamicsVoList数据进行处理,当type为2的时候,把userName的数值赋值到storeName
|
|
|
lifeUserDynamicsVoList.forEach(item -> {
|
|
|
if (item.getType().equals("2")) {
|
|
|
item.setStoreName(item.getUserName());
|
|
|
+ storeUserIdList.add(item.getStoreUserId());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ for (String storeId : storeUserIdList) {
|
|
|
+ Integer totalCount = 0;
|
|
|
+ double storeScore;
|
|
|
+ Object ratingObj = commonRatingService.getRatingCount(Integer.parseInt(storeId), 1);
|
|
|
+ if (ratingObj != null) {
|
|
|
+ Map<String, Object> ratingMap = (Map<String, Object>) ratingObj;
|
|
|
+ Object totalCountObj = ratingMap.get("totalCount");
|
|
|
+ if (totalCountObj != null) {
|
|
|
+ // 安全转换为整数
|
|
|
+ try {
|
|
|
+ totalCount = Integer.parseInt(totalCountObj.toString().trim());
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ totalCount = 0; // 转换失败时默认值
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ totalCount = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ commitCountMap.put(storeId, totalCount);
|
|
|
+ }
|
|
|
if (!StringUtils.isEmpty(type)) {
|
|
|
lifeUserDynamicsVoList = lifeUserDynamicsVoList.stream().filter(item -> type.equals(item.getType())).collect(Collectors.toList());
|
|
|
}
|
|
|
@@ -207,6 +234,12 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
// 设置动态对象的状态信息:是否关注对方、是否被关注、是否点赞及评论数量
|
|
|
// 设置.imagePath。视频为mp4+jpg格式,图片为jpg/png格式。
|
|
|
for (LifeUserDynamicsVo vo : lifeUserDynamicsVoList) {
|
|
|
+ // 设置评价数量
|
|
|
+ if (commitCountMap.containsKey(vo.getStoreUserId())) {
|
|
|
+ vo.setRatingCount(commitCountMap.get(vo.getStoreUserId()).toString());
|
|
|
+ } else {
|
|
|
+ vo.setRatingCount("0");
|
|
|
+ }
|
|
|
if (followList.contains(vo.getPhoneId())) {
|
|
|
vo.setIsFollowThis("1");
|
|
|
} else {
|