Browse Source

Merge remote-tracking branch 'origin/master'

qxy 3 months ago
parent
commit
bff460fa36

+ 12 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreInfoScoreVo.java

@@ -0,0 +1,12 @@
+package shop.alien.entity.store.vo;
+
+import lombok.Data;
+
+@Data
+public class StoreInfoScoreVo {
+    private Double total;
+    private Double score;
+    private Double tasteScore;
+    private Double enScore;
+    private Double serviceScore;
+}

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/StoreCommentAppealMapper.java

@@ -26,7 +26,7 @@ public interface StoreCommentAppealMapper extends BaseMapper<StoreCommentAppeal>
      * @param queryWrapper 查询条件
      * @return IPage<StoreCommentAppealVo>
      */
-    @Select("select a.*, b.dict_detail appeal_status_str, c.comment_content, c.comment_star, c.score, c.other_score,c.is_anonymous, d.user_name, d.user_image, e.store_name, f.phone store_phone, f.name store_contact, e.store_type " +
+    @Select("select a.*, b.dict_detail appeal_status_str, c.comment_content, c.comment_star, c.score score, c.other_score,c.is_anonymous, d.user_name, d.user_image, e.store_name, f.phone store_phone, f.name store_contact, e.store_type " +
             "from store_comment_appeal a " +
             "left join store_dictionary b on a.appeal_status = b.dict_id and b.type_name = 'appealStatus' and b.delete_flag = 0 " +
             "left join store_comment c on a.comment_id = c.id " +

+ 3 - 6
alien-entity/src/main/java/shop/alien/mapper/StoreCommentMapper.java

@@ -8,10 +8,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import shop.alien.entity.store.LifeAppealManage;
 import shop.alien.entity.store.StoreComment;
-import shop.alien.entity.store.vo.LifeAppealManageVo;
-import shop.alien.entity.store.vo.LifeUserOrderCommentVo;
-import shop.alien.entity.store.vo.StoreCommentVo;
-import shop.alien.entity.store.vo.StoreCommitPercentVo;
+import shop.alien.entity.store.vo.*;
 
 import java.util.List;
 import java.util.Map;
@@ -115,7 +112,7 @@ public interface StoreCommentMapper extends BaseMapper<StoreComment> {
             "(select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and reply_id is null and score >= 0.5 and score <= 2.5 and store_id = #{storeId}) lowCommentCount, " +
             "(select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and score is not null and store_id = #{storeId}) allCommentCount, " +
             "(select count(1) from store_comment where business_type = 5 and reply_id is null and delete_flag = 0 and store_id = #{storeId}) rootCommentCount, " +
-            "(select count(DISTINCT reply_id) from store_comment where reply_id is NOT null and store_id = #{storeId} and phone_id like '%store%' and delete_flag = 0) commentCount ")
+            "(select count(DISTINCT reply_id) from store_comment where reply_id is NOT null and store_id = #{storeId} and phone_id like '%store%' and delete_flag = 0 and business_type = 1) commentCount ")
     StoreCommitPercentVo getCommentByStoreId(Integer storeId);
 
     @Select("SELECT " +
@@ -131,7 +128,7 @@ public interface StoreCommentMapper extends BaseMapper<StoreComment> {
             "AND delete_flag = 0 " +
             "AND reply_id IS NULL " +
             "AND store_id = #{storeId}")
-    Map<String, String> getCommentCountAndScoreInfo(@Param("storeId") Integer storeId);
+    StoreInfoScoreVo getCommentCountAndScoreInfo(@Param("storeId") Integer storeId);
 
 
     @Select("SELECT " +

+ 2 - 2
alien-entity/src/main/java/shop/alien/mapper/StoreEvaluationMapper.java

@@ -18,8 +18,8 @@ public interface StoreEvaluationMapper extends BaseMapper<StoreEvaluation> {
 
     // 获取全部店铺平均分
     @Select("select store_id,ifnull(round(avg(score), 1), 0) avg_score,count(*) total_num\n" +
-            "from store_evaluation eval,store_info store\n" +
-            "where eval.store_id = store.id and eval.delete_flag = 0\n" +
+            "from store_comment eval,store_info store\n" +
+            "where eval.store_id = store.id and eval.delete_flag = 0 and eval.business_type = 5\n" +
             "group by store_id ")
     List<Map<String, Object>> allStoreAvgScore();
 }

+ 1 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreCommentController.java

@@ -71,7 +71,7 @@ public class StoreCommentController {
             @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "String", paramType = "query")
     })
     @GetMapping("/getCommitCountAndScore")
-    public R<Map<String, String>> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days) {
+    public R<Map<String, Object>> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days) {
         log.info("StoreCommentController.getCommitCountAndScore?businessId={}&businessType={}&storeId={}&phoneId={}&days={}", businessId, businessType, storeId, phoneId, days);
         return R.data(storeCommentService.getCommitCountAndScore(businessId, businessType, storeId, phoneId, days));
     }

+ 19 - 4
alien-store/src/main/java/shop/alien/store/service/LifeUserStoreService.java

@@ -96,9 +96,9 @@ public class LifeUserStoreService {
             // 查询符合条件的优惠券列表
             List<LifeCoupon> quanList = lifeCouponMapper.selectList(quanWrapper);
             // 获取全部店铺的评分与平均花销
-            Map<Object, List<Map<String, Object>>> avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
+            Map<String, List<Map<String, Object>>> avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id").toString()));
             // 获取用户订单信息,用于计算平均消费
-            Map<Object, List<Map<String, Object>>> avgPriceMap = lifeUserOrderMapper.allStoreAvgPrice().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
+            Map<String, List<Map<String, Object>>> avgPriceMap = lifeUserOrderMapper.allStoreAvgPrice().stream().collect(Collectors.groupingBy(o -> o.get("store_id").toString()));
             // 获取所有店铺的打卡次数
             List<Map<Integer, Integer>> storeClockInCountList = storeClockInService.getStoreClockInCount();
             // 遍历所有门店信息,构造返回结果
@@ -122,15 +122,26 @@ public class LifeUserStoreService {
                 // 如果存在评分数据,则添加评分、平均消费及评价总数
                 if (avgScoreMap.containsKey(String.valueOf(store.getId()))) {
                     storeMap.put("avgScore", avgScoreMap.get(String.valueOf(store.getId())).get(0).get("avg_score"));
-                    storeMap.put("avgPrice", avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price"));
+                    //storeMap.put("avgPrice", avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price"));
                     // 条数
                     storeMap.put("totalNum", avgScoreMap.get(String.valueOf(store.getId())).get(0).get("total_num"));
                 } else {
                     // 否则,设置默认值
                     storeMap.put("avgScore", 0);
-                    storeMap.put("avgPrice", 0);
+                    //storeMap.put("avgPrice", 0);
                     storeMap.put("totalNum", 0);
                 }
+                if (avgPriceMap.containsKey(String.valueOf(store.getId()))) {
+                    //storeMap.put("avgScore", avgScoreMap.get(String.valueOf(store.getId())).get(0).get("avg_score"));
+                    storeMap.put("avgPrice", avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price"));
+                    // 条数
+                    //storeMap.put("totalNum", avgScoreMap.get(String.valueOf(store.getId())).get(0).get("total_num"));
+                } else {
+                    // 否则,设置默认值
+                    //storeMap.put("avgScore", 0);
+                    storeMap.put("avgPrice", 0);
+                    //storeMap.put("totalNum", 0);
+                }
                 // 添加门店名称
                 storeMap.put("storeName", store.getStoreName());
                 // 添加门店地址
@@ -195,6 +206,10 @@ public class LifeUserStoreService {
                         .sorted(Comparator.comparingDouble(storeMap -> (double) storeMap.get("distance")))
                         .collect(Collectors.toList());
             }
+
+            returnMaps = returnMaps.stream().sorted(Comparator.comparingDouble(storeMap -> Double.parseDouble( storeMap.get("avgScore").toString()) * -1)).collect(Collectors.toList());
+            //returnMaps.sort(Collections.reverseOrder());
+
             // 返回最终结果列表
             return returnMaps;
         } catch (Exception e) {

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/StoreCommentService.java

@@ -53,7 +53,7 @@ public interface StoreCommentService extends IService<StoreComment> {
      * @param storeId      门店id
      * @return Integer
      */
-    Map<String, String> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days);
+    Map<String, Object> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days);
 
     /**
      * 评论

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreClockInServiceImpl.java

@@ -140,7 +140,7 @@ public class StoreClockInServiceImpl extends ServiceImpl<StoreClockInMapper, Sto
 //            vo.setClockInStoreNum(clockInStoreNumMap.get(vo.getStoreId()));
 //            // 打卡次数
 //            vo.setClockInNum(clockInNum);
-            vo.setCommentCount(Integer.parseInt(storeCommentService.getCommitCountAndScore(vo.getId(), 4, vo.getStoreId(),null,null).get("commitCount")));
+            vo.setCommentCount(Integer.parseInt(storeCommentService.getCommitCountAndScore(vo.getId(), 4, vo.getStoreId(),null,null).get("commitCount").toString()));
         });
 
 

+ 9 - 10
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentServiceImpl.java

@@ -320,8 +320,8 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
      * @return Integer
      */
     @Override
-    public Map<String, String> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days) {
-        Map<String, String> map = new HashMap<>();
+    public Map<String, Object> getCommitCountAndScore(Integer businessId, Integer businessType, Integer storeId, String phoneId, Integer days) {
+        Map<String, Object> map = new HashMap<>();
         AtomicReference<Integer> count = new AtomicReference<>(0);
         QueryWrapper<StoreCommentVo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq(null != businessId, "a.business_id", businessId);
@@ -393,7 +393,7 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             });
         }
         map.put("commitCount", count.toString());
-        map.put("img", storeCommentVoList.stream().map(StoreCommentVo::getUserImage).limit(6).collect(Collectors.joining(",")));
+        map.put("img", storeCommentVoList.stream().filter(i -> i.getScore() >= 4.5).map(StoreCommentVo::getUserImage).distinct().limit(6).collect(Collectors.toList()));
         if (sumScore == 0 || storeCommentVoList.isEmpty()) {
             map.put("score", "0");
         } else {
@@ -576,13 +576,12 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             storeComment.setCreatedUserId(storeComment.getUserId());
 
             int i = this.save(storeComment) ? 0 : 1;
-            Map<String, String> commentCountAndScore = storeCommentMapper.getCommentCountAndScoreInfo(storeId);
-            String totalStr = String.valueOf(commentCountAndScore.get("total"));
-            double total = StringUtils.isNotEmpty(totalStr) ? Double.parseDouble(totalStr) : 0;
-            double scoreAvg = StringUtils.isNotEmpty(commentCountAndScore.get("score")) ? Double.parseDouble(commentCountAndScore.get("score")) / total : 0;
-            double tasteScore = StringUtils.isNotEmpty(commentCountAndScore.get("tasteScore")) ? Double.parseDouble(commentCountAndScore.get("tasteScore")) / total : 0;
-            double enScore = StringUtils.isNotEmpty(commentCountAndScore.get("enScore")) ? Double.parseDouble(commentCountAndScore.get("enScore")) / total : 0;
-            double serviceScore = StringUtils.isNotEmpty(commentCountAndScore.get("serviceScore")) ? Double.parseDouble(commentCountAndScore.get("serviceScore")) / total : 0;
+            StoreInfoScoreVo storeInfoScoreVo = storeCommentMapper.getCommentCountAndScoreInfo(storeId);
+            double total = storeInfoScoreVo.getTotal();
+            double scoreAvg = (total == 0 ? 0 : storeInfoScoreVo.getScore() / total);
+            double tasteScore = (total == 0 ? 0 : storeInfoScoreVo.getTasteScore() / total);
+            double enScore = (total == 0 ? 0 : storeInfoScoreVo.getEnScore() / total);
+            double serviceScore = (total == 0 ? 0 : storeInfoScoreVo.getServiceScore() / total);
             StoreInfo storeInfo = new StoreInfo();
             storeInfo.setId(storeId);
             storeInfo.setScoreAvg(scoreAvg);

+ 10 - 7
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1002,9 +1002,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             result.setScore(Double.parseDouble(avgScoreMap.get(String.valueOf(result.getId())).get(0).get("avg_score").toString()));
         }*/
 
-        Map<String, String> commitCountAndScore = storeCommentService.getCommitCountAndScore(null, 5, Integer.parseInt(storeId), null, null);
-        result.setScore(Double.parseDouble(commitCountAndScore.get("score")));
-        result.setCommitCount(commitCountAndScore.get("commitCount"));
+        Map<String, Object> commitCountAndScore = storeCommentService.getCommitCountAndScore(null, 5, Integer.parseInt(storeId), null, null);
+        result.setScore(Double.parseDouble(commitCountAndScore.get("score").toString()));
+        result.setCommitCount(commitCountAndScore.get("commitCount").toString());
 
 
         // 在该店铺的打卡次数
@@ -1435,9 +1435,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         // 查询符合条件的团购套餐列表
         List<LifeGroupBuyMain> lifeGroupBuyMainList = lifeGroupBuyMainMapper.selectList(lambdaUpdateWrapper);
         // 获取全部店铺的评分与平均花销
-        Map<Object, List<Map<String, Object>>> avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
+        Map<String, List<Map<String, Object>>> avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id").toString()));
         // 获取用户订单信息,用于计算平均消费
-        Map<Object, List<Map<String, Object>>> avgPriceMap = lifeUserOrderMapper.allStoreAvgPrice().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
+        Map<String, List<Map<String, Object>>> avgPriceMap = lifeUserOrderMapper.allStoreAvgPrice().stream().collect(Collectors.groupingBy(o -> o.get("store_id").toString()));
         // 获取所有店铺的打卡次数
         List<Map<Integer, Integer>> storeClockInCountList = storeClockInService.getStoreClockInCount();
         // 遍历所有门店信息,构造返回结果
@@ -1452,7 +1452,6 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             // 如果存在评分数据,则添加评分、平均消费及评价总数
             if (avgScoreMap.containsKey(String.valueOf(store.getId()))) {
                 store.setAvgScore(avgScoreMap.get(String.valueOf(store.getId())).get(0).get("avg_score").toString());
-                store.setAvgPrice(avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price").toString());
                 store.setTotalNum(avgScoreMap.get(String.valueOf(store.getId())).get(0).get("total_num").toString());
                 /*storeMap.put("avgScore", avgScoreMap.get(String.valueOf(store.getId())).get(0).get("avg_score"));
                 storeMap.put("avgPrice", avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price"));
@@ -1464,9 +1463,13 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 storeMap.put("avgPrice", 0);
                 storeMap.put("totalNum", 0);*/
                 store.setAvgScore("0");
-                store.setAvgPrice("0");
                 store.setTotalNum("0");
             }
+            if (avgPriceMap.containsKey(String.valueOf(store.getId()))) {
+                store.setAvgPrice(avgPriceMap.get(String.valueOf(store.getId())).get(0).get("avg_price").toString());
+            } else {
+                store.setAvgPrice("0");
+            }
             // 添加门店名称
             storeMap.put("storeName", store.getStoreName());
             // 添加门店地址