Showing
2 changed files
with
10 additions
and
6 deletions
| ... | @@ -34,7 +34,9 @@ public enum ErrorCodeEnum implements BaseEnum { | ... | @@ -34,7 +34,9 @@ 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_CANCEL_FAILED(406000010, "支付撤销失败") | ||
| 38 | ; | 40 | ; |
| 39 | private final int code; | 41 | private final int code; |
| 40 | 42 | ... | ... |
| ... | @@ -373,15 +373,16 @@ public class PayServiceClient { | ... | @@ -373,15 +373,16 @@ public class PayServiceClient { |
| 373 | // RequestBody body = RequestBody.create(mediaType, jsonDataString); | 373 | // RequestBody body = RequestBody.create(mediaType, jsonDataString); |
| 374 | 374 | ||
| 375 | String url = businessConfig.getCancelPayUrl() + "?" + "appid=" + appId + "&paycontent=" + payContent + "&signinfo=" + signInfo; | 375 | String url = businessConfig.getCancelPayUrl() + "?" + "appid=" + appId + "&paycontent=" + payContent + "&signinfo=" + signInfo; |
| 376 | + log.info("cancel order pay url:" + url); | ||
| 376 | Request request = | 377 | Request request = |
| 377 | new Request.Builder().url(url).get().build(); | 378 | new Request.Builder().url(url).get().build(); |
| 378 | - | ||
| 379 | Response payResponse = client.newCall(request).execute(); | 379 | Response payResponse = client.newCall(request).execute(); |
| 380 | if (payResponse.code() != 200) { | 380 | if (payResponse.code() != 200) { |
| 381 | + log.error("cancel order pay failed, resp http code:" + payResponse.code()); | ||
| 381 | return false; | 382 | return false; |
| 382 | } | 383 | } |
| 383 | String cancelPayJsonData = payResponse.body().string(); | 384 | String cancelPayJsonData = payResponse.body().string(); |
| 384 | - log.info("pay json:" + cancelPayJsonData); | 385 | + log.info("cancel order pay resp:" + cancelPayJsonData); |
| 385 | ObjectMapper objectMapper = new ObjectMapper(); | 386 | ObjectMapper objectMapper = new ObjectMapper(); |
| 386 | objectMapper.configure(Feature.ALLOW_MISSING_VALUES, true); | 387 | objectMapper.configure(Feature.ALLOW_MISSING_VALUES, true); |
| 387 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | 388 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| ... | @@ -391,7 +392,8 @@ public class PayServiceClient { | ... | @@ -391,7 +392,8 @@ public class PayServiceClient { |
| 391 | objectMapper.readValue(cancelPayJsonData, CancelPayResponseDto.class); | 392 | objectMapper.readValue(cancelPayJsonData, CancelPayResponseDto.class); |
| 392 | 393 | ||
| 393 | if (payResponseDto.getCode() != 0) { | 394 | if (payResponseDto.getCode() != 0) { |
| 394 | - return false; | 395 | + log.error("cancel order pay failed, resp code:" + payResponseDto.getCode()); |
| 396 | + throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_PAY_CANCEL_FAILED); | ||
| 395 | } else { | 397 | } else { |
| 396 | // 更新订单撤销状态 | 398 | // 更新订单撤销状态 |
| 397 | final var build = | 399 | final var build = |
| ... | @@ -404,8 +406,8 @@ public class PayServiceClient { | ... | @@ -404,8 +406,8 @@ public class PayServiceClient { |
| 404 | return true; | 406 | return true; |
| 405 | } | 407 | } |
| 406 | } catch (Exception e) { | 408 | } catch (Exception e) { |
| 407 | - log.error(e.getStackTrace().toString()); | 409 | + log.error(e.getMessage()); |
| 408 | - return false; | 410 | + throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_PAY_CANCEL_FAILED); |
| 409 | } | 411 | } |
| 410 | } | 412 | } |
| 411 | } | 413 | } | ... | ... |
-
Please register or login to post a comment