xdd 1 week ago
parent
commit
e001c3237b

+ 12 - 12
fs-service-system/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java

@@ -6,10 +6,7 @@ import java.util.Map;
 import com.fs.live.domain.LiveOrderItem;
 import com.fs.live.domain.LiveOrderItem;
 import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.live.vo.LiveOrderItemVo;
 import com.fs.live.vo.LiveOrderItemVo;
-import org.apache.ibatis.annotations.MapKey;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.*;
 
 
 /**
 /**
  * 订单详情Mapper接口
  * 订单详情Mapper接口
@@ -70,14 +67,17 @@ public interface LiveOrderItemMapper {
     List<LiveOrderItem> selectLiveOrderItemByOrderId(Long orderId);
     List<LiveOrderItem> selectLiveOrderItemByOrderId(Long orderId);
 
 
     @MapKey("orderId")
     @MapKey("orderId")
-    @Select("select a.item_id, a.order_id, a.order_code, a.cart_id, a.goods_id, a.product_id,a. product_attr_value_id, a.json_info, a.num, a.is_after_sales, a.is_prescribe, a.store_id, a.is_gift\n" +
-            "        , b.product_name, b.image as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce\n" +
-            "        from live_order_item a\n" +
-            "        left join fs_store_product b on a.product_id = b.product_id\n" +
-            "        where order_id in\n" +
-            "        <foreach item=\"orderId\" collection=\"orderIds\" open=\"(\" separator=\",\" close=\")\">\n" +
-            "            #{orderId}\n" +
-            "        </foreach>")
+    @Select("<script>" +
+            "select a.item_id, a.order_id as orderId, a.order_code, a.cart_id, a.goods_id, a.product_id, a.product_attr_value_id, a.json_info, a.num, a.is_after_sales, a.is_prescribe, a.store_id, a.is_gift\n" +
+            ", b.product_name, b.image as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce\n" +
+            "from live_order_item a\n" +
+            "left join fs_store_product b on a.product_id = b.product_id\n" +
+            "where order_id in\n" +
+            "<foreach item='id' collection='orderIds' open='(' separator=',' close=')'> " +
+            " #{id} " +
+            "</foreach>" +
+            "</script>")
+    @ResultMap("liveOrderItemVoMap")
     Map<Long,List<LiveOrderItemVo>> selectLiveOrderItemByOrderIds(@Param("orderIds") List<Long> orderIds);
     Map<Long,List<LiveOrderItemVo>> selectLiveOrderItemByOrderIds(@Param("orderIds") List<Long> orderIds);
 
 
     int insertBatchList(@Param("liveOrderItemList") List<LiveOrderItem> liveOrderItemList);
     int insertBatchList(@Param("liveOrderItemList") List<LiveOrderItem> liveOrderItemList);

+ 38 - 47
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -9,7 +9,6 @@ import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.*;
-import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -748,56 +747,48 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if(CollectionUtils.isEmpty(allOrderIds)) {
         if(CollectionUtils.isEmpty(allOrderIds)) {
             return Collections.emptyList();
             return Collections.emptyList();
         }
         }
-        try{
-            CompletableFuture<Map<Long, FsStoreDelivers>> deliversFuture = CompletableFuture.supplyAsync(() ->
-                    fsStoreDeliversMapper.findByOrderIdWithTypeBatch(allOrderIds, 1));
-            CompletableFuture<Map<Long, LiveAfterSales>> afterSalesFuture = CompletableFuture.supplyAsync(() ->
-                    liveAfterSalesMapper.findByOrderIds(allOrderIds));
-            CompletableFuture<Map<Long, List<LiveOrderItemVo>>> orderItemsFuture = CompletableFuture.supplyAsync(() ->
-                    liveOrderItemMapper.selectLiveOrderItemByOrderIds(allOrderIds));
-
-            CompletableFuture.allOf(deliversFuture, afterSalesFuture, orderItemsFuture).join();
-            Map<Long, FsStoreDelivers> byOrderIdWithTypeBatch = deliversFuture.get();
-            Map<Long, LiveAfterSales> liveAfterSalesMap = afterSalesFuture.get();
-            Map<Long, List<LiveOrderItemVo>> liveOrderItemMaps = orderItemsFuture.get();
-
-            for (LiveOrderListVo order : liveOrders) {
-                FsStoreDelivers delivers = byOrderIdWithTypeBatch.get(order.getOrderId());
-
-                if(ObjectUtil.isNotNull(delivers)) {
-                    order.setDeliveryCode(delivers.getDeliverSn());
-                    order.setDeliveryName(delivers.getDeliverName());
-                    order.setDeliverySn(delivers.getDeliverId());
-                    order.setDeliveryStatus(delivers.getStatus());
-                    order.setDeliveryType(String.valueOf(delivers.getStateEx()));
-                }else {
-                    order.setDeliveryCode(null);
-                    order.setDeliveryName(null);
-                    order.setDeliverySn(null);
-                    order.setDeliveryStatus(null);
-                    order.setDeliveryType(null);
-                }
-                if(ObjectUtil.isNotNull(liveAfterSalesMap)){
-                    LiveAfterSales liveAfterSales = liveAfterSalesMap.get(order.getOrderId());
-                    if(ObjectUtil.isNotNull(liveAfterSales)) {
-                        order.setAfterSaleId(liveAfterSales.getId());
-                    }
-                }
 
 
-                if(ObjectUtil.isNotNull(liveOrderItemMaps)){
-                    Long orderId = order.getOrderId();
-                    List<LiveOrderItemVo> liveOrderItemVos = liveOrderItemMaps.get(orderId);
-                    if(CollectionUtils.isNotEmpty(liveOrderItemVos)) {
-                        order.setOrderItemList(liveOrderItemVos);
-                    }
+        Map<Long, FsStoreDelivers> byOrderIdWithTypeBatch = fsStoreDeliversMapper
+                .findByOrderIdWithTypeBatch(allOrderIds, 1);
+
+        Map<Long,LiveAfterSales> liveAfterSalesMap = liveAfterSalesMapper.findByOrderIds(allOrderIds);
+
+        Map<Long, List<LiveOrderItemVo>> liveOrderItemMaps = liveOrderItemMapper.selectLiveOrderItemByOrderIds(allOrderIds);
+
+
+        for (LiveOrderListVo order : liveOrders) {
+            FsStoreDelivers delivers = byOrderIdWithTypeBatch.get(order.getOrderId());
+
+            if(ObjectUtil.isNotNull(delivers)) {
+                order.setDeliveryCode(delivers.getDeliverSn());
+                order.setDeliveryName(delivers.getDeliverName());
+                order.setDeliverySn(delivers.getDeliverId());
+                order.setDeliveryStatus(delivers.getStatus());
+                order.setDeliveryType(String.valueOf(delivers.getStateEx()));
+            }else {
+                order.setDeliveryCode(null);
+                order.setDeliveryName(null);
+                order.setDeliverySn(null);
+                order.setDeliveryStatus(null);
+                order.setDeliveryType(null);
+            }
+            if(ObjectUtil.isNotNull(liveAfterSalesMap)){
+                LiveAfterSales liveAfterSales = liveAfterSalesMap.get(order.getOrderId());
+                if(ObjectUtil.isNotNull(liveAfterSales)) {
+                    order.setAfterSaleId(liveAfterSales.getId());
                 }
                 }
             }
             }
-            if (liveOrders.isEmpty()) {
-                return liveOrders;
+
+            if(ObjectUtil.isNotNull(liveOrderItemMaps)){
+                Long orderId = order.getOrderId();
+                List<LiveOrderItemVo> liveOrderItemVos = liveOrderItemMaps.get(orderId);
+                if(CollectionUtils.isEmpty(liveOrderItemVos)) {
+                    order.setOrderItemList(liveOrderItemVos);
+                }
             }
             }
-        }catch (Exception e){
-            log.error("查询订单详情失败", e);
-            throw new RuntimeException("查询订单详情失败");
+        }
+        if (liveOrders.isEmpty()) {
+            return liveOrders;
         }
         }
         return liveOrders;
         return liveOrders;
     }
     }

+ 22 - 1
fs-service-system/src/main/resources/mapper/live/LiveOrderItemMapper.xml

@@ -19,6 +19,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="storeId"    column="store_id"    />
         <result property="storeId"    column="store_id"    />
         <result property="isGift"    column="is_gift"    />
         <result property="isGift"    column="is_gift"    />
     </resultMap>
     </resultMap>
+    <resultMap id="liveOrderItemVoMap" type="com.fs.live.vo.LiveOrderItemVo">
+        <result property="itemId" column="item_id"/>
+        <result property="orderId" column="orderId"/>
+        <result property="orderCode" column="order_code"/>
+        <result property="cartId" column="cart_id"/>
+        <result property="goodsId" column="goods_id"/>
+        <result property="productId" column="product_id"/>
+        <result property="productAttrValueId" column="product_attr_value_id"/>
+        <result property="jsonInfo" column="json_info"/>
+        <result property="num" column="num" javaType="java.lang.Long"/>
+        <result property="isAfterSales" column="is_after_sales"/>
+        <result property="isPrescribe" column="is_prescribe"/>
+        <result property="storeId" column="store_id"/>
+        <result property="isGift" column="is_gift"/>
+        <result property="productName" column="product_name"/>
+        <result property="imgUrl" column="img_url"/>
+        <result property="price" column="price"/>
+        <result property="otPrice" column="ot_price"/>
+        <result property="sales" column="sales" javaType="java.lang.Integer"/>
+        <result property="productIntroduce" column="product_introduce"/>
+    </resultMap>
+
 
 
     <sql id="selectLiveOrderItemVo">
     <sql id="selectLiveOrderItemVo">
         select item_id, order_id, order_code, cart_id, goods_id, product_id, product_attr_value_id, json_info, num, is_after_sales, is_prescribe, store_id, is_gift from live_order_item
         select item_id, order_id, order_code, cart_id, goods_id, product_id, product_attr_value_id, json_info, num, is_after_sales, is_prescribe, store_id, is_gift from live_order_item
@@ -43,7 +65,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     </select>
 
 
 
 
-
     <select id="selectCheckedByUserId" parameterType="java.util.List" resultType="com.fs.live.vo.LiveOrderItemVo">
     <select id="selectCheckedByUserId" parameterType="java.util.List" resultType="com.fs.live.vo.LiveOrderItemVo">
         select a.item_id, a.order_id, a.order_code, a.cart_id, a.goods_id, a.product_id,a. product_attr_value_id, a.json_info, a.num, a.is_after_sales, a.is_prescribe, a.store_id, a.is_gift
         select a.item_id, a.order_id, a.order_code, a.cart_id, a.goods_id, a.product_id,a. product_attr_value_id, a.json_info, a.num, a.is_after_sales, a.is_prescribe, a.store_id, a.is_gift
         , b.product_name, b.image as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce
         , b.product_name, b.image as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce

+ 1 - 0
fs-user-app/src/main/java/com/fs/app/controller/LiveOrderController.java

@@ -118,6 +118,7 @@ public class LiveOrderController extends AppBaseController
             PageInfo<LiveOrderListVo> result = new PageInfo<>(list);
             PageInfo<LiveOrderListVo> result = new PageInfo<>(list);
             return R.ok().put("data", result);
             return R.ok().put("data", result);
         } catch (Exception e) {
         } catch (Exception e) {
+            log.error("查询失败!",e);
             return R.error("操作异常");
             return R.error("操作异常");
         }
         }