Forráskód Böngészése

新增非二手逻辑

zhangchen 3 hónapja
szülő
commit
dd4f811abe

+ 8 - 0
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsReportingServiceImpl.java

@@ -3,6 +3,7 @@ package shop.alien.second.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import shop.alien.entity.second.SecondGoods;
@@ -14,6 +15,7 @@ import shop.alien.mapper.LifeUserViolationMapper;
 import shop.alien.mapper.StoreDictionaryMapper;
 import shop.alien.mapper.second.SecondGoodsMapper;
 import shop.alien.second.service.SecondGoodsReportingService;
+import shop.alien.second.util.JsonUtils;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
@@ -91,6 +93,12 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
             String context = "您于" + dateTime.format(targetFormatter) + "举报“" + lifeUser.getUserName() + "”“" + storeDictionary.getDictDetail() + "”举报内容为“"
                     + lifeUserViolation.getOtherReasonContent()  + "”";
             secondReportingVo.setReportingContext(context);
+        } else if (lifeUserViolation.getReportContextType().equals("1") || lifeUserViolation.getReportContextType().equals("2") || lifeUserViolation.getReportContextType().equals("3")) {
+            // 用户信息
+           if(StringUtils.isNotBlank(lifeNotice.getContext())){
+               String context = JsonUtils.getJsonValue(lifeNotice.getContext(), "message");
+               secondReportingVo.setReportingContext(context);
+           }
         }
 
         secondReportingVo.setFeedbackContext("平台已受理,感谢您的反馈!");

+ 34 - 0
alien-second/src/main/java/shop/alien/second/util/JsonUtils.java

@@ -0,0 +1,34 @@
+package shop.alien.second.util;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class JsonUtils {
+    private static final ObjectMapper objectMapper = new ObjectMapper();
+
+    /**
+     * 从JSON字符串中获取指定key的值
+     */
+    public static String getJsonValue(String jsonString, String key) {
+        try {
+            JsonNode jsonNode = objectMapper.readTree(jsonString);
+            JsonNode valueNode = jsonNode.get(key);
+            return valueNode != null ? valueNode.asText() : null;
+        } catch (Exception e) {
+            throw new RuntimeException("解析JSON失败", e);
+        }
+    }
+
+    /**
+     * 获取指定key的值(支持各种数据类型)
+     */
+    public static <T> T getJsonValue(String jsonString, String key, Class<T> valueType) {
+        try {
+            JsonNode jsonNode = objectMapper.readTree(jsonString);
+            JsonNode valueNode = jsonNode.get(key);
+            return objectMapper.treeToValue(valueNode, valueType);
+        } catch (Exception e) {
+            throw new RuntimeException("解析JSON失败", e);
+        }
+    }
+}