xdd hace 1 semana
padre
commit
9fe76eda49

+ 33 - 6
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -62,10 +62,7 @@ import com.fs.store.enums.OrderInfoEnum;
 import com.fs.store.enums.OrderLogEnum;
 import com.fs.store.enums.ShipperCodeEnum;
 import com.fs.store.enums.ShippingTempEnum;
-import com.fs.store.mapper.FsStoreDeliversMapper;
-import com.fs.store.mapper.FsStoreProductAttrValueMapper;
-import com.fs.store.mapper.FsUserMapper;
-import com.fs.store.mapper.FsWarehousesMapper;
+import com.fs.store.mapper.*;
 import com.fs.store.param.FsStoreOrderAddTuiMoneyParam;
 import com.fs.store.param.LiveOrderComputedParam;
 import com.fs.store.service.*;
@@ -2053,12 +2050,42 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         }
     }
 
+    @Autowired
+    private FsStoreProductMapper fsStoreProductMapper;
     @Override
     public List<LiveGoodsVo> selectLiveOrderItemList(String orderId) {
         LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(orderId);
-        return liveGoodsMapper.selectProductListByOrder(liveOrder);
-    }
+        Asserts.notNull(liveOrder, String.format("该订单 %s 没有找到!", orderId));
+        List<LiveGoodsVo> liveGoodsVos = liveGoodsMapper.selectProductListByOrder(liveOrder);
+
+        if (CollectionUtils.isEmpty(liveGoodsVos)) {
+            return liveGoodsVos;
+        }
+        List<String> productIds = liveGoodsVos.stream()
+                .map(LiveGoodsVo::getProductId)
+                .filter(Objects::nonNull)
+                .map(String::valueOf)
+                .distinct()
+                .collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(productIds)) {
+            return liveGoodsVos;
+        }
+
+        Map<Long, FsStoreProduct> productWarehouseMap =
+                fsStoreProductMapper.selectWarehouseCodeByProductIds(productIds);
+
+        liveGoodsVos.forEach(goodsVo -> {
+            Long productId = goodsVo.getProductId();
+            if (productId != null) {
+                FsStoreProduct storeProduct = productWarehouseMap.get(productId);
+                if (storeProduct != null) {
+                    goodsVo.setWarehouseCode(storeProduct.getWarehouseCode());
+                }
+            }
+        });
+        return liveGoodsVos;
 
+    }
 
 
     @Override

+ 5 - 0
fs-service-system/src/main/java/com/fs/live/vo/LiveGoodsVo.java

@@ -23,4 +23,9 @@ public class LiveGoodsVo {
     private Boolean isFavorite;
     private Boolean isShow;
     private Long barCode;
+
+    /**
+     * 仓库代码
+     */
+    private String warehouseCode;
 }

+ 4 - 3
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreProductMapper.java

@@ -6,9 +6,7 @@ import java.util.Map;
 import com.fs.store.domain.FsStoreProduct;
 import com.fs.store.param.FsStoreProductQueryParam;
 import com.fs.store.vo.*;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.*;
 
 /**
  * 商品Mapper接口
@@ -219,6 +217,9 @@ public interface FsStoreProductMapper
 
     List<FsStoreProduct> selectFsStoreProductByProductIds(@Param("productIds")List<String> productIdList);
 
+    @MapKey("productId")
+    Map<Long,FsStoreProduct> selectWarehouseCodeByProductIds(@Param("productIds")List<String> productIdList);
+
     @Select({"<script> " +
             "select * from fs_store_product where find_in_set(product_id,#{ids})  " +
             "</script>"})

+ 6 - 0
fs-service-system/src/main/resources/mapper/store/FsStoreProductMapper.xml

@@ -264,5 +264,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                #{productId}
            </foreach>
     </select>
+    <select id="selectWarehouseCodeByProductIds" resultType="com.fs.store.domain.FsStoreProduct">
+        select product_id,warehouse_code from fs_store_product where product_id in
+        <foreach item="productId" collection="productIds" open="(" separator="," close=")">
+            #{productId}
+        </foreach>
+    </select>
 
 </mapper>