Browse Source

订单详情,和订单详情导出新增仓库代码字段

xdd 1 month ago
parent
commit
f119ca9547

+ 13 - 0
fs-admin/src/main/java/com/fs/store/controller/FsStoreHealthOrderController.java

@@ -2,6 +2,7 @@ package com.fs.store.controller;
 
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
@@ -12,6 +13,8 @@ import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.service.ICompanyMoneyLogsService;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.store.cache.IFsStoreProductCacheService;
+import com.fs.store.domain.FsStoreProduct;
 import com.fs.store.dto.StoreOrderProductDTO;
 import com.fs.store.param.FsStoreOrderParam;
 import com.fs.store.service.*;
@@ -50,6 +53,9 @@ public class FsStoreHealthOrderController extends BaseController {
     @Autowired
     private ICompanyMoneyLogsService moneyLogsService;
 
+    @Autowired
+    private IFsStoreProductCacheService fsStoreProductCacheService;
+
     /**
      * 查询健康商城订单列表
      */
@@ -156,6 +162,13 @@ public class FsStoreHealthOrderController extends BaseController {
         //对手机号脱敏
         if (list != null) {
             for (FsStoreOrderItemExportVO vo : list) {
+                // 设置仓库名称
+                if(ObjectUtil.isNotNull(vo.getProductId())){
+                    FsStoreProduct fsStoreProduct = fsStoreProductCacheService.selectFsStoreProductById(vo.getProductId());
+                    if(ObjectUtil.isNotNull(fsStoreProduct)){
+                        vo.setWarehouseCode(fsStoreProduct.getWarehouseCode());
+                    }
+                }
                 if (vo.getUserPhone() != null) {
                     String phone = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{1})", "$1****$2");
                     vo.setUserPhone(phone);

+ 15 - 0
fs-admin/src/main/java/com/fs/store/controller/FsStoreOrderController.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.core.domain.R;
@@ -19,6 +20,7 @@ import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.express.FsStoreDeliversService;
 import com.fs.express.dto.DeliveryDTO;
+import com.fs.store.cache.IFsStoreProductCacheService;
 import com.fs.store.domain.*;
 import com.fs.store.dto.*;
 import com.fs.store.enums.ShipperCodeEnum;
@@ -72,6 +74,9 @@ public class FsStoreOrderController extends BaseController {
 
     @Autowired
     private FsStoreDeliversService fsStoreDeliversService;
+
+    @Autowired
+    private IFsStoreProductCacheService fsStoreProductCacheService;
     /**
      * 查询订单列表
      */
@@ -298,7 +303,17 @@ public class FsStoreOrderController extends BaseController {
 
         FsStoreOrderItem itemMap = new FsStoreOrderItem();
         itemMap.setOrderId(order.getId());
+        // 设置仓库代码
         List<FsStoreOrderItem> items = orderItemService.selectFsStoreOrderItemList(itemMap);
+        for (FsStoreOrderItem item : items) {
+            if(ObjectUtil.isNotNull(item.getProductId())){
+                FsStoreProduct fsStoreProduct =
+                        fsStoreProductCacheService.selectFsStoreProductById(item.getProductId());
+                if(ObjectUtil.isNotNull(fsStoreProduct)){
+                    item.setWarehouseCode(fsStoreProduct.getWarehouseCode());
+                }
+            }
+        }
         FsStoreOrderStatus statusMap = new FsStoreOrderStatus();
         statusMap.setOrderId(order.getId());
         List<FsStoreOrderStatus> logs = orderStatusService.selectFsStoreOrderStatusList(statusMap);

+ 14 - 0
fs-service-system/src/main/java/com/fs/store/cache/IFsStoreProductCacheService.java

@@ -0,0 +1,14 @@
+package com.fs.store.cache;
+
+import com.fs.store.domain.FsStoreProduct;
+
+public interface IFsStoreProductCacheService {
+    /**
+     * 查询商品
+     *
+     * @param productId 商品ID
+     * @return 商品
+     */
+    public FsStoreProduct selectFsStoreProductById(Long productId);
+
+}

+ 34 - 0
fs-service-system/src/main/java/com/fs/store/cache/impl/IFsStoreProductCacheServiceImpl.java

@@ -0,0 +1,34 @@
+package com.fs.store.cache.impl;
+
+import com.fs.store.cache.IFsStoreProductCacheService;
+import com.fs.store.domain.FsStoreProduct;
+import com.fs.store.service.IFsStoreProductService;
+import com.fs.system.cache.impl.SysDictDataCacheServiceImpl;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.TimeUnit;
+
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class IFsStoreProductCacheServiceImpl implements IFsStoreProductCacheService {
+    private final IFsStoreProductService fsStoreProductService;
+    /**
+     * 使用Caffeine本地缓存
+     * maximumSize: 最大缓存条数
+     * expireAfterWrite: 写入后多久过期(分钟)
+     */
+    private static final Cache<Long, FsStoreProduct> CACHE = Caffeine.newBuilder()
+            .maximumSize(1000)
+            .expireAfterWrite(1, TimeUnit.MINUTES)
+            .build();
+
+    @Override
+    public FsStoreProduct selectFsStoreProductById(Long productId) {
+        return CACHE.get(productId, e -> fsStoreProductService.selectFsStoreProductById(productId));
+    }
+}

+ 10 - 83
fs-service-system/src/main/java/com/fs/store/domain/FsStoreOrderItem.java

@@ -2,13 +2,17 @@ package com.fs.store.domain;
 
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 /**
  * 订单详情对象 fs_store_order_item
- * 
+ *
  * @author fs
  * @date 2022-03-21
  */
+@EqualsAndHashCode(callSuper = true)
+@Data
 public class FsStoreOrderItem extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -41,89 +45,12 @@ public class FsStoreOrderItem extends BaseEntity
     @Excel(name = "是否能售后0不能1能")
     private Integer isAfterSales;
 
-    private Integer isPrescribe;
-
-    public Integer getIsPrescribe() {
-        return isPrescribe;
-    }
-
-    public void setIsPrescribe(Integer isPrescribe) {
-        this.isPrescribe = isPrescribe;
-    }
-
-    public void setItemId(Long itemId)
-    {
-        this.itemId = itemId;
-    }
-
-    public Long getItemId() 
-    {
-        return itemId;
-    }
-    public void setOrderId(Long orderId) 
-    {
-        this.orderId = orderId;
-    }
-
-    public Long getOrderId() 
-    {
-        return orderId;
-    }
-    public void setOrderCode(String orderCode) 
-    {
-        this.orderCode = orderCode;
-    }
-
-    public String getOrderCode() 
-    {
-        return orderCode;
-    }
-    public void setCartId(Long cartId) 
-    {
-        this.cartId = cartId;
-    }
+    /**
+     * 仓库代码
+     */
+    private String warehouseCode;
 
-    public Long getCartId() 
-    {
-        return cartId;
-    }
-    public void setProductId(Long productId) 
-    {
-        this.productId = productId;
-    }
-
-    public Long getProductId() 
-    {
-        return productId;
-    }
-
-    public void setJsonInfo(String jsonInfo) 
-    {
-        this.jsonInfo = jsonInfo;
-    }
-
-    public String getJsonInfo() 
-    {
-        return jsonInfo;
-    }
-    public void setNum(Integer num)
-    {
-        this.num = num;
-    }
-
-    public Integer getNum()
-    {
-        return num;
-    }
-    public void setIsAfterSales(Integer isAfterSales) 
-    {
-        this.isAfterSales = isAfterSales;
-    }
-
-    public Integer getIsAfterSales() 
-    {
-        return isAfterSales;
-    }
+    private Integer isPrescribe;
 
 
 }

+ 8 - 0
fs-service-system/src/main/java/com/fs/store/vo/FsStoreOrderItemExportVO.java

@@ -30,6 +30,9 @@ public class FsStoreOrderItemExportVO implements Serializable
     @Excel(name = "产品编码")
     private String barCode;
 
+    @Excel(name = "仓库代码")
+    private String warehouseCode;
+
 
     @Excel(name = "规格")
     private String sku;
@@ -99,4 +102,9 @@ public class FsStoreOrderItemExportVO implements Serializable
     @Excel(name = "套餐包分类", dictType = "store_product_package_cate")
     private String cateId;
 
+    /**
+     * 产品id
+     */
+    private Long productId;
+
 }

+ 1 - 2
fs-service-system/src/main/resources/mapper/store/FsStoreCouponIssueMapper.xml

@@ -64,10 +64,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             fs_store_coupon_issue
         WHERE
             coupon_type = 1
-          AND  remain_count> 0
           AND ifnull(is_del,0)= 0
           AND `status`=1
-
+          AND now() BETWEEN start_time and limit_time
         UNION
 
         SELECT