feat: 商城商品查询修改

This commit is contained in:
weizhiqiang 2024-09-18 15:19:19 +08:00
parent 8f9a3b1264
commit a0212606bd
4 changed files with 42 additions and 13 deletions

View file

@ -49,4 +49,8 @@ public class ShopMaterialStore extends OperatorUserInfo {
@Property(value = "门店信息")
private Map<String, Object> storeMation;
@TableField(exist = false)
@Property(value = "上架的商品信息")
private ShopMaterial shopMaterial;
}

View file

@ -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<ShopMate
void addAllStoreForMaterial(String materialId);
void saveShopMaterialStore(InputObject inputObject, OutputObject outputObject);
List<ShopMaterialStore> queryShopMaterialList(InputObject inputObject, OutputObject outputObject);
}

View file

@ -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<ShopMater
@Override
public void queryShopMaterialList(InputObject inputObject, OutputObject outputObject) {
CommonPageInfo commonPageInfo = inputObject.getParams(CommonPageInfo.class);
Page pages = PageHelper.startPage(commonPageInfo.getPage(), commonPageInfo.getLimit());
MPJLambdaWrapper<ShopMaterial> wrapper = new MPJLambdaWrapper<ShopMaterial>()
.innerJoin(Material.class, Material::getId, ShopMaterial::getMaterialId)
.like(StrUtil.isNotBlank(commonPageInfo.getKeyword()), Material::getName, commonPageInfo.getKeyword());
List<ShopMaterial> shopMaterialList = skyeyeBaseMapper.selectJoinList(ShopMaterial.class, wrapper);
List<ShopMaterialStore> shopMaterialStoreList = shopMaterialStoreService.queryShopMaterialList(inputObject, outputObject);
List<String> materialIdList = shopMaterialStoreList.stream().map(ShopMaterialStore::getMaterialId).collect(Collectors.toList());
// 根据商品id查询上架的商品信息
QueryWrapper<ShopMaterial> queryWrapper = new QueryWrapper<>();
queryWrapper.in(MybatisPlusUtil.toColumns(ShopMaterial::getMaterialId), materialIdList);
List<ShopMaterial> shopMaterialList = list(queryWrapper);
// 根据id批量查询详细的商品信息
List<String> idList = shopMaterialList.stream().map(ShopMaterial::getId).collect(Collectors.toList());
List<ShopMaterial> shopMaterials = selectByIds(idList.toArray(new String[]{}));
outputObject.setBeans(shopMaterials);
outputObject.settotal(pages.getTotal());
Map<String, ShopMaterial> 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

View file

@ -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<Shop
// 保存门店商品数据
createEntity(newList, InputObject.getLogParamsStatic().get("id").toString());
}
@Override
public List<ShopMaterialStore> queryShopMaterialList(InputObject inputObject, OutputObject outputObject) {
CommonPageInfo commonPageInfo = inputObject.getParams(CommonPageInfo.class);
Page pages = PageHelper.startPage(commonPageInfo.getPage(), commonPageInfo.getLimit());
MPJLambdaWrapper<ShopMaterialStore> wrapper = new MPJLambdaWrapper<ShopMaterialStore>()
.innerJoin(Material.class, Material::getId, ShopMaterialStore::getMaterialId)
.like(StrUtil.isNotBlank(commonPageInfo.getKeyword()), Material::getName, commonPageInfo.getKeyword());
List<ShopMaterialStore> shopMaterialList = skyeyeBaseMapper.selectJoinList(ShopMaterialStore.class, wrapper);
iShopStoreService.setDataMation(shopMaterialList, ShopMaterialStore::getStoreId);
outputObject.settotal(pages.getTotal());
return shopMaterialList;
}
}