@@ -311,8 +311,12 @@ public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
311311
312312 case TradeType .APP : {
313313 // APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数
314- String appId = this .getConfig ().getAppId ();
315- Map <String , String > configMap = new HashMap <>();
314+ String appId = unifiedOrderResult .getAppid ();
315+ if (StringUtils .isNotEmpty (unifiedOrderResult .getSubAppId ())) {
316+ appId = unifiedOrderResult .getSubAppId ();
317+ }
318+
319+ Map <String , String > configMap = new HashMap <>(8 );
316320 // 此map用于参与调起sdk支付的二次签名,格式全小写,timestamp只能是10位,格式固定,切勿修改
317321 String partnerId = getConfig ().getMchId ();
318322 configMap .put ("prepayid" , prepayId );
@@ -336,21 +340,20 @@ public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
336340
337341 case TradeType .JSAPI : {
338342 String signType = SignType .MD5 ;
343+ String appid = unifiedOrderResult .getAppid ();
344+ if (StringUtils .isNotEmpty (this .getConfig ().getSubAppId ())) {
345+ appid = this .getConfig ().getSubAppId ();
346+ }
347+
339348 WxPayMpOrderResult payResult = WxPayMpOrderResult .builder ()
340- .appId (unifiedOrderResult . getAppid () )
349+ .appId (appid )
341350 .timeStamp (timestamp )
342351 .nonceStr (nonceStr )
343352 .packageValue ("prepay_id=" + prepayId )
344353 .signType (signType )
345354 .build ();
346355
347- payResult .setPaySign (
348- SignUtils .createSign (
349- payResult ,
350- signType ,
351- this .getConfig ().getMchKey (),
352- false )
353- );
356+ payResult .setPaySign (SignUtils .createSign (payResult , signType , this .getConfig ().getMchKey (), false ));
354357 return (T ) payResult ;
355358 }
356359
@@ -534,7 +537,7 @@ private String handleGzipBill(String url, String requestStr) throws WxPayExcepti
534537 }
535538 }
536539 } catch (Exception e ) {
537- this .log .error ("解析对账单文件时出错" ,e );
540+ this .log .error ("解析对账单文件时出错" , e );
538541 }
539542
540543 return null ;
0 commit comments