|
|
@@ -18,13 +18,16 @@ import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.dto.StoreStaffReviewDto;
|
|
|
import shop.alien.entity.store.vo.*;
|
|
|
import shop.alien.mapper.LifeLikeRecordMapper;
|
|
|
+import shop.alien.mapper.StoreInfoMapper;
|
|
|
import shop.alien.mapper.StoreStaffCommentMapper;
|
|
|
import shop.alien.mapper.StoreStaffConfigMapper;
|
|
|
import shop.alien.mapper.StoreStaffReviewMapper;
|
|
|
+import shop.alien.mapper.StoreUserMapper;
|
|
|
import shop.alien.store.service.StoreStaffCommentService;
|
|
|
import shop.alien.store.service.StoreStaffReviewService;
|
|
|
import shop.alien.store.util.ai.AiContentModerationUtil;
|
|
|
import shop.alien.store.util.ai.AiVideoModerationUtil;
|
|
|
+import shop.alien.util.common.DistanceUtil;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
@@ -51,6 +54,8 @@ public class StoreStaffReviewServiceImpl extends ServiceImpl<StoreStaffReviewMap
|
|
|
private final StoreStaffCommentMapper storeStaffCommentMapper;
|
|
|
private final LifeLikeRecordMapper lifeLikeRecordMapper;
|
|
|
private final StoreStaffConfigMapper storeStaffConfigMapper;
|
|
|
+ private final StoreInfoMapper storeInfoMapper;
|
|
|
+ private final StoreUserMapper storeUserMapper;
|
|
|
private final AiContentModerationUtil aiContentModerationUtil;
|
|
|
@Qualifier("commonVideoTaskExecutor")
|
|
|
private final ExecutorService commonVideoTaskExecutor;
|
|
|
@@ -154,8 +159,8 @@ public class StoreStaffReviewServiceImpl extends ServiceImpl<StoreStaffReviewMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R<StoreStaffReviewDetailVo> getReviewDetail(Integer reviewId, Integer currentUserId) {
|
|
|
- log.info("获取评价详情, reviewId={}, currentUserId={}", reviewId, currentUserId);
|
|
|
+ public R<StoreStaffReviewDetailVo> getReviewDetail(Integer reviewId, Integer currentUserId, Double longitude, Double latitude) {
|
|
|
+ log.info("获取评价详情, reviewId={}, currentUserId={}, longitude={}, latitude={}", reviewId, currentUserId, longitude, latitude);
|
|
|
|
|
|
if (reviewId == null) {
|
|
|
return R.fail("评价ID不能为空");
|
|
|
@@ -183,19 +188,79 @@ public class StoreStaffReviewServiceImpl extends ServiceImpl<StoreStaffReviewMap
|
|
|
|
|
|
// 查询人员信息
|
|
|
StoreStaffConfig staffInfo = null;
|
|
|
+ Integer storeId = null;
|
|
|
if (reviewVo.getStaffUserId() != null) {
|
|
|
try {
|
|
|
staffInfo = storeStaffConfigMapper.selectById(reviewVo.getStaffUserId());
|
|
|
+ if (staffInfo != null) {
|
|
|
+ storeId = staffInfo.getStoreId();
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.warn("查询人员信息失败, staffUserId={}, error={}", reviewVo.getStaffUserId(), e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 查询店铺信息(包括店铺头像、评分和距离)
|
|
|
+ StoreStaffReviewDetailVo.StoreInfoForStaffReviewVo storeInfoVo = null;
|
|
|
+ if (storeId != null) {
|
|
|
+ try {
|
|
|
+ // 查询店铺基本信息
|
|
|
+ StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
|
|
|
+ if (storeInfo != null) {
|
|
|
+ storeInfoVo = new StoreStaffReviewDetailVo.StoreInfoForStaffReviewVo();
|
|
|
+ storeInfoVo.setStoreId(storeId);
|
|
|
+ storeInfoVo.setStoreName(storeInfo.getStoreName());
|
|
|
+
|
|
|
+ // 设置店铺评分(平均评分)
|
|
|
+ if (storeInfo.getScoreAvg() != null) {
|
|
|
+ storeInfoVo.setScore(storeInfo.getScoreAvg());
|
|
|
+ } else {
|
|
|
+ storeInfoVo.setScore(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询店铺头像(来自store_user表的head_img字段)
|
|
|
+ LambdaQueryWrapper<StoreUser> userWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userWrapper.eq(StoreUser::getStoreId, storeId)
|
|
|
+ .eq(StoreUser::getDeleteFlag, 0);
|
|
|
+ StoreUser storeUser = storeUserMapper.selectOne(userWrapper);
|
|
|
+ if (storeUser != null && storeUser.getHeadImg() != null && !storeUser.getHeadImg().trim().isEmpty()) {
|
|
|
+ storeInfoVo.setHeadImg(storeUser.getHeadImg());
|
|
|
+ } else {
|
|
|
+ storeInfoVo.setHeadImg(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算距离(如果提供了用户经纬度)
|
|
|
+ if (longitude != null && latitude != null && storeInfo.getStorePosition() != null && !storeInfo.getStorePosition().trim().isEmpty()) {
|
|
|
+ try {
|
|
|
+ String[] positionArray = storeInfo.getStorePosition().split(",");
|
|
|
+ if (positionArray.length >= 2) {
|
|
|
+ double storeLon = Double.parseDouble(positionArray[0].trim());
|
|
|
+ double storeLat = Double.parseDouble(positionArray[1].trim());
|
|
|
+ // 计算距离(单位:公里)
|
|
|
+ double distanceKm = DistanceUtil.haversineCalculateDistance(longitude, latitude, storeLon, storeLat);
|
|
|
+ storeInfoVo.setDistance(distanceKm);
|
|
|
+ } else {
|
|
|
+ storeInfoVo.setDistance(null);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("计算店铺距离失败, storeId={}, error={}", storeId, e.getMessage());
|
|
|
+ storeInfoVo.setDistance(null);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ storeInfoVo.setDistance(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("查询店铺信息失败, storeId={}, error={}", storeId, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 构建返回结果
|
|
|
StoreStaffReviewDetailVo detailVo = new StoreStaffReviewDetailVo();
|
|
|
detailVo.setReview(reviewVo);
|
|
|
detailVo.setCommentList(comments != null ? comments : new ArrayList<>());
|
|
|
detailVo.setStaffInfo(staffInfo);
|
|
|
+ detailVo.setStoreInfo(storeInfoVo);
|
|
|
|
|
|
return R.data(detailVo);
|
|
|
}
|