|
@@ -35,6 +35,11 @@ public class VirtualPayService {
|
|
|
/** 虚拟支付下单场景标识(wx.requestVirtualPayment 固定 URI 前缀) */
|
|
/** 虚拟支付下单场景标识(wx.requestVirtualPayment 固定 URI 前缀) */
|
|
|
private static final String URI_REQUEST_VIRTUAL_PAYMENT = "requestVirtualPayment";
|
|
private static final String URI_REQUEST_VIRTUAL_PAYMENT = "requestVirtualPayment";
|
|
|
|
|
|
|
|
|
|
+ /** 微信 query_order 错误码:数据不存在(微信侧无该订单号,确定性未支付结论,可安全关单) */
|
|
|
|
|
+ private static final int ERRCODE_ORDER_NOT_FOUND = 268490002;
|
|
|
|
|
+ /** query_order 自定义结果状态:微信侧订单不存在(官方 status 仅 0-10,-1 为本地扩展) */
|
|
|
|
|
+ public static final int STATUS_ORDER_NOT_FOUND = -1;
|
|
|
|
|
+
|
|
|
/** 签名算法标识 */
|
|
/** 签名算法标识 */
|
|
|
private static final String SIGN_TYPE_HMAC_SHA256 = "HMAC-SHA256";
|
|
private static final String SIGN_TYPE_HMAC_SHA256 = "HMAC-SHA256";
|
|
|
|
|
|
|
@@ -525,6 +530,12 @@ public class VirtualPayService {
|
|
|
JSONObject resp = JSON.parseObject(respBody);
|
|
JSONObject resp = JSON.parseObject(respBody);
|
|
|
int errcode = resp.getIntValue("errcode");
|
|
int errcode = resp.getIntValue("errcode");
|
|
|
if (errcode != 0) {
|
|
if (errcode != 0) {
|
|
|
|
|
+ // 268490002=数据不存在:微信订单库无该 order_id(下单从未在微信侧创建成功)。
|
|
|
|
|
+ // 这是确定性的"未支付"结论(区别于网络/签名等临时失败),返回 status=-1 供超时任务安全关单
|
|
|
|
|
+ if (errcode == ERRCODE_ORDER_NOT_FOUND) {
|
|
|
|
|
+ log.info("query_order微信侧无此订单, 视为未支付可关单: outTradeNo={}", outTradeNo);
|
|
|
|
|
+ return new QueryOrderResult(false, STATUS_ORDER_NOT_FOUND, null);
|
|
|
|
|
+ }
|
|
|
log.warn("query_order返回错误: outTradeNo={}, errcode={}, errmsg={}",
|
|
log.warn("query_order返回错误: outTradeNo={}, errcode={}, errmsg={}",
|
|
|
outTradeNo, errcode, resp.getString("errmsg"));
|
|
outTradeNo, errcode, resp.getString("errmsg"));
|
|
|
return null; // 查询失败:调用方不得关单
|
|
return null; // 查询失败:调用方不得关单
|
|
@@ -558,7 +569,7 @@ public class VirtualPayService {
|
|
|
public static class QueryOrderResult {
|
|
public static class QueryOrderResult {
|
|
|
/** 是否已支付(status∈{2,3,4}) */
|
|
/** 是否已支付(status∈{2,3,4}) */
|
|
|
public final boolean paid;
|
|
public final boolean paid;
|
|
|
- /** 微信侧订单状态枚举 */
|
|
|
|
|
|
|
+ /** 微信侧订单状态枚举(-1=微信无此订单,本地扩展,仅查询接口返回) */
|
|
|
public final int status;
|
|
public final int status;
|
|
|
/** 微信交易单号(order.wxpay_order_id) */
|
|
/** 微信交易单号(order.wxpay_order_id) */
|
|
|
public final String wxpayOrderId;
|
|
public final String wxpayOrderId;
|