Jiaqi Xia

feat: add class-level meal suspension check and fix school level chcek

......@@ -115,6 +115,13 @@ public class MealOrderServiceImpl implements MealOrderService {
null
);
// 直接过滤出学校级别的停餐记录
if (schoolSuspensionRecords != null) {
schoolSuspensionRecords = schoolSuspensionRecords.stream()
.filter(r -> r.getClassId() == 0 && r.getDinerId() == 0)
.toList();
}
if (schoolSuspensionRecords != null && !schoolSuspensionRecords.isEmpty()) {
var latestSchoolSuspension = schoolSuspensionRecords.stream()
.max((a, b) -> Long.compare(a.getCreatedAt(), b.getCreatedAt()))
......@@ -127,7 +134,34 @@ public class MealOrderServiceImpl implements MealOrderService {
}
}
// 5.2 再查询学生级别的停餐信息
// 5.2 再查询班级级别的停餐信息
var classSuspensionRecords = mealOrderServiceRpcClient.queryDinerMealSuspensionRecordsByCondition(
loginInfo.getEnterpriseId(),
List.of(dinerById.getClientId()),
List.of(dinerById.getClassId()),
null
);
// 直接过滤出班级级别的停餐记录
if (classSuspensionRecords != null) {
classSuspensionRecords = classSuspensionRecords.stream()
.filter(r -> r.getDinerId() == 0)
.toList();
}
if (classSuspensionRecords != null && !classSuspensionRecords.isEmpty()) {
var latestClassSuspension = classSuspensionRecords.stream()
.max((a, b) -> Long.compare(a.getCreatedAt(), b.getCreatedAt()))
.orElse(null);
if (latestClassSuspension != null &&
currentTime >= latestClassSuspension.getStartAt() &&
currentTime <= latestClassSuspension.getEndAt()) {
throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_MEAL_SUSPENDED);
}
}
// 5.3 再查询学生级别的停餐信息
var studentSuspensionRecords = mealOrderServiceRpcClient.queryDinerMealSuspensionRecordsByCondition(
loginInfo.getEnterpriseId(),
List.of(dinerById.getClientId()),
......