xdd 2 kuukautta sitten
vanhempi
commit
c247f3a8c7

+ 7 - 0
fs-service-system/src/main/java/com/fs/express/cache/FsStoreDeliversCacheService.java

@@ -11,4 +11,11 @@ public interface FsStoreDeliversCacheService {
      * @return List<FsStoreDelivers>
      */
     Integer findExpressStatusByOrderId(Long orderId);
+
+    /**
+     * 根据orderCode查询发货信息(取第一条)
+     * @param orderCode 订单号
+     * @return FsStoreDelivers
+     */
+    FsStoreDelivers findByOrderCode(String orderCode);
 }

+ 11 - 2
fs-service-system/src/main/java/com/fs/express/cache/impl/FsStoreDeliversCacheServiceImpl.java

@@ -3,14 +3,12 @@ package com.fs.express.cache.impl;
 import com.fs.express.FsStoreDeliversService;
 import com.fs.express.cache.FsStoreDeliversCacheService;
 import com.fs.store.domain.FsStoreDelivers;
-import com.fs.store.domain.FsUser;
 import com.github.benmanes.caffeine.cache.Cache;
 import com.github.benmanes.caffeine.cache.Caffeine;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -18,11 +16,17 @@ import java.util.concurrent.TimeUnit;
 public class FsStoreDeliversCacheServiceImpl implements FsStoreDeliversCacheService {
     @Autowired
     private FsStoreDeliversService fsStoreDeliversService;
+
     private static final Cache<Long, Integer> EXPRESS_STATUS_CACHE = Caffeine.newBuilder()
             .maximumSize(1000)
             .expireAfterWrite(3, TimeUnit.MINUTES)
             .build();
 
+    private static final Cache<String, FsStoreDelivers> ORDER_CODE_CACHE = Caffeine.newBuilder()
+            .maximumSize(1000)
+            .expireAfterWrite(3, TimeUnit.MINUTES)
+            .build();
+
     @Override
     public Integer findExpressStatusByOrderId(Long orderId) {
         EXPRESS_STATUS_CACHE.get(orderId, key -> {
@@ -36,4 +40,9 @@ public class FsStoreDeliversCacheServiceImpl implements FsStoreDeliversCacheServ
 
         return 0;
     }
+
+    @Override
+    public FsStoreDelivers findByOrderCode(String orderCode) {
+        return ORDER_CODE_CACHE.get(orderCode, key -> fsStoreDeliversService.findByOrderCode(orderCode));
+    }
 }

+ 11 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -55,6 +55,7 @@ import com.fs.erp.service.IErpOrderService;
 import com.fs.erp.utils.ErpContextHolder;
 import com.fs.express.FsStoreDeliversService;
 import com.fs.express.cache.FsStoreDeliversCacheService;
+import com.fs.store.domain.FsStoreDelivers;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.dto.*;
@@ -235,6 +236,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     @Autowired
     private FsStoreDeliversService fsStoreDeliversService;
 
+    @Autowired
+    private FsStoreDeliversCacheService fsStoreDeliversCacheService;
+
     @Autowired
     private IFsStoreProductPackageService fsStoreProductPackageService;
     @Autowired
@@ -1323,6 +1327,13 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                     vo.setItems(items);
                 }
             }
+            // 从fs_store_delivers表通过orderCode获取deliveryId
+            if(StringUtils.isNotEmpty(vo.getOrderCode())){
+                FsStoreDelivers delivers = fsStoreDeliversCacheService.findByOrderCode(vo.getOrderCode());
+                if(delivers != null && StringUtils.isNotEmpty(delivers.getDeliverId())){
+                    vo.setDeliveryId(delivers.getDeliverId());
+                }
+            }
             //处理是否可以申请售后
             vo.setIsAfterSales(0);
             if(vo.getStatus().equals(OrderInfoEnum.STATUS_3.getValue())){