chen.yinxiang

fix:就餐人必传

...@@ -15,7 +15,8 @@ public class OrderSubscriptionMessageDTO { ...@@ -15,7 +15,8 @@ public class OrderSubscriptionMessageDTO {
15 @ApiModel(description = "创建订阅消息记录") 15 @ApiModel(description = "创建订阅消息记录")
16 public static class CreateOrderSubscriptionMessageDTO { 16 public static class CreateOrderSubscriptionMessageDTO {
17 17
18 - @ApiModelProperty(value = "就餐人ID,可为空,后端根据实际情况处理", required = false) 18 + @NotNull(message = "dinerId 不能为空")
19 + @ApiModelProperty(value = "就餐人ID,必填", required = true)
19 private Integer dinerId; 20 private Integer dinerId;
20 21
21 @ApiModelProperty(value = "订阅消息模板ID,可为空,为空时使用配置的默认值", required = false) 22 @ApiModelProperty(value = "订阅消息模板ID,可为空,为空时使用配置的默认值", required = false)
......
...@@ -310,12 +310,12 @@ public class MealOrderServiceImpl implements MealOrderService { ...@@ -310,12 +310,12 @@ public class MealOrderServiceImpl implements MealOrderService {
310 if (openId == null || openId.isBlank()) { 310 if (openId == null || openId.isBlank()) {
311 throw new IllegalStateException("当前登录用户 openId 为空,无法创建订阅提醒"); 311 throw new IllegalStateException("当前登录用户 openId 为空,无法创建订阅提醒");
312 } 312 }
313 - if (dto.getJumpPath() == null || dto.getJumpPath().isBlank()) {
314 - throw new IllegalArgumentException("jumpPath 不能为空");
315 - }
316 313
317 - // 1. 处理就餐人 ID:如果为空,从关联关系推断 314 + // 1. dinerId 必传(避免默认推断导致业务歧义)
318 - int dinerId = dto.getDinerId() != null ? dto.getDinerId() : getDefaultDinerId(enterpriseId, openId); 315 + if (dto.getDinerId() == null) {
316 + throw new IllegalArgumentException("dinerId 不能为空");
317 + }
318 + int dinerId = dto.getDinerId();
319 319
320 // 2. 处理模板 ID:如果为空,使用配置的默认值 320 // 2. 处理模板 ID:如果为空,使用配置的默认值
321 String finalTemplateId = (dto.getTemplateId() != null && !dto.getTemplateId().isBlank()) 321 String finalTemplateId = (dto.getTemplateId() != null && !dto.getTemplateId().isBlank())
...@@ -349,23 +349,6 @@ public class MealOrderServiceImpl implements MealOrderService { ...@@ -349,23 +349,6 @@ public class MealOrderServiceImpl implements MealOrderService {
349 ); 349 );
350 } 350 }
351 351
352 - /**
353 - * 如果前端未传就餐人 ID,从当前用户的关联关系中推断默认值
354 - * 如果只有一个关联的就餐人,返回该就餐人 ID;如果有多个或没有,返回 0
355 - */
356 - private int getDefaultDinerId(int enterpriseId, String openId) {
357 - final var loginInfo = LoginContextHolder.getLoginInfo();
358 - final var mpAccountDinerRefs = mealOrderServiceRpcClient.queryMpAccountDinerRefsByCondition(
359 - enterpriseId,
360 - Collections.singletonList(loginInfo.getId()),
361 - Collections.emptyList()
362 - );
363 - if (mpAccountDinerRefs.size() == 1) {
364 - return mpAccountDinerRefs.get(0).getDinerId();
365 - }
366 - return 0;
367 - }
368 -
369 private static final class Period { 352 private static final class Period {
370 final long startAt; 353 final long startAt;
371 final Long endAt; 354 final Long endAt;
......