统计数据归档查询、商品数据分类缓存、已知问题修复
This commit is contained in:
@@ -2,8 +2,6 @@ package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.service.ShopConfigService;
|
||||
import com.czg.annotation.SaStaffCheckPermission;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
@@ -72,22 +70,9 @@ public class ProductController {
|
||||
public CzgResult<List<ProductDTO>> getProductList(ProductDTO param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
param.setShopId(shopId);
|
||||
ProductDTO cacheParam = new ProductDTO();
|
||||
cacheParam.setShopId(shopId);
|
||||
List<ProductDTO> data = getProductCacheList(cacheParam, param);
|
||||
productService.refreshProductStock(param, data);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
private List<ProductDTO> getProductCacheList(ProductDTO cacheParam, ProductDTO param) {
|
||||
List<ProductDTO> productList = productService.getProductList(cacheParam);
|
||||
if (StrUtil.isNotEmpty(param.getName())) {
|
||||
productList = productList.stream().filter(obj -> StrUtil.contains(obj.getName(), param.getName())).toList();
|
||||
}
|
||||
if (ObjUtil.isNotNull(param.getCategoryId())) {
|
||||
productList = productList.stream().filter(obj -> param.getCategoryId().equals(obj.getCategoryId())).toList();
|
||||
}
|
||||
return productList;
|
||||
List<ProductDTO> productList = productService.getProductCacheList(param);
|
||||
productService.refreshProductStock(param, productList);
|
||||
return CzgResult.success(productList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,6 +145,9 @@ public class ProductController {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
param.setShopId(shopId);
|
||||
productService.updateProductStock(param);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||
});
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.product.dto.ProdGroupDTO;
|
||||
import com.czg.product.param.ShopProductSkuParam;
|
||||
import com.czg.product.service.ProdGroupService;
|
||||
import com.czg.product.service.UProductService;
|
||||
@@ -21,7 +20,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,19 +55,13 @@ public class UProductController {
|
||||
@GetMapping("/miniApp/group/query")
|
||||
public CzgResult<List<ShopGroupProductVo>> queryGroupProductList() {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
ProdGroupDTO param = new ProdGroupDTO();
|
||||
List<ProdGroupDTO> prodGroupList = prodGroupService.getProdGroupList(param);
|
||||
Map<Long, ProdGroupDTO> groupMap = prodGroupList.stream().collect(Collectors.toMap(ProdGroupDTO::getId, i -> i));
|
||||
List<ShopGroupProductVo> list = uProductService.queryGroupProductList(shopId);
|
||||
Map<Long, Integer> productStock = uProductService.findShopProductStock(shopId);
|
||||
list.forEach(item -> {
|
||||
uProductService.refreshProductStock(productStock, item.getProductList());
|
||||
ProdGroupDTO config = groupMap.get(item.getId());
|
||||
item.getProductList().forEach(prod -> {
|
||||
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
|
||||
if (config != null) {
|
||||
prod.setIsSaleTime(uProductService.calcIsSaleTime(config.getUseTime(), config.getSaleStartTime(), config.getSaleEndTime()));
|
||||
}
|
||||
prod.setIsSaleTime(uProductService.calcIsSaleTime(item.getUseTime(), item.getSaleStartTime(), item.getSaleEndTime()));
|
||||
});
|
||||
});
|
||||
return CzgResult.success(list);
|
||||
|
||||
Reference in New Issue
Block a user