diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java index 4cb6785ff..ef937bab2 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/Applyment4SubService.java @@ -67,7 +67,8 @@ public interface Applyment4SubService { * @param subMchid 特约商户号 * @param request 修改结算账户请求对象信息 * @throws WxPayException the wx pay exception + * @return */ - void modifySettlement(String subMchid, ModifySettlementRequest request) throws WxPayException; + String modifySettlement(String subMchid, ModifySettlementRequest request) throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java index cd81d60ae..3f97b150a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java @@ -174,8 +174,9 @@ public interface EcommerceService { * * @param request 关闭普通订单请求 * @throws WxPayException the wx pay exception + * @return */ - void closePartnerTransactions(PartnerTransactionsCloseRequest request) throws WxPayException; + String closePartnerTransactions(PartnerTransactionsCloseRequest 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 4c95249b2..50ee046fe 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
@@ -11,6 +11,7 @@ import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
import java.io.File;
import java.io.InputStream;
@@ -89,6 +90,16 @@ public interface WxPayService {
*/
String postV3(String url, HttpPost httpPost) throws WxPayException;
+ /**
+ * 发送http请求,得到响应字符串.
+ *
+ * @param url 请求地址
+ * @param httpRequest 请求信息,可以是put,post,get,delete等请求
+ * @return 返回请求结果字符串 string
+ * @throws WxPayException the wx pay exception
+ */
+ String requestV3(String url, HttpRequestBase httpRequest) throws WxPayException;
+
/**
* 发送get V3请求,得到响应字符串.
*
@@ -96,7 +107,7 @@ public interface WxPayService {
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
- String getV3(URI url) throws WxPayException;
+ String getV3(String url) throws WxPayException;
/**
* 发送下载 V3请求,得到响应流.
@@ -105,7 +116,7 @@ public interface WxPayService {
* @return 返回请求响应流 input stream
* @throws WxPayException the wx pay exception
*/
- InputStream downloadV3(URI url) throws WxPayException;
+ InputStream downloadV3(String url) throws WxPayException;
/**
* 获取企业付款服务类.
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java
index defb01a9f..8da4c4058 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/Applyment4SubServiceImpl.java
@@ -10,13 +10,11 @@ import com.google.gson.GsonBuilder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import java.net.URI;
import java.security.cert.X509Certificate;
@Slf4j
@RequiredArgsConstructor
public class Applyment4SubServiceImpl implements Applyment4SubService {
-
private static final Gson GSON = new GsonBuilder().create();
private final WxPayService payService;
@@ -41,28 +39,28 @@ public class Applyment4SubServiceImpl implements Applyment4SubService {
@Override
public ApplymentStateQueryResult queryApplyStatusByBusinessCode(String businessCode) throws WxPayException {
String url = String.format("%s/v3/applyment4sub/applyment/business_code/%s", this.payService.getPayBaseUrl(), businessCode);
- String result = payService.getV3(URI.create(url));
+ String result = payService.getV3(url);
return GSON.fromJson(result, ApplymentStateQueryResult.class);
}
@Override
public ApplymentStateQueryResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException {
String url = String.format("%s/v3/applyment4sub/applyment/applyment_id/%s", this.payService.getPayBaseUrl(), applymentId);
- String result = payService.getV3(URI.create(url));
+ String result = payService.getV3(url);
return GSON.fromJson(result, ApplymentStateQueryResult.class);
}
@Override
public SettlementInfoResult querySettlementBySubMchid(String subMchid) throws WxPayException {
String url = String.format("%s/v3/apply4sub/sub_merchants/%s/settlement", this.payService.getPayBaseUrl(), subMchid);
- String result = payService.getV3(URI.create(url));
+ String result = payService.getV3(url);
return GSON.fromJson(result, SettlementInfoResult.class);
}
@Override
- public void modifySettlement(String subMchid,ModifySettlementRequest request) throws WxPayException {
+ public String modifySettlement(String subMchid, ModifySettlementRequest request) throws WxPayException {
String url = String.format("%s/v3/apply4sub/sub_merchants/%s/modify-settlement", this.payService.getPayBaseUrl(), subMchid);
encryptFiled(request);
- String result = payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+ return payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
index 1192d609e..4f13618f3 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
@@ -44,14 +44,14 @@ public class EcommerceServiceImpl implements EcommerceService {
@Override
public ApplymentsStatusResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException {
String url = String.format("%s/v3/ecommerce/applyments/%s", this.payService.getPayBaseUrl(), applymentId);
- String result = this.payService.getV3(URI.create(url));
+ String result = this.payService.getV3(url);
return GSON.fromJson(result, ApplymentsStatusResult.class);
}
@Override
public ApplymentsStatusResult queryApplyStatusByOutRequestNo(String outRequestNo) throws WxPayException {
String url = String.format("%s/v3/ecommerce/applyments/out-request-no/%s", this.payService.getPayBaseUrl(), outRequestNo);
- String result = this.payService.getV3(URI.create(url));
+ String result = this.payService.getV3(url);
return GSON.fromJson(result, ApplymentsStatusResult.class);
}
@@ -96,7 +96,7 @@ public class EcommerceServiceImpl implements EcommerceService {
@Override
public CombineTransactionsResult queryCombineTransactions(String outTradeNo) throws WxPayException {
String url = String.format("%s/v3/combine-transactions/out-trade-no/%s", this.payService.getPayBaseUrl(), outTradeNo);
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, CombineTransactionsResult.class);
}
@@ -145,46 +145,41 @@ public class EcommerceServiceImpl implements EcommerceService {
url = String.format("%s/v3/pay/partner/transactions/id/%s", this.payService.getPayBaseUrl(), request.getTransactionId());
}
String query = String.format("?sp_mchid=%s&sub_mchid=%s", request.getSpMchid(), request.getSubMchid());
- URI uri = URI.create(url + query);
- String response = this.payService.getV3(uri);
+ String response = this.payService.getV3(url + query);
return GSON.fromJson(response, PartnerTransactionsResult.class);
}
@Override
- public void closePartnerTransactions(PartnerTransactionsCloseRequest request) throws WxPayException {
+ public String closePartnerTransactions(PartnerTransactionsCloseRequest request) throws WxPayException {
String url = String.format("%s/v3/pay/partner/transactions/out-trade-no/%s/close", this.payService.getPayBaseUrl(), request.getOutTradeNo());
- String response = this.payService.postV3(url, GSON.toJson(request));
+ return this.payService.postV3(url, GSON.toJson(request));
}
@Override
public FundBalanceResult spNowBalance(SpAccountTypeEnum accountType) throws WxPayException {
String url = String.format("%s/v3/merchant/fund/balance/%s", this.payService.getPayBaseUrl(), accountType);
- URI uri = URI.create(url);
- String response = this.payService.getV3(uri);
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, FundBalanceResult.class);
}
@Override
public FundBalanceResult spDayEndBalance(SpAccountTypeEnum accountType, String date) throws WxPayException {
String url = String.format("%s/v3/merchant/fund/dayendbalance/%s?date=%s", this.payService.getPayBaseUrl(), accountType, date);
- URI uri = URI.create(url);
- String response = this.payService.getV3(uri);
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, FundBalanceResult.class);
}
@Override
public FundBalanceResult subNowBalance(String subMchid) throws WxPayException {
String url = String.format("%s/v3/ecommerce/fund/balance/%s", this.payService.getPayBaseUrl(), subMchid);
- URI uri = URI.create(url);
- String response = this.payService.getV3(uri);
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, FundBalanceResult.class);
}
@Override
public FundBalanceResult subDayEndBalance(String subMchid, String date) throws WxPayException {
String url = String.format("%s/v3/ecommerce/fund/enddaybalance/%s?date=%s", this.payService.getPayBaseUrl(), subMchid, date);
- URI uri = URI.create(url);
- String response = this.payService.getV3(uri);
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, FundBalanceResult.class);
}
@@ -200,7 +195,7 @@ public class EcommerceServiceImpl implements EcommerceService {
public ProfitSharingResult queryProfitSharing(ProfitSharingQueryRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/profitsharing/orders?sub_mchid=%s&transaction_id=%s&out_order_no=%s",
this.payService.getPayBaseUrl(), request.getSubMchid(), request.getTransactionId(), request.getOutOrderNo());
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, ProfitSharingResult.class);
}
@@ -239,7 +234,7 @@ public class EcommerceServiceImpl implements EcommerceService {
url = String.format("%s/v3/ecommerce/profitsharing/returnorders?sub_mchid=%s&order_id=%s&out_return_no=%s",
this.payService.getPayBaseUrl(), subMchid, orderId, outReturnNo);
}
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, ReturnOrdersResult.class);
}
@@ -260,14 +255,14 @@ public class EcommerceServiceImpl implements EcommerceService {
@Override
public RefundQueryResult queryRefundByRefundId(String subMchid, String refundId) throws WxPayException {
String url = String.format("%s/v3/ecommerce/refunds/id/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), refundId, subMchid);
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, RefundQueryResult.class);
}
@Override
public RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRefundNo) throws WxPayException {
String url = String.format("%s/v3/ecommerce/refunds/out-refund-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRefundNo, subMchid);
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, RefundQueryResult.class);
}
@@ -309,14 +304,14 @@ public class EcommerceServiceImpl implements EcommerceService {
@Override
public SubWithdrawStatusResult querySubWithdrawByOutRequestNo(String subMchid, String outRequestNo) throws WxPayException {
String url = String.format("%s/v3/ecommerce/fund/withdraw/out-request-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRequestNo, subMchid);
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, SubWithdrawStatusResult.class);
}
@Override
public SpWithdrawStatusResult querySpWithdrawByOutRequestNo(String outRequestNo) throws WxPayException {
String url = String.format("%s/v3/merchant/fund/withdraw/out-request-no/%s", this.payService.getPayBaseUrl(), outRequestNo);
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, SpWithdrawStatusResult.class);
}
@@ -330,27 +325,27 @@ public class EcommerceServiceImpl implements EcommerceService {
@Override
public SettlementResult querySettlement(String subMchid) throws WxPayException {
String url = String.format("%s/v3/apply4sub/sub_merchants/%s/settlement", this.payService.getPayBaseUrl(), subMchid);
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, SettlementResult.class);
}
@Override
public TradeBillResult applyBill(TradeBillRequest request) throws WxPayException {
String url = String.format("%s/v3/bill/tradebill?%s", this.payService.getPayBaseUrl(), this.parseURLPair(request));
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, TradeBillResult.class);
}
@Override
public FundBillResult applyFundBill(FundBillTypeEnum billType, FundBillRequest request) throws WxPayException {
String url = String.format(billType.getUrl(), this.payService.getPayBaseUrl(), this.parseURLPair(request));
- String response = this.payService.getV3(URI.create(url));
+ String response = this.payService.getV3(url);
return GSON.fromJson(response, FundBillResult.class);
}
@Override
public InputStream downloadBill(String url) throws WxPayException {
- return this.payService.downloadV3(URI.create(url));
+ return this.payService.downloadV3(url);
}
/**
@@ -380,8 +375,10 @@ public class EcommerceServiceImpl implements EcommerceService {
StringBuilder sb = new StringBuilder();
while (it.hasNext()) {
Map.Entry