zhuyifan

fix

...@@ -70,6 +70,7 @@ public class LoginInterceptor implements HandlerInterceptor { ...@@ -70,6 +70,7 @@ public class LoginInterceptor implements HandlerInterceptor {
70 StpUtil.checkLogin(); 70 StpUtil.checkLogin();
71 final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); 71 final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID));
72 final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); 72 final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE));
73 + final var userId = StpUtil.getExtra(CommonConstants.USER_ID);
73 if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { 74 if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) {
74 final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID)); 75 final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID));
75 final var loginId = StpUtil.getLoginIdAsInt(); 76 final var loginId = StpUtil.getLoginIdAsInt();
...@@ -115,8 +116,7 @@ public class LoginInterceptor implements HandlerInterceptor { ...@@ -115,8 +116,7 @@ public class LoginInterceptor implements HandlerInterceptor {
115 builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()).loginSource(LoginSourceEnum.KDS); 116 builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()).loginSource(LoginSourceEnum.KDS);
116 return true; 117 return true;
117 } else { 118 } else {
118 - final var loginId = StpUtil.getLoginIdAsString(); 119 + builder.id(userId == null ? null : Convert.toInt(userId)).openId(StpUtil.getLoginIdAsString()).enterpriseId(enterpriseId).loginSource(LoginSourceEnum.MINI_PROGRAM);
119 - builder.openId(loginId).enterpriseId(enterpriseId).loginSource(LoginSourceEnum.MINI_PROGRAM);
120 return true; 120 return true;
121 } 121 }
122 } 122 }
......
...@@ -75,7 +75,7 @@ public class ResourceInjector implements HandlerInterceptor { ...@@ -75,7 +75,7 @@ public class ResourceInjector implements HandlerInterceptor {
75 log.info("Resource not found; id:{}", id); 75 log.info("Resource not found; id:{}", id);
76 throw ClientEndExceptions.ResourceNotFound.build("项目点不存在"); 76 throw ClientEndExceptions.ResourceNotFound.build("项目点不存在");
77 } 77 }
78 - httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_CLIENT, response); 78 + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_CLIENT, response.getClient());
79 } 79 }
80 80
81 /* 81 /*
......
...@@ -55,6 +55,9 @@ public class DinerDTO { ...@@ -55,6 +55,9 @@ public class DinerDTO {
55 @NotNull(message = "班级不能为空") 55 @NotNull(message = "班级不能为空")
56 private Integer classId; 56 private Integer classId;
57 57
58 + @ApiModelProperty(value = "学号")
59 + private String studentNo;
60 +
58 @ApiModelProperty(value = "姓名") 61 @ApiModelProperty(value = "姓名")
59 private String name; 62 private String name;
60 } 63 }
......
...@@ -123,6 +123,9 @@ public class MealOrderServiceRpcClient { ...@@ -123,6 +123,9 @@ public class MealOrderServiceRpcClient {
123 } 123 }
124 124
125 public List<SingleDinerRpcResponse> getDinersByIds(int enterpriseId, List<Integer> dinerIds) { 125 public List<SingleDinerRpcResponse> getDinersByIds(int enterpriseId, List<Integer> dinerIds) {
126 + if (CollectionUtils.isEmpty(dinerIds)) {
127 + return Collections.emptyList();
128 + }
126 return mealOrderServiceRpcBlockingStub.getDinersByIds(GetDinersByIdsRpcRequest.newBuilder() 129 return mealOrderServiceRpcBlockingStub.getDinersByIds(GetDinersByIdsRpcRequest.newBuilder()
127 .setEnterpriseId(enterpriseId) 130 .setEnterpriseId(enterpriseId)
128 .addAllIds(dinerIds) 131 .addAllIds(dinerIds)
...@@ -148,6 +151,9 @@ public class MealOrderServiceRpcClient { ...@@ -148,6 +151,9 @@ public class MealOrderServiceRpcClient {
148 } 151 }
149 152
150 public List<SingleGradeClassRpcResponse> getGradeClassesByIds(int enterpriseId, List<Integer> gradeClassIds) { 153 public List<SingleGradeClassRpcResponse> getGradeClassesByIds(int enterpriseId, List<Integer> gradeClassIds) {
154 + if (CollectionUtils.isEmpty(gradeClassIds)) {
155 + return Collections.emptyList();
156 + }
151 return mealOrderServiceRpcBlockingStub.getGradeClassesByIds(GetGradeClassesByIdsRpcRequest.newBuilder() 157 return mealOrderServiceRpcBlockingStub.getGradeClassesByIds(GetGradeClassesByIdsRpcRequest.newBuilder()
152 .setEnterpriseId(enterpriseId) 158 .setEnterpriseId(enterpriseId)
153 .addAllIds(gradeClassIds) 159 .addAllIds(gradeClassIds)
...@@ -167,6 +173,9 @@ public class MealOrderServiceRpcClient { ...@@ -167,6 +173,9 @@ public class MealOrderServiceRpcClient {
167 } 173 }
168 174
169 public List<SingleMealOrderRpcResponse> queryReserveMealOrdersByDinerIds(int enterpriseId, List<Integer> dinerIds) { 175 public List<SingleMealOrderRpcResponse> queryReserveMealOrdersByDinerIds(int enterpriseId, List<Integer> dinerIds) {
176 + if (CollectionUtils.isEmpty(dinerIds)) {
177 + return Collections.emptyList();
178 + }
170 return mealOrderServiceRpcBlockingStub.queryReserveMealOrdersByDinerIds(QueryReserveMealOrdersByDinerIdsRpcRequest.newBuilder() 179 return mealOrderServiceRpcBlockingStub.queryReserveMealOrdersByDinerIds(QueryReserveMealOrdersByDinerIdsRpcRequest.newBuilder()
171 .setEnterpriseId(enterpriseId) 180 .setEnterpriseId(enterpriseId)
172 .addAllDinerIds(dinerIds) 181 .addAllDinerIds(dinerIds)
...@@ -201,6 +210,9 @@ public class MealOrderServiceRpcClient { ...@@ -201,6 +210,9 @@ public class MealOrderServiceRpcClient {
201 } 210 }
202 211
203 public boolean deleteMpAccountDinerRefsByIds(int enterpriseId, List<Integer> ids) { 212 public boolean deleteMpAccountDinerRefsByIds(int enterpriseId, List<Integer> ids) {
213 + if (CollectionUtils.isEmpty(ids)) {
214 + return false;
215 + }
204 return mealOrderServiceRpcBlockingStub.deleteMpAccountDinerRefsByIds(DeleteMpAccountDinerRefsByIdsRpcRequest.newBuilder() 216 return mealOrderServiceRpcBlockingStub.deleteMpAccountDinerRefsByIds(DeleteMpAccountDinerRefsByIdsRpcRequest.newBuilder()
205 .setEnterpriseId(enterpriseId) 217 .setEnterpriseId(enterpriseId)
206 .addAllIds(ids) 218 .addAllIds(ids)
...@@ -215,6 +227,9 @@ public class MealOrderServiceRpcClient { ...@@ -215,6 +227,9 @@ public class MealOrderServiceRpcClient {
215 } 227 }
216 228
217 public List<SingleMealMenuRecordRpcResponse> queryLatestMealMenuRecordsByClientIds(int enterpriseId, List<Integer> ids) { 229 public List<SingleMealMenuRecordRpcResponse> queryLatestMealMenuRecordsByClientIds(int enterpriseId, List<Integer> ids) {
230 + if (CollectionUtils.isEmpty(ids)) {
231 + return Collections.emptyList();
232 + }
218 return mealOrderServiceRpcBlockingStub.queryLatestMealMenuRecordsByClientIds(QueryLatestMealMenuRecordsByClientIdsRpcRequest.newBuilder() 233 return mealOrderServiceRpcBlockingStub.queryLatestMealMenuRecordsByClientIds(QueryLatestMealMenuRecordsByClientIdsRpcRequest.newBuilder()
219 .setEnterpriseId(enterpriseId) 234 .setEnterpriseId(enterpriseId)
220 .addAllClientId(ids) 235 .addAllClientId(ids)
...@@ -255,8 +270,8 @@ public class MealOrderServiceRpcClient { ...@@ -255,8 +270,8 @@ public class MealOrderServiceRpcClient {
255 return mealOrderServiceRpcBlockingStub.queryMealOrdersByCondition(QueryMealOrdersByConditionRpcRequest.newBuilder() 270 return mealOrderServiceRpcBlockingStub.queryMealOrdersByCondition(QueryMealOrdersByConditionRpcRequest.newBuilder()
256 .setEnterpriseId(enterpriseId) 271 .setEnterpriseId(enterpriseId)
257 .setShouldFilterAccountIds(accountId != null).addAccountIds(accountId == null ? 0 : accountId) 272 .setShouldFilterAccountIds(accountId != null).addAccountIds(accountId == null ? 0 : accountId)
258 - .setShouldFilterReserveDateStart(true).setReserveDateStart(reserveDateStart == null ? 0 : reserveDateStart) 273 + .setShouldFilterReserveDateStart(reserveDateStart != null).setReserveDateStart(reserveDateStart == null ? 0 : reserveDateStart)
259 - .setShouldFilterReserveDateEnd(true).setReserveDateEnd(reserveDateEnd == null ? 0 : reserveDateEnd) 274 + .setShouldFilterReserveDateEnd(reserveDateEnd != null).setReserveDateEnd(reserveDateEnd == null ? 0 : reserveDateEnd)
260 .build()).getResponsesList(); 275 .build()).getResponsesList();
261 } 276 }
262 } 277 }
......
...@@ -116,11 +116,11 @@ public class DinerServiceImpl implements DinerService { ...@@ -116,11 +116,11 @@ public class DinerServiceImpl implements DinerService {
116 throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.CLIENT_CODE_NOT_EXISTS); 116 throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.CLIENT_CODE_NOT_EXISTS);
117 } 117 }
118 final var singleClientRpcResponse = clientsByCodes.get(0); 118 final var singleClientRpcResponse = clientsByCodes.get(0);
119 - if (diner.getClientId() == singleClientRpcResponse.getId() && diner.getClassId() == updateDinerDTO.getClassId() && !diner.getName().equals(updateDinerDTO.getName())) { 119 + if (diner.getClientId() == singleClientRpcResponse.getId() && diner.getClassId() == updateDinerDTO.getClassId() && diner.getStudentNo().equals(updateDinerDTO.getStudentNo()) && !diner.getName().equals(updateDinerDTO.getName())) {
120 mealOrderServiceRpcClient.updateDiner(loginInfo, DinerModification.newBuilder().setId(diner.getId()).setShouldUpdateName(true).setName(updateDinerDTO.getName()).build()); 120 mealOrderServiceRpcClient.updateDiner(loginInfo, DinerModification.newBuilder().setId(diner.getId()).setShouldUpdateName(true).setName(updateDinerDTO.getName()).build());
121 return; 121 return;
122 } 122 }
123 - final var diners = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(singleClientRpcResponse.getId()), List.of(updateDinerDTO.getClassId()), diner.getStudentNo()); 123 + final var diners = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(singleClientRpcResponse.getId()), List.of(updateDinerDTO.getClassId()), updateDinerDTO.getStudentNo());
124 if (!diners.isEmpty()) { 124 if (!diners.isEmpty()) {
125 throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_ALREADY_EXISTS); 125 throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_ALREADY_EXISTS);
126 } 126 }
...@@ -129,6 +129,7 @@ public class DinerServiceImpl implements DinerService { ...@@ -129,6 +129,7 @@ public class DinerServiceImpl implements DinerService {
129 .setShouldUpdateClientId(true).setClientId(singleClientRpcResponse.getId()) 129 .setShouldUpdateClientId(true).setClientId(singleClientRpcResponse.getId())
130 .setShouldUpdateClassId(updateDinerDTO.getClassId() != null).setClassId(updateDinerDTO.getClassId() == null ? diner.getClassId() : updateDinerDTO.getClassId()) 130 .setShouldUpdateClassId(updateDinerDTO.getClassId() != null).setClassId(updateDinerDTO.getClassId() == null ? diner.getClassId() : updateDinerDTO.getClassId())
131 .setShouldUpdateName(updateDinerDTO.getName() != null).setName(updateDinerDTO.getName() == null ? diner.getName() : updateDinerDTO.getName()) 131 .setShouldUpdateName(updateDinerDTO.getName() != null).setName(updateDinerDTO.getName() == null ? diner.getName() : updateDinerDTO.getName())
132 + .setShouldUpdateStudentNo(updateDinerDTO.getStudentNo() != null).setStudentNo(updateDinerDTO.getStudentNo() == null ? diner.getStudentNo() : updateDinerDTO.getStudentNo())
132 .build()); 133 .build());
133 } 134 }
134 135
......
...@@ -66,9 +66,10 @@ public class LoginServiceImpl implements LoginService { ...@@ -66,9 +66,10 @@ public class LoginServiceImpl implements LoginService {
66 } else { 66 } else {
67 mpAccountId = mpAccountByOpenId.getId(); 67 mpAccountId = mpAccountByOpenId.getId();
68 } 68 }
69 - Assert.isTrue(mpAccountId == 0, "创建小程序账号失败"); 69 + Assert.isTrue(mpAccountId != 0, "创建小程序账号失败");
70 - StpUtil.login(mpAccountId, SaLoginModel.create() 70 + StpUtil.login(loginDto.getOpenId(), SaLoginModel.create()
71 .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId()) 71 .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId())
72 + .setExtra(CommonConstants.USER_ID, mpAccountId)
72 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) 73 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue())
73 .build()); 74 .build());
74 return StpUtil.getTokenInfo(); 75 return StpUtil.getTokenInfo();
......
...@@ -41,14 +41,15 @@ public class MealOrderServiceImpl implements MealOrderService { ...@@ -41,14 +41,15 @@ public class MealOrderServiceImpl implements MealOrderService {
41 final var loginInfo = LoginContextHolder.getLoginInfo(); 41 final var loginInfo = LoginContextHolder.getLoginInfo();
42 var mealOrderRpcResponses = mealOrderServiceRpcClient.queryMealOrdersByCondition(loginInfo.getEnterpriseId(), loginInfo.getId(), null, null); 42 var mealOrderRpcResponses = mealOrderServiceRpcClient.queryMealOrdersByCondition(loginInfo.getEnterpriseId(), loginInfo.getId(), null, null);
43 final var today = LocalDate.now(); 43 final var today = LocalDate.now();
44 - final var startTimestamp = today.with(DayOfWeek.MONDAY).atStartOfDay().atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli(); 44 + final var lastWeekStart = today.minusWeeks(1).with(DayOfWeek.MONDAY).atStartOfDay().atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli();
45 - final var endTimestamp = today.with(DayOfWeek.SUNDAY).atTime(LocalTime.MAX).atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli(); 45 + final var lastWeekEnd = today.minusWeeks(1).with(DayOfWeek.SUNDAY).atTime(LocalTime.MAX).atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli();
46 + final var thisWeekStart = today.with(DayOfWeek.MONDAY).atStartOfDay().atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli();
46 if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.COMPLETED) { 47 if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.COMPLETED) {
47 - mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() < startTimestamp).toList(); 48 + mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() < lastWeekStart).toList();
48 } else if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.UNDER_WAY) { 49 } else if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.UNDER_WAY) {
49 - mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() >= startTimestamp && e.getReserveDate() <= endTimestamp).toList(); 50 + mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() >= lastWeekStart && e.getReserveDate() <= lastWeekEnd).toList();
50 } else if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.BE_BOOKED) { 51 } else if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.BE_BOOKED) {
51 - mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() > endTimestamp).toList(); 52 + mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() > thisWeekStart).toList();
52 } 53 }
53 return mealOrderRpcResponses.stream().map(this::getMealOrderById).toList(); 54 return mealOrderRpcResponses.stream().map(this::getMealOrderById).toList();
54 } 55 }
......