Kaynağa Gözat

fix: 补货模块 Long 精度问题 — shopId/productId 前后端转换保护

- ReplenishmentSuggestionVO.shopId 和 SuggestionItem.productId 添加
  @JsonSerialize(ToStringSerializer) 注解,避免 JS Number 截断
- ReplenishmentOrderQueryDTO.shopId/creatorId 改为 String 类型,
  防止前端通过 URL query param 传雪花ID时精度丢失导致查询条件错误
- ReplenishmentOrderServiceImpl.getPage 适配 String→Long 转换

Co-Authored-By: Claude <noreply@anthropic.com>
skyline 2 gün önce
ebeveyn
işleme
d69131892b

+ 7 - 4
haha-entity/src/main/java/com/haha/entity/dto/ReplenishmentOrderQueryDTO.java

@@ -5,6 +5,9 @@ import lombok.EqualsAndHashCode;
 
 /**
  * 补货单查询DTO
+ *
+ * 注意:shopId/creatorId 使用 String 类型而非 Long,
+ * 避免前端 JS 传递雪花ID时因 Number 精度丢失导致查询条件错误。
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -21,9 +24,9 @@ public class ReplenishmentOrderQueryDTO extends PageQueryDTO {
     private String deviceId;
 
     /**
-     * 门店ID
+     * 门店ID(前端传 String 避免 Long 精度丢失)
      */
-    private Long shopId;
+    private String shopId;
 
     /**
      * 状态
@@ -41,7 +44,7 @@ public class ReplenishmentOrderQueryDTO extends PageQueryDTO {
     private String endTime;
 
     /**
-     * 创建人ID
+     * 创建人ID(前端传 String 避免 Long 精度丢失)
      */
-    private Long creatorId;
+    private String creatorId;
 }

+ 8 - 0
haha-entity/src/main/java/com/haha/entity/dto/ReplenishmentSuggestionVO.java

@@ -1,5 +1,7 @@
 package com.haha.entity.dto;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -14,13 +16,19 @@ public class ReplenishmentSuggestionVO {
 
     private String deviceId;
     private String deviceName;
+
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long shopId;
+
     private String shopName;
     private List<SuggestionItem> items;
 
     @Data
     public static class SuggestionItem {
+
+        @JsonSerialize(using = ToStringSerializer.class)
         private Long productId;
+
         private String productCode;
         private String productName;
         private String productImage;

+ 4 - 4
haha-service/src/main/java/com/haha/service/impl/ReplenishmentOrderServiceImpl.java

@@ -64,14 +64,14 @@ public class ReplenishmentOrderServiceImpl extends ServiceImpl<ReplenishmentOrde
         if (StringUtils.hasText(queryDTO.getDeviceId())) {
             wrapper.eq(ReplenishmentOrder::getDeviceId, queryDTO.getDeviceId());
         }
-        if (queryDTO.getShopId() != null) {
-            wrapper.eq(ReplenishmentOrder::getShopId, queryDTO.getShopId());
+        if (StringUtils.hasText(queryDTO.getShopId())) {
+            wrapper.eq(ReplenishmentOrder::getShopId, Long.parseLong(queryDTO.getShopId()));
         }
         if (queryDTO.getStatus() != null) {
             wrapper.eq(ReplenishmentOrder::getStatus, queryDTO.getStatus());
         }
-        if (queryDTO.getCreatorId() != null) {
-            wrapper.eq(ReplenishmentOrder::getCreatorId, queryDTO.getCreatorId());
+        if (StringUtils.hasText(queryDTO.getCreatorId())) {
+            wrapper.eq(ReplenishmentOrder::getCreatorId, Long.parseLong(queryDTO.getCreatorId()));
         }
         if (StringUtils.hasText(queryDTO.getStartTime())) {
             wrapper.ge(ReplenishmentOrder::getCreateTime,