1010import com .github .binarywang .wxpay .bean .order .WxPayNativeOrderResult ;
1111import com .github .binarywang .wxpay .bean .request .*;
1212import com .github .binarywang .wxpay .bean .result .*;
13+ import com .github .binarywang .wxpay .bean .result .enums .PartnerTradeTypeEnum ;
1314import com .github .binarywang .wxpay .bean .result .enums .TradeTypeEnum ;
1415import com .github .binarywang .wxpay .config .WxPayConfig ;
1516import com .github .binarywang .wxpay .config .WxPayConfigHolder ;
@@ -538,6 +539,16 @@ public void closeOrderV3(String outTradeNo) throws WxPayException {
538539 this .closeOrderV3 (request );
539540 }
540541
542+ @ Override
543+ public void closePartnerOrderV3 (String outTradeNo ) throws WxPayException {
544+ if (StringUtils .isBlank (outTradeNo )) {
545+ throw new WxPayException ("out_trade_no不能为空" );
546+ }
547+ WxPayPartnerOrderCloseV3Request request = new WxPayPartnerOrderCloseV3Request ();
548+ request .setOutTradeNo (StringUtils .trimToNull (outTradeNo ));
549+ this .closePartnerOrderV3 (request );
550+ }
551+
541552 @ Override
542553 public void closeOrderV3 (WxPayOrderCloseV3Request request ) throws WxPayException {
543554 if (StringUtils .isBlank (request .getMchid ())) {
@@ -547,6 +558,18 @@ public void closeOrderV3(WxPayOrderCloseV3Request request) throws WxPayException
547558 this .postV3 (url , GSON .toJson (request ));
548559 }
549560
561+ @ Override
562+ public void closePartnerOrderV3 (WxPayPartnerOrderCloseV3Request request ) throws WxPayException {
563+ if (StringUtils .isBlank (request .getSpMchId ())) {
564+ request .setSpMchId (this .getConfig ().getMchId ());
565+ }
566+ if (StringUtils .isBlank (request .getSubMchId ())) {
567+ request .setSubMchId (this .getConfig ().getSubMchId ());
568+ }
569+ String url = String .format ("%s/v3/pay/partner/transactions/out-trade-no/%s/close" , this .getPayBaseUrl (), request .getOutTradeNo ());
570+ this .postV3 (url , GSON .toJson (request ));
571+ }
572+
550573 @ Override
551574 public void closeCombine (CombineCloseRequest request ) throws WxPayException {
552575 String url = String .format ("%s/v3/combine-transactions/out-trade-no/%s/close" , this .getPayBaseUrl (), request .getCombineOutTradeNo ());
@@ -664,34 +687,19 @@ public <T> T createOrderV3(TradeTypeEnum tradeType, WxPayUnifiedOrderV3Request r
664687 }
665688
666689 @ Override
667- public <T > T createPartnerOrderV3 (TradeTypeEnum tradeType , WxPayPartnerUnifiedOrderV3Request request ) throws WxPayException {
690+ public <T > T createPartnerOrderV3 (PartnerTradeTypeEnum tradeType , WxPayPartnerUnifiedOrderV3Request request ) throws WxPayException {
668691 WxPayUnifiedOrderV3Result result = this .unifiedPartnerOrderV3 (tradeType , request );
669692 //获取应用ID
670693 String appId = StringUtils .isBlank (request .getSubAppid ()) ? request .getSpAppid () : request .getSubAppid ();
671- return result .getPayInfo (tradeType , appId , request .getSubMchId (), this .getConfig ().getPrivateKey ());
694+ return result .getPartnerPayInfo (tradeType , appId , request .getSubMchId (), this .getConfig ().getPrivateKey ());
672695 }
673696
674697 @ Override
675- public WxPayUnifiedOrderV3Result unifiedPartnerOrderV3 (TradeTypeEnum tradeType , WxPayPartnerUnifiedOrderV3Request request ) throws WxPayException {
676- if (StringUtils .isBlank (request .getSpAppid ())) {
677- request .setSpAppid (this .getConfig ().getAppId ());
678- }
679- if (StringUtils .isBlank (request .getSpMchId ())) {
680- request .setSpMchId (this .getConfig ().getMchId ());
681- }
682- if (StringUtils .isBlank (request .getNotifyUrl ())) {
683- request .setNotifyUrl (this .getConfig ().getNotifyUrl ());
684- }
685- if (StringUtils .isBlank (request .getSubAppid ())) {
686- request .setSubAppid (this .getConfig ().getSubAppId ());
687- }
688- if (StringUtils .isBlank (request .getSubMchId ())) {
689- request .setSubMchId (this .getConfig ().getSubMchId ());
690- }
691-
692- String url = this .getPayBaseUrl () + tradeType .getPartnerUrl ();
693- String response = this .postV3 (url , GSON .toJson (request ));
694- return GSON .fromJson (response , WxPayUnifiedOrderV3Result .class );
698+ public WxPayUnifiedOrderV3Result unifiedPartnerOrderV3 (PartnerTradeTypeEnum tradeType , WxPayPartnerUnifiedOrderV3Request request ) throws WxPayException {
699+ WxPayUnifiedOrderV3Result result = this .unifiedPartnerOrderV3 (tradeType , request );
700+ //获取应用ID
701+ String appId = StringUtils .isBlank (request .getSubAppid ()) ? request .getSpAppid () : request .getSubAppid ();
702+ return result .getPartnerPayInfo (tradeType , appId , request .getSubMchId (), this .getConfig ().getPrivateKey ());
695703 }
696704
697705 @ Override
0 commit comments