Showing
5 changed files
with
260 additions
and
18 deletions
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientcustomerorderservice.OrderOperationType; | ||
| 4 | +import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; | ||
| 5 | +import com.infoloop.tianting.model.dto.MenuDbDTO.DishRuleJson; | ||
| 6 | +import com.infoloop.tianting.model.dto.MenuDbDTO.OrderRuleJson; | ||
| 7 | +import io.swagger.annotations.ApiModel; | ||
| 8 | +import java.util.List; | ||
| 9 | +import lombok.Builder; | ||
| 10 | +import lombok.Data; | ||
| 11 | +import lombok.ToString; | ||
| 12 | + | ||
| 13 | +@Data | ||
| 14 | +@ApiModel(description = "操作记录DTO") | ||
| 15 | +public class OperationDTO { | ||
| 16 | + | ||
| 17 | + @Data | ||
| 18 | + @Builder | ||
| 19 | + @ToString | ||
| 20 | + @ApiModel(description = "单个操作记录Dto") | ||
| 21 | + public static class SingleOperationDto { | ||
| 22 | + | ||
| 23 | + private Integer orderId; | ||
| 24 | + OrderOperationType type; | ||
| 25 | + private boolean shouldCreateOriginalOrderJson; | ||
| 26 | + private String originalOrderJson; | ||
| 27 | + private boolean shouldCreateAdjustOrderJson; | ||
| 28 | + private String adjustOrderJson; | ||
| 29 | + private boolean shouldCreateOriginalOrderDetailJson; | ||
| 30 | + private String originalOrderDetailJson; | ||
| 31 | + private boolean shouldCreateAdjustOrderDetailJson; | ||
| 32 | + private String adjustOrderDetailJson; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Data | ||
| 36 | + @Builder | ||
| 37 | + @ToString | ||
| 38 | + @ApiModel(description = "批量操作记录Dto") | ||
| 39 | + public static class BatchOperationDto { | ||
| 40 | + private List<SingleOperationDto> creations; | ||
| 41 | + private Integer enterpriseId; | ||
| 42 | + private Integer createdBy; | ||
| 43 | + private String operator; | ||
| 44 | + private OrderSourceEnum creationSource; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | +} |
| ... | @@ -576,7 +576,10 @@ public class OrderDbDTO { | ... | @@ -576,7 +576,10 @@ public class OrderDbDTO { |
| 576 | @ToString | 576 | @ToString |
| 577 | @ApiModel(description = "检查是否已预定过某一餐单") | 577 | @ApiModel(description = "检查是否已预定过某一餐单") |
| 578 | public static class getMenuOrderCountDto { | 578 | public static class getMenuOrderCountDto { |
| 579 | - private Integer customerId; | 579 | + @Builder.Default |
| 580 | + private String openId = ""; | ||
| 581 | + @Builder.Default | ||
| 582 | + private Integer customerId = 0; | ||
| 580 | private Integer menuId; | 583 | private Integer menuId; |
| 581 | private LocalDateTime mealTime; | 584 | private LocalDateTime mealTime; |
| 582 | } | 585 | } | ... | ... |
| 1 | package com.infoloop.tianting.service.client; | 1 | package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | +import com.fasterxml.jackson.core.JsonProcessingException; | ||
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 3 | import com.infoloop.tianting.SingleResponse; | 5 | import com.infoloop.tianting.SingleResponse; |
| 4 | import com.infoloop.tianting.SingleSpecialResponse; | 6 | import com.infoloop.tianting.SingleSpecialResponse; |
| 7 | +import com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperationRecordsRequest; | ||
| 8 | +import com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperationRecordsResponse; | ||
| 5 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; | 9 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; |
| 6 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse; | 10 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse; |
| 7 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; | 11 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; |
| ... | @@ -13,10 +17,14 @@ import com.infoloop.tianting.clientcustomerorderservice.CloseTimeType; | ... | @@ -13,10 +17,14 @@ import com.infoloop.tianting.clientcustomerorderservice.CloseTimeType; |
| 13 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest; | 17 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest; |
| 14 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcResponse; | 18 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcResponse; |
| 15 | import com.infoloop.tianting.clientcustomerorderservice.CustomerNotice; | 19 | import com.infoloop.tianting.clientcustomerorderservice.CustomerNotice; |
| 20 | +import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailByIdRpcRequest; | ||
| 21 | +import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByIdsRpcRequest; | ||
| 16 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByOrderIdsRpcRequest; | 22 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByOrderIdsRpcRequest; |
| 17 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByCustomerIdRpcRequest; | 23 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByCustomerIdRpcRequest; |
| 18 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByCustomerIdRpcResponse; | 24 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByCustomerIdRpcResponse; |
| 19 | import com.infoloop.tianting.clientcustomerorderservice.MealDetail; | 25 | import com.infoloop.tianting.clientcustomerorderservice.MealDetail; |
| 26 | +import com.infoloop.tianting.clientcustomerorderservice.OrderOperationRecordCreation; | ||
| 27 | +import com.infoloop.tianting.clientcustomerorderservice.OrderOperationType; | ||
| 20 | import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; | 28 | import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; |
| 21 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | 29 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; |
| 22 | import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; | 30 | import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; |
| ... | @@ -31,14 +39,18 @@ import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrde | ... | @@ -31,14 +39,18 @@ import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrde |
| 31 | import com.infoloop.tianting.context.LoginContextHolder; | 39 | import com.infoloop.tianting.context.LoginContextHolder; |
| 32 | import com.infoloop.tianting.enums.OrderTypeEnum; | 40 | import com.infoloop.tianting.enums.OrderTypeEnum; |
| 33 | import com.infoloop.tianting.model.common.PageResult; | 41 | import com.infoloop.tianting.model.common.PageResult; |
| 42 | +import com.infoloop.tianting.model.dto.OperationDTO.BatchOperationDto; | ||
| 43 | +import com.infoloop.tianting.model.dto.OperationDTO.SingleOperationDto; | ||
| 34 | import com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderDetailDto; | 44 | import com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderDetailDto; |
| 35 | import com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderDto; | 45 | import com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderDto; |
| 36 | import com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderResponse; | 46 | import com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderResponse; |
| 47 | +import com.infoloop.tianting.model.dto.OrderDbDTO.MealDetailDto; | ||
| 37 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailBatchUpdateDto; | 48 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailBatchUpdateDto; |
| 38 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto; | 49 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto; |
| 39 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | 50 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; |
| 40 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto; | 51 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto; |
| 41 | import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto; | 52 | import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto; |
| 53 | +import com.infoloop.tianting.utils.DateUtil; | ||
| 42 | import io.swagger.models.auth.In; | 54 | import io.swagger.models.auth.In; |
| 43 | import java.time.LocalDate; | 55 | import java.time.LocalDate; |
| 44 | import java.time.ZoneOffset; | 56 | import java.time.ZoneOffset; |
| ... | @@ -87,6 +99,8 @@ public class OrderServiceRpcClient { | ... | @@ -87,6 +99,8 @@ public class OrderServiceRpcClient { |
| 87 | .setStatus(queryOrderDto.getStatus()) | 99 | .setStatus(queryOrderDto.getStatus()) |
| 88 | .setShouldFilterMenuIds(queryOrderDto.getShouldFilterMenuId()) | 100 | .setShouldFilterMenuIds(queryOrderDto.getShouldFilterMenuId()) |
| 89 | .addAllMenuIds(List.of(queryOrderDto.getMenuId())) | 101 | .addAllMenuIds(List.of(queryOrderDto.getMenuId())) |
| 102 | + .setShouldFilterOpenIds(queryOrderDto.getShouldFilterOpenId()) | ||
| 103 | + .addAllOpenIds(List.of(queryOrderDto.getOpenId())) | ||
| 90 | .build(); | 104 | .build(); |
| 91 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); | 105 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); |
| 92 | } | 106 | } |
| ... | @@ -127,6 +141,11 @@ public class OrderServiceRpcClient { | ... | @@ -127,6 +141,11 @@ public class OrderServiceRpcClient { |
| 127 | public BatchUpdateClientCustomerOrderDetailsRpcResponse batchUpdateClientCustomerOrderDetails( | 141 | public BatchUpdateClientCustomerOrderDetailsRpcResponse batchUpdateClientCustomerOrderDetails( |
| 128 | OrderDetailBatchUpdateDto orderDetailBatchUpdateDto) { | 142 | OrderDetailBatchUpdateDto orderDetailBatchUpdateDto) { |
| 129 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | 143 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); |
| 144 | + final var operator = operatorServiceRpcClient.getCOperatorById(operatorLoginInfo.getId()); | ||
| 145 | + List<Integer> idsOfNeedUpdateMenuDetails = new ArrayList<>(); | ||
| 146 | + List<Integer> idsOfAddCount = new ArrayList<>(); | ||
| 147 | + List<OrderDetailDto> orgionalOrderDetails = new ArrayList<>(); | ||
| 148 | + List<OrderDetailDto> newOrderDetails = new ArrayList<>(); | ||
| 130 | final var modifications = orderDetailBatchUpdateDto.getDetails().stream().map( d-> { | 149 | final var modifications = orderDetailBatchUpdateDto.getDetails().stream().map( d-> { |
| 131 | MealDetail mealDetail = MealDetail.newBuilder().build();; | 150 | MealDetail mealDetail = MealDetail.newBuilder().build();; |
| 132 | Integer menuDetailId = 0; | 151 | Integer menuDetailId = 0; |
| ... | @@ -135,6 +154,7 @@ public class OrderServiceRpcClient { | ... | @@ -135,6 +154,7 @@ public class OrderServiceRpcClient { |
| 135 | Integer skuId = 0; | 154 | Integer skuId = 0; |
| 136 | String showName = ""; | 155 | String showName = ""; |
| 137 | if (d.getShouldUpdateMenuDetailId()) { | 156 | if (d.getShouldUpdateMenuDetailId()) { |
| 157 | + idsOfNeedUpdateMenuDetails.add(d.getId()); | ||
| 138 | menuDetailId = d.getMenuDetailId(); | 158 | menuDetailId = d.getMenuDetailId(); |
| 139 | final var menuDetail = menuServiceRpcClient.getMenuDetailById( | 159 | final var menuDetail = menuServiceRpcClient.getMenuDetailById( |
| 140 | operatorLoginInfo.getEnterpriseId(), menuDetailId).getResponse(); | 160 | operatorLoginInfo.getEnterpriseId(), menuDetailId).getResponse(); |
| ... | @@ -165,7 +185,6 @@ public class OrderServiceRpcClient { | ... | @@ -165,7 +185,6 @@ public class OrderServiceRpcClient { |
| 165 | .addAllSkus(skus) | 185 | .addAllSkus(skus) |
| 166 | .build(); | 186 | .build(); |
| 167 | } | 187 | } |
| 168 | - | ||
| 169 | } | 188 | } |
| 170 | 189 | ||
| 171 | ServeStatusEnum serveStatus = ServeStatusEnum.UNKNOWN_SERVE_STATUS; | 190 | ServeStatusEnum serveStatus = ServeStatusEnum.UNKNOWN_SERVE_STATUS; |
| ... | @@ -174,6 +193,7 @@ public class OrderServiceRpcClient { | ... | @@ -174,6 +193,7 @@ public class OrderServiceRpcClient { |
| 174 | } | 193 | } |
| 175 | Integer count = 0; | 194 | Integer count = 0; |
| 176 | if (d.getShouldUpdateCount()) { | 195 | if (d.getShouldUpdateCount()) { |
| 196 | + idsOfAddCount.add(d.getId()); | ||
| 177 | count = d.getCount(); | 197 | count = d.getCount(); |
| 178 | } | 198 | } |
| 179 | final var detail = ClientCustomerOrderDetailModification.newBuilder() | 199 | final var detail = ClientCustomerOrderDetailModification.newBuilder() |
| ... | @@ -204,7 +224,159 @@ public class OrderServiceRpcClient { | ... | @@ -204,7 +224,159 @@ public class OrderServiceRpcClient { |
| 204 | .setUpdateSourceValue(orderDetailBatchUpdateDto.getUpdatedSource().getNumber()) | 224 | .setUpdateSourceValue(orderDetailBatchUpdateDto.getUpdatedSource().getNumber()) |
| 205 | .addAllModifications(modifications) | 225 | .addAllModifications(modifications) |
| 206 | .build(); | 226 | .build(); |
| 207 | - return orderServiceRpcBlockingStub.batchUpdateClientCustomerOrderDetails(request); | 227 | + final var totalIds = new ArrayList<>(idsOfNeedUpdateMenuDetails); |
| 228 | + totalIds.addAll(idsOfAddCount); | ||
| 229 | + if (!idsOfNeedUpdateMenuDetails.isEmpty() || !idsOfAddCount.isEmpty()) { | ||
| 230 | + final var orgionalResponseList = getClientCustomerOrderDetailsByIds(totalIds); | ||
| 231 | + orgionalOrderDetails = orgionalResponseList.stream().map(d -> | ||
| 232 | + OrderDetailDto.builder() | ||
| 233 | + .id(d.getId()) | ||
| 234 | + .count(d.getCount()) | ||
| 235 | + .categoryId(d.getCategoryId()) | ||
| 236 | + .mealId(d.getMealId()) | ||
| 237 | + .menuDetailId(d.getMenuDetailId()) | ||
| 238 | + .orderId(d.getOrderId()) | ||
| 239 | + .price(d.getPrice()) | ||
| 240 | + .showName(d.getShowName()) | ||
| 241 | + .mealDetailJson(MealDetailDto.builder() | ||
| 242 | + .allergies(d.getMealDetailJson().getAllergiesList()) | ||
| 243 | + .basicMaterials(d.getMealDetailJson().getBasicMaterials()) | ||
| 244 | + .dockers(d.getMealDetailJson().getDockersList()) | ||
| 245 | + .efficacies(d.getMealDetailJson().getEfficaciesList()) | ||
| 246 | + .fat(d.getMealDetailJson().getFat()) | ||
| 247 | + .tastes(d.getMealDetailJson().getTastesList()) | ||
| 248 | + .protein(d.getMealDetailJson().getProtein()) | ||
| 249 | + .carbohydrate(d.getMealDetailJson().getCarbohydrate()) | ||
| 250 | + .energy(d.getMealDetailJson().getEnergy()) | ||
| 251 | + .avoids(d.getMealDetailJson().getAvoidsList()) | ||
| 252 | + .skus(d.getMealDetailJson().getSkusList()) | ||
| 253 | + .build()) | ||
| 254 | + .adjustSkuRemark(d.getAdjustSkuRemark()) | ||
| 255 | + .enterpriseId(d.getEnterpriseId()) | ||
| 256 | + .skuId(d.getSkuId()) | ||
| 257 | + .serveStatus(d.getServeStatus()) | ||
| 258 | + .creationSource(d.getCreationSource().getNumber()) | ||
| 259 | + .createdBy(d.getCreatedBy()) | ||
| 260 | + .createdAt(DateUtil.formatDate(d.getCreatedAt())) | ||
| 261 | + .updateSource(d.getUpdateSource().getNumber()) | ||
| 262 | + .updatedAt(DateUtil.formatDate(d.getUpdatedAt())) | ||
| 263 | + .updatedBy(d.getUpdatedBy()) | ||
| 264 | + .build()).collect(Collectors.toList()); | ||
| 265 | + } | ||
| 266 | + final var res = orderServiceRpcBlockingStub.batchUpdateClientCustomerOrderDetails(request); | ||
| 267 | + if(res.getIsUpdated()) { | ||
| 268 | + if (!idsOfNeedUpdateMenuDetails.isEmpty() || !idsOfAddCount.isEmpty()) { | ||
| 269 | + | ||
| 270 | + final var newResponseList = getClientCustomerOrderDetailsByIds(totalIds); | ||
| 271 | + newOrderDetails = newResponseList.stream().map(d -> | ||
| 272 | + OrderDetailDto.builder() | ||
| 273 | + .id(d.getId()) | ||
| 274 | + .count(d.getCount()) | ||
| 275 | + .categoryId(d.getCategoryId()) | ||
| 276 | + .mealId(d.getMealId()) | ||
| 277 | + .menuDetailId(d.getMenuDetailId()) | ||
| 278 | + .orderId(d.getOrderId()) | ||
| 279 | + .price(d.getPrice()) | ||
| 280 | + .showName(d.getShowName()) | ||
| 281 | + .mealDetailJson(MealDetailDto.builder() | ||
| 282 | + .allergies(d.getMealDetailJson().getAllergiesList()) | ||
| 283 | + .basicMaterials(d.getMealDetailJson().getBasicMaterials()) | ||
| 284 | + .dockers(d.getMealDetailJson().getDockersList()) | ||
| 285 | + .efficacies(d.getMealDetailJson().getEfficaciesList()) | ||
| 286 | + .fat(d.getMealDetailJson().getFat()) | ||
| 287 | + .tastes(d.getMealDetailJson().getTastesList()) | ||
| 288 | + .protein(d.getMealDetailJson().getProtein()) | ||
| 289 | + .carbohydrate(d.getMealDetailJson().getCarbohydrate()) | ||
| 290 | + .energy(d.getMealDetailJson().getEnergy()) | ||
| 291 | + .avoids(d.getMealDetailJson().getAvoidsList()) | ||
| 292 | + .skus(d.getMealDetailJson().getSkusList()) | ||
| 293 | + .build()) | ||
| 294 | + .adjustSkuRemark(d.getAdjustSkuRemark()) | ||
| 295 | + .enterpriseId(d.getEnterpriseId()) | ||
| 296 | + .skuId(d.getSkuId()) | ||
| 297 | + .serveStatus(d.getServeStatus()) | ||
| 298 | + .creationSource(d.getCreationSource().getNumber()) | ||
| 299 | + .createdBy(d.getCreatedBy()) | ||
| 300 | + .createdAt(DateUtil.formatDate(d.getCreatedAt())) | ||
| 301 | + .updateSource(d.getUpdateSource().getNumber()) | ||
| 302 | + .updatedAt(DateUtil.formatDate(d.getUpdatedAt())) | ||
| 303 | + .updatedBy(d.getUpdatedBy()) | ||
| 304 | + .build()).collect(Collectors.toList()); | ||
| 305 | + | ||
| 306 | + // 替换菜品的操作记录 | ||
| 307 | + List<SingleOperationDto> operations = new ArrayList<>(); | ||
| 308 | + for (OrderDetailDto orgionalDetail: orgionalOrderDetails) { | ||
| 309 | + OrderOperationType orderOperationType = OrderOperationType.UNKNOWN_OPERATION_TYPE; | ||
| 310 | + if (idsOfNeedUpdateMenuDetails.contains(orgionalDetail.getId())) { | ||
| 311 | + orderOperationType = OrderOperationType.REPLACE_DISHES; | ||
| 312 | + } | ||
| 313 | + else if(idsOfAddCount.contains(orgionalDetail.getId())) { | ||
| 314 | + orderOperationType = OrderOperationType.ADD_DISHES; | ||
| 315 | + } | ||
| 316 | + ObjectMapper objectMapper = new ObjectMapper(); | ||
| 317 | + String orgionalDetailStr = ""; | ||
| 318 | + String newDetailStr = ""; | ||
| 319 | + final var newDetail = newOrderDetails.stream().filter(n -> n.getId().equals(orgionalDetail.getId())).findFirst(); | ||
| 320 | + if (newDetail.isPresent()) { | ||
| 321 | + try { | ||
| 322 | + newDetailStr = objectMapper.writeValueAsString(newDetail.get()); | ||
| 323 | + } catch (JsonProcessingException e) { | ||
| 324 | + System.out.println("orderDetail json 转换失败"); | ||
| 325 | + } | ||
| 326 | + } | ||
| 327 | + try { | ||
| 328 | + orgionalDetailStr = objectMapper.writeValueAsString(orgionalDetail); | ||
| 329 | + } catch (JsonProcessingException e) { | ||
| 330 | + System.out.println("orderDetail json 转换失败"); | ||
| 331 | + } | ||
| 332 | + final var operation = SingleOperationDto.builder() | ||
| 333 | + .orderId(orgionalDetail.getOrderId()) | ||
| 334 | + .shouldCreateAdjustOrderDetailJson(true) | ||
| 335 | + .shouldCreateOriginalOrderDetailJson(true) | ||
| 336 | + .shouldCreateAdjustOrderJson(false) | ||
| 337 | + .shouldCreateOriginalOrderJson(false) | ||
| 338 | + .adjustOrderDetailJson(newDetailStr) | ||
| 339 | + .originalOrderDetailJson(orgionalDetailStr) | ||
| 340 | + .type(orderOperationType) | ||
| 341 | + .build(); | ||
| 342 | + operations.add(operation); | ||
| 343 | + } | ||
| 344 | + final var batchOperations = BatchOperationDto.builder() | ||
| 345 | + .createdBy(operatorLoginInfo.getId()) | ||
| 346 | + .creationSource(OrderSourceEnum.STALL) | ||
| 347 | + .enterpriseId(operatorLoginInfo.getEnterpriseId()) | ||
| 348 | + .operator(operator.getName()) | ||
| 349 | + .creations(operations) | ||
| 350 | + .build(); | ||
| 351 | + batchCreateOrderOperationRecords(batchOperations); | ||
| 352 | + } | ||
| 353 | + } | ||
| 354 | + return res; | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + public BatchCreateOrderOperationRecordsResponse batchCreateOrderOperationRecords( | ||
| 358 | + BatchOperationDto batchOperationDto) { | ||
| 359 | + | ||
| 360 | + final var request = BatchCreateOrderOperationRecordsRequest.newBuilder() | ||
| 361 | + .addAllCreations(batchOperationDto.getCreations().stream().map(c -> | ||
| 362 | + OrderOperationRecordCreation.newBuilder() | ||
| 363 | + .setOrderId(c.getOrderId()) | ||
| 364 | + .setShouldCreateAdjustOrderJson(c.isShouldCreateAdjustOrderJson()) | ||
| 365 | +// .setAdjustOrderJson(c.getAdjustOrderJson()) | ||
| 366 | + .setShouldCreateOriginalOrderJson(c.isShouldCreateOriginalOrderJson()) | ||
| 367 | +// .setOriginalOrderJson(c.getOriginalOrderJson()) | ||
| 368 | + .setShouldCreateAdjustOrderDetailJson(c.isShouldCreateAdjustOrderDetailJson()) | ||
| 369 | + .setAdjustOrderDetailJson(c.getAdjustOrderDetailJson()) | ||
| 370 | + .setShouldCreateOriginalOrderDetailJson(c.isShouldCreateOriginalOrderDetailJson()) | ||
| 371 | + .setOriginalOrderDetailJson(c.getOriginalOrderDetailJson()) | ||
| 372 | + .build()).collect(Collectors.toList())) | ||
| 373 | + .setCreatedBy(batchOperationDto.getCreatedBy()) | ||
| 374 | + .setEnterpriseId(batchOperationDto.getEnterpriseId()) | ||
| 375 | + .setOperator(batchOperationDto.getOperator()) | ||
| 376 | + .setCreationSource(batchOperationDto.getCreationSource()) | ||
| 377 | + .build(); | ||
| 378 | + return orderServiceRpcBlockingStub.batchCreateOrderOperationRecords(request); | ||
| 379 | + | ||
| 208 | } | 380 | } |
| 209 | 381 | ||
| 210 | public QueryClientCustomerOrdersByPaginationRpcResponse queryClientCustomerOrdersByPagination( | 382 | public QueryClientCustomerOrdersByPaginationRpcResponse queryClientCustomerOrdersByPagination( |
| ... | @@ -229,6 +401,14 @@ public class OrderServiceRpcClient { | ... | @@ -229,6 +401,14 @@ public class OrderServiceRpcClient { |
| 229 | .build()).getResponsesList(); | 401 | .build()).getResponsesList(); |
| 230 | } | 402 | } |
| 231 | 403 | ||
| 404 | + public List<SingleClientCustomerOrderDetailRpcResponse> getClientCustomerOrderDetailsByIds(List<Integer> ids) { | ||
| 405 | + return orderServiceRpcBlockingStub.getClientCustomerOrderDetailsByIds( | ||
| 406 | + GetClientCustomerOrderDetailsByIdsRpcRequest.newBuilder() | ||
| 407 | + .setIncludeDeleted(false) | ||
| 408 | + .addAllIds(ids) | ||
| 409 | + .build()).getResponsesList(); | ||
| 410 | + } | ||
| 411 | + | ||
| 232 | public List<SingleClientCustomerOrderDetailRpcResponse> getOrderDetailsByOrderIds(List<Integer> orderIds) { | 412 | public List<SingleClientCustomerOrderDetailRpcResponse> getOrderDetailsByOrderIds(List<Integer> orderIds) { |
| 233 | return orderServiceRpcBlockingStub.getClientCustomerOrderDetailsByOrderIds( | 413 | return orderServiceRpcBlockingStub.getClientCustomerOrderDetailsByOrderIds( |
| 234 | GetClientCustomerOrderDetailsByOrderIdsRpcRequest.newBuilder() | 414 | GetClientCustomerOrderDetailsByOrderIdsRpcRequest.newBuilder() |
| ... | @@ -305,7 +485,7 @@ public class OrderServiceRpcClient { | ... | @@ -305,7 +485,7 @@ public class OrderServiceRpcClient { |
| 305 | .setMenuId(createOrderDto.getMenuId()) | 485 | .setMenuId(createOrderDto.getMenuId()) |
| 306 | .setTotalNum(createOrderDto.getTotalNum()) | 486 | .setTotalNum(createOrderDto.getTotalNum()) |
| 307 | .setPayPrice(createOrderDto.getPayPrice()) | 487 | .setPayPrice(createOrderDto.getPayPrice()) |
| 308 | - .setMealTime(createOrderDto.getMealTime().toInstant(ZoneOffset.UTC).toEpochMilli()) | 488 | + .setMealTime(mealDate.atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli()) |
| 309 | .setShouldCreateTableCode(createOrderDto.getCloseTimeType().equals(CloseTimeType.IMMEDIATELY)) | 489 | .setShouldCreateTableCode(createOrderDto.getCloseTimeType().equals(CloseTimeType.IMMEDIATELY)) |
| 310 | .setTableCode(createOrderDto.getTableCode()) | 490 | .setTableCode(createOrderDto.getTableCode()) |
| 311 | .setShouldCreatePickupCode(createOrderDto.getCloseTimeType().equals(CloseTimeType.IMMEDIATELY)) | 491 | .setShouldCreatePickupCode(createOrderDto.getCloseTimeType().equals(CloseTimeType.IMMEDIATELY)) | ... | ... |
| ... | @@ -102,7 +102,8 @@ public class OrderServiceImpl implements OrderService { | ... | @@ -102,7 +102,8 @@ public class OrderServiceImpl implements OrderService { |
| 102 | createOrderDto.setCustomerId(operatorCreateOrderDto.getCustomerId()); | 102 | createOrderDto.setCustomerId(operatorCreateOrderDto.getCustomerId()); |
| 103 | createOrderDto.setStallId(operatorCreateOrderDto.getStallId()); | 103 | createOrderDto.setStallId(operatorCreateOrderDto.getStallId()); |
| 104 | createOrderDto.setMenuId(operatorCreateOrderDto.getMenuId()); | 104 | createOrderDto.setMenuId(operatorCreateOrderDto.getMenuId()); |
| 105 | - createOrderDto.setMealTime(operatorCreateOrderDto.getMealTime()); | 105 | + final var mealTime = operatorCreateOrderDto.getMealTime().toLocalDate().atStartOfDay(); |
| 106 | + createOrderDto.setMealTime(mealTime); | ||
| 106 | createOrderDto.setRemark(operatorCreateOrderDto.getRemark()); | 107 | createOrderDto.setRemark(operatorCreateOrderDto.getRemark()); |
| 107 | createOrderDto.setCreatedBy(operatorLoginInfo.getId()); | 108 | createOrderDto.setCreatedBy(operatorLoginInfo.getId()); |
| 108 | createOrderDto.setClientId(operator.getClientId()); | 109 | createOrderDto.setClientId(operator.getClientId()); |
| ... | @@ -251,8 +252,10 @@ public class OrderServiceImpl implements OrderService { | ... | @@ -251,8 +252,10 @@ public class OrderServiceImpl implements OrderService { |
| 251 | .mealTimeEnd(mealTimeEnd) | 252 | .mealTimeEnd(mealTimeEnd) |
| 252 | .shouldFilterMenuId(true) | 253 | .shouldFilterMenuId(true) |
| 253 | .menuId(checkIfOrdered.getMenuId()) | 254 | .menuId(checkIfOrdered.getMenuId()) |
| 254 | - .shouldFilterCustomerIds(true) | 255 | + .shouldFilterCustomerIds(checkIfOrdered.getCustomerId().equals(0)? false: true) |
| 255 | .customerIds(List.of(checkIfOrdered.getCustomerId())) | 256 | .customerIds(List.of(checkIfOrdered.getCustomerId())) |
| 257 | + .shouldFilterOpenId(checkIfOrdered.getOpenId().isEmpty()? false: true) | ||
| 258 | + .openId(checkIfOrdered.getOpenId()) | ||
| 256 | .build(); | 259 | .build(); |
| 257 | final var orderList = orderServiceRpcClient.getOrdersByCondition(queryOrderDto); | 260 | final var orderList = orderServiceRpcClient.getOrdersByCondition(queryOrderDto); |
| 258 | return orderList.size(); | 261 | return orderList.size(); | ... | ... |
| 1 | package com.infoloop.tianting.service.impl; | 1 | package com.infoloop.tianting.service.impl; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | 3 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; |
| 4 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 4 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | 5 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; |
| 5 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 6 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 7 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 6 | import com.infoloop.tianting.context.LoginContextHolder; | 8 | import com.infoloop.tianting.context.LoginContextHolder; |
| 7 | import com.infoloop.tianting.enums.SettlementDimensionEnum; | 9 | import com.infoloop.tianting.enums.SettlementDimensionEnum; |
| 8 | import com.infoloop.tianting.exception.ClientEndExceptions.BusinessException; | 10 | import com.infoloop.tianting.exception.ClientEndExceptions.BusinessException; |
| ... | @@ -70,8 +72,8 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -70,8 +72,8 @@ public class SettlementServiceImpl implements SettlementService { |
| 70 | 72 | ||
| 71 | public ByteArrayOutputStream generateOrderSettlementExcelBySku(SettlementRequestDto settlementRequest) { | 73 | public ByteArrayOutputStream generateOrderSettlementExcelBySku(SettlementRequestDto settlementRequest) { |
| 72 | 74 | ||
| 73 | - final var startDate = settlementRequest.getTimeStart().toLocalDate().atStartOfDay(); | 75 | + final var startDate = settlementRequest.getTimeStart().plusHours(8).toLocalDate().atStartOfDay(); |
| 74 | - final var endDate = settlementRequest.getTimeEnd().toLocalDate().plusDays(1).atStartOfDay(); | 76 | + final var endDate = settlementRequest.getTimeEnd().plusHours(8).toLocalDate().plusDays(1).atStartOfDay(); |
| 75 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | 77 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); |
| 76 | final int enterpriseId = LoginContextHolder.hasLogin() ? operatorLoginInfo.getEnterpriseId() : settlementRequest.getEnterpriseId(); | 78 | final int enterpriseId = LoginContextHolder.hasLogin() ? operatorLoginInfo.getEnterpriseId() : settlementRequest.getEnterpriseId(); |
| 77 | final var queryOrderDto = QueryOrderByConditionDto.builder() | 79 | final var queryOrderDto = QueryOrderByConditionDto.builder() |
| ... | @@ -90,6 +92,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -90,6 +92,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 90 | .collect(Collectors.toList()); | 92 | .collect(Collectors.toList()); |
| 91 | final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); | 93 | final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); |
| 92 | List<Integer> skuIds = orderDetailList.stream() | 94 | List<Integer> skuIds = orderDetailList.stream() |
| 95 | + .filter(d -> !d.getServeStatus().equals(ServeStatusEnum.SERVE_REJECT)) | ||
| 93 | .map(SingleClientCustomerOrderDetailRpcResponse::getSkuId) | 96 | .map(SingleClientCustomerOrderDetailRpcResponse::getSkuId) |
| 94 | .distinct() | 97 | .distinct() |
| 95 | .collect(Collectors.toList()); | 98 | .collect(Collectors.toList()); |
| ... | @@ -153,7 +156,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -153,7 +156,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 153 | 156 | ||
| 154 | //找出当天所有已点的菜品明细 | 157 | //找出当天所有已点的菜品明细 |
| 155 | final var curOrderDetails = orderDetailList.stream() | 158 | final var curOrderDetails = orderDetailList.stream() |
| 156 | - .filter(d -> curOrderIds.contains(d.getOrderId())) | 159 | + .filter(d -> curOrderIds.contains(d.getOrderId()) && !d.getServeStatus().equals(ServeStatusEnum.SERVE_REJECT)) |
| 157 | .collect(Collectors.toList()); | 160 | .collect(Collectors.toList()); |
| 158 | 161 | ||
| 159 | for (SingleMenuDetailRpcResponse m: curMenuDetails) { | 162 | for (SingleMenuDetailRpcResponse m: curMenuDetails) { |
| ... | @@ -198,14 +201,20 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -198,14 +201,20 @@ public class SettlementServiceImpl implements SettlementService { |
| 198 | 201 | ||
| 199 | } | 202 | } |
| 200 | } | 203 | } |
| 201 | - final var client = inventoryServiceRpcClient.getClientById(enterpriseId, | 204 | +// final var client = inventoryServiceRpcClient.getClientById(enterpriseId, |
| 202 | - settlementRequest.getClientId()).getClient(); | 205 | +// settlementRequest.getClientId()).getClient(); |
| 206 | + final var stalls = inventoryServiceRpcClient.getStallsByIds(operatorLoginInfo.getEnterpriseId(), settlementRequest.getStallIds()).getClientsList(); | ||
| 207 | + final var stallNames = stalls.stream() | ||
| 208 | + .filter(s -> settlementRequest.getStallIds().contains(s.getId())) | ||
| 209 | + .map(SingleClientRpcResponse::getName).collect(Collectors.toList()); | ||
| 210 | + String joinedString = String.join(" ", stallNames); | ||
| 203 | final var settlementDataDto = SettlementDataDto.builder() | 211 | final var settlementDataDto = SettlementDataDto.builder() |
| 204 | .classifyOrders(classifyOrders) | 212 | .classifyOrders(classifyOrders) |
| 205 | - .client(client.getName()) | 213 | + .client(joinedString) |
| 206 | - .startTime(DateUtil.formatDate(settlementRequest.getTimeStart(), DateUtil.YYYY_MM_DD)) | 214 | + .startTime(DateUtil.formatDate(settlementRequest.getTimeStart().plusHours(8), DateUtil.YYYY_MM_DD)) |
| 207 | - .endTime(DateUtil.formatDate(settlementRequest.getTimeEnd(), DateUtil.YYYY_MM_DD)) | 215 | + .endTime(DateUtil.formatDate(settlementRequest.getTimeEnd().plusHours(8), DateUtil.YYYY_MM_DD)) |
| 208 | .build(); | 216 | .build(); |
| 217 | + | ||
| 209 | try { | 218 | try { |
| 210 | final var bytes = writeToExcelBySku(settlementDataDto); | 219 | final var bytes = writeToExcelBySku(settlementDataDto); |
| 211 | return bytes; | 220 | return bytes; |
| ... | @@ -319,8 +328,8 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -319,8 +328,8 @@ public class SettlementServiceImpl implements SettlementService { |
| 319 | 328 | ||
| 320 | public ByteArrayOutputStream generateOrderSettlementExcelByMeal(SettlementRequestDto settlementRequest) { | 329 | public ByteArrayOutputStream generateOrderSettlementExcelByMeal(SettlementRequestDto settlementRequest) { |
| 321 | 330 | ||
| 322 | - final var startDate = settlementRequest.getTimeStart().toLocalDate().atStartOfDay(); | 331 | + final var startDate = settlementRequest.getTimeStart().plusHours(8).toLocalDate().atStartOfDay(); |
| 323 | - final var endDate = settlementRequest.getTimeEnd().toLocalDate().plusDays(1).atStartOfDay(); | 332 | + final var endDate = settlementRequest.getTimeEnd().plusHours(8).toLocalDate().plusDays(1).atStartOfDay(); |
| 324 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | 333 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); |
| 325 | final var queryOrderDto = QueryOrderByConditionDto.builder() | 334 | final var queryOrderDto = QueryOrderByConditionDto.builder() |
| 326 | .enterpriseId(LoginContextHolder.hasLogin() ? operatorLoginInfo.getEnterpriseId() : settlementRequest.getEnterpriseId()) | 335 | .enterpriseId(LoginContextHolder.hasLogin() ? operatorLoginInfo.getEnterpriseId() : settlementRequest.getEnterpriseId()) |
| ... | @@ -424,8 +433,8 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -424,8 +433,8 @@ public class SettlementServiceImpl implements SettlementService { |
| 424 | final var settlementDataByMealDto = SettlementDataByMealDto.builder() | 433 | final var settlementDataByMealDto = SettlementDataByMealDto.builder() |
| 425 | .classifyOrders(classifyOrders) | 434 | .classifyOrders(classifyOrders) |
| 426 | .client(client.getName()) | 435 | .client(client.getName()) |
| 427 | - .startTime(settlementRequest.getTimeStart()) | 436 | + .startTime(settlementRequest.getTimeStart().plusHours(8)) |
| 428 | - .endTime(settlementRequest.getTimeEnd()) | 437 | + .endTime(settlementRequest.getTimeEnd().plusHours(8)) |
| 429 | .build(); | 438 | .build(); |
| 430 | try { | 439 | try { |
| 431 | final var bytes = writeToExcelByMeal(settlementDataByMealDto); | 440 | final var bytes = writeToExcelByMeal(settlementDataByMealDto); | ... | ... |
-
Please register or login to post a comment