Commit aab77929c766c01fce4c4dbdc31930ab1e757a67
1 parent
dd5fc334
adjust timeout for testing purpose
Showing
2 changed files
with
26 additions
and
26 deletions
cashier-boss/src/main/java/com/diligrp/cashier/boss/Constants.java
| @@ -14,7 +14,7 @@ public final class Constants { | @@ -14,7 +14,7 @@ public final class Constants { | ||
| 14 | // TOKEN的签名长度 | 14 | // TOKEN的签名长度 |
| 15 | public static final int TOKEN_SIGN_LENGTH = 8; | 15 | public static final int TOKEN_SIGN_LENGTH = 8; |
| 16 | // TOKEN过期时长,单位秒 - 5分钟 | 16 | // TOKEN过期时长,单位秒 - 5分钟 |
| 17 | - public static final long TOKEN_TIMEOUT_SECONDS = 5 * 60; | 17 | + public static final long TOKEN_TIMEOUT_SECONDS = 10 * 60; |
| 18 | 18 | ||
| 19 | public final static String CONTENT_TYPE = "application/json;charset=UTF-8"; | 19 | public final static String CONTENT_TYPE = "application/json;charset=UTF-8"; |
| 20 | 20 |
cashier-pipeline/src/main/java/com/diligrp/cashier/pipeline/client/RcbOnlineHttpClient.java
| @@ -83,13 +83,13 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -83,13 +83,13 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 83 | params.put("sign", RcbSignatureUtils.sign(params, key)); | 83 | params.put("sign", RcbSignatureUtils.sign(params, key)); |
| 84 | 84 | ||
| 85 | String payload = JsonUtils.toJsonString(params); | 85 | String payload = JsonUtils.toJsonString(params); |
| 86 | - LOG.info("Sending rcb minipro prepay request: {}\n{}", request.getPaymentId(), payload); | 86 | + LOG.info("Sending rcb MiniPro prepay request: {}\n{}", request.getPaymentId(), payload); |
| 87 | HttpResult result = send(uri + "/cposp/pay/unifiedorder", payload); | 87 | HttpResult result = send(uri + "/cposp/pay/unifiedorder", payload); |
| 88 | if (result.statusCode != STATUS_OK) { | 88 | if (result.statusCode != STATUS_OK) { |
| 89 | - LOG.error("Failed to send rcb minipro prepay, statusCode: {}", result.statusCode); | 89 | + LOG.error("Failed to send rcb MiniPro prepay request: {}", result.statusCode); |
| 90 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "调用小程序预支付接口失败: " + result.statusCode); | 90 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "调用小程序预支付接口失败: " + result.statusCode); |
| 91 | } | 91 | } |
| 92 | - LOG.debug("Received rcb minipro prepay response: {}", result.responseText); | 92 | + LOG.debug("Received from rcb MiniPro pipeline: {}\n{}", request.getPaymentId(), result.responseText); |
| 93 | 93 | ||
| 94 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); | 94 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 95 | String resultCode = data.get("resultCode"); | 95 | String resultCode = data.get("resultCode"); |
| @@ -101,7 +101,7 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -101,7 +101,7 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 101 | } | 101 | } |
| 102 | return data.get("payInfo"); | 102 | return data.get("payInfo"); |
| 103 | } else { | 103 | } else { |
| 104 | - LOG.error("Failed to send minipro prepay request, errorCode: {}, resultMessage: {}", resultCode, resultMessage); | 104 | + LOG.error("Failed to send MiniPro prepay request: {}\n{}", request.getPaymentId(), result.responseText); |
| 105 | throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "调用小程序预支付接口失败: " + resultMessage); | 105 | throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "调用小程序预支付接口失败: " + resultMessage); |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| @@ -117,13 +117,13 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -117,13 +117,13 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 117 | 117 | ||
| 118 | params.put("sign", RcbSignatureUtils.sign(params, key)); | 118 | params.put("sign", RcbSignatureUtils.sign(params, key)); |
| 119 | String payload = JsonUtils.toJsonString(params); | 119 | String payload = JsonUtils.toJsonString(params); |
| 120 | - LOG.debug("Sending rcb order query request: {}", payload); | 120 | + LOG.info("Sending rcb query prepay order state request: {}", request.getPaymentId()); |
| 121 | HttpResult result = send(uri + "/cposp/pay/orderQuery", payload); | 121 | HttpResult result = send(uri + "/cposp/pay/orderQuery", payload); |
| 122 | if (result.statusCode != STATUS_OK) { | 122 | if (result.statusCode != STATUS_OK) { |
| 123 | - LOG.error("Failed to query rcb order, statusCode: {}", result.statusCode); | 123 | + LOG.error("Failed to query rcb prepay order state: {}", result.statusCode); |
| 124 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "查询支付状态失败: " + result.statusCode); | 124 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "查询支付状态失败: " + result.statusCode); |
| 125 | } | 125 | } |
| 126 | - LOG.debug("Received rcb order query response: {}", result.responseText); | 126 | + LOG.debug("Received from rcb online pipeline: {}\n{}", request.getPaymentId(), result.responseText); |
| 127 | 127 | ||
| 128 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); | 128 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 129 | String signature = data.remove("sign"); | 129 | String signature = data.remove("sign"); |
| @@ -153,8 +153,8 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -153,8 +153,8 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 153 | return new OnlinePaymentResponse(request.getPaymentId(), outTradeNo, paymentType, | 153 | return new OnlinePaymentResponse(request.getPaymentId(), outTradeNo, paymentType, |
| 154 | payUserInfo, when, RcbStateUtils.paymentState(orderStatus), errorDesc); | 154 | payUserInfo, when, RcbStateUtils.paymentState(orderStatus), errorDesc); |
| 155 | } else { | 155 | } else { |
| 156 | - LOG.error("Failed to query rcb order, errorCode: {}, resultMessage: {}", resultCode, resultMessage); | ||
| 157 | - throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "调用支付结果查询接口失败"); | 156 | + LOG.error("Failed to query rcb prepay order state: {}\n{}", request.getPaymentId(), result.responseText); |
| 157 | + throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "调用支付结果查询接口失败: " + resultMessage); | ||
| 158 | } | 158 | } |
| 159 | } | 159 | } |
| 160 | 160 | ||
| @@ -169,20 +169,20 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -169,20 +169,20 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 169 | params.put("sign", RcbSignatureUtils.sign(params, key)); | 169 | params.put("sign", RcbSignatureUtils.sign(params, key)); |
| 170 | 170 | ||
| 171 | String payload = JsonUtils.toJsonString(params); | 171 | String payload = JsonUtils.toJsonString(params); |
| 172 | - LOG.info("Sending close rcb order request: {}", payload); | 172 | + LOG.info("Sending close rcb prepay order request: {}", request.getPaymentId()); |
| 173 | HttpResult result = send(uri + "/cposp/pay/closeOrder", payload); | 173 | HttpResult result = send(uri + "/cposp/pay/closeOrder", payload); |
| 174 | if (result.statusCode != STATUS_OK) { | 174 | if (result.statusCode != STATUS_OK) { |
| 175 | - LOG.error("Failed to close rcb order, statusCode: {}", result.statusCode); | 175 | + LOG.error("Failed to close rcb prepay order: {}", request.getPaymentId()); |
| 176 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "关闭支付订单失败: " + result.statusCode); | 176 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "关闭支付订单失败: " + result.statusCode); |
| 177 | } | 177 | } |
| 178 | - LOG.info("Received close rcb order response: {}", result.responseText); | 178 | + LOG.debug("Received from rcb online pipeline: {}\n{}", request.getPaymentId(), result.responseText); |
| 179 | 179 | ||
| 180 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); | 180 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 181 | String resultCode = data.get("resultCode"); | 181 | String resultCode = data.get("resultCode"); |
| 182 | String resultMessage = data.get("resultMessage"); | 182 | String resultMessage = data.get("resultMessage"); |
| 183 | if (!"00".equals(resultCode)) { | 183 | if (!"00".equals(resultCode)) { |
| 184 | - LOG.error("Failed to close rcb order, errorCode: {}, resultMessage: {}", resultCode, resultMessage); | ||
| 185 | - throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "关闭支付订单失败"); | 184 | + LOG.error("Failed to close rcb prepay order: {}\n{}", request.getPaymentId(), result.responseText); |
| 185 | + throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "关闭支付订单失败: " + resultMessage); | ||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | String signature = data.remove("sign"); | 188 | String signature = data.remove("sign"); |
| @@ -205,20 +205,21 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -205,20 +205,21 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 205 | 205 | ||
| 206 | LocalDateTime now = LocalDateTime.now(); | 206 | LocalDateTime now = LocalDateTime.now(); |
| 207 | String payload = JsonUtils.toJsonString(params); | 207 | String payload = JsonUtils.toJsonString(params); |
| 208 | - LOG.debug("Sending refund request: {}", payload); | 208 | + LOG.info("Sending rcb payment refund request: {}", request.getRefundId()); |
| 209 | + | ||
| 209 | HttpResult result = send(uri + "/cposp/pay/refund", payload); | 210 | HttpResult result = send(uri + "/cposp/pay/refund", payload); |
| 210 | if (result.statusCode != STATUS_OK) { | 211 | if (result.statusCode != STATUS_OK) { |
| 211 | - LOG.error("Failed to refund rcb order, statusCode: {}", result.statusCode); | 212 | + LOG.error("Failed to send rcb refund request: {}", request.getRefundId()); |
| 212 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "发送退款请求失败: " + result.statusCode); | 213 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "发送退款请求失败: " + result.statusCode); |
| 213 | } | 214 | } |
| 214 | - LOG.debug("Received rcb order refund response: {}", result.responseText); | 215 | + LOG.debug("Received from rcb online pipeline: {}\n{}", request.getRefundId(), result.responseText); |
| 215 | 216 | ||
| 216 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); | 217 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 217 | String resultCode = data.get("resultCode"); | 218 | String resultCode = data.get("resultCode"); |
| 218 | String resultMessage = data.get("resultMessage"); | 219 | String resultMessage = data.get("resultMessage"); |
| 219 | if (!"00".equals(resultCode)) { | 220 | if (!"00".equals(resultCode)) { |
| 220 | - LOG.error("Failed to refund, errorCode: {}, resultMessage: {}", resultCode, resultMessage); | ||
| 221 | - throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "发送退款请求失败"); | 221 | + LOG.error("Failed to request rcb payment refund: {}\n{}", request.getRefundId(), result.responseText); |
| 222 | + throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "发送退款请求失败: " + resultMessage); | ||
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | String signature = data.remove("sign"); | 225 | String signature = data.remove("sign"); |
| @@ -238,20 +239,20 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -238,20 +239,20 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 238 | */ | 239 | */ |
| 239 | protected String getBatchNo() { | 240 | protected String getBatchNo() { |
| 240 | try { | 241 | try { |
| 241 | - String key = "rcb:online:batchNo" + DateUtils.formatDate(LocalDate.now(), DateUtils.YYYYMMDD); | 242 | + String key = "cashier:rcb:batchNo" + DateUtils.formatDate(LocalDate.now(), DateUtils.YYYYMMDD); |
| 242 | String batchNo = stringRedisTemplate.opsForValue().get(key); | 243 | String batchNo = stringRedisTemplate.opsForValue().get(key); |
| 243 | if (batchNo != null) { | 244 | if (batchNo != null) { |
| 244 | return batchNo; | 245 | return batchNo; |
| 245 | } | 246 | } |
| 246 | 247 | ||
| 247 | String payload = String.format("{\"merchantNo\": \"%s\", \"terminalNo\": \"%s\"}", merchantNo, terminalNo); | 248 | String payload = String.format("{\"merchantNo\": \"%s\", \"terminalNo\": \"%s\"}", merchantNo, terminalNo); |
| 248 | - LOG.debug("Sending signIn request: {}", payload); | 249 | + LOG.debug("Sending rcb signIn request: {}", payload); |
| 249 | HttpResult result = send(uri + "/cposp/pay/signIn", payload); | 250 | HttpResult result = send(uri + "/cposp/pay/signIn", payload); |
| 250 | if (result.statusCode != STATUS_OK) { | 251 | if (result.statusCode != STATUS_OK) { |
| 251 | LOG.error("Failed to get rcb batch no, statusCode: {}", result.statusCode); | 252 | LOG.error("Failed to get rcb batch no, statusCode: {}", result.statusCode); |
| 252 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "获取签到批次号: " + result.statusCode); | 253 | throw new PaymentPipelineException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "获取签到批次号: " + result.statusCode); |
| 253 | } | 254 | } |
| 254 | - LOG.debug("Received rcb signIn response: {}", result.responseText); | 255 | + LOG.debug("Received from rcb online pipeline: {}", result.responseText); |
| 255 | 256 | ||
| 256 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); | 257 | Map<String, String> data = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 257 | String resultCode = data.get("resultCode"); | 258 | String resultCode = data.get("resultCode"); |
| @@ -274,9 +275,8 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -274,9 +275,8 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 274 | 275 | ||
| 275 | protected String getTraceNo() { | 276 | protected String getTraceNo() { |
| 276 | try { | 277 | try { |
| 277 | - String key = "rcb:online:traceNo" + DateUtils.formatDate(LocalDate.now(), DateUtils.YYYYMMDD); | 278 | + String key = "cashier:rcb:traceNo" + DateUtils.formatDate(LocalDate.now(), DateUtils.YYYYMMDD); |
| 278 | StringBuilder traceNo = new StringBuilder(); | 279 | StringBuilder traceNo = new StringBuilder(); |
| 279 | - | ||
| 280 | List<Object> results = stringRedisTemplate.executePipelined(new SessionCallback<Object>() { | 280 | List<Object> results = stringRedisTemplate.executePipelined(new SessionCallback<Object>() { |
| 281 | @Override | 281 | @Override |
| 282 | public Object execute(@NonNull RedisOperations operations) throws DataAccessException { | 282 | public Object execute(@NonNull RedisOperations operations) throws DataAccessException { |
| @@ -295,7 +295,7 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | @@ -295,7 +295,7 @@ public class RcbOnlineHttpClient extends ServiceEndpointSupport { | ||
| 295 | } | 295 | } |
| 296 | return traceNo.toString(); | 296 | return traceNo.toString(); |
| 297 | } catch (Exception ex) { | 297 | } catch (Exception ex) { |
| 298 | - LOG.error("Failed to get traceNo", ex); | 298 | + LOG.error("Failed to get rcb traceNo", ex); |
| 299 | throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "获取系统跟踪号失败"); | 299 | throw new PaymentPipelineException(ErrorCode.SERVICE_ACCESS_ERROR, "获取系统跟踪号失败"); |
| 300 | } | 300 | } |
| 301 | } | 301 | } |