feat(店铺/智能柜): 增加按店铺ID和模式筛选功能

修改店铺列表接口,支持传入mode参数进行筛选
智能柜详情接口改为按shopId查询相关数据
This commit is contained in:
dzq 2025-06-13 15:40:31 +08:00
parent ad1d764991
commit 4e4c4876b6
6 changed files with 38 additions and 14 deletions

View File

@ -41,8 +41,8 @@ public class CabinetCellController {
private final CabinetMainboardModelFactory cabinetMainboardModelFactory; private final CabinetMainboardModelFactory cabinetMainboardModelFactory;
@GetMapping("/detail") @GetMapping("/detail")
public ResponseDTO<List<CabinetDetailDTO>> getCabinetDetail() { public ResponseDTO<List<CabinetDetailDTO>> getCabinetDetail(@RequestParam Long shopId) {
return ResponseDTO.ok(smartCabinetApplicationService.getCabinetDetail()); return ResponseDTO.ok(smartCabinetApplicationService.getCabinetDetail(shopId));
} }
@PostMapping("/openCabinet/{cabinetId}/{pinNo}") @PostMapping("/openCabinet/{cabinetId}/{pinNo}")

View File

@ -41,12 +41,14 @@ public class ShopController {
private final CategoryApplicationService categoryApplicationService; private final CategoryApplicationService categoryApplicationService;
@GetMapping("/list") @GetMapping("/list")
public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid) { public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid,
@RequestParam(required = false) Long mode) {
List<ShopEntity> shopList; List<ShopEntity> shopList;
Long modeValue = mode != null ? mode : 4L;
if (StringUtils.isNotBlank(corpid)) { if (StringUtils.isNotBlank(corpid)) {
shopList = shopApplicationService.getShopListByCorpid(corpid); shopList = shopApplicationService.getShopListByCorpid(corpid, modeValue);
} else { } else {
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid); shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid, modeValue);
} }
return ResponseDTO.ok(shopList); return ResponseDTO.ok(shopList);
} }

View File

@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -146,11 +147,32 @@ public class SmartCabinetApplicationService {
* 获取所有智能柜的详细信息 * 获取所有智能柜的详细信息
* @return 包含柜体信息单元格信息和商品信息的列表 * @return 包含柜体信息单元格信息和商品信息的列表
*/ */
public List<CabinetDetailDTO> getCabinetDetail() { public List<CabinetDetailDTO> getCabinetDetail(Long shopId) {
// 获取所有智能柜单元格和商品的基础数据 // 获取所有智能柜单元格和商品的基础数据
List<SmartCabinetEntity> smartCabinets = smartCabinetService.selectAll(); QueryWrapper<SmartCabinetEntity> smartCabinetEntityQueryWrapper = new QueryWrapper<>();
List<CabinetCellEntity> cabinetCells = cabinetCellService.selectAll(); smartCabinetEntityQueryWrapper.eq("shop_id", shopId)
List<ShopGoodsEntity> goodsList = shopGoodsService.selectAll(); .eq("deleted", false);
List<SmartCabinetEntity> smartCabinets = smartCabinetService.list(smartCabinetEntityQueryWrapper);
QueryWrapper<CabinetCellEntity> cabinetCellEntityQueryWrapper = new QueryWrapper<>();
cabinetCellEntityQueryWrapper.in("cabinet_id",
smartCabinets.stream()
.map(SmartCabinetEntity::getCabinetId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList()))
.eq("deleted", false);
List<CabinetCellEntity> cabinetCells = cabinetCellService.list(cabinetCellEntityQueryWrapper);
QueryWrapper<ShopGoodsEntity> shopGoodsEntityQueryWrapper = new QueryWrapper<>();
shopGoodsEntityQueryWrapper.in("goods_id",
cabinetCells.stream()
.map(CabinetCellEntity::getGoodsId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList()))
.eq("deleted", false);
List<ShopGoodsEntity> goodsList = shopGoodsService.list(shopGoodsEntityQueryWrapper);
List<CabinetDetailDTO> result = new ArrayList<>(); List<CabinetDetailDTO> result = new ArrayList<>();
// 遍历每个智能柜构建详细信息 // 遍历每个智能柜构建详细信息

View File

@ -37,8 +37,8 @@ public class ShopApplicationService {
return new ShopDTO(shopEntity); return new ShopDTO(shopEntity);
} }
public List<ShopEntity> getShopListByCorpid(String corpid) { public List<ShopEntity> getShopListByCorpid(String corpid, Long mode) {
return shopService.getShopListByCorpid(corpid); return shopService.getShopListByCorpid(corpid, mode);
} }
public void addShop(AddShopCommand command) { public void addShop(AddShopCommand command) {

View File

@ -28,5 +28,5 @@ public interface ShopService extends IService<ShopEntity> {
Long countAllRecord(); Long countAllRecord();
List<ShopEntity> getShopListByCorpid(String corpid); List<ShopEntity> getShopListByCorpid(String corpid, Long mode);
} }

View File

@ -50,10 +50,10 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopEntity> impleme
} }
@Override @Override
public List<ShopEntity> getShopListByCorpid(String corpid) { public List<ShopEntity> getShopListByCorpid(String corpid, Long mode) {
QueryWrapper<ShopEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("corpid", corpid) queryWrapper.eq("corpid", corpid)
.ne("mode", 4) .ne("mode", mode)
.eq("deleted", 0); .eq("deleted", 0);
return this.list(queryWrapper); return this.list(queryWrapper);
} }