|
@@ -22,6 +22,8 @@ import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.vo.CommonCommentVo;
|
|
import shop.alien.entity.store.vo.CommonCommentVo;
|
|
|
import shop.alien.entity.store.vo.CommonRatingVo;
|
|
import shop.alien.entity.store.vo.CommonRatingVo;
|
|
|
|
|
+import shop.alien.entity.store.vo.MyMergedReviewItemVo;
|
|
|
|
|
+import shop.alien.entity.store.vo.OrderReviewVo;
|
|
|
import shop.alien.entity.store.vo.StoreInfoScoreVo;
|
|
import shop.alien.entity.store.vo.StoreInfoScoreVo;
|
|
|
import shop.alien.entity.store.vo.WebSocketVo;
|
|
import shop.alien.entity.store.vo.WebSocketVo;
|
|
|
import shop.alien.entity.storePlatform.StoreOperationalActivity;
|
|
import shop.alien.entity.storePlatform.StoreOperationalActivity;
|
|
@@ -31,6 +33,7 @@ import shop.alien.util.common.Constants;
|
|
|
import shop.alien.store.config.WebSocketProcess;
|
|
import shop.alien.store.config.WebSocketProcess;
|
|
|
import shop.alien.store.service.CommonCommentService;
|
|
import shop.alien.store.service.CommonCommentService;
|
|
|
import shop.alien.store.service.CommonRatingService;
|
|
import shop.alien.store.service.CommonRatingService;
|
|
|
|
|
+import shop.alien.store.service.OrderReviewService;
|
|
|
import shop.alien.store.service.LifeDiscountCouponStoreFriendService;
|
|
import shop.alien.store.service.LifeDiscountCouponStoreFriendService;
|
|
|
import shop.alien.store.util.CommonConstant;
|
|
import shop.alien.store.util.CommonConstant;
|
|
|
import shop.alien.store.util.ai.AiContentModerationUtil;
|
|
import shop.alien.store.util.ai.AiContentModerationUtil;
|
|
@@ -88,6 +91,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
|
|
|
private final StoreOperationalActivityMapper storeOperationalActivityMapper;
|
|
private final StoreOperationalActivityMapper storeOperationalActivityMapper;
|
|
|
private final ReceiptAuditUtil receiptAuditUtil;
|
|
private final ReceiptAuditUtil receiptAuditUtil;
|
|
|
private final StoreClockInMapper storeClockInMapper;
|
|
private final StoreClockInMapper storeClockInMapper;
|
|
|
|
|
+ private final OrderReviewService orderReviewService;
|
|
|
|
|
|
|
|
public static final List<String> SERVICES_LIST = ImmutableList.of(
|
|
public static final List<String> SERVICES_LIST = ImmutableList.of(
|
|
|
TextReviewServiceEnum.COMMENT_DETECTION_PRO.getService(),
|
|
TextReviewServiceEnum.COMMENT_DETECTION_PRO.getService(),
|
|
@@ -1132,6 +1136,121 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
|
|
|
return iPageR;
|
|
return iPageR;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R<IPage<MyMergedReviewItemVo>> getMyMergedRatingList(Integer pageNum, Integer pageSize, Integer businessType,
|
|
|
|
|
+ Long userId, Integer auditStatus, Integer currentUserId) {
|
|
|
|
|
+ if (userId == null) {
|
|
|
|
|
+ return R.fail("userId不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ int pn = pageNum == null || pageNum < 1 ? 1 : pageNum;
|
|
|
|
|
+ int ps = pageSize == null || pageSize < 1 ? 10 : pageSize;
|
|
|
|
|
+ int perSource = Math.min(pn * ps, 1000);
|
|
|
|
|
+ int biz = businessType != null ? businessType : RatingBusinessTypeEnum.STORE_RATING.getBusinessType();
|
|
|
|
|
+
|
|
|
|
|
+ List<MyMergedReviewItemVo> merged = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ R storeR = getMyRatingList(1, perSource, biz, userId, auditStatus);
|
|
|
|
|
+ if (R.isSuccess(storeR) && storeR.getData() != null) {
|
|
|
|
|
+ IPage<?> sp = (IPage<?>) storeR.getData();
|
|
|
|
|
+ for (Object o : sp.getRecords()) {
|
|
|
|
|
+ if (o instanceof CommonRatingVo) {
|
|
|
|
|
+ merged.add(toMergedStoreItem((CommonRatingVo) o));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ R<IPage<OrderReviewVo>> lawyerR = orderReviewService.getMyReviewList(1, perSource, userId.intValue(), currentUserId);
|
|
|
|
|
+ if (R.isSuccess(lawyerR) && lawyerR.getData() != null && lawyerR.getData().getRecords() != null) {
|
|
|
|
|
+ for (OrderReviewVo vo : lawyerR.getData().getRecords()) {
|
|
|
|
|
+ merged.add(toMergedLawyerItem(vo));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ merged.sort(Comparator.comparing(MyMergedReviewItemVo::getPublishTime,
|
|
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder())).reversed());
|
|
|
|
|
+
|
|
|
|
|
+ long storeTotal = 0L;
|
|
|
|
|
+ if (R.isSuccess(storeR) && storeR.getData() != null) {
|
|
|
|
|
+ storeTotal = ((IPage<?>) storeR.getData()).getTotal();
|
|
|
|
|
+ }
|
|
|
|
|
+ long lawyerTotal = 0L;
|
|
|
|
|
+ if (R.isSuccess(lawyerR) && lawyerR.getData() != null) {
|
|
|
|
|
+ lawyerTotal = lawyerR.getData().getTotal();
|
|
|
|
|
+ }
|
|
|
|
|
+ long total = storeTotal + lawyerTotal;
|
|
|
|
|
+
|
|
|
|
|
+ int from = (pn - 1) * ps;
|
|
|
|
|
+ List<MyMergedReviewItemVo> pageSlice;
|
|
|
|
|
+ if (from >= merged.size()) {
|
|
|
|
|
+ pageSlice = Collections.emptyList();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ int to = Math.min(from + ps, merged.size());
|
|
|
|
|
+ pageSlice = merged.subList(from, to);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Page<MyMergedReviewItemVo> page = new Page<>(pn, ps, total);
|
|
|
|
|
+ page.setRecords(pageSlice);
|
|
|
|
|
+ return R.data(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static MyMergedReviewItemVo toMergedStoreItem(CommonRatingVo vo) {
|
|
|
|
|
+ MyMergedReviewItemVo m = new MyMergedReviewItemVo();
|
|
|
|
|
+ m.setItemType("STORE");
|
|
|
|
|
+ m.setStoreRatingId(vo.getId());
|
|
|
|
|
+ m.setPublishTime(vo.getCreatedTime());
|
|
|
|
|
+ m.setScore(vo.getScore());
|
|
|
|
|
+ m.setContent(vo.getContent());
|
|
|
|
|
+ m.setMediaUrls(splitImageUrlsToMediaList(vo.getImageUrls()));
|
|
|
|
|
+ m.setStoreId(vo.getBusinessId());
|
|
|
|
|
+ m.setStoreName(vo.getStoreName());
|
|
|
|
|
+ m.setStoreIcon(null);
|
|
|
|
|
+ m.setBusinessType(vo.getBusinessType());
|
|
|
|
|
+ return m;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static MyMergedReviewItemVo toMergedLawyerItem(OrderReviewVo vo) {
|
|
|
|
|
+ MyMergedReviewItemVo m = new MyMergedReviewItemVo();
|
|
|
|
|
+ m.setItemType("LAWYER");
|
|
|
|
|
+ m.setLawyerReviewId(vo.getId());
|
|
|
|
|
+ m.setPublishTime(vo.getCreatedTime());
|
|
|
|
|
+ m.setScore(vo.getOverallRating());
|
|
|
|
|
+ m.setContent(vo.getReviewContent());
|
|
|
|
|
+ m.setMediaUrls(vo.getReviewImages() != null ? new ArrayList<>(vo.getReviewImages()) : new ArrayList<>());
|
|
|
|
|
+ m.setLawyerName(vo.getLawyerName());
|
|
|
|
|
+ m.setLawyerAvatar(vo.getLawyerAvatar());
|
|
|
|
|
+ m.setLawyerFirm(vo.getLawFirmName());
|
|
|
|
|
+ m.setRatingTag(lawyerRatingTagText(vo.getOverallRating()));
|
|
|
|
|
+ m.setLawyerUserId(vo.getLawyerUserId());
|
|
|
|
|
+ m.setOrderId(vo.getOrderId());
|
|
|
|
|
+ return m;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static List<String> splitImageUrlsToMediaList(String imageUrls) {
|
|
|
|
|
+ if (imageUrls == null || imageUrls.trim().isEmpty()) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ return Arrays.stream(imageUrls.split(","))
|
|
|
|
|
+ .map(String::trim)
|
|
|
|
|
+ .filter(s -> !s.isEmpty())
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String lawyerRatingTagText(Double overallRating) {
|
|
|
|
|
+ if (overallRating == null) {
|
|
|
|
|
+ return "我给出评价";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (overallRating >= 4.5D) {
|
|
|
|
|
+ return "我给出超赞";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (overallRating >= 3.5D) {
|
|
|
|
|
+ return "我给出好评";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (overallRating >= 2.5D) {
|
|
|
|
|
+ return "我给出中评";
|
|
|
|
|
+ }
|
|
|
|
|
+ return "我给出差评";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
@Override
|
|
@Override
|
|
|
public Double getAverageScore(Integer businessType, Long businessId) {
|
|
public Double getAverageScore(Integer businessType, Long businessId) {
|