|
|
@@ -13,7 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import shop.alien.entity.store.StoreBookingCategory;
|
|
|
import shop.alien.entity.store.StoreBookingTable;
|
|
|
+import shop.alien.entity.store.UserReservation;
|
|
|
import shop.alien.mapper.StoreBookingCategoryMapper;
|
|
|
+import shop.alien.mapper.UserReservationMapper;
|
|
|
import shop.alien.store.service.StoreBookingCategoryService;
|
|
|
import shop.alien.store.service.StoreBookingTableService;
|
|
|
import shop.alien.util.common.JwtUtil;
|
|
|
@@ -33,6 +35,7 @@ import java.util.List;
|
|
|
public class StoreBookingCategoryServiceImpl extends ServiceImpl<StoreBookingCategoryMapper, StoreBookingCategory> implements StoreBookingCategoryService {
|
|
|
|
|
|
private final StoreBookingTableService storeBookingTableService;
|
|
|
+ private final UserReservationMapper userReservationMapper;
|
|
|
|
|
|
@Override
|
|
|
public List<StoreBookingCategory> getCategoryList(Integer storeId) {
|
|
|
@@ -311,6 +314,30 @@ public class StoreBookingCategoryServiceImpl extends ServiceImpl<StoreBookingCat
|
|
|
return this.update(updateWrapper);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean hasReservationInCategory(Integer categoryId, Integer storeId) {
|
|
|
+ log.info("StoreBookingCategoryServiceImpl.hasReservationInCategory?categoryId={}, storeId={}", categoryId, storeId);
|
|
|
+
|
|
|
+ if (categoryId == null || storeId == null) {
|
|
|
+ log.warn("查询分类下是否有预订信息失败:分类ID或门店ID不能为空");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询该门店该分类下是否有预订信息
|
|
|
+ LambdaQueryWrapper<UserReservation> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(UserReservation::getStoreId, storeId)
|
|
|
+ .eq(UserReservation::getCategoryId, categoryId);
|
|
|
+ // @TableLogic 会自动过滤已删除的记录(delete_flag=0)
|
|
|
+
|
|
|
+ long count = userReservationMapper.selectCount(wrapper);
|
|
|
+ boolean hasReservation = count > 0;
|
|
|
+
|
|
|
+ log.info("查询分类下是否有预订信息完成,categoryId={}, storeId={}, count={}, hasReservation={}",
|
|
|
+ categoryId, storeId, count, hasReservation);
|
|
|
+
|
|
|
+ return hasReservation;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 从JWT获取当前登录用户ID
|
|
|
*
|