فهرست منبع

Merge remote-tracking branch 'origin/master'

wxd 4 روز پیش
والد
کامیت
c70ac040b3

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/WebsocketVo.java

@@ -20,6 +20,9 @@ public class WebsocketVo {
     @ApiModelProperty(value = "公告类型  (0-系统通知和订单提醒之外的类型  1-系统通知 2-订单提醒)")
     private String noticeType;
 
+    @ApiModelProperty(value = "是否已读  0:未读  1:已读")
+    private Integer isRead;
+
     @ApiModelProperty(value = "消息类型  1-文本  2-图片 3-链接分享  4-二手交易(确认/拒绝/取消)  5-二手交易签到提醒  6-二手交易已签到")
     private String type;
 

+ 5 - 7
alien-store/src/main/java/shop/alien/store/controller/StoreImgController.java

@@ -27,11 +27,9 @@ import java.util.List;
 @RequestMapping("/img")
 @RequiredArgsConstructor
 public class StoreImgController {
-
     private final StoreImgService storeImgService;
     private final StoreInfoService storeInfoService;
 
-
     @ApiOperation("获取图片")
     @ApiOperationSupport(order = 1)
     @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
@@ -67,7 +65,7 @@ public class StoreImgController {
     }
 
     @ApiOperation("新增/修改/删除图片")
-    @ApiOperationSupport(order = 3)
+    @ApiOperationSupport(order = 4)
     @PostMapping("/saveOrUpdateImg")
     public R<String> saveOrUpdateImg(@RequestBody StoreImgInfoVo storeImgInfoVo) {
         log.info("StoreImgController.saveOrUpdateImg?storeImgInfoVo={}", storeImgInfoVo);
@@ -92,7 +90,7 @@ public class StoreImgController {
 
 
     @ApiOperation(value = "删除图片")
-    @ApiOperationSupport(order = 4)
+    @ApiOperationSupport(order = 5)
     @PostMapping("/delete")
     public R<String> delete(@RequestBody List<Integer> ids) {
         log.info("StoreImgController.delete?ids={}", ids);
@@ -103,14 +101,14 @@ public class StoreImgController {
     }
 
     @ApiOperation("获取轮播图")
-    @ApiOperationSupport(order = 5)
+    @ApiOperationSupport(order = 6)
     @GetMapping("/getCarouselImage")
     public R<List<StoreImg>> getCarouselImage() {
         return R.data(storeImgService.getCarouselImage());
     }
 
     @ApiOperation("获取用户打卡广场小人图片")
-    @ApiOperationSupport(order = 6)
+    @ApiOperationSupport(order = 7)
     @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", paramType = "query", required = true)})
     @GetMapping("/getUserClockImg")
     public R<String> getUserClockImg(Integer userId) {
@@ -119,7 +117,7 @@ public class StoreImgController {
     }
 
     @ApiOperation("通过businessId获取图片")
-    @ApiOperationSupport(order = 6)
+    @ApiOperationSupport(order = 8)
     @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
             @ApiImplicitParam(name = "imgType", value = "图片类型, 0:其他, 1:入口图, 2:相册, 3:菜品, 4:环境, 5:价目表, 6:推荐菜, 7:菜单, 8:用户评论, 9:商家申诉, 10:商家头像, 11:店铺轮播图", dataType = "Integer", paramType = "query", required = true),
             @ApiImplicitParam(name = "businessId", value = "业务ID", dataType = "Integer", paramType = "query", required = true)})

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

@@ -101,7 +101,7 @@ public class StoreMenuController {
     }
 
     @ApiOperation("获取门店菜品推荐数量")
-    @ApiOperationSupport(order = 1)
+    @ApiOperationSupport(order = 7)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true)
     })

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

@@ -44,39 +44,16 @@ public class UserViolationController {
     @ApiOperation("举报")
     @ApiOperationSupport(order = 1)
     @PostMapping("/reporting")
-    public R<String> reporting(@RequestBody LifeUserViolation lifeuserViolation) throws IOException, InterruptedException {
+    public R<String> reporting(@RequestBody LifeUserViolation lifeuserViolation) throws Exception  {
         log.info("UserViolationController.reporting?lifeuserViolation={}", lifeuserViolation.toString());
         int reporting = lifeUserViolationService.reporting(lifeuserViolation);
         if (0 == reporting) {
             return R.fail("举报失败");
         } else {
-            if (lifeuserViolation.getReportContextType().equals("4") || lifeuserViolation.getReportContextType().equals("5")) {
-                LifeNotice lifeNotice = getLifeNotice(lifeuserViolation);
-                lifeNoticeMapper.insert(lifeNotice);
-            }
             return R.data("举报成功");
         }
     }
 
-    private static LifeNotice getLifeNotice(LifeUserViolation lifeuserViolation) throws JsonProcessingException {
-        JSONObject data = JwtUtil.getCurrentUserInfo();
-        String phoneId = null;
-        if (data != null) {
-            phoneId = data.getString("phone");
-        }
-        LifeNotice lifeNotice = new LifeNotice();
-        lifeNotice.setSenderId("system");
-        lifeNotice.setReceiverId("user_" + phoneId);
-        lifeNotice.setBusinessId(lifeuserViolation.getId());
-        lifeNotice.setTitle("举报通知");
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("title", "平台已受理");
-        jsonObject.put("message", "平台已受理,感谢您的反馈!");
-        lifeNotice.setContext(jsonObject.toJSONString());
-        lifeNotice.setNoticeType(1);
-        return lifeNotice;
-    }
-
     @ApiOperation("举报结果")
     @ApiOperationSupport(order = 2)
     @GetMapping("/reportListByUserId")

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/LifeUserViolationService.java

@@ -19,7 +19,7 @@ import java.util.Map;
  */
 public interface LifeUserViolationService extends IService<LifeUserViolation> {
 
-    int reporting(LifeUserViolation lifeuserViolation);
+    int reporting(LifeUserViolation lifeuserViolation) throws Exception ;
 
     Map<String, Object> reportListByUserId(String userId);
 

+ 53 - 2
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserViolationServiceImpl.java

@@ -1,5 +1,6 @@
 package shop.alien.store.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -17,9 +19,12 @@ import shop.alien.entity.store.dto.LifeUserViolationDto;
 import shop.alien.entity.store.excelVo.LifeUserViolationExcelVO;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
 import shop.alien.entity.store.vo.LifeUserViolationVo;
+import shop.alien.entity.store.vo.WebsocketVo;
 import shop.alien.mapper.*;
+import shop.alien.store.config.WebSocketProcess;
 import shop.alien.store.service.*;
 import shop.alien.store.util.FunctionMagic;
+import shop.alien.util.common.JwtUtil;
 
 import java.io.IOException;
 import java.time.Instant;
@@ -40,6 +45,7 @@ import static shop.alien.util.common.constant.Constant.*;
  * @author ssk
  * @since 2025-04-29
  */
+@Slf4j
 @Service
 @RequiredArgsConstructor
 public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationMapper, LifeUserViolation> implements LifeUserViolationService {
@@ -63,6 +69,8 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
 
     private final LifeNoticeMapper lifeNoticeMapper;
 
+    private final WebSocketProcess webSocketProcess;
+
     @Value("${spring.web.resources.excel-path}")
     private String excelPath;
 
@@ -73,8 +81,51 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
     private String fileUrl;
 
     @Override
-    public int reporting(LifeUserViolation lifeuserViolation) {
-        return lifeUserViolationMapper.insert(lifeuserViolation);
+    public int reporting(LifeUserViolation lifeuserViolation) throws Exception  {
+        try {
+            int result = lifeUserViolationMapper.insert(lifeuserViolation);
+            if (result > 0) {
+                if (lifeuserViolation.getReportContextType().equals("4") || lifeuserViolation.getReportContextType().equals("5")) {
+                    String phoneId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType") + "_" + JwtUtil.getCurrentUserInfo().getString("phone");
+
+                    LifeNotice lifeNotice = getLifeNotice(lifeuserViolation);
+                    lifeNoticeMapper.insert(lifeNotice);
+
+                    WebsocketVo websocketVo = new WebsocketVo();
+                    websocketVo.setSenderId("system");
+                    websocketVo.setReceiverId(phoneId);
+                    websocketVo.setCategory("notice");
+                    websocketVo.setNoticeType("1");
+                    websocketVo.setIsRead(0);
+                    websocketVo.setText(com.alibaba.fastjson2.JSONObject.from(lifeNotice).toJSONString());
+                    webSocketProcess.sendMessage(phoneId, com.alibaba.fastjson2.JSONObject.from(websocketVo).toJSONString());
+                }
+                return result;
+            }
+        } catch (Exception e) {
+            log.error("LifeUserViolationServiceImpl_reporting Error Stack={}", e.getMessage());
+            throw new Exception(e);
+        }
+        return 0;
+    }
+
+    private static LifeNotice getLifeNotice(LifeUserViolation lifeuserViolation)  {
+        JSONObject data = JwtUtil.getCurrentUserInfo();
+        String phoneId = null;
+        if (data != null) {
+            phoneId = data.getString("phone");
+        }
+        LifeNotice lifeNotice = new LifeNotice();
+        lifeNotice.setSenderId("system");
+        lifeNotice.setReceiverId("user_" + phoneId);
+        lifeNotice.setBusinessId(lifeuserViolation.getId());
+        lifeNotice.setTitle("举报通知");
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("title", "平台已受理");
+        jsonObject.put("message", "平台已受理,感谢您的反馈!");
+        lifeNotice.setContext(jsonObject.toJSONString());
+        lifeNotice.setNoticeType(1);
+        return lifeNotice;
     }
 
     @Override