Explorar el Código

Merge remote-tracking branch 'origin/sit' into sit

qinxuyang hace 13 horas
padre
commit
e7d55dc2d7

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

@@ -443,10 +443,14 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                 storeInfo.setScoreThree(new BigDecimal(scoreThree).setScale(2, RoundingMode.HALF_UP).doubleValue());
                 storeInfoMapper.updateById(storeInfo);
             }
-            StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()).eq(StoreUser::getDeleteFlag, 0));
+            // 须用 businessId 查询门店账号:当 total<10 时未执行 storeInfo.setId,storeInfo.getId() 恒为 null,会导致查不到店主、差评通知路径 NPE(好评可提交、差评失败)
+            StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, businessId).eq(StoreUser::getDeleteFlag, 0));
 
             // 如果差评,则发送差评提醒
             if(score != null && score >= 0.5 && score <= 2.5){
+                if (storeUser == null || StringUtils.isEmpty(storeUser.getPhone())) {
+                    log.warn("差评通知跳过:未找到门店主账号或手机号为空,storeId={}", businessId);
+                } else {
                 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                 String commonDate = simpleDateFormat.format(new Date());
                 LifeNotice lifeMessage = new LifeNotice();
@@ -469,6 +473,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                 websocketVo.setIsRead(0);
                 websocketVo.setText(JSONObject.from(lifeMessage).toJSONString());
                 webSocketProcess.sendMessage("store_" + storeUser.getPhone(), JSONObject.from(websocketVo).toJSONString());
+                }
             }
             // 用户好评且 AI 审核通过后:按运营活动表(评论有礼)配置的 coupon_id/voucher_id 发放,用 participation_limit 限制参与次数,发放成功后扣减库存,按优惠券/代金券发对应通知
             // 支持多个活动同时生效:如果一个商家有多个正在开启的活动(如一个送优惠券,一个送代金券),都会执行