|
@@ -82,25 +82,40 @@ public class OmgPaymentQueryService {
|
|
|
log.info("OMG payment query started orderId={}, userId={}, storeId={}, merchantTradeNo={}",
|
|
log.info("OMG payment query started orderId={}, userId={}, storeId={}, merchantTradeNo={}",
|
|
|
OmgPaymentController.safeLogOrderId(order.getDdId()), userId, order.getStoreId(),
|
|
OmgPaymentController.safeLogOrderId(order.getDdId()), userId, order.getStoreId(),
|
|
|
OmgPaymentCreateService.maskMerchantTradeNo(attempt.getMerchantTradeNo()));
|
|
OmgPaymentCreateService.maskMerchantTradeNo(attempt.getMerchantTradeNo()));
|
|
|
|
|
+ return queryAttempt(attempt, order.getDdId(), order.getStoreId(), "USER");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** Reuses the verified query and settlement path for one scheduler-reserved CREATED attempt. */
|
|
|
|
|
+ public OmgQueryPaymentResponse reconcile(OmgPaymentAttempt attempt) {
|
|
|
|
|
+ Long storeId = attempt == null ? null : attempt.getStoreId();
|
|
|
|
|
+ validateAttempt(attempt, storeId);
|
|
|
|
|
+ log.info("OMG automatic compensation query started orderId={}, storeId={}, merchantTradeNo={}, queryCount={}",
|
|
|
|
|
+ OmgPaymentController.safeLogOrderId(attempt.getDdId()), storeId,
|
|
|
|
|
+ OmgPaymentCreateService.maskMerchantTradeNo(attempt.getMerchantTradeNo()),
|
|
|
|
|
+ attempt.getQueryCount());
|
|
|
|
|
+ return queryAttempt(attempt, attempt.getDdId(), storeId, "AUTO");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ private OmgQueryPaymentResponse queryAttempt(OmgPaymentAttempt attempt, String orderId,
|
|
|
|
|
+ Long storeId, String source) {
|
|
|
try {
|
|
try {
|
|
|
Map<String, String> response = parser.parse(gateway.query(buildRequest(attempt)));
|
|
Map<String, String> response = parser.parse(gateway.query(buildRequest(attempt)));
|
|
|
validateResponse(response, attempt);
|
|
validateResponse(response, attempt);
|
|
|
String tradeStatus = response.get("TradeStatus");
|
|
String tradeStatus = response.get("TradeStatus");
|
|
|
String status = synchronizeIfFinal(tradeStatus, response, attempt);
|
|
String status = synchronizeIfFinal(tradeStatus, response, attempt);
|
|
|
- log.info("OMG payment query completed orderId={}, merchantTradeNo={}, tradeNo={}, "
|
|
|
|
|
|
|
+ log.info("OMG payment query completed source={}, orderId={}, merchantTradeNo={}, tradeNo={}, "
|
|
|
+ "gatewayTradeStatus={}, localStatus={}",
|
|
+ "gatewayTradeStatus={}, localStatus={}",
|
|
|
- OmgPaymentController.safeLogOrderId(order.getDdId()),
|
|
|
|
|
|
|
+ source, OmgPaymentController.safeLogOrderId(orderId),
|
|
|
OmgPaymentCreateService.maskMerchantTradeNo(attempt.getMerchantTradeNo()),
|
|
OmgPaymentCreateService.maskMerchantTradeNo(attempt.getMerchantTradeNo()),
|
|
|
maskTradeNo(response.get("TradeNo")), tradeStatus, status);
|
|
maskTradeNo(response.get("TradeNo")), tradeStatus, status);
|
|
|
return toResponse(status, response);
|
|
return toResponse(status, response);
|
|
|
} catch (OmgPaymentBusinessException exception) {
|
|
} catch (OmgPaymentBusinessException exception) {
|
|
|
throw exception;
|
|
throw exception;
|
|
|
} catch (Exception exception) {
|
|
} catch (Exception exception) {
|
|
|
- log.error("OMG payment query failed orderId={}, merchantTradeNo={}",
|
|
|
|
|
- OmgPaymentController.safeLogOrderId(order.getDdId()),
|
|
|
|
|
|
|
+ log.error("OMG payment query failed source={}, orderId={}, merchantTradeNo={}",
|
|
|
|
|
+ source, OmgPaymentController.safeLogOrderId(orderId),
|
|
|
OmgPaymentCreateService.maskMerchantTradeNo(attempt.getMerchantTradeNo()), exception);
|
|
OmgPaymentCreateService.maskMerchantTradeNo(attempt.getMerchantTradeNo()), exception);
|
|
|
- throw business(PAYMENT_QUERY_FAILED, order.getStoreId());
|
|
|
|
|
|
|
+ throw business(PAYMENT_QUERY_FAILED, storeId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|