|
@@ -519,10 +519,18 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
|
|
|
Double score = commonRating.getScore();
|
|
Double score = commonRating.getScore();
|
|
|
if(1 == commonRating.getBusinessType()){
|
|
if(1 == commonRating.getBusinessType()){
|
|
|
// 更新门店评价信息
|
|
// 更新门店评价信息
|
|
|
|
|
+
|
|
|
StoreInfoScoreVo storeInfoScoreVo = commonRatingMapper.getCommentCountAndScoreInfo(commonRating.getBusinessType(),businessId);
|
|
StoreInfoScoreVo storeInfoScoreVo = commonRatingMapper.getCommentCountAndScoreInfo(commonRating.getBusinessType(),businessId);
|
|
|
|
|
+
|
|
|
|
|
+ List<StoreInfoScoreVo> storeInfoScoreNew = commonRatingMapper.getStoreInfoScoreNew(commonRating.getBusinessType(),businessId);
|
|
|
|
|
+
|
|
|
|
|
+ Integer commentCount = storeInfoScoreNew.size();
|
|
|
|
|
+
|
|
|
double total = storeInfoScoreVo.getTotal();
|
|
double total = storeInfoScoreVo.getTotal();
|
|
|
StoreInfo storeInfo = new StoreInfo();
|
|
StoreInfo storeInfo = new StoreInfo();
|
|
|
- if(total >= 10){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //如果有效条数大于10条,则正常进行平均数计算
|
|
|
|
|
+ if(commentCount > 10){
|
|
|
double scoreAvg = (total == 0 ? 0 : storeInfoScoreVo.getScore() / total);
|
|
double scoreAvg = (total == 0 ? 0 : storeInfoScoreVo.getScore() / total);
|
|
|
double scoreOne = (total == 0 ? 0 : storeInfoScoreVo.getScoreOne() / total);
|
|
double scoreOne = (total == 0 ? 0 : storeInfoScoreVo.getScoreOne() / total);
|
|
|
double scoreTwo = (total == 0 ? 0 : storeInfoScoreVo.getScoreTwo() / total);
|
|
double scoreTwo = (total == 0 ? 0 : storeInfoScoreVo.getScoreTwo() / total);
|
|
@@ -534,6 +542,41 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
|
|
|
storeInfo.setScoreThree(new BigDecimal(scoreThree).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
storeInfo.setScoreThree(new BigDecimal(scoreThree).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
storeInfoMapper.updateById(storeInfo);
|
|
storeInfoMapper.updateById(storeInfo);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //如果有效条数=10,则进行特殊处理
|
|
|
|
|
+ if(commentCount == 10){
|
|
|
|
|
+ //判断首次达到10条还是第N次达到10条
|
|
|
|
|
+ StoreInfo storeInfoNew = storeInfoMapper.selectById(businessId);
|
|
|
|
|
+ //首次达到10条 平均分是3.0 ,第N次达到10条 4.0
|
|
|
|
|
+ if(storeInfoNew.getScoreAvg() == 0){
|
|
|
|
|
+ double scoreAvg = 3.0;
|
|
|
|
|
+// double scoreOne = 3.0;
|
|
|
|
|
+// double scoreTwo = 3.0;
|
|
|
|
|
+// double scoreThree =3.0;
|
|
|
|
|
+ storeInfo.setId(businessId);
|
|
|
|
|
+ storeInfo.setScoreAvg(new BigDecimal(scoreAvg).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
+ storeInfoMapper.updateById(storeInfo);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ double scoreAvg = 4.0 ;
|
|
|
|
|
+ storeInfo.setId(businessId);
|
|
|
|
|
+ storeInfo.setScoreAvg(new BigDecimal(scoreAvg).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
+ storeInfoMapper.updateById(storeInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// if(total >= 10){
|
|
|
|
|
+// double scoreAvg = (total == 0 ? 0 : storeInfoScoreVo.getScore() / total);
|
|
|
|
|
+// double scoreOne = (total == 0 ? 0 : storeInfoScoreVo.getScoreOne() / total);
|
|
|
|
|
+// double scoreTwo = (total == 0 ? 0 : storeInfoScoreVo.getScoreTwo() / total);
|
|
|
|
|
+// double scoreThree = (total == 0 ? 0 : storeInfoScoreVo.getScoreThree() / total);
|
|
|
|
|
+// storeInfo.setId(businessId);
|
|
|
|
|
+// storeInfo.setScoreAvg(new BigDecimal(scoreAvg).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
+// 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());
|
|
|
|
|
+// storeInfoMapper.updateById(storeInfo);
|
|
|
|
|
+// }
|
|
|
// 须用 businessId 查询门店账号:当 total<10 时未执行 storeInfo.setId,storeInfo.getId() 恒为 null,会导致查不到店主、差评通知路径 NPE(好评可提交、差评失败)
|
|
// 须用 businessId 查询门店账号:当 total<10 时未执行 storeInfo.setId,storeInfo.getId() 恒为 null,会导致查不到店主、差评通知路径 NPE(好评可提交、差评失败)
|
|
|
StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, businessId).eq(StoreUser::getDeleteFlag, 0));
|
|
StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, businessId).eq(StoreUser::getDeleteFlag, 0));
|
|
|
|
|
|
|
@@ -1182,16 +1225,35 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
|
|
|
List<CommonRating> ratings = commonRatingMapper.selectList(wrapper);
|
|
List<CommonRating> ratings = commonRatingMapper.selectList(wrapper);
|
|
|
|
|
|
|
|
int total = ratings.size();
|
|
int total = ratings.size();
|
|
|
- if (total == 0) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //如果评价数量小于10,则重置评分为3.5 评价=10 重置评分4.0
|
|
|
|
|
+ List<StoreInfoScoreVo> storeInfoScoreNew = commonRatingMapper.getStoreInfoScoreNew(1,businessId);
|
|
|
|
|
+ Integer commentCount = storeInfoScoreNew.size();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (commentCount == 10) {
|
|
|
|
|
+ // 没有评价,设置默认评分为0
|
|
|
|
|
+ StoreInfo storeInfo = new StoreInfo();
|
|
|
|
|
+ storeInfo.setId(businessId);
|
|
|
|
|
+ storeInfo.setScoreAvg(4.0);
|
|
|
|
|
+// storeInfo.setScoreOne(3.0);
|
|
|
|
|
+// storeInfo.setScoreTwo(3.0);
|
|
|
|
|
+// storeInfo.setScoreThree(3.0);
|
|
|
|
|
+ storeInfoMapper.updateById(storeInfo);
|
|
|
|
|
+ log.info("店铺有效评价被删除=10条,重置评分为4.0,businessId={}", businessId);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (commentCount < 10) {
|
|
|
// 没有评价,设置默认评分为0
|
|
// 没有评价,设置默认评分为0
|
|
|
StoreInfo storeInfo = new StoreInfo();
|
|
StoreInfo storeInfo = new StoreInfo();
|
|
|
storeInfo.setId(businessId);
|
|
storeInfo.setId(businessId);
|
|
|
- storeInfo.setScoreAvg(0.0);
|
|
|
|
|
- storeInfo.setScoreOne(0.0);
|
|
|
|
|
- storeInfo.setScoreTwo(0.0);
|
|
|
|
|
- storeInfo.setScoreThree(0.0);
|
|
|
|
|
|
|
+ storeInfo.setScoreAvg(3.5);
|
|
|
|
|
+// storeInfo.setScoreOne(3.0);
|
|
|
|
|
+// storeInfo.setScoreTwo(3.0);
|
|
|
|
|
+// storeInfo.setScoreThree(3.0);
|
|
|
storeInfoMapper.updateById(storeInfo);
|
|
storeInfoMapper.updateById(storeInfo);
|
|
|
- log.info("店铺无有效评价,重置评分为0,businessId={}", businessId);
|
|
|
|
|
|
|
+ log.info("店铺有效评价被删除<10条,重置评分为3.5,businessId={}", businessId);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|