Jelajahi Sumber

修复评分问题bug

liudongzhi 1 Minggu lalu
induk
melakukan
4954bece4a

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreInfo.java

@@ -371,4 +371,8 @@ public class StoreInfo {
     @TableField("alipay_smid")
     private String alipaySmid;
 
+    @ApiModelProperty(value = "评价首次突破10条  状态为1   未突破为 0  默认为0")
+    @TableField("break_ten")
+    private Integer breakTen;
+
 }

+ 14 - 3
alien-store/src/main/java/shop/alien/store/service/impl/CommonRatingServiceImpl.java

@@ -449,6 +449,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                 storeInfo.setScoreOne(new BigDecimal(scoreOne).setScale(2, RoundingMode.HALF_UP).doubleValue());
                 storeInfo.setScoreTwo(new BigDecimal(scoreTwo).setScale(2, RoundingMode.HALF_UP).doubleValue());
                 storeInfo.setScoreThree(new BigDecimal(scoreThree).setScale(2, RoundingMode.HALF_UP).doubleValue());
+                storeInfo.setBreakTen(1);
                 storeInfoMapper.updateById(storeInfo);
             }
 
@@ -580,7 +581,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                     }
                     
                     if (totalIssuedCount > 0) {
-                        log.info("CommonRatingService 好评送券汇总:总发放数量={}, 活动数={}, userId={}, storeId={}",
+                        log.info("CommonRatingService 好评=送券汇总:总发放数量={}, 活动数={}, userId{}, storeId={}",
                                 totalIssuedCount, activities.size(), commonRating.getUserId(), businessId);
                     }
                 } catch (Exception ex) {
@@ -1132,6 +1133,10 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                    .eq(CommonRating::getIsShow, 1)
                    .eq(CommonRating::getAuditStatus, 1);
             List<CommonRating> ratings = commonRatingMapper.selectList(wrapper);
+
+           StoreInfo  storeInfoNew=storeInfoMapper.getStoreInfo(businessId);
+
+
             
             int total = ratings.size();
 
@@ -1153,7 +1158,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                 return;
             }
 
-            if (commentCount < 10) {
+            if (commentCount < 10 && storeInfoNew.getBreakTen()==1) {
                 // 没有评价,设置默认评分为0
                 StoreInfo storeInfo = new StoreInfo();
                 storeInfo.setId(businessId);
@@ -1165,7 +1170,13 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                 log.info("店铺有效评价被删除<10条,重置评分为3.5,businessId={}", businessId);
                 return;
             }
-            
+            //如果没到10条有效评价,则不更新评分,还继续为0
+            if (commentCount < 10) {
+             return ;
+             }
+
+
+
             // 计算平均评分
             double scoreSum = ratings.stream().mapToDouble(r -> r.getScore() != null ? r.getScore() : 0.0).sum();
             double scoreOneSum = ratings.stream().mapToDouble(r -> r.getScoreOne() != null ? r.getScoreOne() : 0.0).sum();