微信查询订单
This commit is contained in:
@@ -11,6 +11,7 @@ import com.czg.PayCst;
|
|||||||
import com.czg.dto.req.PayParamsDto;
|
import com.czg.dto.req.PayParamsDto;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||||
|
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -82,6 +83,10 @@ public class AlipayIsvPayManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, Object> queryOrder(AlipayConfigDto configDto, String orderNo, String subMerchantId) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 金额转换
|
* 金额转换
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -195,6 +195,53 @@ public class WechatPayManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单
|
||||||
|
* @param configDto 配置
|
||||||
|
* @param orderNo 订单号
|
||||||
|
* @param subMerchantId 子商户号
|
||||||
|
* SUCCESS:支付成功
|
||||||
|
* REFUND:转入退款
|
||||||
|
* NOTPAY:未支付
|
||||||
|
* CLOSED:已关闭
|
||||||
|
* REVOKED:已撤销(仅付款码支付会返回)
|
||||||
|
* USERPAYING:用户支付中(仅付款码支付会返回)
|
||||||
|
* PAYERROR:支付失败(仅付款码支付会返回)
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> queryOrder(WechatPayConfigDto configDto, String orderNo, String subMerchantId) {
|
||||||
|
try {
|
||||||
|
if (configDto == null) {
|
||||||
|
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
String resp = WechatReqUtils.getReq(configDto, "/v3/pay/partner/transactions/out-trade-no/" + orderNo,
|
||||||
|
Map.of("sp_mchid", configDto.getMerchantId(), "sub_mchid", subMerchantId));
|
||||||
|
log.info("微信查询订单,订单号:{}, 响应:{}", orderNo, resp);
|
||||||
|
|
||||||
|
JSONObject res = new JSONObject();
|
||||||
|
res.put("orderNo", orderNo);
|
||||||
|
|
||||||
|
JSONObject object = JSONObject.parseObject(resp);
|
||||||
|
String tradeState = object.getString("trade_state");
|
||||||
|
res.put("message", object.getString("trade_state_desc"));
|
||||||
|
if (PAY_SUCCESS.equals(tradeState)) {
|
||||||
|
res.put("status", "TRADE_SUCCESS");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("USERPAYING".equals(tradeState)) {
|
||||||
|
res.put("status", "TRADE_AWAIT");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.put("status", "TRADE_FAIL");
|
||||||
|
return res;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("微信查询订单异常: orderNo = {}, e = {}", orderNo, e.getMessage());
|
||||||
|
throw new CzgException("微信查询订单异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将String转换为InputStream
|
* 将String转换为InputStream
|
||||||
* @param str 待转换的字符串
|
* @param str 待转换的字符串
|
||||||
@@ -231,14 +278,17 @@ public class WechatPayManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
barPay(null, new PayParamsDto()
|
// barPay(null, new PayParamsDto()
|
||||||
.setMerchantId("1738216504")
|
// .setMerchantId("1738216504")
|
||||||
.setOrderNo("sa101293120sss1")
|
// .setOrderNo("sa101293120sss1")
|
||||||
.setTitle("1213")
|
// .setTitle("1213")
|
||||||
.setBody("1213")
|
// .setBody("1213")
|
||||||
.setAmount(1L)
|
// .setAmount(1L)
|
||||||
.setAppId("wxd88fffa983758a30")
|
// .setAppId("wxd88fffa983758a30")
|
||||||
.setClientIp("127.0.0.1")
|
// .setClientIp("127.0.0.1")
|
||||||
.setBarCode("130013153082460022"));
|
// .setBarCode("130013153082460022"));
|
||||||
|
|
||||||
|
Map<String, Object> sss1 = queryOrder(null, "sa101293120sss1", "1738216504");
|
||||||
|
System.out.println(sss1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class WechatReqUtils {
|
|||||||
log.info("微信支付请求:url = {} \nauthorization: {}", request.getUrl(), authorization);
|
log.info("微信支付请求:url = {} \nauthorization: {}", request.getUrl(), authorization);
|
||||||
HttpResponse response = request.execute();
|
HttpResponse response = request.execute();
|
||||||
String s = response.body();
|
String s = response.body();
|
||||||
log.info("微信支付请求:url = {}\n\tmethod: {}\n\tbody: {}\n\tresp: {}", url, method, body, s);
|
log.info("微信支付请求:\n\turl = {}\n\tmethod: {}\n\tbody: {}\n\tresp: {}", url, method, body, s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user