fix(order): optimize dish replacement logic and update payment transaction ID
Showing
11 changed files
with
76 additions
and
5 deletions
| ... | @@ -60,4 +60,5 @@ public class PayController { | ... | @@ -60,4 +60,5 @@ public class PayController { |
| 60 | public String cancel(@Valid @RequestBody PayDTO.PayRefundRequestDto payRefundRequestDto) { | 60 | public String cancel(@Valid @RequestBody PayDTO.PayRefundRequestDto payRefundRequestDto) { |
| 61 | return payServiceClient.orderPayRefund(payRefundRequestDto); | 61 | return payServiceClient.orderPayRefund(payRefundRequestDto); |
| 62 | } | 62 | } |
| 63 | + | ||
| 63 | } | 64 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | +package com.infoloop.tianting.model.bo; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Data | ||
| 7 | +public class OrderDetailBO { | ||
| 8 | + | ||
| 9 | + private int id; | ||
| 10 | + | ||
| 11 | + public int skuId; | ||
| 12 | + | ||
| 13 | + private String skuName; | ||
| 14 | + | ||
| 15 | + private Integer price; | ||
| 16 | + | ||
| 17 | + private int count; | ||
| 18 | + | ||
| 19 | + private String adjustSkuRemark; | ||
| 20 | + | ||
| 21 | + private ServeStatusEnum serveStatus; | ||
| 22 | +} |
| ... | @@ -520,6 +520,7 @@ public class OrderDbDTO { | ... | @@ -520,6 +520,7 @@ public class OrderDbDTO { |
| 520 | private Integer count; | 520 | private Integer count; |
| 521 | private String adjustSkuRemark; | 521 | private String adjustSkuRemark; |
| 522 | private String serveStatus; | 522 | private String serveStatus; |
| 523 | + private Integer price; | ||
| 523 | } | 524 | } |
| 524 | 525 | ||
| 525 | 526 | ... | ... |
| ... | @@ -9,6 +9,8 @@ import lombok.Builder; | ... | @@ -9,6 +9,8 @@ import lombok.Builder; |
| 9 | import lombok.Data; | 9 | import lombok.Data; |
| 10 | import lombok.NoArgsConstructor; | 10 | import lombok.NoArgsConstructor; |
| 11 | 11 | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 12 | @Data | 14 | @Data |
| 13 | @ApiModel(description = "支付DTO") | 15 | @ApiModel(description = "支付DTO") |
| 14 | public class PayDTO { | 16 | public class PayDTO { |
| ... | @@ -31,6 +33,7 @@ public class PayDTO { | ... | @@ -31,6 +33,7 @@ public class PayDTO { |
| 31 | @AllArgsConstructor | 33 | @AllArgsConstructor |
| 32 | public static class PayRefundRequestDto { | 34 | public static class PayRefundRequestDto { |
| 33 | private Integer orderId; | 35 | private Integer orderId; |
| 36 | + private List<Integer> orderDetailIds; | ||
| 34 | private String hospitalCode; | 37 | private String hospitalCode; |
| 35 | } | 38 | } |
| 36 | 39 | ... | ... |
| ... | @@ -18,6 +18,9 @@ public class PaymentCallbackResult { | ... | @@ -18,6 +18,9 @@ public class PaymentCallbackResult { |
| 18 | @JacksonXmlProperty(localName = "TransSN") | 18 | @JacksonXmlProperty(localName = "TransSN") |
| 19 | private String transSN; | 19 | private String transSN; |
| 20 | 20 | ||
| 21 | + @JacksonXmlProperty(localName = "TradeReferenceNo") | ||
| 22 | + private String tradeReferenceNo; | ||
| 23 | + | ||
| 21 | @JacksonXmlProperty(localName = "TransType") | 24 | @JacksonXmlProperty(localName = "TransType") |
| 22 | private String transType; | 25 | private String transType; |
| 23 | 26 | ... | ... |
| ... | @@ -103,6 +103,8 @@ public class SettlementDTO { | ... | @@ -103,6 +103,8 @@ public class SettlementDTO { |
| 103 | private String remark; | 103 | private String remark; |
| 104 | private String avoidRemark; | 104 | private String avoidRemark; |
| 105 | private String onlinePay; | 105 | private String onlinePay; |
| 106 | + private String operationType; | ||
| 107 | + private String transactionId; | ||
| 106 | } | 108 | } |
| 107 | 109 | ||
| 108 | @Data | 110 | @Data | ... | ... |
| ... | @@ -22,6 +22,8 @@ import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderBy | ... | @@ -22,6 +22,8 @@ import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderBy |
| 22 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByIdsRpcRequest; | 22 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByIdsRpcRequest; |
| 23 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByOrderIdsRpcRequest; | 23 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByOrderIdsRpcRequest; |
| 24 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByCustomerIdRpcRequest; | 24 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrdersByCustomerIdRpcRequest; |
| 25 | +import com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecordsByOrderIdsRequest; | ||
| 26 | +import com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecordsByOrderIdsResponse; | ||
| 25 | import com.infoloop.tianting.clientcustomerorderservice.MealDetail; | 27 | import com.infoloop.tianting.clientcustomerorderservice.MealDetail; |
| 26 | import com.infoloop.tianting.clientcustomerorderservice.OnlinePayEnum; | 28 | import com.infoloop.tianting.clientcustomerorderservice.OnlinePayEnum; |
| 27 | import com.infoloop.tianting.clientcustomerorderservice.OrderOperationRecordCreation; | 29 | import com.infoloop.tianting.clientcustomerorderservice.OrderOperationRecordCreation; |
| ... | @@ -240,6 +242,7 @@ public class OrderServiceRpcClient { | ... | @@ -240,6 +242,7 @@ public class OrderServiceRpcClient { |
| 240 | final var operator = operatorServiceRpcClient.getCOperatorById(operatorLoginInfo.getId()); | 242 | final var operator = operatorServiceRpcClient.getCOperatorById(operatorLoginInfo.getId()); |
| 241 | final var idsOfNeedUpdateMenuDetails = new ArrayList<Integer>(); | 243 | final var idsOfNeedUpdateMenuDetails = new ArrayList<Integer>(); |
| 242 | final var idsOfAddCount = new ArrayList<Integer>(); | 244 | final var idsOfAddCount = new ArrayList<Integer>(); |
| 245 | + final var idsOfNoReject = new ArrayList<Integer>(); | ||
| 243 | List<OrderDetailDto> originalOrderDetails = new ArrayList<>(); | 246 | List<OrderDetailDto> originalOrderDetails = new ArrayList<>(); |
| 244 | List<OrderDetailDto> newOrderDetails; | 247 | List<OrderDetailDto> newOrderDetails; |
| 245 | final var modifications = orderDetailBatchUpdateDto.getDetails().stream().map(d -> { | 248 | final var modifications = orderDetailBatchUpdateDto.getDetails().stream().map(d -> { |
| ... | @@ -280,9 +283,11 @@ public class OrderServiceRpcClient { | ... | @@ -280,9 +283,11 @@ public class OrderServiceRpcClient { |
| 280 | .build(); | 283 | .build(); |
| 281 | } | 284 | } |
| 282 | } | 285 | } |
| 283 | - | ||
| 284 | ServeStatusEnum serveStatus = ServeStatusEnum.UNKNOWN_SERVE_STATUS; | 286 | ServeStatusEnum serveStatus = ServeStatusEnum.UNKNOWN_SERVE_STATUS; |
| 285 | if (d.getShouldUpdateServeStatus()) { | 287 | if (d.getShouldUpdateServeStatus()) { |
| 288 | + if (d.getServeStatus() == ServeStatusEnum.SERVE_REJECT) { | ||
| 289 | + idsOfNoReject.add(d.getId()); | ||
| 290 | + } | ||
| 286 | serveStatus = d.getServeStatus(); | 291 | serveStatus = d.getServeStatus(); |
| 287 | } | 292 | } |
| 288 | Integer count = 0; | 293 | Integer count = 0; |
| ... | @@ -319,7 +324,8 @@ public class OrderServiceRpcClient { | ... | @@ -319,7 +324,8 @@ public class OrderServiceRpcClient { |
| 319 | .build(); | 324 | .build(); |
| 320 | final var totalIds = new ArrayList<>(idsOfNeedUpdateMenuDetails); | 325 | final var totalIds = new ArrayList<>(idsOfNeedUpdateMenuDetails); |
| 321 | totalIds.addAll(idsOfAddCount); | 326 | totalIds.addAll(idsOfAddCount); |
| 322 | - if (!idsOfNeedUpdateMenuDetails.isEmpty() || !idsOfAddCount.isEmpty()) { | 327 | + totalIds.addAll(idsOfNoReject); |
| 328 | + if (!totalIds.isEmpty()) { | ||
| 323 | final var orgionalResponseList = getClientCustomerOrderDetailsByIds(totalIds); | 329 | final var orgionalResponseList = getClientCustomerOrderDetailsByIds(totalIds); |
| 324 | originalOrderDetails = orgionalResponseList.stream().map(d -> OrderDetailDto.builder() | 330 | originalOrderDetails = orgionalResponseList.stream().map(d -> OrderDetailDto.builder() |
| 325 | .id(d.getId()) | 331 | .id(d.getId()) |
| ... | @@ -357,7 +363,7 @@ public class OrderServiceRpcClient { | ... | @@ -357,7 +363,7 @@ public class OrderServiceRpcClient { |
| 357 | } | 363 | } |
| 358 | final var res = orderServiceRpcBlockingStub.batchUpdateClientCustomerOrderDetails(request); | 364 | final var res = orderServiceRpcBlockingStub.batchUpdateClientCustomerOrderDetails(request); |
| 359 | if (res.getIsUpdated()) { | 365 | if (res.getIsUpdated()) { |
| 360 | - if (!idsOfNeedUpdateMenuDetails.isEmpty() || !idsOfAddCount.isEmpty()) { | 366 | + if (!totalIds.isEmpty()) { |
| 361 | final var newResponseList = getClientCustomerOrderDetailsByIds(totalIds); | 367 | final var newResponseList = getClientCustomerOrderDetailsByIds(totalIds); |
| 362 | newOrderDetails = newResponseList.stream().map(d -> | 368 | newOrderDetails = newResponseList.stream().map(d -> |
| 363 | OrderDetailDto.builder() | 369 | OrderDetailDto.builder() |
| ... | @@ -392,15 +398,20 @@ public class OrderServiceRpcClient { | ... | @@ -392,15 +398,20 @@ public class OrderServiceRpcClient { |
| 392 | .updateSource(d.getUpdateSource().getNumber()) | 398 | .updateSource(d.getUpdateSource().getNumber()) |
| 393 | .updatedAt(DateUtil.formatDate(d.getUpdatedAt())) | 399 | .updatedAt(DateUtil.formatDate(d.getUpdatedAt())) |
| 394 | .updatedBy(d.getUpdatedBy()) | 400 | .updatedBy(d.getUpdatedBy()) |
| 395 | - .build()).collect(Collectors.toList()); | 401 | + .build()).toList(); |
| 396 | // 替换菜品的操作记录 | 402 | // 替换菜品的操作记录 |
| 397 | List<SingleOperationDto> operations = new ArrayList<>(); | 403 | List<SingleOperationDto> operations = new ArrayList<>(); |
| 398 | for (OrderDetailDto originalDetail : originalOrderDetails) { | 404 | for (OrderDetailDto originalDetail : originalOrderDetails) { |
| 405 | + if (!totalIds.contains(originalDetail.getId())) { | ||
| 406 | + continue; | ||
| 407 | + } | ||
| 399 | OrderOperationType orderOperationType = OrderOperationType.UNKNOWN_OPERATION_TYPE; | 408 | OrderOperationType orderOperationType = OrderOperationType.UNKNOWN_OPERATION_TYPE; |
| 400 | if (idsOfNeedUpdateMenuDetails.contains(originalDetail.getId())) { | 409 | if (idsOfNeedUpdateMenuDetails.contains(originalDetail.getId())) { |
| 401 | orderOperationType = OrderOperationType.REPLACE_DISHES; | 410 | orderOperationType = OrderOperationType.REPLACE_DISHES; |
| 402 | } else if (idsOfAddCount.contains(originalDetail.getId())) { | 411 | } else if (idsOfAddCount.contains(originalDetail.getId())) { |
| 403 | orderOperationType = OrderOperationType.ADD_DISHES; | 412 | orderOperationType = OrderOperationType.ADD_DISHES; |
| 413 | + } else if (idsOfNoReject.contains(originalDetail.getId())) { | ||
| 414 | + orderOperationType = OrderOperationType.NOT_SERVE; | ||
| 404 | } | 415 | } |
| 405 | String originalDetailStr; | 416 | String originalDetailStr; |
| 406 | String newDetailStr = ""; | 417 | String newDetailStr = ""; |
| ... | @@ -413,6 +424,7 @@ public class OrderServiceRpcClient { | ... | @@ -413,6 +424,7 @@ public class OrderServiceRpcClient { |
| 413 | .count(newDetail.get().getCount()) | 424 | .count(newDetail.get().getCount()) |
| 414 | .adjustSkuRemark(newDetail.get().getAdjustSkuRemark()) | 425 | .adjustSkuRemark(newDetail.get().getAdjustSkuRemark()) |
| 415 | .serveStatus(newDetail.get().getServeStatus().name()) | 426 | .serveStatus(newDetail.get().getServeStatus().name()) |
| 427 | + .price(newDetail.get().getPrice()) | ||
| 416 | .build(); | 428 | .build(); |
| 417 | newDetailStr = JsonUtil.writeAsJson(List.of(newOrderDetailOperation)); | 429 | newDetailStr = JsonUtil.writeAsJson(List.of(newOrderDetailOperation)); |
| 418 | } | 430 | } |
| ... | @@ -423,6 +435,7 @@ public class OrderServiceRpcClient { | ... | @@ -423,6 +435,7 @@ public class OrderServiceRpcClient { |
| 423 | .count(originalDetail.getCount()) | 435 | .count(originalDetail.getCount()) |
| 424 | .adjustSkuRemark(originalDetail.getAdjustSkuRemark()) | 436 | .adjustSkuRemark(originalDetail.getAdjustSkuRemark()) |
| 425 | .serveStatus(originalDetail.getServeStatus().name()) | 437 | .serveStatus(originalDetail.getServeStatus().name()) |
| 438 | + .price(originalDetail.getPrice()) | ||
| 426 | .build(); | 439 | .build(); |
| 427 | originalDetailStr = JsonUtil.writeAsJson(List.of(originalOrderDetailOperation)); | 440 | originalDetailStr = JsonUtil.writeAsJson(List.of(originalOrderDetailOperation)); |
| 428 | final var operation = SingleOperationDto.builder() | 441 | final var operation = SingleOperationDto.builder() |
| ... | @@ -471,7 +484,6 @@ public class OrderServiceRpcClient { | ... | @@ -471,7 +484,6 @@ public class OrderServiceRpcClient { |
| 471 | .setCreationSource(batchOperationDto.getCreationSource()) | 484 | .setCreationSource(batchOperationDto.getCreationSource()) |
| 472 | .build(); | 485 | .build(); |
| 473 | return orderServiceRpcBlockingStub.batchCreateOrderOperationRecords(request); | 486 | return orderServiceRpcBlockingStub.batchCreateOrderOperationRecords(request); |
| 474 | - | ||
| 475 | } | 487 | } |
| 476 | 488 | ||
| 477 | public QueryClientCustomerOrdersByPaginationRpcResponse queryClientCustomerOrdersByPagination(QueryOrderByPaginationDto queryOrderDto) { | 489 | public QueryClientCustomerOrdersByPaginationRpcResponse queryClientCustomerOrdersByPagination(QueryOrderByPaginationDto queryOrderDto) { |
| ... | @@ -489,6 +501,14 @@ public class OrderServiceRpcClient { | ... | @@ -489,6 +501,14 @@ public class OrderServiceRpcClient { |
| 489 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByPagination(request); | 501 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByPagination(request); |
| 490 | } | 502 | } |
| 491 | 503 | ||
| 504 | + public GetOrderOperationRecordsByOrderIdsResponse getOrderOperationRecordsByOrderIds(int enterpriseId, List<Integer> orderIds) { | ||
| 505 | + final var request = GetOrderOperationRecordsByOrderIdsRequest.newBuilder() | ||
| 506 | + .setEnterpriseId(enterpriseId) | ||
| 507 | + .addAllOrderIds(orderIds) | ||
| 508 | + .build(); | ||
| 509 | + return orderServiceRpcBlockingStub.getOrderOperationRecordsByOrderIds(request); | ||
| 510 | + } | ||
| 511 | + | ||
| 492 | public QueryClientCustomerOrdersByConditionRpcResponse queryClientCustomerOrdersByCondition(OrderDbDTO.QueryOrderDto queryOrderDto) { | 512 | public QueryClientCustomerOrdersByConditionRpcResponse queryClientCustomerOrdersByCondition(OrderDbDTO.QueryOrderDto queryOrderDto) { |
| 493 | final var request = QueryClientCustomerOrdersByConditionRpcRequest.newBuilder() | 513 | final var request = QueryClientCustomerOrdersByConditionRpcRequest.newBuilder() |
| 494 | .setShouldFilterStatus(true) | 514 | .setShouldFilterStatus(true) | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
| ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.utils; | ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.utils; |
| 2 | 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonInclude; | 3 | import com.fasterxml.jackson.annotation.JsonInclude; |
| 4 | import com.fasterxml.jackson.core.JsonProcessingException; | 4 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 5 | +import com.fasterxml.jackson.core.type.TypeReference; | ||
| 5 | import com.fasterxml.jackson.databind.DeserializationFeature; | 6 | import com.fasterxml.jackson.databind.DeserializationFeature; |
| 6 | import com.fasterxml.jackson.databind.JsonNode; | 7 | import com.fasterxml.jackson.databind.JsonNode; |
| 7 | import com.fasterxml.jackson.databind.ObjectMapper; | 8 | import com.fasterxml.jackson.databind.ObjectMapper; |
| ... | @@ -41,6 +42,14 @@ public class JsonUtil { | ... | @@ -41,6 +42,14 @@ public class JsonUtil { |
| 41 | } | 42 | } |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 45 | + public static <T> T readJsonAs(final String json, final TypeReference<T> typeRef) { | ||
| 46 | + try { | ||
| 47 | + return OBJECT_MAPPER.readValue(json, typeRef); | ||
| 48 | + } catch (IOException e) { | ||
| 49 | + throw new RuntimeException(e); | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + | ||
| 44 | public static <T> T convertValue(final Object object, final Class<T> clazz) { | 53 | public static <T> T convertValue(final Object object, final Class<T> clazz) { |
| 45 | return OBJECT_MAPPER.convertValue(object, clazz); | 54 | return OBJECT_MAPPER.convertValue(object, clazz); |
| 46 | } | 55 | } | ... | ... |
| ... | @@ -32,6 +32,7 @@ service ClientCustomerOrderServiceRpc { | ... | @@ -32,6 +32,7 @@ service ClientCustomerOrderServiceRpc { |
| 32 | 32 | ||
| 33 | // 操作记录 | 33 | // 操作记录 |
| 34 | rpc GetOrderOperationRecordsByOrderId (GetOrderOperationRecordsByOrderIdRequest) returns (GetOrderOperationRecordsByOrderIdResponse) {} | 34 | rpc GetOrderOperationRecordsByOrderId (GetOrderOperationRecordsByOrderIdRequest) returns (GetOrderOperationRecordsByOrderIdResponse) {} |
| 35 | + rpc GetOrderOperationRecordsByOrderIds (GetOrderOperationRecordsByOrderIdsRequest) returns (GetOrderOperationRecordsByOrderIdsResponse) {} | ||
| 35 | rpc BatchCreateOrderOperationRecords (BatchCreateOrderOperationRecordsRequest) returns (BatchCreateOrderOperationRecordsResponse) {} | 36 | rpc BatchCreateOrderOperationRecords (BatchCreateOrderOperationRecordsRequest) returns (BatchCreateOrderOperationRecordsResponse) {} |
| 36 | 37 | ||
| 37 | 38 | ||
| ... | @@ -624,6 +625,15 @@ message GetOrderOperationRecordsByOrderIdResponse { | ... | @@ -624,6 +625,15 @@ message GetOrderOperationRecordsByOrderIdResponse { |
| 624 | repeated OrderOperationRecord responses = 1; | 625 | repeated OrderOperationRecord responses = 1; |
| 625 | } | 626 | } |
| 626 | 627 | ||
| 628 | +message GetOrderOperationRecordsByOrderIdsRequest { | ||
| 629 | + int32 enterpriseId = 1; | ||
| 630 | + repeated int32 orderIds = 2; | ||
| 631 | +} | ||
| 632 | + | ||
| 633 | +message GetOrderOperationRecordsByOrderIdsResponse { | ||
| 634 | + repeated OrderOperationRecord responses = 1; | ||
| 635 | +} | ||
| 636 | + | ||
| 627 | message OrderOperationRecordCreation { | 637 | message OrderOperationRecordCreation { |
| 628 | int32 orderId = 1; | 638 | int32 orderId = 1; |
| 629 | OrderOperationType type = 2; | 639 | OrderOperationType type = 2; | ... | ... |
-
Please register or login to post a comment