From a0212606bd946e6a95349ddc9b0e88e2c161aa74 Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Wed, 18 Sep 2024 15:19:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=9F=8E=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/ShopMaterialStore.java | 4 +++ .../service/ShopMaterialStoreService.java | 3 ++ .../service/impl/ShopMaterialServiceImpl.java | 29 ++++++++++--------- .../impl/ShopMaterialStoreServiceImpl.java | 19 ++++++++++++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/entity/ShopMaterialStore.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/entity/ShopMaterialStore.java index 3899cd3e..54fef33b 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/entity/ShopMaterialStore.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/entity/ShopMaterialStore.java @@ -49,4 +49,8 @@ public class ShopMaterialStore extends OperatorUserInfo { @Property(value = "门店信息") private Map storeMation; + @TableField(exist = false) + @Property(value = "上架的商品信息") + private ShopMaterial shopMaterial; + } diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java index 3e38ce6f..82eaf88b 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java @@ -5,6 +5,7 @@ package com.skyeye.shopmaterial.service; import com.skyeye.base.business.service.SkyeyeBusinessService; +import com.skyeye.common.entity.search.CommonPageInfo; import com.skyeye.common.object.InputObject; import com.skyeye.common.object.OutputObject; import com.skyeye.shopmaterial.entity.ShopMaterialStore; @@ -38,4 +39,6 @@ public interface ShopMaterialStoreService extends SkyeyeBusinessService queryShopMaterialList(InputObject inputObject, OutputObject outputObject); } diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialServiceImpl.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialServiceImpl.java index 98338d77..d17a5955 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialServiceImpl.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialServiceImpl.java @@ -8,14 +8,10 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.github.pagehelper.Page; -import com.github.pagehelper.PageHelper; -import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.skyeye.annotation.service.SkyeyeService; import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl; import com.skyeye.common.constans.CommonCharConstants; import com.skyeye.common.constans.CommonNumConstants; -import com.skyeye.common.entity.search.CommonPageInfo; import com.skyeye.common.object.InputObject; import com.skyeye.common.object.OutputObject; import com.skyeye.common.util.mybatisplus.MybatisPlusUtil; @@ -26,6 +22,7 @@ import com.skyeye.material.service.MaterialService; import com.skyeye.shopmaterial.dao.ShopMaterialDao; import com.skyeye.shopmaterial.entity.ShopMaterial; import com.skyeye.shopmaterial.entity.ShopMaterialNorms; +import com.skyeye.shopmaterial.entity.ShopMaterialStore; import com.skyeye.shopmaterial.service.ShopMaterialNormsService; import com.skyeye.shopmaterial.service.ShopMaterialService; import com.skyeye.shopmaterial.service.ShopMaterialStoreService; @@ -153,17 +150,23 @@ public class ShopMaterialServiceImpl extends SkyeyeBusinessServiceImpl wrapper = new MPJLambdaWrapper() - .innerJoin(Material.class, Material::getId, ShopMaterial::getMaterialId) - .like(StrUtil.isNotBlank(commonPageInfo.getKeyword()), Material::getName, commonPageInfo.getKeyword()); - - List shopMaterialList = skyeyeBaseMapper.selectJoinList(ShopMaterial.class, wrapper); + List shopMaterialStoreList = shopMaterialStoreService.queryShopMaterialList(inputObject, outputObject); + List materialIdList = shopMaterialStoreList.stream().map(ShopMaterialStore::getMaterialId).collect(Collectors.toList()); + // 根据商品id查询上架的商品信息 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in(MybatisPlusUtil.toColumns(ShopMaterial::getMaterialId), materialIdList); + List shopMaterialList = list(queryWrapper); + // 根据id批量查询详细的商品信息 List idList = shopMaterialList.stream().map(ShopMaterial::getId).collect(Collectors.toList()); List shopMaterials = selectByIds(idList.toArray(new String[]{})); - outputObject.setBeans(shopMaterials); - outputObject.settotal(pages.getTotal()); + Map materialMap = shopMaterials.stream().collect( + Collectors.toMap(ShopMaterial::getMaterialId, shopMaterial -> shopMaterial)); + shopMaterialStoreList.forEach(shopMaterialStore -> { + ShopMaterial shopMaterial = materialMap.get(shopMaterialStore.getMaterialId()); + shopMaterialStore.setShopMaterial(shopMaterial); + }); + + outputObject.setBeans(shopMaterialStoreList); } @Override diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java index 6b6edce3..422618f4 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java @@ -8,11 +8,16 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.skyeye.annotation.service.SkyeyeService; import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl; +import com.skyeye.common.entity.search.CommonPageInfo; import com.skyeye.common.object.InputObject; import com.skyeye.common.object.OutputObject; import com.skyeye.common.util.mybatisplus.MybatisPlusUtil; +import com.skyeye.material.entity.Material; import com.skyeye.rest.shop.service.IShopStoreService; import com.skyeye.shopmaterial.dao.ShopMaterialStoreDao; import com.skyeye.shopmaterial.entity.ShopMaterialStore; @@ -120,4 +125,18 @@ public class ShopMaterialStoreServiceImpl extends SkyeyeBusinessServiceImpl queryShopMaterialList(InputObject inputObject, OutputObject outputObject) { + CommonPageInfo commonPageInfo = inputObject.getParams(CommonPageInfo.class); + Page pages = PageHelper.startPage(commonPageInfo.getPage(), commonPageInfo.getLimit()); + MPJLambdaWrapper wrapper = new MPJLambdaWrapper() + .innerJoin(Material.class, Material::getId, ShopMaterialStore::getMaterialId) + .like(StrUtil.isNotBlank(commonPageInfo.getKeyword()), Material::getName, commonPageInfo.getKeyword()); + + List shopMaterialList = skyeyeBaseMapper.selectJoinList(ShopMaterialStore.class, wrapper); + iShopStoreService.setDataMation(shopMaterialList, ShopMaterialStore::getStoreId); + outputObject.settotal(pages.getTotal()); + return shopMaterialList; + } }