mirror of
https://gitee.com/elegant_wings/xiongan-meeting.git
synced 2025-06-21 04:59:36 +08:00
描述:查询订单状态
This commit is contained in:
parent
87e4e33aab
commit
267b06a00c
@ -82,4 +82,29 @@ public class WxPayController extends BaseController {
|
||||
return returnParam;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单支付后回调
|
||||
*/
|
||||
@PostMapping("wxMerchantOrderQuery")
|
||||
public HashMap wxMerchantOrderQuery(@RequestBody Map<String , String> paramMap) {
|
||||
HashMap<String, String> resultMap = wxPayCommon.wxMerchantOrderQuery(paramMap.get("outTradeNo"));
|
||||
// 商户订单号
|
||||
String out_trade_no = resultMap.get("out_trade_no");
|
||||
// 微信支付订单号
|
||||
String transaction_id = resultMap.get("transaction_id");
|
||||
// 交易状态
|
||||
// * SUCCESS:支付成功
|
||||
// * REFUND:转入退款
|
||||
// * NOTPAY:未支付
|
||||
// * CLOSED:已关闭
|
||||
// * REVOKED:已撤销(仅付款码支付会返回)
|
||||
// * USERPAYING:用户支付中(仅付款码支付会返回)
|
||||
// * PAYERROR:支付失败(仅付款码支付会返回)
|
||||
String trade_state = resultMap.get("trade_state");
|
||||
|
||||
return R.data(resultMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
|
||||
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
@ -72,6 +73,20 @@ public class WxPayCommon {
|
||||
return httpPost;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求对象(Get请求)
|
||||
*
|
||||
* @return Get请求
|
||||
*/
|
||||
public HttpGet getHttpGet(String url) {
|
||||
// 1.设置请求地址
|
||||
HttpGet httpGet = new HttpGet(wxPayConfig.getDomain().concat(url));
|
||||
// 3.设置请求信息
|
||||
httpGet.setHeader("Accept", "application/json");
|
||||
return httpGet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析响应数据
|
||||
*
|
||||
@ -164,8 +179,6 @@ public class WxPayCommon {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建微信支付订单-jsapi方式
|
||||
*
|
||||
@ -217,5 +230,24 @@ public class WxPayCommon {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商户订单号查询订单
|
||||
*/
|
||||
public HashMap<String, String> wxMerchantOrderQuery(String outTradeNo) {
|
||||
// 创建请求
|
||||
HttpGet httpGet = getHttpGet(WxApiConstants.MERCHANT_ORDER_NUMBER_QUERY + "/" + outTradeNo + "?mchid=" + wxPayConfig.getMchId());
|
||||
// 完成签名并执行请求
|
||||
CloseableHttpResponse response = null;
|
||||
try {
|
||||
response = wxPayConfig.getWxPayClient().execute(httpGet);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("商户订单号查询订单请求失败");
|
||||
}
|
||||
// 解析response对象
|
||||
HashMap<String, String> resultMap = resolverResponse(response);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,4 +12,10 @@ public class WxApiConstants {
|
||||
public static final String JSAPI_PAY = "/v3/pay/transactions/jsapi";
|
||||
|
||||
|
||||
/**
|
||||
* 商户订单号查询订单
|
||||
*/
|
||||
public static final String MERCHANT_ORDER_NUMBER_QUERY = "/v3/pay/transactions/out-trade-no";
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user