pad点餐接口实现

This commit is contained in:
张松
2025-02-20 14:30:00 +08:00
parent d8935700f2
commit 5b587995ba
3 changed files with 43 additions and 14 deletions

View File

@@ -43,7 +43,7 @@ public class PadProdServiceImpl implements PadProdService {
public Page<PadProductCategoryDTO> pageInfo(Page<PadProductCategoryDTO> objectPage, Long productCategoryId, Long shopId) {
JoinQueryWrapper queryWrapper = new JoinQueryWrapper().eq(PadProductCategory::getShopId, shopId);
if (productCategoryId != null) {
queryWrapper.eq(PadProductCategory::getId, productCategoryId);
queryWrapper.eq(PadProductCategory::getProductCategoryId, productCategoryId);
}
queryWrapper.orderBy(PadProductCategory::getSort, true).orderBy(PadProductCategory::getId, false);
return padProductCategoryDetailMapper.xmlPaginate("selectPageByKeyAndShopId", objectPage, queryWrapper);
@@ -98,16 +98,19 @@ public class PadProdServiceImpl implements PadProdService {
}
checkInfo(shopId, padDetailEditDTO.getPadLayoutId(), padDetailEditDTO.getProductIdList());
padProductCategoryDetailService.remove(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, padDetailEditDTO.getId()));
category.setPadLayoutId(padDetailEditDTO.getPadLayoutId());
padProductCategoryService.updateById(category);
ArrayList<PadProductCategoryDetail> details = new ArrayList<>();
padDetailEditDTO.getProductIdList().forEach(item -> {
details.add(new PadProductCategoryDetail().setPadProductCategoryId(padDetailEditDTO.getId()).setProductId(item));
});
return padProductCategoryDetailService.saveBatch(details);
if (padDetailEditDTO.getProductIdList() != null && !padDetailEditDTO.getProductIdList().isEmpty()) {
padProductCategoryDetailService.remove(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, padDetailEditDTO.getId()));
ArrayList<PadProductCategoryDetail> details = new ArrayList<>();
padDetailEditDTO.getProductIdList().forEach(item -> {
details.add(new PadProductCategoryDetail().setPadProductCategoryId(padDetailEditDTO.getId()).setProductId(item));
});
return padProductCategoryDetailService.saveBatch(details);
}
return true;
}
private void checkInfo(Long shopId, Long padLayoutId, List<Long> productIdList) {
@@ -116,9 +119,11 @@ public class PadProdServiceImpl implements PadProdService {
throw new ApiNotPrintException("pad布局不存在");
}
long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList));
if (proCount != productIdList.size()) {
throw new ApiNotPrintException("存在错误商品id");
if (productIdList != null && !productIdList.isEmpty()) {
long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList));
if (proCount != productIdList.size()) {
throw new ApiNotPrintException("存在错误商品id");
}
}
}