feat: add class-level meal suspension check and fix school level chcek
Showing
1 changed file
with
35 additions
and
1 deletions
| ... | @@ -115,6 +115,13 @@ public class MealOrderServiceImpl implements MealOrderService { | ... | @@ -115,6 +115,13 @@ public class MealOrderServiceImpl implements MealOrderService { |
| 115 | null | 115 | null |
| 116 | ); | 116 | ); |
| 117 | 117 | ||
| 118 | + // 直接过滤出学校级别的停餐记录 | ||
| 119 | + if (schoolSuspensionRecords != null) { | ||
| 120 | + schoolSuspensionRecords = schoolSuspensionRecords.stream() | ||
| 121 | + .filter(r -> r.getClassId() == 0 && r.getDinerId() == 0) | ||
| 122 | + .toList(); | ||
| 123 | + } | ||
| 124 | + | ||
| 118 | if (schoolSuspensionRecords != null && !schoolSuspensionRecords.isEmpty()) { | 125 | if (schoolSuspensionRecords != null && !schoolSuspensionRecords.isEmpty()) { |
| 119 | var latestSchoolSuspension = schoolSuspensionRecords.stream() | 126 | var latestSchoolSuspension = schoolSuspensionRecords.stream() |
| 120 | .max((a, b) -> Long.compare(a.getCreatedAt(), b.getCreatedAt())) | 127 | .max((a, b) -> Long.compare(a.getCreatedAt(), b.getCreatedAt())) |
| ... | @@ -127,7 +134,34 @@ public class MealOrderServiceImpl implements MealOrderService { | ... | @@ -127,7 +134,34 @@ public class MealOrderServiceImpl implements MealOrderService { |
| 127 | } | 134 | } |
| 128 | } | 135 | } |
| 129 | 136 | ||
| 130 | - // 5.2 再查询学生级别的停餐信息 | 137 | + // 5.2 再查询班级级别的停餐信息 |
| 138 | + var classSuspensionRecords = mealOrderServiceRpcClient.queryDinerMealSuspensionRecordsByCondition( | ||
| 139 | + loginInfo.getEnterpriseId(), | ||
| 140 | + List.of(dinerById.getClientId()), | ||
| 141 | + List.of(dinerById.getClassId()), | ||
| 142 | + null | ||
| 143 | + ); | ||
| 144 | + | ||
| 145 | + // 直接过滤出班级级别的停餐记录 | ||
| 146 | + if (classSuspensionRecords != null) { | ||
| 147 | + classSuspensionRecords = classSuspensionRecords.stream() | ||
| 148 | + .filter(r -> r.getDinerId() == 0) | ||
| 149 | + .toList(); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + if (classSuspensionRecords != null && !classSuspensionRecords.isEmpty()) { | ||
| 153 | + var latestClassSuspension = classSuspensionRecords.stream() | ||
| 154 | + .max((a, b) -> Long.compare(a.getCreatedAt(), b.getCreatedAt())) | ||
| 155 | + .orElse(null); | ||
| 156 | + | ||
| 157 | + if (latestClassSuspension != null && | ||
| 158 | + currentTime >= latestClassSuspension.getStartAt() && | ||
| 159 | + currentTime <= latestClassSuspension.getEndAt()) { | ||
| 160 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_MEAL_SUSPENDED); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + // 5.3 再查询学生级别的停餐信息 | ||
| 131 | var studentSuspensionRecords = mealOrderServiceRpcClient.queryDinerMealSuspensionRecordsByCondition( | 165 | var studentSuspensionRecords = mealOrderServiceRpcClient.queryDinerMealSuspensionRecordsByCondition( |
| 132 | loginInfo.getEnterpriseId(), | 166 | loginInfo.getEnterpriseId(), |
| 133 | List.of(dinerById.getClientId()), | 167 | List.of(dinerById.getClientId()), | ... | ... |
-
Please register or login to post a comment