diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EntPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EntPayService.java index 43162f79..d0be5c4b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EntPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EntPayService.java @@ -42,6 +42,19 @@ public interface EntPayService { * @throws WxPayException the wx pay exception */ EntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException; + /** + *
+ * 查询企业付款API. + * 用于商户的企业付款操作进行结果查询,返回付款操作详细结果。 + * 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3 + * 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo + *+ * + * @param partnerTradeNo 商户订单号 + * @return the ent pay query result + * @throws WxPayException the wx pay exception + */ + EntPayQueryResult queryEntPay(EntPayQueryRequest request) throws WxPayException; /** *
@@ -92,4 +105,17 @@ public interface EntPayService {
* @throws WxPayException the wx pay exception
*/
EntPayBankQueryResult queryPayBank(String partnerTradeNo) throws WxPayException;
+ /**
+ * 企业付款到银行卡查询.
+ *
+ * 用于对商户企业付款到银行卡操作进行结果查询,返回付款操作详细结果。
+ * 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_3
+ * 接口链接:https://api.mch.weixin.qq.com/mmpaysptrans/query_bank
+ *
+ *
+ * @param partnerTradeNo 商户订单号
+ * @return the ent pay bank query result
+ * @throws WxPayException the wx pay exception
+ */
+ EntPayBankQueryResult queryPayBank(EntPayBankQueryRequest request) throws WxPayException;
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
index e8bb1079..08b59e21 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
@@ -14,30 +14,8 @@ import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryResult;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult;
-import com.github.binarywang.wxpay.bean.request.WxPayAuthcode2OpenidRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayDownloadBillRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayDownloadFundFlowRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayOrderCloseRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayOrderQueryRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayOrderReverseRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayRefundQueryRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayReportRequest;
-import com.github.binarywang.wxpay.bean.request.WxPaySendRedpackRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayShorturlRequest;
-import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
-import com.github.binarywang.wxpay.bean.result.WxPayBillResult;
-import com.github.binarywang.wxpay.bean.result.WxPayFundFlowResult;
-import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult;
-import com.github.binarywang.wxpay.bean.result.WxPayOrderCloseResult;
-import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult;
-import com.github.binarywang.wxpay.bean.result.WxPayOrderReverseResult;
-import com.github.binarywang.wxpay.bean.result.WxPayRedpackQueryResult;
-import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryResult;
-import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
-import com.github.binarywang.wxpay.bean.result.WxPaySendRedpackResult;
-import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderResult;
+import com.github.binarywang.wxpay.bean.request.*;
+import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.exception.WxPayException;
@@ -326,6 +304,20 @@ public interface WxPayService {
* @throws WxPayException the wx pay exception
*/
WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException;
+ /**
+ *
+ * 查询红包记录.
+ * 用于商户对已发放的红包进行查询红包的具体信息,可支持普通红包和裂变包。
+ * 请求Url:https://api.mch.weixin.qq.com/mmpaymkttransfers/gethbinfo
+ * 是否需要证书:是(证书及使用说明详见商户证书)
+ * 请求方式:POST
+ *
+ *
+ * @param mchBillNo 商户发放红包的商户订单号,比如10000098201411111234567890
+ * @return the wx pay redpack query result
+ * @throws WxPayException the wx pay exception
+ */
+ WxPayRedpackQueryResult queryRedpack(WxPayRedpackQueryRequest request) throws WxPayException;
/**
*
@@ -685,4 +677,26 @@ public interface WxPayService {
* @throws WxPayException the wx pay exception
*/
String queryComment(Date beginDate, Date endDate, Integer offset, Integer limit) throws WxPayException;
+
+ /**
+ *
+ * 拉取订单评价数据.
+ * 商户可以通过该接口拉取用户在微信支付交易记录中针对你的支付记录进行的评价内容。商户可结合商户系统逻辑对该内容数据进行存储、分析、展示、客服回访以及其他使用。如商户业务对评价内容有依赖,可主动引导用户进入微信支付交易记录进行评价。
+ * 注意:
+ * 1. 该内容所有权为提供内容的微信用户,商户在使用内容的过程中应遵从用户意愿
+ * 2. 一次最多拉取200条评价数据,可根据时间区间分批次拉取
+ * 3. 接口只能拉取最近三个月以内的评价数据
+ * 接口链接:https://api.mch.weixin.qq.com/billcommentsp/batchquerycomment
+ * 是否需要证书:需要
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_17&index=10
+ *
+ *
+ * @param beginDate 开始时间
+ * @param endDate 结束时间
+ * @param offset 位移
+ * @param limit 条数,建议填null,否则接口会报签名错误
+ * @return the string
+ * @throws WxPayException the wx pay exception
+ */
+ String queryComment(WxPayQueryCommentRequest request) throws WxPayException;
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
index fdd3bcdd..39645d69 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
@@ -251,6 +251,17 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
result.checkResult(this, request.getSignType(), true);
return result;
}
+ @Override
+ public WxPayRedpackQueryResult queryRedpack(WxPayRedpackQueryRequest request) throws WxPayException {
+ request.setBillType(BillType.MCHT);
+ request.checkAndSign(this.getConfig());
+
+ String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo";
+ String responseContent = this.post(url, request.toXML(), true);
+ WxPayRedpackQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayRedpackQueryResult.class);
+ result.checkResult(this, request.getSignType(), true);
+ return result;
+ }
@Override
public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxPayException {
@@ -822,4 +833,18 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
return responseContent;
}
+ @Override
+ public String queryComment(WxPayQueryCommentRequest request) throws WxPayException {
+ request.checkAndSign(this.getConfig());
+ request.setSignType(SignType.HMAC_SHA256);
+ String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment";
+
+ String responseContent = this.post(url, request.toXML(), true);
+ if (responseContent.startsWith("<")) {
+ throw WxPayException.from(BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class));
+ }
+
+ return responseContent;
+ }
+
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java
index d694f42e..59db3ee0 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImpl.java
@@ -74,6 +74,17 @@ public class EntPayServiceImpl implements EntPayService {
return result;
}
+ @Override
+ public EntPayQueryResult queryEntPay(EntPayQueryRequest request) throws WxPayException {
+ request.checkAndSign(this.payService.getConfig());
+
+ String url = this.payService.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo";
+ String responseContent = this.payService.post(url, request.toXML(), true);
+ EntPayQueryResult result = BaseWxPayResult.fromXML(responseContent, EntPayQueryResult.class);
+ result.checkResult(this.payService, request.getSignType(), true);
+ return result;
+ }
+
@Override
public String getPublicKey() throws WxPayException {
WxPayDefaultRequest request = new WxPayDefaultRequest();
@@ -118,6 +129,17 @@ public class EntPayServiceImpl implements EntPayService {
return result;
}
+ @Override
+ public EntPayBankQueryResult queryPayBank(EntPayBankQueryRequest request) throws WxPayException {
+ request.checkAndSign(this.payService.getConfig());
+
+ String url = this.payService.getPayBaseUrl() + "/mmpaysptrans/query_bank";
+ String responseContent = this.payService.post(url, request.toXML(), true);
+ EntPayBankQueryResult result = BaseWxPayResult.fromXML(responseContent, EntPayBankQueryResult.class);
+ result.checkResult(this.payService, request.getSignType(), true);
+ return result;
+ }
+
private String encryptRSA(File publicKeyFile, String srcString) throws WxPayException {
try {
Security.addProvider(new BouncyCastleProvider());
@@ -145,26 +167,4 @@ public class EntPayServiceImpl implements EntPayService {
throw new WxPayException("生成加密公钥文件时发生异常", e);
}
}
-
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- * @throws WxPayException the wx pay exception
- * @throws IOException the io exception
- */
- public static void main(String[] args) throws WxPayException, IOException {
- String key = "-----BEGIN RSA PUBLIC KEY-----\n" +
- "MIIBCgKCAQEAtEeUSop/YGqZ53Y++R9NapFSZmorj+SL/brmJUU7+hyClEnPOeG/\n" +
- "v6/ZrX9qo25JAojrBDbqaW9L+HtzI141vusarRYIGPvVqTV30L5db0Yq7AmX7Hs9\n" +
- "s+nEtoMAwMWUzQPXLUs2mt6rpu85HwAIK3F4Xb+OFIbXCJTbDvWYtQssn07lr+IY\n" +
- "jPA00sON71egmuRrCoQClkhf0vgrhj7eHUCRZRJ2zf4UU31fHv+kO441hVD5TTP8\n" +
- "bjJvFm6TW3sgQE8aCDbomtu+syk4Tv/4ONCqxG8d/kF1TlU+idGWEU179uR/KSjP\n" +
- "p7kM7BoaY2goFgYAe4DsI8Fh33dCOiKyVwIDAQAB\n" +
- "-----END RSA PUBLIC KEY-----";
- Path tmpFile = Files.createTempFile("payToBank", ".pem");
- Files.write(tmpFile, key.getBytes(StandardCharsets.UTF_8));
- System.out.println(new EntPayServiceImpl(null).encryptRSA(tmpFile.toFile(), "111111"));
- }
-
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java
index 5d6f3be4..1703c200 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java
@@ -4,6 +4,13 @@ import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import javax.net.ssl.SSLContext;
+import com.github.binarywang.wxpay.bean.WxPayApiData;
+import com.github.binarywang.wxpay.bean.request.WxPayQueryCommentRequest;
+import com.github.binarywang.wxpay.bean.request.WxPayRedpackQueryRequest;
+import com.github.binarywang.wxpay.bean.result.WxPayCommonResult;
+import com.github.binarywang.wxpay.bean.result.WxPayRedpackQueryResult;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import jodd.util.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
index 72f2539f..81d35614 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
@@ -1,5 +1,14 @@
package com.github.binarywang.wxpay.service.impl;
+import java.nio.charset.StandardCharsets;
+import javax.net.ssl.SSLContext;
+
+import com.github.binarywang.wxpay.bean.request.WxPayQueryCommentRequest;
+import com.github.binarywang.wxpay.bean.request.WxPayRedpackQueryRequest;
+import com.github.binarywang.wxpay.bean.result.WxPayCommonResult;
+import com.github.binarywang.wxpay.bean.result.WxPayRedpackQueryResult;
+import org.apache.commons.lang3.StringUtils;
+
import com.github.binarywang.wxpay.bean.WxPayApiData;
import com.github.binarywang.wxpay.exception.WxPayException;
import jodd.http.HttpConnectionProvider;