Просмотр исходного кода

修改评分,删除评价小于10的时候回复到3.0,不计算平均分

liudongzhi 1 неделя назад
Родитель
Сommit
589030392e

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

@@ -1091,16 +1091,16 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
             List<CommonRating> ratings = commonRatingMapper.selectList(wrapper);
             
             int total = ratings.size();
-            if (total == 0) {
+            if (total < 10) {
                 // 没有评价,设置默认评分为0
                 StoreInfo storeInfo = new StoreInfo();
                 storeInfo.setId(businessId);
-                storeInfo.setScoreAvg(0.0);
-                storeInfo.setScoreOne(0.0);
-                storeInfo.setScoreTwo(0.0);
-                storeInfo.setScoreThree(0.0);
+                storeInfo.setScoreAvg(3.0);
+                storeInfo.setScoreOne(3.0);
+                storeInfo.setScoreTwo(3.0);
+                storeInfo.setScoreThree(3.0);
                 storeInfoMapper.updateById(storeInfo);
-                log.info("店铺无有效评价,重置评分为0,businessId={}", businessId);
+                log.info("店铺无有效评价,重置评分为3.0,businessId={}", businessId);
                 return;
             }