|
@@ -1,29 +1,8 @@ |
|
|
package com.github.binarywang.wxpay.service.impl; |
|
|
package com.github.binarywang.wxpay.service.impl; |
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
|
import java.nio.file.Paths; |
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.zip.ZipException; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
import com.github.binarywang.utils.qrcode.QrcodeUtils; |
|
|
import com.github.binarywang.utils.qrcode.QrcodeUtils; |
|
|
import com.github.binarywang.wxpay.bean.WxPayApiData; |
|
|
import com.github.binarywang.wxpay.bean.WxPayApiData; |
|
|
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryRequest; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryRequest; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryResult; |
|
|
|
|
|
|
|
|
import com.github.binarywang.wxpay.bean.coupon.*; |
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; |
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; |
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; |
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; |
|
|
import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult; |
|
|
import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult; |
|
@@ -31,39 +10,8 @@ import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; |
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; |
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; |
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult; |
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult; |
|
|
import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; |
|
|
import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; |
|
|
import com.github.binarywang.wxpay.bean.request.WxPayAuthcode2OpenidRequest; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayDefaultRequest; |
|
|
|
|
|
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.WxPayQueryCommentRequest; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayRedpackQueryRequest; |
|
|
|
|
|
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.BaseWxPayResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayAuthcode2OpenidResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayBillResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayCommonResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayFundFlowBaseResult; |
|
|
|
|
|
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.WxPaySandboxSignKeyResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPaySendRedpackResult; |
|
|
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayShorturlResult; |
|
|
|
|
|
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.config.WxPayConfig; |
|
|
import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; |
|
|
import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; |
|
|
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; |
|
|
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; |
|
@@ -75,6 +23,17 @@ import com.github.binarywang.wxpay.util.SignUtils; |
|
|
import com.google.common.base.Joiner; |
|
|
import com.google.common.base.Joiner; |
|
|
import com.google.common.collect.Maps; |
|
|
import com.google.common.collect.Maps; |
|
|
import jodd.io.ZipUtil; |
|
|
import jodd.io.ZipUtil; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
|
import java.nio.file.Paths; |
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
import java.util.zip.ZipException; |
|
|
|
|
|
|
|
|
import static com.github.binarywang.wxpay.constant.WxPayConstants.QUERY_COMMENT_DATE_FORMAT; |
|
|
import static com.github.binarywang.wxpay.constant.WxPayConstants.QUERY_COMMENT_DATE_FORMAT; |
|
|
import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; |
|
|
import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; |
|
@@ -142,7 +101,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { |
|
|
|
|
|
|
|
|
String url = this.getPayBaseUrl() + "/secapi/pay/refund"; |
|
|
String url = this.getPayBaseUrl() + "/secapi/pay/refund"; |
|
|
if (this.getConfig().isUseSandboxEnv()) { |
|
|
if (this.getConfig().isUseSandboxEnv()) { |
|
|
url = PAY_BASE_URL + "/sandboxnew/pay/refund"; |
|
|
|
|
|
|
|
|
url = PAY_BASE_URL + "/sandboxnew/pay/refund"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String responseContent = this.post(url, request.toXML(), true); |
|
|
String responseContent = this.post(url, request.toXML(), true); |
|
@@ -242,15 +201,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { |
|
|
public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException { |
|
|
public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException { |
|
|
WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest(); |
|
|
WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest(); |
|
|
request.setMchBillNo(mchBillNo); |
|
|
request.setMchBillNo(mchBillNo); |
|
|
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; |
|
|
|
|
|
|
|
|
return this.queryRedpack(request); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public WxPayRedpackQueryResult queryRedpack(WxPayRedpackQueryRequest request) throws WxPayException { |
|
|
public WxPayRedpackQueryResult queryRedpack(WxPayRedpackQueryRequest request) throws WxPayException { |
|
|
request.setBillType(BillType.MCHT); |
|
|
request.setBillType(BillType.MCHT); |
|
@@ -820,25 +773,16 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { |
|
|
request.setEndTime(QUERY_COMMENT_DATE_FORMAT.format(endDate)); |
|
|
request.setEndTime(QUERY_COMMENT_DATE_FORMAT.format(endDate)); |
|
|
request.setOffset(offset); |
|
|
request.setOffset(offset); |
|
|
request.setLimit(limit); |
|
|
request.setLimit(limit); |
|
|
request.setSignType(SignType.HMAC_SHA256); |
|
|
|
|
|
|
|
|
|
|
|
request.checkAndSign(this.getConfig()); |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
return this.queryComment(request); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public String queryComment(WxPayQueryCommentRequest request) throws WxPayException { |
|
|
public String queryComment(WxPayQueryCommentRequest request) throws WxPayException { |
|
|
request.checkAndSign(this.getConfig()); |
|
|
request.checkAndSign(this.getConfig()); |
|
|
request.setSignType(SignType.HMAC_SHA256); |
|
|
request.setSignType(SignType.HMAC_SHA256); |
|
|
String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment"; |
|
|
String responseContent = this.post(url, request.toXML(), true); |
|
|
String responseContent = this.post(url, request.toXML(), true); |
|
|
if (responseContent.startsWith("<")) { |
|
|
if (responseContent.startsWith("<")) { |
|
|
throw WxPayException.from(BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class)); |
|
|
throw WxPayException.from(BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class)); |
|
|