Showing
2 changed files
with
30 additions
and
2 deletions
| ... | @@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -13,6 +13,7 @@ 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.validation.annotation.Validated; | 15 | import org.springframework.validation.annotation.Validated; |
| 16 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 16 | import org.springframework.web.bind.annotation.PostMapping; | 17 | import org.springframework.web.bind.annotation.PostMapping; |
| 17 | import org.springframework.web.bind.annotation.RequestBody; | 18 | import org.springframework.web.bind.annotation.RequestBody; |
| 18 | import org.springframework.web.bind.annotation.ResponseStatus; | 19 | import org.springframework.web.bind.annotation.ResponseStatus; |
| ... | @@ -31,7 +32,7 @@ public class PayController { | ... | @@ -31,7 +32,7 @@ public class PayController { |
| 31 | private final PayServiceClient payServiceClient; | 32 | private final PayServiceClient payServiceClient; |
| 32 | 33 | ||
| 33 | @SaIgnore | 34 | @SaIgnore |
| 34 | - @ApiOperation(value = "支付") | 35 | + @ApiOperation(value = "支付信息") |
| 35 | @PostMapping("/pay/inform") | 36 | @PostMapping("/pay/inform") |
| 36 | @ResponseStatus(HttpStatus.OK) | 37 | @ResponseStatus(HttpStatus.OK) |
| 37 | public PayResponseDto pay(@Valid @RequestBody PayDTO.PayInformRequestDto payInformRequestDto) { | 38 | public PayResponseDto pay(@Valid @RequestBody PayDTO.PayInformRequestDto payInformRequestDto) { |
| ... | @@ -39,6 +40,14 @@ public class PayController { | ... | @@ -39,6 +40,14 @@ public class PayController { |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | @SaIgnore | 42 | @SaIgnore |
| 43 | + @ApiOperation(value = "支付中") | ||
| 44 | + @PostMapping("/order/{orderId}/pay/waiting") | ||
| 45 | + @ResponseStatus(HttpStatus.OK) | ||
| 46 | + public boolean waiting(@PathVariable("orderId")Integer orderId) { | ||
| 47 | + return payServiceClient.waiting(orderId); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @SaIgnore | ||
| 42 | @ApiOperation(value = "支付通知") | 51 | @ApiOperation(value = "支付通知") |
| 43 | @PostMapping(value = "/pay/callback") | 52 | @PostMapping(value = "/pay/callback") |
| 44 | @ResponseStatus(HttpStatus.OK) | 53 | @ResponseStatus(HttpStatus.OK) | ... | ... |
| ... | @@ -116,7 +116,7 @@ public class PayServiceClient { | ... | @@ -116,7 +116,7 @@ public class PayServiceClient { |
| 116 | log.error("Order not found, orderId: {}", orderId); | 116 | log.error("Order not found, orderId: {}", orderId); |
| 117 | return false; | 117 | return false; |
| 118 | } | 118 | } |
| 119 | - if (orderById.getPayStatus() == PayStatusEnum.SUCCEED || orderById.getPayStatus() == PayStatusEnum.FAILED) { | 119 | + if (orderById.getPayStatus() != PayStatusEnum.IN_PROGRESS) { |
| 120 | log.info("Order {} already processed, skipping.", orderId); | 120 | log.info("Order {} already processed, skipping.", orderId); |
| 121 | return true; | 121 | return true; |
| 122 | } | 122 | } |
| ... | @@ -155,4 +155,23 @@ public class PayServiceClient { | ... | @@ -155,4 +155,23 @@ public class PayServiceClient { |
| 155 | throw new RuntimeException("支付通知处理失败", e); | 155 | throw new RuntimeException("支付通知处理失败", e); |
| 156 | } | 156 | } |
| 157 | } | 157 | } |
| 158 | + | ||
| 159 | + public boolean waiting(Integer orderId) { | ||
| 160 | + final var orderById = orderServiceRpcClient.getOrderById(orderId); | ||
| 161 | + if (orderById == null) { | ||
| 162 | + log.error("waiting Order not found, orderId: {}", orderId); | ||
| 163 | + return false; | ||
| 164 | + } | ||
| 165 | + if (orderById.getPayStatus() != PayStatusEnum.TO_PAY) { | ||
| 166 | + log.info("waiting Order {} already processed, skipping.", orderId); | ||
| 167 | + return false; | ||
| 168 | + } | ||
| 169 | + final var build = ClientCustomerOrderModification.newBuilder() | ||
| 170 | + .setId(orderId) | ||
| 171 | + .setShouldUpdatePayStatus(true).setPayStatus(PayStatusEnum.IN_PROGRESS) | ||
| 172 | + .build(); | ||
| 173 | + final var updateResponse = orderServiceRpcClient.updateClientCustomerOrderPaymentResult(orderById, build); | ||
| 174 | + log.info("waiting updateClientCustomerOrder result: {}", updateResponse.getIsUpdated()); | ||
| 175 | + return updateResponse.getIsUpdated(); | ||
| 176 | + } | ||
| 158 | } | 177 | } | ... | ... |
-
Please register or login to post a comment