|
1 | 1 | package com.github.binarywang.wxpay.service.impl; |
2 | 2 |
|
3 | | -import java.io.File; |
4 | | -import java.nio.charset.StandardCharsets; |
5 | | -import java.nio.file.Files; |
6 | | -import java.nio.file.Path; |
7 | | -import java.nio.file.Paths; |
8 | | -import java.util.Date; |
9 | | -import java.util.HashMap; |
10 | | -import java.util.LinkedList; |
11 | | -import java.util.List; |
12 | | -import java.util.Map; |
13 | | -import java.util.zip.ZipException; |
14 | | - |
15 | | -import org.apache.commons.lang3.StringUtils; |
16 | | -import org.slf4j.Logger; |
17 | | -import org.slf4j.LoggerFactory; |
18 | | - |
19 | 3 | import com.github.binarywang.utils.qrcode.QrcodeUtils; |
20 | 4 | import com.github.binarywang.wxpay.bean.WxPayApiData; |
21 | | -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryRequest; |
22 | | -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryResult; |
23 | | -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; |
24 | | -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; |
25 | | -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryRequest; |
26 | | -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryResult; |
| 5 | +import com.github.binarywang.wxpay.bean.coupon.*; |
27 | 6 | import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; |
28 | 7 | import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; |
29 | 8 | import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult; |
30 | 9 | import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; |
31 | 10 | import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; |
32 | 11 | import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult; |
33 | 12 | import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; |
34 | | -import com.github.binarywang.wxpay.bean.request.WxPayAuthcode2OpenidRequest; |
35 | | -import com.github.binarywang.wxpay.bean.request.WxPayDefaultRequest; |
36 | | -import com.github.binarywang.wxpay.bean.request.WxPayDownloadBillRequest; |
37 | | -import com.github.binarywang.wxpay.bean.request.WxPayDownloadFundFlowRequest; |
38 | | -import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; |
39 | | -import com.github.binarywang.wxpay.bean.request.WxPayOrderCloseRequest; |
40 | | -import com.github.binarywang.wxpay.bean.request.WxPayOrderQueryRequest; |
41 | | -import com.github.binarywang.wxpay.bean.request.WxPayOrderReverseRequest; |
42 | | -import com.github.binarywang.wxpay.bean.request.WxPayQueryCommentRequest; |
43 | | -import com.github.binarywang.wxpay.bean.request.WxPayRedpackQueryRequest; |
44 | | -import com.github.binarywang.wxpay.bean.request.WxPayRefundQueryRequest; |
45 | | -import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest; |
46 | | -import com.github.binarywang.wxpay.bean.request.WxPayReportRequest; |
47 | | -import com.github.binarywang.wxpay.bean.request.WxPaySendRedpackRequest; |
48 | | -import com.github.binarywang.wxpay.bean.request.WxPayShorturlRequest; |
49 | | -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; |
50 | | -import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; |
51 | | -import com.github.binarywang.wxpay.bean.result.WxPayAuthcode2OpenidResult; |
52 | | -import com.github.binarywang.wxpay.bean.result.WxPayBillResult; |
53 | | -import com.github.binarywang.wxpay.bean.result.WxPayCommonResult; |
54 | | -import com.github.binarywang.wxpay.bean.result.WxPayFundFlowBaseResult; |
55 | | -import com.github.binarywang.wxpay.bean.result.WxPayFundFlowResult; |
56 | | -import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; |
57 | | -import com.github.binarywang.wxpay.bean.result.WxPayOrderCloseResult; |
58 | | -import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult; |
59 | | -import com.github.binarywang.wxpay.bean.result.WxPayOrderReverseResult; |
60 | | -import com.github.binarywang.wxpay.bean.result.WxPayRedpackQueryResult; |
61 | | -import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryResult; |
62 | | -import com.github.binarywang.wxpay.bean.result.WxPayRefundResult; |
63 | | -import com.github.binarywang.wxpay.bean.result.WxPaySandboxSignKeyResult; |
64 | | -import com.github.binarywang.wxpay.bean.result.WxPaySendRedpackResult; |
65 | | -import com.github.binarywang.wxpay.bean.result.WxPayShorturlResult; |
66 | | -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderResult; |
| 13 | +import com.github.binarywang.wxpay.bean.request.*; |
| 14 | +import com.github.binarywang.wxpay.bean.result.*; |
67 | 15 | import com.github.binarywang.wxpay.config.WxPayConfig; |
68 | 16 | import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; |
69 | 17 | import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; |
|
75 | 23 | import com.google.common.base.Joiner; |
76 | 24 | import com.google.common.collect.Maps; |
77 | 25 | import jodd.io.ZipUtil; |
| 26 | +import org.apache.commons.lang3.StringUtils; |
| 27 | +import org.slf4j.Logger; |
| 28 | +import org.slf4j.LoggerFactory; |
| 29 | + |
| 30 | +import java.io.File; |
| 31 | +import java.nio.charset.StandardCharsets; |
| 32 | +import java.nio.file.Files; |
| 33 | +import java.nio.file.Path; |
| 34 | +import java.nio.file.Paths; |
| 35 | +import java.util.*; |
| 36 | +import java.util.zip.ZipException; |
78 | 37 |
|
79 | 38 | import static com.github.binarywang.wxpay.constant.WxPayConstants.QUERY_COMMENT_DATE_FORMAT; |
80 | 39 | import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; |
@@ -142,7 +101,7 @@ public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayExceptio |
142 | 101 |
|
143 | 102 | String url = this.getPayBaseUrl() + "/secapi/pay/refund"; |
144 | 103 | if (this.getConfig().isUseSandboxEnv()) { |
145 | | - url = PAY_BASE_URL + "/sandboxnew/pay/refund"; |
| 104 | + url = PAY_BASE_URL + "/sandboxnew/pay/refund"; |
146 | 105 | } |
147 | 106 |
|
148 | 107 | String responseContent = this.post(url, request.toXML(), true); |
@@ -242,15 +201,9 @@ public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throw |
242 | 201 | public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException { |
243 | 202 | WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest(); |
244 | 203 | request.setMchBillNo(mchBillNo); |
245 | | - request.setBillType(BillType.MCHT); |
246 | | - request.checkAndSign(this.getConfig()); |
247 | | - |
248 | | - String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo"; |
249 | | - String responseContent = this.post(url, request.toXML(), true); |
250 | | - WxPayRedpackQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayRedpackQueryResult.class); |
251 | | - result.checkResult(this, request.getSignType(), true); |
252 | | - return result; |
| 204 | + return this.queryRedpack(request); |
253 | 205 | } |
| 206 | + |
254 | 207 | @Override |
255 | 208 | public WxPayRedpackQueryResult queryRedpack(WxPayRedpackQueryRequest request) throws WxPayException { |
256 | 209 | request.setBillType(BillType.MCHT); |
@@ -820,25 +773,16 @@ public String queryComment(Date beginDate, Date endDate, Integer offset, Integer |
820 | 773 | request.setEndTime(QUERY_COMMENT_DATE_FORMAT.format(endDate)); |
821 | 774 | request.setOffset(offset); |
822 | 775 | request.setLimit(limit); |
823 | | - request.setSignType(SignType.HMAC_SHA256); |
824 | | - |
825 | | - request.checkAndSign(this.getConfig()); |
826 | 776 |
|
827 | | - String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment"; |
828 | | - |
829 | | - String responseContent = this.post(url, request.toXML(), true); |
830 | | - if (responseContent.startsWith("<")) { |
831 | | - throw WxPayException.from(BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class)); |
832 | | - } |
833 | | - |
834 | | - return responseContent; |
| 777 | + return this.queryComment(request); |
835 | 778 | } |
| 779 | + |
836 | 780 | @Override |
837 | 781 | public String queryComment(WxPayQueryCommentRequest request) throws WxPayException { |
838 | 782 | request.checkAndSign(this.getConfig()); |
839 | 783 | request.setSignType(SignType.HMAC_SHA256); |
840 | | - String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment"; |
841 | 784 |
|
| 785 | + String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment"; |
842 | 786 | String responseContent = this.post(url, request.toXML(), true); |
843 | 787 | if (responseContent.startsWith("<")) { |
844 | 788 | throw WxPayException.from(BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class)); |
|
0 commit comments