|
@@ -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
|