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; + } }