菜品上架下架

This commit is contained in:
zjf committed 2026-10-05 19:53:31 +08:00
1 parent 93379302e4
commit ffb9a08755
4 files changed
+11 -6

No files matched your search

@@ -16,6 +16,9 @@ public class CanteenSpuExportQuery {
private String merchantId;
/** 上架状态:0上架 1下架 -1回收 */
private Integer status;
/** 勾选导出时的 SPU id */
private List<String> ids;
}
@@ -318,7 +318,7 @@ public class CanteenSpuController {
ids = query.getIds().stream().map(this::parseLongId).filter(Objects::nonNull).toArray(Long[]::new);
}
return canteenSpuImportHelper.toExportRows(
canteenSpuService.listForExport(query.getName(), categoryId, merchantId, ids));
canteenSpuService.listForExport(query.getName(), categoryId, merchantId, query.getStatus(), ids));
}
private Long parseLongId(String raw) {
@@ -74,7 +74,7 @@ public interface CanteenSpuService extends IService<CanteenSpuEntity> {
/**
* 导出列表查询(与列表页 selectPage 同筛选:商户/名称/分类,并排除已关联线上菜品)
*/
List<CanteenSpuEntity> listForExport(String name, Long categoryId, Long merchantId, Long[] ids);
List<CanteenSpuEntity> listForExport(String name, Long categoryId, Long merchantId, Integer status, Long[] ids);
/**
* 分页查询,并且过滤已选择的菜品
@@ -503,6 +503,7 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
LambdaQueryWrapper<CanteenSpuEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(canteenSpu.getName()), CanteenSpuEntity::getName, canteenSpu.getName());
wrapper.eq(Objects.nonNull(canteenSpu.getCategoryId()), CanteenSpuEntity::getCategoryId, canteenSpu.getCategoryId());
wrapper.eq(Objects.nonNull(canteenSpu.getStatus()), CanteenSpuEntity::getStatus, canteenSpu.getStatus());
merchantScopeHelper.applyMerchantIdScope(wrapper, canteenSpu.getMerchantId(), CanteenSpuEntity::getMerchantId);
wrapper.orderByAsc(CanteenSpuEntity::getSort).orderByDesc(CanteenSpuEntity::getId);
@@ -511,11 +512,12 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
}
@Override
public List<CanteenSpuEntity> listForExport(String name, Long categoryId, Long merchantId, Long[] ids) {
public List<CanteenSpuEntity> listForExport(String name, Long categoryId, Long merchantId, Integer status, Long[] ids) {
// 与 selectPage(菜品列表页)保持同一套筛选,避免导出比列表多/变成“全部”
LambdaQueryWrapper<CanteenSpuEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(name), CanteenSpuEntity::getName, name);
wrapper.eq(Objects.nonNull(categoryId), CanteenSpuEntity::getCategoryId, categoryId);
wrapper.eq(Objects.nonNull(status), CanteenSpuEntity::getStatus, status);
merchantScopeHelper.applyMerchantIdScope(wrapper, merchantId, CanteenSpuEntity::getMerchantId);
LambdaQueryWrapper<CanteenOnlineSpuEntity> onlineQw = new LambdaQueryWrapper<>();
@@ -569,10 +571,9 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
LambdaQueryWrapper<CanteenSpuEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(canteenSpu.getName()), CanteenSpuEntity::getName, canteenSpu.getName());
wrapper.eq(Objects.nonNull(canteenSpu.getCategoryId()), CanteenSpuEntity::getCategoryId, canteenSpu.getCategoryId());
// 套餐组成只可选单品(spu_type 为空或 1);排除逻辑删除与回收
// 套餐组成只可选本商户上架单品(status:0上架 1下架)
wrapper.and(w -> w.isNull(CanteenSpuEntity::getSpuType).or().eq(CanteenSpuEntity::getSpuType, 1));
wrapper.and(w -> w.eq(CanteenSpuEntity::getDelFlag, "0").or().isNull(CanteenSpuEntity::getDelFlag));
wrapper.ne(CanteenSpuEntity::getStatus, -1);
wrapper.eq(CanteenSpuEntity::getStatus, 0);
merchantScopeHelper.applyMerchantIdScope(wrapper, canteenSpu.getMerchantId(), CanteenSpuEntity::getMerchantId);
wrapper.orderByAsc(CanteenSpuEntity::getSort).orderByDesc(CanteenSpuEntity::getId);
@@ -661,6 +662,7 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
LambdaQueryWrapper<CanteenSpuEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(canteenSpu.getName()), CanteenSpuEntity::getName, canteenSpu.getName());
wrapper.eq(Objects.nonNull(canteenSpu.getCategoryId()), CanteenSpuEntity::getCategoryId, canteenSpu.getCategoryId());
wrapper.eq(Objects.nonNull(canteenSpu.getStatus()), CanteenSpuEntity::getStatus, canteenSpu.getStatus());
applyHourTypeCategoryFilter(wrapper, canteenSpu.getHourType());
merchantScopeHelper.applyMerchantIdScope(wrapper, canteenSpu.getMerchantId(), CanteenSpuEntity::getMerchantId);
wrapper.orderByAsc(CanteenSpuEntity::getSort).orderByDesc(CanteenSpuEntity::getId);