zhuyifan

Merge branch 'feature/order_cancel' into 'master'

Feature/order cancel



See merge request !1
Showing 171 changed files with 456 additions and 76 deletions
...@@ -16,4 +16,6 @@ public class BusinessConfig { ...@@ -16,4 +16,6 @@ public class BusinessConfig {
16 private String clientCustomerQueryUrl; 16 private String clientCustomerQueryUrl;
17 private String payUrl; 17 private String payUrl;
18 private String payClientId; 18 private String payClientId;
19 + private String cancelPayUrl;
20 + private String refundSecurityKey;
19 } 21 }
......
...@@ -7,10 +7,10 @@ import com.infoloop.tianting.intercepter.LoginInterceptor; ...@@ -7,10 +7,10 @@ import com.infoloop.tianting.intercepter.LoginInterceptor;
7 import com.infoloop.tianting.intercepter.RequestMonitor; 7 import com.infoloop.tianting.intercepter.RequestMonitor;
8 import com.infoloop.tianting.intercepter.ResourceInjector; 8 import com.infoloop.tianting.intercepter.ResourceInjector;
9 import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; 9 import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient;
10 +import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient;
10 import com.infoloop.tianting.service.client.OperatorServiceRpcClient; 11 import com.infoloop.tianting.service.client.OperatorServiceRpcClient;
11 import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; 12 import com.infoloop.tianting.service.client.WOperatorServiceRpcClient;
12 import com.infoloop.tianting.tracing.HttpTracingInterceptor; 13 import com.infoloop.tianting.tracing.HttpTracingInterceptor;
13 -import lombok.RequiredArgsConstructor;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.boot.web.servlet.FilterRegistrationBean; 15 import org.springframework.boot.web.servlet.FilterRegistrationBean;
16 import org.springframework.context.annotation.Bean; 16 import org.springframework.context.annotation.Bean;
...@@ -37,12 +37,13 @@ public class WebMvcConfig implements WebMvcConfigurer { ...@@ -37,12 +37,13 @@ public class WebMvcConfig implements WebMvcConfigurer {
37 final ResourceInjector resourceInjector, 37 final ResourceInjector resourceInjector,
38 final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient, 38 final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient,
39 final OperatorServiceRpcClient operatorServiceRpcClient, 39 final OperatorServiceRpcClient operatorServiceRpcClient,
40 - final WOperatorServiceRpcClient wOperatorServiceRpcClient) { 40 + final WOperatorServiceRpcClient wOperatorServiceRpcClient,
41 + final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient) {
41 this.httpInterceptors = new ArrayList<>(); 42 this.httpInterceptors = new ArrayList<>();
42 this.httpInterceptors.add(new HttpTracingInterceptor(tracing)); 43 this.httpInterceptors.add(new HttpTracingInterceptor(tracing));
43 this.httpInterceptors.add(new RequestMonitor()); 44 this.httpInterceptors.add(new RequestMonitor());
44 this.httpInterceptors.add(new ApiSignInterceptor()); 45 this.httpInterceptors.add(new ApiSignInterceptor());
45 - this.httpInterceptors.add(new LoginInterceptor(clientCustomerServiceRpcClient, operatorServiceRpcClient, wOperatorServiceRpcClient)); 46 + this.httpInterceptors.add(new LoginInterceptor(clientCustomerServiceRpcClient, meiZhongYiHeServiceClient, operatorServiceRpcClient, wOperatorServiceRpcClient));
46 this.httpInterceptors.add(resourceInjector); 47 this.httpInterceptors.add(resourceInjector);
47 48
48 } 49 }
......
...@@ -35,4 +35,11 @@ public class ClientOrderController { ...@@ -35,4 +35,11 @@ public class ClientOrderController {
35 return orderService.getOrdersByPagination(queryOrderDto); 35 return orderService.getOrdersByPagination(queryOrderDto);
36 } 36 }
37 37
38 + @ApiOperation(value = "院区端已撤销订单")
39 + @PostMapping("/client/orders/refund/pagination")
40 + @ResponseStatus(HttpStatus.OK)
41 + public OrderPageResult<OrderDto> getRefundOrderByByPagination(@Valid @RequestBody OrderDbDTO.QueryRefundOrderByPaginationDto queryOrderDto) {
42 + return orderService.getRefundOrdersByPagination(queryOrderDto);
43 + }
44 +
38 } 45 }
......
1 package com.infoloop.tianting.controller; 1 package com.infoloop.tianting.controller;
2 2
3 import com.github.xiaoymin.knife4j.annotations.ApiSupport; 3 import com.github.xiaoymin.knife4j.annotations.ApiSupport;
4 -import com.infoloop.tianting.model.dto.ClientLabelDTO;
5 -import com.infoloop.tianting.model.dto.ClientLabelDTO.LabelDto;
6 import com.infoloop.tianting.model.dto.KdsDTO; 4 import com.infoloop.tianting.model.dto.KdsDTO;
7 import com.infoloop.tianting.model.dto.KdsDTO.KdsMealDetailDto; 5 import com.infoloop.tianting.model.dto.KdsDTO.KdsMealDetailDto;
8 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; 6 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto;
...@@ -10,8 +8,6 @@ import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto; ...@@ -10,8 +8,6 @@ import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto;
10 import com.infoloop.tianting.service.KdsService; 8 import com.infoloop.tianting.service.KdsService;
11 import io.swagger.annotations.Api; 9 import io.swagger.annotations.Api;
12 import io.swagger.annotations.ApiOperation; 10 import io.swagger.annotations.ApiOperation;
13 -import java.util.List;
14 -import javax.validation.Valid;
15 import lombok.RequiredArgsConstructor; 11 import lombok.RequiredArgsConstructor;
16 import lombok.extern.slf4j.Slf4j; 12 import lombok.extern.slf4j.Slf4j;
17 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
...@@ -22,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -22,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestBody;
22 import org.springframework.web.bind.annotation.ResponseStatus; 18 import org.springframework.web.bind.annotation.ResponseStatus;
23 import org.springframework.web.bind.annotation.RestController; 19 import org.springframework.web.bind.annotation.RestController;
24 20
21 +import javax.validation.Valid;
22 +import java.util.List;
23 +
25 @Api(tags = "KDS") 24 @Api(tags = "KDS")
26 @ApiSupport(order = -1) 25 @ApiSupport(order = -1)
27 @Slf4j 26 @Slf4j
......
...@@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor; ...@@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
12 import lombok.extern.slf4j.Slf4j; 12 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.http.HttpStatus; 14 import org.springframework.http.HttpStatus;
15 +import org.springframework.http.MediaType;
15 import org.springframework.validation.annotation.Validated; 16 import org.springframework.validation.annotation.Validated;
16 import org.springframework.web.bind.annotation.PathVariable; 17 import org.springframework.web.bind.annotation.PathVariable;
17 import org.springframework.web.bind.annotation.PostMapping; 18 import org.springframework.web.bind.annotation.PostMapping;
...@@ -53,4 +54,10 @@ public class PayController { ...@@ -53,4 +54,10 @@ public class PayController {
53 return payServiceClient.callback(paymentCallbackDTO); 54 return payServiceClient.callback(paymentCallbackDTO);
54 } 55 }
55 56
57 + @ApiOperation(value = "支付撤销")
58 + @PostMapping(value = "/pay/refund", produces = MediaType.TEXT_HTML_VALUE)
59 + @ResponseStatus(HttpStatus.OK)
60 + public String cancel(@Valid @RequestBody PayDTO.PayRefundRequestDto payRefundRequestDto) {
61 + return payServiceClient.orderPayRefund(payRefundRequestDto);
62 + }
56 } 63 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -34,7 +34,15 @@ public enum ErrorCodeEnum implements BaseEnum { ...@@ -34,7 +34,15 @@ public enum ErrorCodeEnum implements BaseEnum {
34 34
35 SKUS_STOCK_NO_ENOUGH_TODAY(406000008, "下单菜品: {0} 库存不足"), 35 SKUS_STOCK_NO_ENOUGH_TODAY(406000008, "下单菜品: {0} 库存不足"),
36 36
37 - ORDER_CANCEL(406000009, "订单已自动取消") 37 + ORDER_CANCEL(406000009, "订单已自动取消"),
38 +
39 + ORDER_PAY_REFUND_FAILED(406000010, "支付撤销失败"),
40 +
41 + ORDER_NOT_FOUND(406000011, "订单未找到"),
42 +
43 + ORDER_NOT_ONLINE_PAY(406000012, "该订单不是在线支付"),
44 +
45 + ORDER_NOT_SUCCESS(406000013, "该订单未支付成功")
38 ; 46 ;
39 private final int code; 47 private final int code;
40 48
......
...@@ -4,12 +4,13 @@ import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordH ...@@ -4,12 +4,13 @@ import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordH
4 import com.infoloop.tianting.clientcustomerservice.ClientCustomerSexEnum; 4 import com.infoloop.tianting.clientcustomerservice.ClientCustomerSexEnum;
5 import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto; 5 import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto;
6 import io.swagger.annotations.ApiModel; 6 import io.swagger.annotations.ApiModel;
7 -import java.util.List;
8 import lombok.AllArgsConstructor; 7 import lombok.AllArgsConstructor;
9 import lombok.Builder; 8 import lombok.Builder;
10 import lombok.Data; 9 import lombok.Data;
11 import lombok.NoArgsConstructor; 10 import lombok.NoArgsConstructor;
12 11
12 +import java.util.List;
13 +
13 @Data 14 @Data
14 @ApiModel(description = "ClientCustomerDTO") 15 @ApiModel(description = "ClientCustomerDTO")
15 public class ClientCustomerDbDTO { 16 public class ClientCustomerDbDTO {
......
...@@ -5,12 +5,12 @@ import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; ...@@ -5,12 +5,12 @@ import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum;
5 import com.infoloop.tianting.deliveryruleservice.ClientDishLabelStatusEnum; 5 import com.infoloop.tianting.deliveryruleservice.ClientDishLabelStatusEnum;
6 import com.infoloop.tianting.deliveryruleservice.ClientLabelTypeEnum; 6 import com.infoloop.tianting.deliveryruleservice.ClientLabelTypeEnum;
7 import io.swagger.annotations.ApiModel; 7 import io.swagger.annotations.ApiModel;
8 -import io.swagger.models.auth.In;
9 -import java.util.List;
10 import lombok.Builder; 8 import lombok.Builder;
11 import lombok.Data; 9 import lombok.Data;
12 import lombok.ToString; 10 import lombok.ToString;
13 11
12 +import java.util.List;
13 +
14 @Data 14 @Data
15 @ApiModel(description = "标签DTO") 15 @ApiModel(description = "标签DTO")
16 public class ClientLabelDTO { 16 public class ClientLabelDTO {
......
...@@ -3,11 +3,11 @@ package com.infoloop.tianting.model.dto; ...@@ -3,11 +3,11 @@ package com.infoloop.tianting.model.dto;
3 import com.infoloop.tianting.clientinventoryservice.ClientType; 3 import com.infoloop.tianting.clientinventoryservice.ClientType;
4 import com.infoloop.tianting.clientinventoryservice.CustomerSource; 4 import com.infoloop.tianting.clientinventoryservice.CustomerSource;
5 import io.swagger.annotations.ApiModel; 5 import io.swagger.annotations.ApiModel;
6 -import io.swagger.models.auth.In;
7 -import java.util.List;
8 import lombok.Builder; 6 import lombok.Builder;
9 import lombok.Data; 7 import lombok.Data;
10 8
9 +import java.util.List;
10 +
11 @Data 11 @Data
12 @ApiModel(description = "院区DTO") 12 @ApiModel(description = "院区DTO")
13 public class InventoryDbDTO { 13 public class InventoryDbDTO {
......
...@@ -6,13 +6,13 @@ import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; ...@@ -6,13 +6,13 @@ import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto;
6 import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto; 6 import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto;
7 import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; 7 import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice;
8 import io.swagger.annotations.ApiModel; 8 import io.swagger.annotations.ApiModel;
9 -import io.swagger.models.auth.In;
10 -import java.util.List;
11 import lombok.AllArgsConstructor; 9 import lombok.AllArgsConstructor;
12 import lombok.Builder; 10 import lombok.Builder;
13 import lombok.Data; 11 import lombok.Data;
14 import lombok.NoArgsConstructor; 12 import lombok.NoArgsConstructor;
15 13
14 +import java.util.List;
15 +
16 @Data 16 @Data
17 @ApiModel(description = "kds DTO") 17 @ApiModel(description = "kds DTO")
18 public class KdsDTO { 18 public class KdsDTO {
......
...@@ -2,11 +2,12 @@ package com.infoloop.tianting.model.dto; ...@@ -2,11 +2,12 @@ package com.infoloop.tianting.model.dto;
2 2
3 import com.infoloop.tianting.setmealscheduleservice.MealStatus; 3 import com.infoloop.tianting.setmealscheduleservice.MealStatus;
4 import io.swagger.annotations.ApiModel; 4 import io.swagger.annotations.ApiModel;
5 -import java.util.List;
6 import lombok.Builder; 5 import lombok.Builder;
7 import lombok.Data; 6 import lombok.Data;
8 import lombok.ToString; 7 import lombok.ToString;
9 8
9 +import java.util.List;
10 +
10 @Data 11 @Data
11 @ApiModel(description = "餐别相关DTO") 12 @ApiModel(description = "餐别相关DTO")
12 public class MealDbDTO { 13 public class MealDbDTO {
......
...@@ -2,14 +2,13 @@ package com.infoloop.tianting.model.dto; ...@@ -2,14 +2,13 @@ package com.infoloop.tianting.model.dto;
2 2
3 import com.infoloop.tianting.clientcustomerorderservice.OrderOperationType; 3 import com.infoloop.tianting.clientcustomerorderservice.OrderOperationType;
4 import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; 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; 5 import io.swagger.annotations.ApiModel;
8 -import java.util.List;
9 import lombok.Builder; 6 import lombok.Builder;
10 import lombok.Data; 7 import lombok.Data;
11 import lombok.ToString; 8 import lombok.ToString;
12 9
10 +import java.util.List;
11 +
13 @Data 12 @Data
14 @ApiModel(description = "操作记录DTO") 13 @ApiModel(description = "操作记录DTO")
15 public class OperationDTO { 14 public class OperationDTO {
......
...@@ -64,6 +64,17 @@ public class OrderDbDTO { ...@@ -64,6 +64,17 @@ public class OrderDbDTO {
64 } 64 }
65 65
66 @Data 66 @Data
67 + @ApiModel(description = "查询已撤销订单Dto")
68 + public static class QueryRefundOrderByPaginationDto {
69 + private Integer enterpriseId;
70 + private Integer clientId;
71 + private Integer pn;
72 + private Integer pz;
73 + private String keyword;
74 + private List<Integer> stallIds;
75 + }
76 +
77 + @Data
67 @Builder 78 @Builder
68 @ApiModel(description = "订单不同状态的数量Dto") 79 @ApiModel(description = "订单不同状态的数量Dto")
69 public static class OrderCountByStatusDto { 80 public static class OrderCountByStatusDto {
...@@ -72,6 +83,7 @@ public class OrderDbDTO { ...@@ -72,6 +83,7 @@ public class OrderDbDTO {
72 private Integer preparingCount; 83 private Integer preparingCount;
73 private Integer allServedCount; 84 private Integer allServedCount;
74 private Integer canceledCount; 85 private Integer canceledCount;
86 + private Integer refundCount;
75 } 87 }
76 88
77 @Data 89 @Data
...@@ -395,7 +407,7 @@ public class OrderDbDTO { ...@@ -395,7 +407,7 @@ public class OrderDbDTO {
395 @ApiModelProperty(value = "支付时间") 407 @ApiModelProperty(value = "支付时间")
396 private String payTime; 408 private String payTime;
397 409
398 - @ApiModelProperty(value = "支付状态,1=待支付,2=支付中,3=支付成功,4=支付失败,5=支付取消") 410 + @ApiModelProperty(value = "支付状态,1=待支付,2=支付中,3=支付成功,4=支付失败,5=支付取消, 6=支付已撤销")
399 private Integer payStatus; 411 private Integer payStatus;
400 412
401 @ApiModelProperty(value = "支付失败原因") 413 @ApiModelProperty(value = "支付失败原因")
...@@ -455,12 +467,18 @@ public class OrderDbDTO { ...@@ -455,12 +467,18 @@ public class OrderDbDTO {
455 @ApiModelProperty(value = "是否已读") 467 @ApiModelProperty(value = "是否已读")
456 private Boolean isRead; 468 private Boolean isRead;
457 469
470 + @ApiModelProperty(value = "是否已撤销")
471 + private Boolean isCanceled;
472 +
458 @ApiModelProperty(value = "截单类型") 473 @ApiModelProperty(value = "截单类型")
459 private Integer closeTimeType; 474 private Integer closeTimeType;
460 475
461 @ApiModelProperty(value = "订单所属用户的信息") 476 @ApiModelProperty(value = "订单所属用户的信息")
462 private CustomerDetailDto customer; 477 private CustomerDetailDto customer;
463 478
479 + @ApiModelProperty(value = "该订单的忌口冲突、医嘱信息")
480 + private List<String> orderNotice;
481 +
464 // @ApiModelProperty(value = "订单菜品详情列表") 482 // @ApiModelProperty(value = "订单菜品详情列表")
465 // private List<OrderDetailDto> orderDetailDtos; 483 // private List<OrderDetailDto> orderDetailDtos;
466 } 484 }
......
...@@ -26,6 +26,15 @@ public class PayDTO { ...@@ -26,6 +26,15 @@ public class PayDTO {
26 } 26 }
27 27
28 @Data 28 @Data
29 + @ApiModel(description = "支付撤销请求dto")
30 + @NoArgsConstructor
31 + @AllArgsConstructor
32 + public static class PayRefundRequestDto {
33 + private Integer orderId;
34 + private String hospitalCode;
35 + }
36 +
37 + @Data
29 @ApiModel(description = "支付MiniPay结果") 38 @ApiModel(description = "支付MiniPay结果")
30 @NoArgsConstructor 39 @NoArgsConstructor
31 @AllArgsConstructor 40 @AllArgsConstructor
...@@ -76,6 +85,15 @@ public class PayDTO { ...@@ -76,6 +85,15 @@ public class PayDTO {
76 } 85 }
77 86
78 @Data 87 @Data
88 + @ApiModel(description = "取消支付响应")
89 + @NoArgsConstructor
90 + @AllArgsConstructor
91 + public static class CancelPayResponseDto {
92 + private Integer code;
93 + private String message;
94 + }
95 +
96 + @Data
79 @Builder 97 @Builder
80 @ApiModel(description = "第三方支付平台通知请求dto") 98 @ApiModel(description = "第三方支付平台通知请求dto")
81 @NoArgsConstructor 99 @NoArgsConstructor
......
...@@ -2,13 +2,13 @@ package com.infoloop.tianting.model.dto; ...@@ -2,13 +2,13 @@ package com.infoloop.tianting.model.dto;
2 2
3 import com.infoloop.tianting.enums.SettlementDimensionEnum; 3 import com.infoloop.tianting.enums.SettlementDimensionEnum;
4 import io.swagger.annotations.ApiModel; 4 import io.swagger.annotations.ApiModel;
5 -import java.util.ArrayList;
6 -import java.util.Map;
7 import lombok.Builder; 5 import lombok.Builder;
8 import lombok.Data; 6 import lombok.Data;
9 7
10 import java.time.LocalDateTime; 8 import java.time.LocalDateTime;
9 +import java.util.ArrayList;
11 import java.util.List; 10 import java.util.List;
11 +import java.util.Map;
12 12
13 @Data 13 @Data
14 @ApiModel(description = "统计DTO") 14 @ApiModel(description = "统计DTO")
......
1 package com.infoloop.tianting.model.dto; 1 package com.infoloop.tianting.model.dto;
2 2
3 import io.swagger.annotations.ApiModel; 3 import io.swagger.annotations.ApiModel;
4 -import io.swagger.annotations.ApiModelProperty;
5 -import io.swagger.models.auth.In;
6 import lombok.AllArgsConstructor; 4 import lombok.AllArgsConstructor;
7 import lombok.Builder; 5 import lombok.Builder;
8 import lombok.Data; 6 import lombok.Data;
......
1 package com.infoloop.tianting.service; 1 package com.infoloop.tianting.service;
2 2
3 import com.infoloop.tianting.model.dto.CategoryDbDTO.CategoryDto; 3 import com.infoloop.tianting.model.dto.CategoryDbDTO.CategoryDto;
4 +
4 import java.util.List; 5 import java.util.List;
5 6
6 public interface CategoriesService { 7 public interface CategoriesService {
......
1 package com.infoloop.tianting.service; 1 package com.infoloop.tianting.service;
2 2
3 -import com.infoloop.tianting.deliveryruleservice.ClientLabelTypeEnum;
4 import com.infoloop.tianting.model.dto.ClientLabelDTO.LabelDto; 3 import com.infoloop.tianting.model.dto.ClientLabelDTO.LabelDto;
5 import com.infoloop.tianting.model.dto.ClientLabelDTO.QueryLabelsDto; 4 import com.infoloop.tianting.model.dto.ClientLabelDTO.QueryLabelsDto;
5 +
6 import java.util.List; 6 import java.util.List;
7 7
8 public interface DeliveryRuleService { 8 public interface DeliveryRuleService {
......
1 package com.infoloop.tianting.service; 1 package com.infoloop.tianting.service;
2 2
3 -import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcResponse;
4 import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; 3 import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto;
5 import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto; 4 import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto;
6 import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; 5 import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto;
6 +
7 import java.util.List; 7 import java.util.List;
8 8
9 public interface InventoryService { 9 public interface InventoryService {
......
...@@ -5,6 +5,7 @@ import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; ...@@ -5,6 +5,7 @@ import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto;
5 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationQueryDto; 5 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationQueryDto;
6 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto; 6 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto;
7 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuQueryDto; 7 import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuQueryDto;
8 +
8 import java.util.List; 9 import java.util.List;
9 10
10 public interface KdsService { 11 public interface KdsService {
......
1 package com.infoloop.tianting.service; 1 package com.infoloop.tianting.service;
2 2
3 import com.infoloop.tianting.model.dto.MealDbDTO.MealDto; 3 import com.infoloop.tianting.model.dto.MealDbDTO.MealDto;
4 +
4 import java.util.List; 5 import java.util.List;
5 6
6 public interface MealService { 7 public interface MealService {
......
...@@ -2,6 +2,7 @@ package com.infoloop.tianting.service; ...@@ -2,6 +2,7 @@ package com.infoloop.tianting.service;
2 2
3 import com.infoloop.tianting.model.dto.ClientLabelDTO.HisAllergy; 3 import com.infoloop.tianting.model.dto.ClientLabelDTO.HisAllergy;
4 import com.infoloop.tianting.model.dto.ClientLabelDTO.HisMedicalAdviceDto; 4 import com.infoloop.tianting.model.dto.ClientLabelDTO.HisMedicalAdviceDto;
5 +
5 import java.util.List; 6 import java.util.List;
6 7
7 public interface MeiZhongYiHeService { 8 public interface MeiZhongYiHeService {
......
...@@ -11,6 +11,7 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto; ...@@ -11,6 +11,7 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto;
11 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDto; 11 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDto;
12 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; 12 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto;
13 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto; 13 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto;
14 +import com.infoloop.tianting.model.dto.OrderDbDTO.QueryRefundOrderByPaginationDto;
14 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto; 15 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto;
15 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderResponse; 16 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderResponse;
16 import com.infoloop.tianting.model.dto.OrderDbDTO.getMenuOrderCountDto; 17 import com.infoloop.tianting.model.dto.OrderDbDTO.getMenuOrderCountDto;
...@@ -21,6 +22,8 @@ public interface OrderService { ...@@ -21,6 +22,8 @@ public interface OrderService {
21 OrderAndDetailsDto getOrdersByCustomerId(Integer customerId); 22 OrderAndDetailsDto getOrdersByCustomerId(Integer customerId);
22 OrderAndDetailsDto getOrdersByCondition(QueryOrderByConditionDto queryOrderDto); 23 OrderAndDetailsDto getOrdersByCondition(QueryOrderByConditionDto queryOrderDto);
23 OrderPageResult<OrderDto> getOrdersByPagination(QueryOrderByPaginationDto queryOrderDto); 24 OrderPageResult<OrderDto> getOrdersByPagination(QueryOrderByPaginationDto queryOrderDto);
25 + OrderPageResult<OrderDto> getRefundOrdersByPagination(
26 + QueryRefundOrderByPaginationDto queryOrderDto);
24 List<OrderDetailDto> getOrderDetailsByOrderId(Integer orderId); 27 List<OrderDetailDto> getOrderDetailsByOrderId(Integer orderId);
25 CreateOrderResponse createOrder(CreateOrderDto createOrderDto); 28 CreateOrderResponse createOrder(CreateOrderDto createOrderDto);
26 CreateOrderResponse orderCreation(OperatorCreateOrderDto createOrderDto); 29 CreateOrderResponse orderCreation(OperatorCreateOrderDto createOrderDto);
......
1 package com.infoloop.tianting.service; 1 package com.infoloop.tianting.service;
2 2
3 import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; 3 import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto;
4 +
4 import java.io.ByteArrayOutputStream; 5 import java.io.ByteArrayOutputStream;
5 6
6 public interface SettlementService { 7 public interface SettlementService {
......
1 package com.infoloop.tianting.service; 1 package com.infoloop.tianting.service;
2 2
3 -import com.infoloop.tianting.model.dto.SkuDbDTO.SkuDto;
4 import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto; 3 import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto;
5 import com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto; 4 import com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto;
6 -import java.util.List;
7 5
8 public interface WxMiniProgramService { 6 public interface WxMiniProgramService {
9 WxUserOpenIdDto getWxUserOpenIdByCode(String code); 7 WxUserOpenIdDto getWxUserOpenIdByCode(String code);
......
...@@ -66,6 +66,7 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto; ...@@ -66,6 +66,7 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto;
66 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailOperationDto; 66 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailOperationDto;
67 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; 67 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto;
68 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto; 68 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto;
69 +import com.infoloop.tianting.model.dto.OrderDbDTO.QueryRefundOrderByPaginationDto;
69 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto; 70 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto;
70 import com.infoloop.tianting.server.UserAuthData; 71 import com.infoloop.tianting.server.UserAuthData;
71 import com.infoloop.tianting.server.WebSocketServer; 72 import com.infoloop.tianting.server.WebSocketServer;
...@@ -186,7 +187,19 @@ public class OrderServiceRpcClient { ...@@ -186,7 +187,19 @@ public class OrderServiceRpcClient {
186 .setUpdateSource(updateOrderDto.getUpdatedSource()) 187 .setUpdateSource(updateOrderDto.getUpdatedSource())
187 .setModification(modification) 188 .setModification(modification)
188 .build(); 189 .build();
189 - return orderServiceRpcBlockingStub.updateClientCustomerOrder(request); 190 + final UpdateClientCustomerOrderRpcResponse updateClientCustomerOrderRpcResponse = orderServiceRpcBlockingStub.updateClientCustomerOrder(request);
191 + if (updateClientCustomerOrderRpcResponse.getIsUpdated() && updateOrderDto.getStatus() == OrderStatusEnum.ORDER_CANCELED) {
192 + final var orderById = getOrderById(updateOrderDto.getId());
193 + if (orderById != null && orderById.getCloseTimeType() == CloseTimeType.IMMEDIATELY) {
194 + final var orderDetails = getOrderDetailsByOrderId(orderById.getId());
195 + final var isSuccess = addSkusSellQuantities(orderById.getEnterpriseId(), orderById.getStallId(), orderDetails.stream().map(e -> AddSkusSellQuantityBO.builder()
196 + .skuId(e.getSkuId())
197 + .quantity(-e.getCount())
198 + .build()).collect(Collectors.toList()));
199 + log.info("Order {} returnSkusSellQuantities result: {}", orderById.getId(), isSuccess);
200 + }
201 + }
202 + return updateClientCustomerOrderRpcResponse;
190 } 203 }
191 204
192 public boolean updateClientCustomerOrderCancel(int enterpriseId, int id) { 205 public boolean updateClientCustomerOrderCancel(int enterpriseId, int id) {
...@@ -461,6 +474,8 @@ public class OrderServiceRpcClient { ...@@ -461,6 +474,8 @@ public class OrderServiceRpcClient {
461 .setKeyword(queryOrderDto.getKeyword() == null ? "" : queryOrderDto.getKeyword()) 474 .setKeyword(queryOrderDto.getKeyword() == null ? "" : queryOrderDto.getKeyword())
462 .setPageNo(queryOrderDto.getPn()) 475 .setPageNo(queryOrderDto.getPn())
463 .setPageSize(queryOrderDto.getPz()) 476 .setPageSize(queryOrderDto.getPz())
477 + .setShouldFilterStatus(true)
478 + .setShouldFilterPayStatus(false)
464 .setStatus(queryOrderDto.getStatus()) 479 .setStatus(queryOrderDto.getStatus())
465 .setEnterpriseId(queryOrderDto.getEnterpriseId()) 480 .setEnterpriseId(queryOrderDto.getEnterpriseId())
466 .setClientId(queryOrderDto.getClientId()) 481 .setClientId(queryOrderDto.getClientId())
...@@ -469,6 +484,22 @@ public class OrderServiceRpcClient { ...@@ -469,6 +484,22 @@ public class OrderServiceRpcClient {
469 return orderServiceRpcBlockingStub.queryClientCustomerOrdersByPagination(request); 484 return orderServiceRpcBlockingStub.queryClientCustomerOrdersByPagination(request);
470 } 485 }
471 486
487 + public QueryClientCustomerOrdersByPaginationRpcResponse queryRefundClientCustomerOrdersByPagination(
488 + QueryRefundOrderByPaginationDto queryOrderDto) {
489 + final var request = QueryClientCustomerOrdersByPaginationRpcRequest.newBuilder()
490 + .setKeyword(queryOrderDto.getKeyword() == null ? "" : queryOrderDto.getKeyword())
491 + .setPageNo(queryOrderDto.getPn())
492 + .setPageSize(queryOrderDto.getPz())
493 + .setShouldFilterStatus(false)
494 + .setShouldFilterPayStatus(true)
495 + .setPayStatus(PayStatusEnum.REFUND)
496 + .setEnterpriseId(queryOrderDto.getEnterpriseId())
497 + .setClientId(queryOrderDto.getClientId())
498 + .addAllStallIds(queryOrderDto.getStallIds())
499 + .build();
500 + return orderServiceRpcBlockingStub.queryClientCustomerOrdersByPagination(request);
501 + }
502 +
472 public List<SingleClientCustomerOrderDetailRpcResponse> getOrderDetailsByOrderId(Integer orderId) { 503 public List<SingleClientCustomerOrderDetailRpcResponse> getOrderDetailsByOrderId(Integer orderId) {
473 return orderServiceRpcBlockingStub.getClientCustomerOrderDetailsByOrderIds( 504 return orderServiceRpcBlockingStub.getClientCustomerOrderDetailsByOrderIds(
474 GetClientCustomerOrderDetailsByOrderIdsRpcRequest.newBuilder() 505 GetClientCustomerOrderDetailsByOrderIdsRpcRequest.newBuilder()
......
...@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
8 import com.fasterxml.jackson.databind.PropertyNamingStrategy; 8 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
9 import com.fasterxml.jackson.dataformat.xml.XmlMapper; 9 import com.fasterxml.jackson.dataformat.xml.XmlMapper;
10 import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderModification; 10 import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderModification;
11 +import com.infoloop.tianting.clientcustomerorderservice.OnlinePayEnum;
11 import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; 12 import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum;
12 import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; 13 import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum;
13 import com.infoloop.tianting.clientresourcetagservice.SingleResourceLabelEntityRefsResponse; 14 import com.infoloop.tianting.clientresourcetagservice.SingleResourceLabelEntityRefsResponse;
...@@ -16,6 +17,7 @@ import com.infoloop.tianting.context.LoginContextHolder; ...@@ -16,6 +17,7 @@ import com.infoloop.tianting.context.LoginContextHolder;
16 import com.infoloop.tianting.exception.ClientEndExceptions; 17 import com.infoloop.tianting.exception.ClientEndExceptions;
17 import com.infoloop.tianting.exception.ErrorCodeEnum; 18 import com.infoloop.tianting.exception.ErrorCodeEnum;
18 import com.infoloop.tianting.model.dto.PayDTO.PayInformRequestDto; 19 import com.infoloop.tianting.model.dto.PayDTO.PayInformRequestDto;
20 +import com.infoloop.tianting.model.dto.PayDTO.PayRefundRequestDto;
19 import com.infoloop.tianting.model.dto.PayDTO.PayResponseDto; 21 import com.infoloop.tianting.model.dto.PayDTO.PayResponseDto;
20 import com.infoloop.tianting.model.dto.PayDTO.ThirdPartyPayInformRequestDto; 22 import com.infoloop.tianting.model.dto.PayDTO.ThirdPartyPayInformRequestDto;
21 import com.infoloop.tianting.model.dto.PaymentCallbackDTO; 23 import com.infoloop.tianting.model.dto.PaymentCallbackDTO;
...@@ -34,6 +36,9 @@ import com.infoloop.tianting.utils.EncryptionUtil; ...@@ -34,6 +36,9 @@ import com.infoloop.tianting.utils.EncryptionUtil;
34 import com.infoloop.tianting.utils.JsonUtil; 36 import com.infoloop.tianting.utils.JsonUtil;
35 import lombok.RequiredArgsConstructor; 37 import lombok.RequiredArgsConstructor;
36 import lombok.extern.slf4j.Slf4j; 38 import lombok.extern.slf4j.Slf4j;
39 +import okhttp3.OkHttpClient;
40 +import org.apache.commons.codec.binary.Base64;
41 +import org.apache.commons.codec.digest.DigestUtils;
37 import org.springframework.beans.factory.annotation.Autowired; 42 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.http.HttpEntity; 43 import org.springframework.http.HttpEntity;
39 import org.springframework.http.HttpHeaders; 44 import org.springframework.http.HttpHeaders;
...@@ -45,6 +50,9 @@ import org.springframework.web.client.RestTemplate; ...@@ -45,6 +50,9 @@ import org.springframework.web.client.RestTemplate;
45 50
46 import java.io.IOException; 51 import java.io.IOException;
47 import java.math.BigDecimal; 52 import java.math.BigDecimal;
53 +import java.math.RoundingMode;
54 +import java.net.URLEncoder;
55 +import java.nio.charset.StandardCharsets;
48 import java.text.MessageFormat; 56 import java.text.MessageFormat;
49 import java.text.ParseException; 57 import java.text.ParseException;
50 import java.time.LocalDate; 58 import java.time.LocalDate;
...@@ -53,7 +61,6 @@ import java.util.ArrayList; ...@@ -53,7 +61,6 @@ import java.util.ArrayList;
53 import java.util.List; 61 import java.util.List;
54 import java.util.stream.Collectors; 62 import java.util.stream.Collectors;
55 63
56 -
57 @Slf4j 64 @Slf4j
58 @Service 65 @Service
59 @RequiredArgsConstructor(onConstructor = @__(@Autowired)) 66 @RequiredArgsConstructor(onConstructor = @__(@Autowired))
...@@ -71,9 +78,14 @@ public class PayServiceClient { ...@@ -71,9 +78,14 @@ public class PayServiceClient {
71 78
72 private final XmlMapper xmlMapper = new XmlMapper(); 79 private final XmlMapper xmlMapper = new XmlMapper();
73 80
81 + private final OkHttpClient client = new OkHttpClient();
82 +
74 public PayResponseDto payInform(PayInformRequestDto payRequestDto) { 83 public PayResponseDto payInform(PayInformRequestDto payRequestDto) {
75 - final var orderById = orderServiceRpcClient.getOrderById(Integer.valueOf(payRequestDto.getOrderId())); 84 + final var orderById =
76 - if (orderById == null || orderById.getPayStatus() == PayStatusEnum.PAY_CANCELED || orderById.getStatus() == OrderStatusEnum.ORDER_CANCELED) { 85 + orderServiceRpcClient.getOrderById(Integer.valueOf(payRequestDto.getOrderId()));
86 + if (orderById == null
87 + || orderById.getPayStatus() == PayStatusEnum.PAY_CANCELED
88 + || orderById.getStatus() == OrderStatusEnum.ORDER_CANCELED) {
77 log.info("Order {} not found or canceled, skipping.", payRequestDto.getOrderId()); 89 log.info("Order {} not found or canceled, skipping.", payRequestDto.getOrderId());
78 throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_CANCEL); 90 throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_CANCEL);
79 } 91 }
...@@ -93,11 +105,13 @@ public class PayServiceClient { ...@@ -93,11 +105,13 @@ public class PayServiceClient {
93 } 105 }
94 HttpEntity<String> requestEntity = new HttpEntity<>(jsonDataString, createHeaders()); 106 HttpEntity<String> requestEntity = new HttpEntity<>(jsonDataString, createHeaders());
95 log.info("payInform request: {}", jsonDataString); 107 log.info("payInform request: {}", jsonDataString);
96 - ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); 108 + ResponseEntity<String> responseEntity =
109 + restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
97 return processResponse(responseEntity); 110 return processResponse(responseEntity);
98 } 111 }
99 112
100 - private ThirdPartyPayInformRequestDto buildRequestData(PayInformRequestDto payRequestDto, String requestDate) { 113 + private ThirdPartyPayInformRequestDto buildRequestData(
114 + PayInformRequestDto payRequestDto, String requestDate) {
101 ThirdPartyPayInformRequestDto jsonData = new ThirdPartyPayInformRequestDto(); 115 ThirdPartyPayInformRequestDto jsonData = new ThirdPartyPayInformRequestDto();
102 jsonData.setClientId(businessConfig.getPayClientId()); 116 jsonData.setClientId(businessConfig.getPayClientId());
103 jsonData.setTradeId(payRequestDto.getOrderId()); 117 jsonData.setTradeId(payRequestDto.getOrderId());
...@@ -105,11 +119,16 @@ public class PayServiceClient { ...@@ -105,11 +119,16 @@ public class PayServiceClient {
105 jsonData.setRequestSource("OFWXApplet"); 119 jsonData.setRequestSource("OFWXApplet");
106 jsonData.setPayerOpenId(LoginContextHolder.getOpenId()); 120 jsonData.setPayerOpenId(LoginContextHolder.getOpenId());
107 jsonData.setHospitalCode(payRequestDto.getHospitalCode()); 121 jsonData.setHospitalCode(payRequestDto.getHospitalCode());
108 - jsonData.setPID(payRequestDto.getPhone()); 122 + jsonData.setPID(LoginContextHolder.getOpenId());
109 jsonData.setRemark(""); 123 jsonData.setRemark("");
110 jsonData.setTransAmount(payRequestDto.getPrice()); 124 jsonData.setTransAmount(payRequestDto.getPrice());
111 jsonData.setTradeDesc(""); 125 jsonData.setTradeDesc("");
112 - jsonData.setSign(EncryptionUtil.sha1Encryption(businessConfig.getPayClientId() + payRequestDto.getOrderId() + requestDate + businessConfig.getPayClientId())); 126 + jsonData.setSign(
127 + EncryptionUtil.sha1Encryption(
128 + businessConfig.getPayClientId()
129 + + payRequestDto.getOrderId()
130 + + requestDate
131 + + businessConfig.getPayClientId()));
113 return jsonData; 132 return jsonData;
114 } 133 }
115 134
...@@ -136,7 +155,8 @@ public class PayServiceClient { ...@@ -136,7 +155,8 @@ public class PayServiceClient {
136 public boolean callback(PaymentCallbackDTO paymentCallbackDTO) { 155 public boolean callback(PaymentCallbackDTO paymentCallbackDTO) {
137 log.info("callback request received: {}", paymentCallbackDTO); 156 log.info("callback request received: {}", paymentCallbackDTO);
138 try { 157 try {
139 - final var paymentCallbackResult = xmlMapper.readValue(paymentCallbackDTO.getPayResult(), PaymentCallbackResult.class); 158 + final var paymentCallbackResult =
159 + xmlMapper.readValue(paymentCallbackDTO.getPayResult(), PaymentCallbackResult.class);
140 log.info("Parsed paymentCallbackResult: {}", paymentCallbackResult); 160 log.info("Parsed paymentCallbackResult: {}", paymentCallbackResult);
141 final var orderId = Integer.parseInt(paymentCallbackResult.getTradeId()); 161 final var orderId = Integer.parseInt(paymentCallbackResult.getTradeId());
142 final var orderById = orderServiceRpcClient.getOrderById(orderId); 162 final var orderById = orderServiceRpcClient.getOrderById(orderId);
...@@ -144,13 +164,18 @@ public class PayServiceClient { ...@@ -144,13 +164,18 @@ public class PayServiceClient {
144 log.error("Order not found, orderId: {}", orderId); 164 log.error("Order not found, orderId: {}", orderId);
145 return false; 165 return false;
146 } 166 }
147 - if (orderById.getPayStatus() != PayStatusEnum.TO_PAY && orderById.getPayStatus() != PayStatusEnum.IN_PROGRESS) { 167 +
168 + final var transType = paymentCallbackResult.getTransType();
169 + if (transType.equals("00")) {
170 + if (orderById.getPayStatus() != PayStatusEnum.TO_PAY
171 + && orderById.getPayStatus() != PayStatusEnum.IN_PROGRESS) {
148 log.error("Order status is not TO_PAY or IN_PROGRESS, orderId: {}", orderId); 172 log.error("Order status is not TO_PAY or IN_PROGRESS, orderId: {}", orderId);
149 return true; 173 return true;
150 } 174 }
151 long payTime; 175 long payTime;
152 try { 176 try {
153 - payTime = DateUtil.parseDate(paymentCallbackResult.getTransDate(), "yyyyMMddHHmmss").getTime(); 177 + payTime =
178 + DateUtil.parseDate(paymentCallbackResult.getTransDate(), "yyyyMMddHHmmss").getTime();
154 } catch (ParseException e) { 179 } catch (ParseException e) {
155 log.error("Failed to parse TransDate: {}", paymentCallbackResult.getTransDate(), e); 180 log.error("Failed to parse TransDate: {}", paymentCallbackResult.getTransDate(), e);
156 throw new IllegalArgumentException("支付时间格式错误: " + paymentCallbackResult.getTransDate(), e); 181 throw new IllegalArgumentException("支付时间格式错误: " + paymentCallbackResult.getTransDate(), e);
...@@ -165,65 +190,107 @@ public class PayServiceClient { ...@@ -165,65 +190,107 @@ public class PayServiceClient {
165 log.error("Invalid RealAmount value: {}", paymentCallbackResult.getRealAmount(), e); 190 log.error("Invalid RealAmount value: {}", paymentCallbackResult.getRealAmount(), e);
166 throw new IllegalArgumentException("支付金额错误: " + paymentCallbackResult.getRealAmount(), e); 191 throw new IllegalArgumentException("支付金额错误: " + paymentCallbackResult.getRealAmount(), e);
167 } 192 }
168 - final var build = ClientCustomerOrderModification.newBuilder() 193 + final var build =
194 + ClientCustomerOrderModification.newBuilder()
169 .setId(orderId) 195 .setId(orderId)
170 - .setShouldUpdatePayTime(true).setPayTime(payTime) 196 + .setShouldUpdatePayTime(true)
171 - .setShouldUpdatePayPrice(true).setPayPrice(realAmount.multiply(new BigDecimal("100")).intValue()) 197 + .setPayTime(payTime)
172 - .setShouldUpdatePayStatus(true).setPayStatus(PayStatusEnum.SUCCEED) 198 + .setShouldUpdatePayPrice(true)
173 - .setShouldUpdateStatus(true).setStatus(OrderStatusEnum.PREPARING) 199 + .setPayPrice(realAmount.multiply(new BigDecimal("100")).intValue())
174 - .setShouldUpdateTransactionId(true).setTransactionId(paymentCallbackResult.getTransSN()) 200 + .setShouldUpdatePayStatus(true)
201 + .setPayStatus(PayStatusEnum.SUCCEED)
202 + .setShouldUpdateStatus(true)
203 + .setStatus(OrderStatusEnum.PREPARING)
204 + .setShouldUpdateTransactionId(true)
205 + .setTransactionId(paymentCallbackResult.getTransSN())
175 .build(); 206 .build();
176 - final var updateResponse = orderServiceRpcClient.updateClientCustomerOrderPaymentResult(orderById, build); 207 + final var updateResponse =
208 + orderServiceRpcClient.updateClientCustomerOrderPaymentResult(orderById, build);
177 log.info("callback updateClientCustomerOrder result: {}", updateResponse.getIsUpdated()); 209 log.info("callback updateClientCustomerOrder result: {}", updateResponse.getIsUpdated());
178 if (updateResponse.getIsUpdated()) { 210 if (updateResponse.getIsUpdated()) {
179 - final var orderPaymentSuccessData = OrderPaymentSuccessData.builder() 211 + final var orderPaymentSuccessData =
212 + OrderPaymentSuccessData.builder()
180 .orderId(orderById.getId()) 213 .orderId(orderById.getId())
181 .orderCode(orderById.getOrderCode()) 214 .orderCode(orderById.getOrderCode())
182 .createTime(DateUtil.formatDate(orderById.getCreatedAt(), DateUtil.Y_M_D_H_M_S)) 215 .createTime(DateUtil.formatDate(orderById.getCreatedAt(), DateUtil.Y_M_D_H_M_S))
183 .payTime(DateUtil.formatDate(orderById.getPayTime(), DateUtil.Y_M_D_H_M_S)) 216 .payTime(DateUtil.formatDate(orderById.getPayTime(), DateUtil.Y_M_D_H_M_S))
184 .build(); 217 .build();
185 - final var data = SocketMessage.<OrderPaymentSuccessData>builder() 218 + final var data =
219 + SocketMessage.<OrderPaymentSuccessData>builder()
186 .type(MessageTypeEnum.ORDER) 220 .type(MessageTypeEnum.ORDER)
187 .noticeType(NoticeTypeEnum.ORDER_PAYMENT_SUCCESS) 221 .noticeType(NoticeTypeEnum.ORDER_PAYMENT_SUCCESS)
188 .subject(NoticeTypeEnum.ORDER_PAYMENT_SUCCESS.getDescription()) 222 .subject(NoticeTypeEnum.ORDER_PAYMENT_SUCCESS.getDescription())
189 .message("您的订单:" + orderById.getOrderCode() + " 支付成功啦,快去查看吧~") 223 .message("您的订单:" + orderById.getOrderCode() + " 支付成功啦,快去查看吧~")
190 .data(orderPaymentSuccessData) 224 .data(orderPaymentSuccessData)
191 .build(); 225 .build();
192 - WebSocketServer.sendMessageToUser(UserSessionKey.builder() 226 + WebSocketServer.sendMessageToUser(
227 + UserSessionKey.builder()
193 .userId(orderById.getOpenId()) 228 .userId(orderById.getOpenId())
194 .userType(UserTypeEnum.MICRO) 229 .userType(UserTypeEnum.MICRO)
195 - .build(), data); 230 + .build(),
231 + data);
196 if (LocalDate.now().equals(DateUtil.toLocalDate(orderById.getMealTime()))) { 232 if (LocalDate.now().equals(DateUtil.toLocalDate(orderById.getMealTime()))) {
197 - final var orderCreateSuccessData = OrderCreateSuccessData.builder() 233 + final var orderCreateSuccessData =
198 - .orderId(orderById.getId()) 234 + OrderCreateSuccessData.builder().orderId(orderById.getId()).build();
199 - .build(); 235 + final var createOrderData =
200 - final var createOrderData = SocketMessage.<OrderCreateSuccessData>builder() 236 + SocketMessage.<OrderCreateSuccessData>builder()
201 .type(MessageTypeEnum.ORDER) 237 .type(MessageTypeEnum.ORDER)
202 .noticeType(NoticeTypeEnum.ORDER_CREATED) 238 .noticeType(NoticeTypeEnum.ORDER_CREATED)
203 .subject(NoticeTypeEnum.ORDER_CREATED.getDescription()) 239 .subject(NoticeTypeEnum.ORDER_CREATED.getDescription())
204 .message("有新的订单下单成功啦,快去查看吧~") 240 .message("有新的订单下单成功啦,快去查看吧~")
205 .data(orderCreateSuccessData) 241 .data(orderCreateSuccessData)
206 .build(); 242 .build();
207 - final var clientOperatorIds = clientResourceTagServiceRpcClient.getOperatorIdsByStallIds(List.of(orderById.getStallId())).stream().map(SingleResourceLabelEntityRefsResponse::getEntityId).distinct().collect(Collectors.toList()); 243 + final var clientOperatorIds =
208 - final var enterpriseOperatorIds = enterpriseResourceServiceRpcClient.getOperatorIdsByStallId(orderById.getEnterpriseId(), orderById.getStallId()); 244 + clientResourceTagServiceRpcClient
245 + .getOperatorIdsByStallIds(List.of(orderById.getStallId())).stream()
246 + .map(SingleResourceLabelEntityRefsResponse::getEntityId)
247 + .distinct()
248 + .collect(Collectors.toList());
249 + final var enterpriseOperatorIds =
250 + enterpriseResourceServiceRpcClient.getOperatorIdsByStallId(
251 + orderById.getEnterpriseId(), orderById.getStallId());
209 final var userAuthData = new ArrayList<UserAuthData>(); 252 final var userAuthData = new ArrayList<UserAuthData>();
210 - userAuthData.addAll(clientOperatorIds.stream().map(e -> UserAuthData.builder().operatorId(e).userType(UserTypeEnum.CLIENT).build()).collect(Collectors.toList())); 253 + userAuthData.addAll(
211 - userAuthData.addAll(enterpriseOperatorIds.stream().map(e -> UserAuthData.builder().operatorId(e).userType(UserTypeEnum.KDS).build()).collect(Collectors.toList())); 254 + clientOperatorIds.stream()
255 + .map(
256 + e ->
257 + UserAuthData.builder()
258 + .operatorId(e)
259 + .userType(UserTypeEnum.CLIENT)
260 + .build())
261 + .collect(Collectors.toList()));
262 + userAuthData.addAll(
263 + enterpriseOperatorIds.stream()
264 + .map(e -> UserAuthData.builder().operatorId(e).userType(UserTypeEnum.KDS).build())
265 + .collect(Collectors.toList()));
212 log.info("received userAuthData:{}", JsonUtil.writeAsJson(userAuthData)); 266 log.info("received userAuthData:{}", JsonUtil.writeAsJson(userAuthData));
213 try { 267 try {
214 - WebSocketServer.sendMessageByUserTypes(List.of(UserTypeEnum.CLIENT, UserTypeEnum.KDS), userAuthData, createOrderData); 268 + WebSocketServer.sendMessageByUserTypes(
269 + List.of(UserTypeEnum.CLIENT, UserTypeEnum.KDS), userAuthData, createOrderData);
215 } catch (IOException e) { 270 } catch (IOException e) {
216 log.error("Failed to send message to user", e); 271 log.error("Failed to send message to user", e);
217 } 272 }
218 } 273 }
219 } 274 }
220 return updateResponse.getIsUpdated(); 275 return updateResponse.getIsUpdated();
276 + } else {
277 + final var build =
278 + ClientCustomerOrderModification.newBuilder()
279 + .setId(orderId)
280 + .setShouldUpdatePayStatus(true)
281 + .setPayStatus(PayStatusEnum.REFUND)
282 + .build();
283 + final var updateResponse =
284 + orderServiceRpcClient.updateClientCustomerOrderPaymentResult(orderById, build);
285 + log.info("callback updateClientCustomerOrder result: {}", updateResponse.getIsUpdated());
286 + return updateResponse.getIsUpdated();
287 + }
221 } catch (JsonProcessingException e) { 288 } catch (JsonProcessingException e) {
222 log.error("Failed to parse XML response, raw XML: {}", paymentCallbackDTO.getPayResult(), e); 289 log.error("Failed to parse XML response, raw XML: {}", paymentCallbackDTO.getPayResult(), e);
223 - throw new RuntimeException("支付通知结果解析失败", e); 290 + throw new RuntimeException("支付/退款通知结果解析失败", e);
224 } catch (Exception e) { 291 } catch (Exception e) {
225 log.error("Unexpected error in callback, request: {}", paymentCallbackDTO, e); 292 log.error("Unexpected error in callback, request: {}", paymentCallbackDTO, e);
226 - throw new RuntimeException("支付通知处理失败", e); 293 + throw new RuntimeException("支付/退款通知处理失败", e);
227 } 294 }
228 } 295 }
229 296
...@@ -237,12 +304,98 @@ public class PayServiceClient { ...@@ -237,12 +304,98 @@ public class PayServiceClient {
237 log.info("waiting Order {} already processed, skipping.", orderId); 304 log.info("waiting Order {} already processed, skipping.", orderId);
238 return false; 305 return false;
239 } 306 }
240 - final var build = ClientCustomerOrderModification.newBuilder() 307 + final var build =
308 + ClientCustomerOrderModification.newBuilder()
241 .setId(orderId) 309 .setId(orderId)
242 - .setShouldUpdatePayStatus(true).setPayStatus(PayStatusEnum.IN_PROGRESS) 310 + .setShouldUpdatePayStatus(true)
311 + .setPayStatus(PayStatusEnum.IN_PROGRESS)
243 .build(); 312 .build();
244 - final var updateResponse = orderServiceRpcClient.updateClientCustomerOrderPaymentResult(orderById, build); 313 + final var updateResponse =
314 + orderServiceRpcClient.updateClientCustomerOrderPaymentResult(orderById, build);
245 log.info("waiting updateClientCustomerOrder result: {}", updateResponse.getIsUpdated()); 315 log.info("waiting updateClientCustomerOrder result: {}", updateResponse.getIsUpdated());
246 return updateResponse.getIsUpdated(); 316 return updateResponse.getIsUpdated();
247 } 317 }
318 +
319 + public String orderPayRefund(PayRefundRequestDto payRefundRequestDto) {
320 + Integer orderId = payRefundRequestDto.getOrderId();
321 + final var orderById = orderServiceRpcClient.getOrderById(orderId);
322 + if (orderById == null) {
323 + log.error("Order not found, orderId: {}", orderId);
324 + throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_NOT_FOUND);
325 + }
326 + if (orderById.getOnlinePay() != OnlinePayEnum.ONLINE) {
327 + log.info("Order {} is not online pay.", orderId);
328 + throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_NOT_ONLINE_PAY);
329 + }
330 + if (orderById.getPayStatus() != PayStatusEnum.SUCCEED) {
331 + log.info("Order {} pay is not succeed.", orderId);
332 + throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_NOT_SUCCESS);
333 + }
334 + LocalDate today = LocalDate.now();
335 + LocalDate tomorrow = today.plusDays(1);
336 + LocalDateTime tomorrowZero = tomorrow.atStartOfDay();
337 + LocalDateTime orderPayTime = DateUtil.toLocalDateTime(orderById.getPayTime()).minusHours(8);
338 + if (!orderPayTime.isBefore(tomorrowZero)) {
339 + log.info("Order {} pay is beyond cancel time.", orderId);
340 + throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_PAY_REFUND_FAILED);
341 + }
342 +
343 + String appId = businessConfig.getPayClientId();
344 +
345 + // 构建paycontent
346 + String payTime = DateUtil.formatDate(orderById.getPayTime(), DateUtil.YMDHMS);
347 +
348 + BigDecimal price =
349 + new BigDecimal(orderById.getPayPrice())
350 + .divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).negate();
351 +
352 + String payContentStr =
353 + orderById.getId()
354 + + "^"
355 + + "01"
356 + + "^"
357 + + ""
358 + + "^"
359 + + orderById.getOpenId()
360 + + "^"
361 + + orderById.getOrderCode()
362 + + "^"
363 + + price
364 + + "^"
365 + + payTime
366 + + "^"
367 + + orderById.getTransactionId()
368 + + "^"
369 + + payRefundRequestDto.getHospitalCode()
370 + + "^"
371 + + ""
372 + + "^"
373 + + LoginContextHolder.getId()
374 + + "^"
375 + + LoginContextHolder.getName();
376 + String payContent =
377 + URLEncoder.encode(
378 + Base64.encodeBase64String(payContentStr.getBytes()), StandardCharsets.UTF_8);
379 +
380 + // 构建signinfo
381 + String signInfoStr = appId + orderById.getId() + payTime + businessConfig.getRefundSecurityKey();
382 + String signInfo = DigestUtils.sha1Hex(signInfoStr.getBytes());
383 +
384 + // 构建请求
385 + try {
386 + String url = businessConfig.getCancelPayUrl() + "?" + "appid=" + appId + "&paycontent=" + payContent + "&signinfo=" + signInfo;
387 + log.info("cancel order pay url:" + url);
388 +// Request request =
389 +// new Request.Builder().url(url).get().build();
390 +// Response payResponse = client.newCall(request).execute();
391 +// if (payResponse.code() != 200) {
392 +// throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_PAY_REFUND_FAILED);
393 +// }
394 +// String htmlContent = payResponse.body().string();
395 + return url;
396 + } catch (Exception e) {
397 + log.error(e.getMessage());
398 + throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_PAY_REFUND_FAILED);
399 + }
400 + }
248 } 401 }
......
...@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
18 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
20 20
21 +import java.util.ArrayList;
21 import java.util.List; 22 import java.util.List;
22 import java.util.stream.Collectors; 23 import java.util.stream.Collectors;
23 24
...@@ -70,8 +71,10 @@ public class MenuServiceImpl implements MenuService { ...@@ -70,8 +71,10 @@ public class MenuServiceImpl implements MenuService {
70 @Override 71 @Override
71 public List<MenuDto> queryPublishedMenusByStallId(Integer enterpriseId, List<Integer> stallIds) { 72 public List<MenuDto> queryPublishedMenusByStallId(Integer enterpriseId, List<Integer> stallIds) {
72 final var response = menuServiceRpcClient.queryPublishedMenusByStallId(enterpriseId, stallIds); 73 final var response = menuServiceRpcClient.queryPublishedMenusByStallId(enterpriseId, stallIds);
73 - return response.getResponsesList().stream().map(menu -> 74 + return new ArrayList<>(response.getResponsesList().stream()
74 - MenuDto.builder() 75 + .collect(Collectors.toMap(
76 + SingleMenuRpcResponse::getId,
77 + menu -> MenuDto.builder()
75 .id(menu.getId()) 78 .id(menu.getId())
76 .code(menu.getCode()) 79 .code(menu.getCode())
77 .enterpriseId(menu.getEnterpriseId()) 80 .enterpriseId(menu.getEnterpriseId())
...@@ -103,7 +106,10 @@ public class MenuServiceImpl implements MenuService { ...@@ -103,7 +106,10 @@ public class MenuServiceImpl implements MenuService {
103 .updateSource(menu.getUpdateSource()) 106 .updateSource(menu.getUpdateSource())
104 .updatedAt(DateUtil.formatDate(menu.getUpdatedAt())) 107 .updatedAt(DateUtil.formatDate(menu.getUpdatedAt()))
105 .publishAt(DateUtil.formatDate(menu.getPublishAt())) 108 .publishAt(DateUtil.formatDate(menu.getPublishAt()))
106 - .build()).collect(Collectors.toList()); 109 + .build(),
110 + (existing, replacement) -> existing
111 + ))
112 + .values());
107 } 113 }
108 114
109 @Override 115 @Override
......
...@@ -7,6 +7,7 @@ import com.infoloop.tianting.clientcustomerorderservice.CloseTimeType; ...@@ -7,6 +7,7 @@ import com.infoloop.tianting.clientcustomerorderservice.CloseTimeType;
7 import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; 7 import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum;
8 import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; 8 import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum;
9 import com.infoloop.tianting.clientcustomerorderservice.OrderTypeEnum; 9 import com.infoloop.tianting.clientcustomerorderservice.OrderTypeEnum;
10 +import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse;
10 import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; 11 import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse;
11 import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerLabelRefRpcResponse; 12 import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerLabelRefRpcResponse;
12 import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse; 13 import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse;
...@@ -37,6 +38,7 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto; ...@@ -37,6 +38,7 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto;
37 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDto; 38 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderDto;
38 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; 39 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto;
39 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto; 40 import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto;
41 +import com.infoloop.tianting.model.dto.OrderDbDTO.QueryRefundOrderByPaginationDto;
40 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto; 42 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto;
41 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderResponse; 43 import com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderResponse;
42 import com.infoloop.tianting.model.dto.OrderDbDTO.getMenuOrderCountDto; 44 import com.infoloop.tianting.model.dto.OrderDbDTO.getMenuOrderCountDto;
...@@ -56,6 +58,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -56,6 +58,7 @@ import org.springframework.beans.factory.annotation.Autowired;
56 import org.springframework.stereotype.Service; 58 import org.springframework.stereotype.Service;
57 59
58 import java.util.ArrayList; 60 import java.util.ArrayList;
61 +import java.util.Arrays;
59 import java.util.List; 62 import java.util.List;
60 import java.util.stream.Collectors; 63 import java.util.stream.Collectors;
61 import java.util.stream.Stream; 64 import java.util.stream.Stream;
...@@ -318,6 +321,7 @@ public class OrderServiceImpl implements OrderService { ...@@ -318,6 +321,7 @@ public class OrderServiceImpl implements OrderService {
318 .updateSource(r.getUpdateSource().getNumber()) 321 .updateSource(r.getUpdateSource().getNumber())
319 .updatedAt(DateUtil.formatDate(r.getUpdatedAt())) 322 .updatedAt(DateUtil.formatDate(r.getUpdatedAt()))
320 .updatedBy(r.getUpdatedBy()) 323 .updatedBy(r.getUpdatedBy())
324 + .isCanceled(r.getIsCanceled())
321 .build()).collect(Collectors.toList()); 325 .build()).collect(Collectors.toList());
322 final var ids = orders.stream().map(OrderDto::getId).collect(Collectors.toList()); 326 final var ids = orders.stream().map(OrderDto::getId).collect(Collectors.toList());
323 final var detailsResponse = orderServiceRpcClient.getOrderDetailsByOrderIds(ids); 327 final var detailsResponse = orderServiceRpcClient.getOrderDetailsByOrderIds(ids);
...@@ -391,6 +395,7 @@ public class OrderServiceImpl implements OrderService { ...@@ -391,6 +395,7 @@ public class OrderServiceImpl implements OrderService {
391 .updateSource(r.getUpdateSource().getNumber()) 395 .updateSource(r.getUpdateSource().getNumber())
392 .updatedAt(DateUtil.formatDate(r.getUpdatedAt())) 396 .updatedAt(DateUtil.formatDate(r.getUpdatedAt()))
393 .updatedBy(r.getUpdatedBy()) 397 .updatedBy(r.getUpdatedBy())
398 + .isCanceled(r.getIsCanceled())
394 .build()).collect(Collectors.toList()); 399 .build()).collect(Collectors.toList());
395 final var ids = orders.stream().map(OrderDto::getId).collect(Collectors.toList()); 400 final var ids = orders.stream().map(OrderDto::getId).collect(Collectors.toList());
396 final var detailsResponse = orderServiceRpcClient.getOrderDetailsByOrderIds(ids); 401 final var detailsResponse = orderServiceRpcClient.getOrderDetailsByOrderIds(ids);
...@@ -437,7 +442,28 @@ public class OrderServiceImpl implements OrderService { ...@@ -437,7 +442,28 @@ public class OrderServiceImpl implements OrderService {
437 final var customerIds = response.getResponsesList().stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); 442 final var customerIds = response.getResponsesList().stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList());
438 final var customerResponse = clientCustomerServiceRpcClient.getClientCustomersByIds( 443 final var customerResponse = clientCustomerServiceRpcClient.getClientCustomersByIds(
439 queryOrderDto.getEnterpriseId(), customerIds); 444 queryOrderDto.getEnterpriseId(), customerIds);
440 - final var results = response.getResponsesList().stream().map(r -> OrderDto.builder() 445 + final var orderIds = response.getResponsesList().stream().map(SingleClientCustomerOrderRpcResponse::getId).collect(Collectors.toList());
446 + final var orderDetails = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds);
447 + final var results = response.getResponsesList().stream().map(r -> {
448 + final var curOrderDetails = orderDetails.stream().filter(d ->
449 + d.getOrderId() == r.getId()).collect(Collectors.toList());
450 + List<String> orderNotice = new ArrayList<>();
451 + for (SingleClientCustomerOrderDetailRpcResponse detail: curOrderDetails) {
452 + final var avoids = detail.getMealDetailJson().getAvoidsList();
453 + final var existAvoids = r.getCustomerNoticeJson().getAvoidsList().stream().anyMatch(avoids::contains);
454 + if (existAvoids) {
455 + orderNotice.add("忌口冲突");
456 + break;
457 + }
458 + }
459 + String[] keywords = {"禁食", "禁水", "禁食水"};
460 + final var result = Arrays.stream(keywords)
461 + .filter(keyword -> r.getCustomerNoticeJson().getDoctorsList().stream().anyMatch(str -> str.contains(keyword)))
462 + .findFirst();
463 + if (result.isPresent()) {
464 + orderNotice.add("医嘱包含" + result.get());
465 + }
466 + return OrderDto.builder()
441 .id(r.getId()) 467 .id(r.getId())
442 .enterpriseId(r.getEnterpriseId()) 468 .enterpriseId(r.getEnterpriseId())
443 .clientId(r.getClientId()) 469 .clientId(r.getClientId())
...@@ -472,19 +498,102 @@ public class OrderServiceImpl implements OrderService { ...@@ -472,19 +498,102 @@ public class OrderServiceImpl implements OrderService {
472 .updatedBy(r.getUpdatedBy()) 498 .updatedBy(r.getUpdatedBy())
473 .closeTimeType(r.getCloseTimeTypeValue()) 499 .closeTimeType(r.getCloseTimeTypeValue())
474 .totalNum(r.getTotalNum()) 500 .totalNum(r.getTotalNum())
501 + .isCanceled(r.getIsCanceled())
475 .customer(getCustomerDetail(r.getCustomerId(), customerResponse.getResponsesList())) 502 .customer(getCustomerDetail(r.getCustomerId(), customerResponse.getResponsesList()))
476 - .build()).collect(Collectors.toList()); 503 + .orderNotice(orderNotice)
504 + .build();
505 + }).collect(Collectors.toList());
477 final var orderCountByStatus = OrderCountByStatusDto.builder() 506 final var orderCountByStatus = OrderCountByStatusDto.builder()
478 .allServedCount(response.getCountByStatus().getAllServedCount()) 507 .allServedCount(response.getCountByStatus().getAllServedCount())
479 .canceledCount(response.getCountByStatus().getCanceledCount()) 508 .canceledCount(response.getCountByStatus().getCanceledCount())
480 .preparingCount(response.getCountByStatus().getPreparingCount()) 509 .preparingCount(response.getCountByStatus().getPreparingCount())
481 .toPrepareCount(response.getCountByStatus().getToPrepareCount()) 510 .toPrepareCount(response.getCountByStatus().getToPrepareCount())
482 .unknownCount(response.getCountByStatus().getUnknownCount()) 511 .unknownCount(response.getCountByStatus().getUnknownCount())
512 + .refundCount(response.getCountByStatus().getRefundCount())
483 .build(); 513 .build();
484 return PageUtil.from(results, response.getTotal(), response.getPages(), 514 return PageUtil.from(results, response.getTotal(), response.getPages(),
485 queryOrderDto.getPn(), queryOrderDto.getPz(), orderCountByStatus); 515 queryOrderDto.getPn(), queryOrderDto.getPz(), orderCountByStatus);
486 } 516 }
487 517
518 + @Override
519 + public OrderPageResult<OrderDto> getRefundOrdersByPagination(
520 + QueryRefundOrderByPaginationDto queryOrderDto) {
521 + final var response = orderServiceRpcClient.queryRefundClientCustomerOrdersByPagination(queryOrderDto);
522 + final var customerIds = response.getResponsesList().stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList());
523 + final var customerResponse = clientCustomerServiceRpcClient.getClientCustomersByIds(
524 + queryOrderDto.getEnterpriseId(), customerIds);
525 + final var orderIds = response.getResponsesList().stream().map(SingleClientCustomerOrderRpcResponse::getId).collect(Collectors.toList());
526 + final var orderDetails = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds);
527 + final var results = response.getResponsesList().stream().map(r -> {
528 + final var curOrderDetails = orderDetails.stream().filter(d ->
529 + d.getOrderId() == r.getId()).collect(Collectors.toList());
530 + List<String> orderNotice = new ArrayList<>();
531 + for (SingleClientCustomerOrderDetailRpcResponse detail: curOrderDetails) {
532 + final var avoids = detail.getMealDetailJson().getAvoidsList();
533 + final var existAvoids = r.getCustomerNoticeJson().getAvoidsList().stream().anyMatch(avoids::contains);
534 + if (existAvoids) {
535 + orderNotice.add("忌口冲突");
536 + break;
537 + }
538 + }
539 + String[] keywords = {"禁食", "禁水", "禁食水"};
540 + final var result = Arrays.stream(keywords)
541 + .filter(keyword -> r.getCustomerNoticeJson().getDoctorsList().stream().anyMatch(str -> str.contains(keyword)))
542 + .findFirst();
543 + if (result.isPresent()) {
544 + orderNotice.add("医嘱包含" + result.get());
545 + }
546 + return OrderDto.builder()
547 + .id(r.getId())
548 + .enterpriseId(r.getEnterpriseId())
549 + .clientId(r.getClientId())
550 + .stallId(r.getStallId())
551 + .customerId(r.getCustomerId())
552 + .openId(r.getOpenId())
553 + .address(r.getAddress())
554 + .orderCode(r.getOrderCode())
555 + .menuId(r.getMenuId())
556 + .pickupCode(r.getPickupCode())
557 + .tableCode(r.getTableCode())
558 + .roomNo(r.getSyncRoomNo().isEmpty() ? r.getRoomNo() : r.getSyncRoomNo())
559 + .adjustRoomNo(!r.getSyncRoomNo().isEmpty())
560 + .status(r.getStatus())
561 + .customerNoticeJson(CustomerNotice.builder()
562 + .avoids(r.getCustomerNoticeJson().getAvoidsList())
563 + .doctors(r.getCustomerNoticeJson().getDoctorsList()).build())
564 + .onlinePay(r.getOnlinePay())
565 + .payStatus(r.getPayStatusValue())
566 + .payPrice(r.getPayPrice())
567 + .payTime(DateUtil.formatDate(r.getPayTime()))
568 + .mealTime(DateUtil.formatDate(r.getMealTime()))
569 + .orderType(r.getOrderTypeValue())
570 + .remark(r.getRemark())
571 + .isDeleted(r.getIsDeleted())
572 + .isRead(r.getIsRead())
573 + .creationSource(r.getCreationSource().getNumber())
574 + .createdBy(r.getCreatedBy())
575 + .createdAt(DateUtil.formatDate(r.getCreatedAt()))
576 + .updateSource(r.getUpdateSource().getNumber())
577 + .updatedAt(DateUtil.formatDate(r.getUpdatedAt()))
578 + .updatedBy(r.getUpdatedBy())
579 + .closeTimeType(r.getCloseTimeTypeValue())
580 + .totalNum(r.getTotalNum())
581 + .isCanceled(r.getIsCanceled())
582 + .customer(getCustomerDetail(r.getCustomerId(), customerResponse.getResponsesList()))
583 + .orderNotice(orderNotice)
584 + .build();
585 + }).collect(Collectors.toList());
586 + final var orderCountByStatus = OrderCountByStatusDto.builder()
587 + .allServedCount(response.getCountByStatus().getAllServedCount())
588 + .canceledCount(response.getCountByStatus().getCanceledCount())
589 + .preparingCount(response.getCountByStatus().getPreparingCount())
590 + .toPrepareCount(response.getCountByStatus().getToPrepareCount())
591 + .unknownCount(response.getCountByStatus().getUnknownCount())
592 + .refundCount(response.getCountByStatus().getRefundCount())
593 + .build();
594 + return PageUtil.from(results, response.getTotal(), response.getPages(),
595 + queryOrderDto.getPn(), queryOrderDto.getPz(), orderCountByStatus);
596 + }
488 private CustomerDetailDto getCustomerDetail(Integer customerId, 597 private CustomerDetailDto getCustomerDetail(Integer customerId,
489 List<SingleClientCustomerRpcResponse> customers) { 598 List<SingleClientCustomerRpcResponse> customers) {
490 final var filterCustomers = customers.stream().filter(c -> c.getId() == customerId) 599 final var filterCustomers = customers.stream().filter(c -> c.getId() == customerId)
......
...@@ -65,7 +65,7 @@ public class SkuServiceImpl implements SkuService { ...@@ -65,7 +65,7 @@ public class SkuServiceImpl implements SkuService {
65 .efficacyList(sku.getEfficaciesList().stream().map(efficacy -> SkuDetailSingleResponseDto.builder().id(efficacy.getId()).name(efficacy.getName()).build()).collect( 65 .efficacyList(sku.getEfficaciesList().stream().map(efficacy -> SkuDetailSingleResponseDto.builder().id(efficacy.getId()).name(efficacy.getName()).build()).collect(
66 Collectors.toList())) 66 Collectors.toList()))
67 .doctorList(sku.getDoctorsList().stream().map(doctor -> SkuSpecialDetailSingleResponseDto 67 .doctorList(sku.getDoctorsList().stream().map(doctor -> SkuSpecialDetailSingleResponseDto
68 - .builder().id(doctor.getId()).name(doctor.getName()).build()).collect( 68 + .builder().id(doctor.getId()).code(doctor.getCode()).name(doctor.getName()).build()).collect(
69 Collectors.toList())) 69 Collectors.toList()))
70 .avoidList(sku.getAvoidsList().stream().map(avoid -> SkuDetailSingleResponseDto.builder().id(avoid.getId()).name(avoid.getName()).build()).collect( 70 .avoidList(sku.getAvoidsList().stream().map(avoid -> SkuDetailSingleResponseDto.builder().id(avoid.getId()).name(avoid.getName()).build()).collect(
71 Collectors.toList())) 71 Collectors.toList()))
......
...@@ -158,4 +158,8 @@ public final class DateUtil extends DateUtils { ...@@ -158,4 +158,8 @@ public final class DateUtil extends DateUtils {
158 return Instant.ofEpochMilli(timestamp).atZone(CHINA_ZONE).toLocalDate(); 158 return Instant.ofEpochMilli(timestamp).atZone(CHINA_ZONE).toLocalDate();
159 } 159 }
160 160
161 + public static LocalDateTime toLocalDateTime(long timestamp) {
162 + return Instant.ofEpochMilli(timestamp).atZone(CHINA_ZONE).toLocalDateTime();
163 + }
164 +
161 } 165 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -74,6 +74,7 @@ enum PayStatusEnum { ...@@ -74,6 +74,7 @@ enum PayStatusEnum {
74 SUCCEED = 3; 74 SUCCEED = 3;
75 FAILED = 4; 75 FAILED = 4;
76 PAY_CANCELED = 5; 76 PAY_CANCELED = 5;
77 + REFUND = 6;
77 } 78 }
78 79
79 enum CloseTimeType { 80 enum CloseTimeType {
...@@ -139,6 +140,7 @@ message SingleClientCustomerOrderRpcResponse { ...@@ -139,6 +140,7 @@ message SingleClientCustomerOrderRpcResponse {
139 bool isConfirm = 34; 140 bool isConfirm = 34;
140 bool isAllocation = 35; 141 bool isAllocation = 35;
141 string syncRoomNo = 36; 142 string syncRoomNo = 36;
143 + bool isCanceled = 37;
142 } 144 }
143 145
144 message GetClientCustomerOrderByIdRpcRequest { 146 message GetClientCustomerOrderByIdRpcRequest {
...@@ -173,12 +175,15 @@ message GetClientCustomerOrdersByCustomerIdRpcResponse { ...@@ -173,12 +175,15 @@ message GetClientCustomerOrdersByCustomerIdRpcResponse {
173 175
174 message QueryClientCustomerOrdersByPaginationRpcRequest { 176 message QueryClientCustomerOrdersByPaginationRpcRequest {
175 string keyword = 1; 177 string keyword = 1;
176 - OrderStatusEnum status = 2; 178 + bool shouldFilterStatus = 2;
177 - int32 clientId = 3; 179 + OrderStatusEnum status = 3;
178 - int32 enterpriseId = 4; 180 + int32 clientId = 4;
179 - int32 pageNo = 5; 181 + int32 enterpriseId = 5;
180 - int32 pageSize = 6; 182 + int32 pageNo = 6;
181 - repeated int32 stallIds = 7; 183 + int32 pageSize = 7;
184 + repeated int32 stallIds = 8;
185 + bool shouldFilterPayStatus = 9;
186 + PayStatusEnum payStatus = 10;
182 } 187 }
183 188
184 message OrderCountByStatus { 189 message OrderCountByStatus {
...@@ -187,6 +192,7 @@ message OrderCountByStatus { ...@@ -187,6 +192,7 @@ message OrderCountByStatus {
187 int32 preparingCount = 3; 192 int32 preparingCount = 3;
188 int32 allServedCount = 4; 193 int32 allServedCount = 4;
189 int32 canceledCount = 5; 194 int32 canceledCount = 5;
195 + int32 refundCount = 6;
190 } 196 }
191 197
192 message QueryClientCustomerOrdersByPaginationRpcResponse { 198 message QueryClientCustomerOrdersByPaginationRpcResponse {
...@@ -246,6 +252,8 @@ message QueryClientCustomerOrdersByConditionRpcRequest { ...@@ -246,6 +252,8 @@ message QueryClientCustomerOrdersByConditionRpcRequest {
246 bool isAllocation = 47; 252 bool isAllocation = 47;
247 bool shouldFilterStatues = 48; 253 bool shouldFilterStatues = 48;
248 repeated OrderStatusEnum statues = 49; 254 repeated OrderStatusEnum statues = 49;
255 + bool shouldFilterIsCanceled = 50;
256 + bool isCanceled = 51;
249 } 257 }
250 258
251 message QueryClientCustomerOrdersByConditionRpcResponse { 259 message QueryClientCustomerOrdersByConditionRpcResponse {
...@@ -375,6 +383,8 @@ message ClientCustomerOrderModification { ...@@ -375,6 +383,8 @@ message ClientCustomerOrderModification {
375 bool isAllocation = 53; 383 bool isAllocation = 53;
376 bool shouldUpdateSyncRoomNo = 54; 384 bool shouldUpdateSyncRoomNo = 54;
377 string syncRoomNo = 55; 385 string syncRoomNo = 55;
386 + bool shouldUpdateIsCanceled = 56;
387 + bool isCanceled = 57;
378 } 388 }
379 389
380 message UpdateClientCustomerOrderRpcRequest { 390 message UpdateClientCustomerOrderRpcRequest {
......
...@@ -80,6 +80,8 @@ business-config.hisCustomerQueryUrl = https://nutri.amcare.com.cn/v3/hiscustomer ...@@ -80,6 +80,8 @@ business-config.hisCustomerQueryUrl = https://nutri.amcare.com.cn/v3/hiscustomer
80 business-config.clientCustomerQueryUrl = https://nutri.amcare.com.cn/v3/clientcustomers/current/query 80 business-config.clientCustomerQueryUrl = https://nutri.amcare.com.cn/v3/clientcustomers/current/query
81 business-config.payUrl = http://10.2.5.162:21051/API/Microapp/CreateOrder?appid={0} 81 business-config.payUrl = http://10.2.5.162:21051/API/Microapp/CreateOrder?appid={0}
82 business-config.payClientId = Order 82 business-config.payClientId = Order
83 +business-config.cancelPayUrl = http://10.2.5.162:21051/frame/requestbase64
84 +business-config.refundSecurityKey = 0987654321
83 85
84 ##Actuator\u914D\u7F6E 86 ##Actuator\u914D\u7F6E
85 management.server.port=8088 87 management.server.port=8088
......