Sfoglia il codice sorgente

修改未通过评价的 消息通知

lutong 2 giorni fa
parent
commit
e7891fae02

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

@@ -85,7 +85,7 @@ public class CommonRatingController {
             storeId = "#{#commonRating.businessId}",
             targetType = "STORE"
     )
-    @ApiOperation(value = "新增评价", notes = "0:成功(包括审核通过和审核不通过但允许创建的情况), 1:失败, 2:内容审核不通过(直接拒绝)。注意:小票审核和打卡审核不通过时,允许创建评论但审核状态设为不通过并记录审核原因")
+    @ApiOperation(value = "新增评价", notes = "0:成功(包括审核通过和审核不通过但允许创建的情况), 1:失败, 2:内容审核不通过(直接拒绝)。注意:小票审核和打卡审核不通过时,允许创建评论但审核状态设为不通过并记录审核原因;若打卡未通过且小票未通过(含未上传有效消费凭证),将推送「评价审核失败通知」并含店铺名、失败原因与参与指引")
     @PostMapping("/addRating")
     public R<Integer> add(@RequestBody CommonRating commonRating) {
         log.info("CommonRatingController.add?commonRating={}", commonRating);

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

@@ -238,7 +238,8 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
             }
             
             // 判断审核结果:如果两个条件都不满足,判定为审核不通过;至少满足一个条件,算审核通过
-            if (!condition1Passed && !condition2Passed) {
+            boolean bothConditionFailed = !condition1Passed && !condition2Passed;
+            if (bothConditionFailed) {
                 // 两个条件都不满足,判定为审核不通过
                 if (auditReason == null) {
                     if (imageUrls.isEmpty()) {
@@ -265,19 +266,29 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                 return 1;
             }
             
-            // 6. 如果审核不通过(小票审核或打卡审核不通过),发送websocket通知给用户
-            if (commonRating.getAuditStatus() != null && commonRating.getAuditStatus() == 2 && StringUtils.isNotEmpty(auditReason)) {
+            // 6. 打卡与小票均未通过(含未上传有效消费凭证)时发送通知:评价审核失败通知 + 引导文案
+            if (commonRating.getAuditStatus() != null && commonRating.getAuditStatus() == 2 && StringUtils.isNotEmpty(auditReason) && bothConditionFailed) {
                 try {
                     // 获取用户信息
                     LifeUser lifeUser = lifeUserMapper.selectById(commonRating.getUserId());
                     if (lifeUser != null && StringUtils.isNotEmpty(lifeUser.getUserPhone())) {
                         String receiverId = "user_" + lifeUser.getUserPhone();
-                        
+
+                        String storeName = "该";
+                        StoreInfo storeForNotice = storeInfoMapper.selectById(commonRating.getBusinessId());
+                        if (storeForNotice != null && StringUtils.isNotEmpty(storeForNotice.getStoreName())) {
+                            storeName = storeForNotice.getStoreName();
+                        }
+                        String noticeTitle = "评价审核失败通知";
+                        String fullMessage = "您对" + storeName + "店铺的评价未通过审核。失败原因:" + auditReason
+                                + "。您可通过成功发布一条打卡内容,或在评价中上传消费记录两种方式参与店铺评价,审核成功后可在\"我的评价及店铺评价\"中查看。";
+
                         // 构建通知内容
                         JSONObject contextJson = new JSONObject();
                         contextJson.put("ratingId", commonRating.getId());
                         contextJson.put("storeId", commonRating.getBusinessId());
-                        contextJson.put("message", "您的评价审核未通过:" + auditReason);
+                        contextJson.put("noticeName", noticeTitle);
+                        contextJson.put("message", fullMessage);
                         contextJson.put("auditReason", auditReason);
                         
                         // 保存通知到数据库
@@ -285,7 +296,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                         lifeNotice.setSenderId("system");
                         lifeNotice.setReceiverId(receiverId);
                         lifeNotice.setBusinessId(commonRating.getBusinessId());
-                        lifeNotice.setTitle("评价审核通知");
+                        lifeNotice.setTitle(noticeTitle);
                         lifeNotice.setContext(contextJson.toJSONString());
                         lifeNotice.setNoticeType(Constants.Notice.SYSTEM_NOTICE); // 系统通知
                         lifeNotice.setIsRead(0);