|
|
@@ -1,13 +1,17 @@
|
|
|
package com.ylx.order.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ylx.common.core.domain.model.WxLoginUser;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
+import com.ylx.merchant.domain.dto.MerchantCommentDTO;
|
|
|
+import com.ylx.merchant.domain.vo.MerchantCommentVO;
|
|
|
import com.ylx.order.domain.CommentUserAudit;
|
|
|
import com.ylx.massage.mapper.TCommentUserAuditMapper;
|
|
|
+import com.ylx.order.domain.TCommentPicture;
|
|
|
import com.ylx.order.domain.TCommentUser;
|
|
|
import com.ylx.order.mapper.TCommentUserMapper;
|
|
|
import com.ylx.order.service.TCommentUserService;
|
|
|
@@ -20,8 +24,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 用户评论表(TCommentUser)表服务实现类
|
|
|
@@ -121,6 +128,41 @@ public class TCommentUserServiceImpl extends ServiceImpl<TCommentUserMapper, TCo
|
|
|
}
|
|
|
log.info("评论入库成功,评论ID:{},订单号:{},用户ID:{}", comment.getId(), dto.getOrderId(), userId);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<MerchantCommentVO> getMerchantComment(MerchantCommentDTO dto) {
|
|
|
+
|
|
|
+ Page<MerchantCommentVO> page = new Page<>(dto.getCurrent(), dto.getSize());
|
|
|
+ // 1.查询评论和订单基础信息
|
|
|
+ page = this.baseMapper.getMerchantComment(page, dto);
|
|
|
+ if(ObjectUtil.isNotNull(page) && ObjectUtil.isNotNull(page.getRecords())){
|
|
|
+ List<MerchantCommentVO> records = page.getRecords();
|
|
|
+
|
|
|
+ // 2. 提取所有评论ID
|
|
|
+ List<String> commentIds = records.stream()
|
|
|
+ .map(MerchantCommentVO::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 3. 批量查询图片
|
|
|
+ List<TCommentPicture> pictures = tCommentPictureService.selectByCommentIds(commentIds);
|
|
|
+
|
|
|
+ // 4. 将图片分组并填充到 VO 中
|
|
|
+ Map<String, List<String>> pictureMap = pictures.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ TCommentPicture::getCommentId,
|
|
|
+ Collectors.mapping(TCommentPicture::getPictureUrl, Collectors.toList())
|
|
|
+ ));
|
|
|
+
|
|
|
+ for (MerchantCommentVO vo : records) {
|
|
|
+ // 设置图片列表,如果没有图片则为空列表
|
|
|
+ vo.setPictures(pictureMap.getOrDefault(vo.getId(), Collections.emptyList()));
|
|
|
+ }
|
|
|
+ page.setRecords(records);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验评论参数
|
|
|
*/
|