From 3555a4aaa496c4a7e39d38ef25d81ffdd0dd249b Mon Sep 17 00:00:00 2001 From: xiafang Date: Tue, 24 Nov 2020 17:05:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=A3=E9=87=91=E5=88=B8=E6=89=B9?= =?UTF-8?q?=E6=AC=A1=E8=AF=A6=E6=83=85=E6=97=A0=E6=B3=95=E8=A7=A3=E6=9E=90?= =?UTF-8?q?body?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/wechat/v3/WechatPayV3Api.java | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatPayV3Api.java b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatPayV3Api.java index 8172dc2..5dc5d49 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatPayV3Api.java +++ b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatPayV3Api.java @@ -97,29 +97,13 @@ public class WechatPayV3Api { public WechatResponseEntity startStock(String stockId) { WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); wechatPayV3Client.withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_START, stockId) - .function(this::startStocksFunction) + .function(this::startStockFunction) .consumer(wechatResponseEntity::convert) .request(); return wechatResponseEntity; } - /** - * 查询批次详情API. - * - * @param stockId the stock id - * @return the wechat response entity - */ - public WechatResponseEntity stockDetail(String stockId) { - WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); - wechatPayV3Client.withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_DETAIL, stockId) - .function(this::startStocksFunction) - .consumer(wechatResponseEntity::convert) - .request(); - return wechatResponseEntity; - } - - - private RequestEntity startStocksFunction(WechatPayV3Type type, String stockId) { + private RequestEntity startStockFunction(WechatPayV3Type type, String stockId) { WechatPayProperties.V3 v3 = wechatMetaBean.getWechatPayProperties().getV3(); String mchId = v3.getMchId(); String httpUrl = type.uri(WeChatServer.CHINA); @@ -136,6 +120,34 @@ public class WechatPayV3Api { throw new PayException("wechat app pay json failed"); } + /** + * 查询批次详情API. + * + * @param stockId the stock id + * @return the wechat response entity + */ + public WechatResponseEntity stockDetail(String stockId) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + wechatPayV3Client.withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_DETAIL, stockId) + .function(this::stockDetailFunction) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + + private RequestEntity stockDetailFunction(WechatPayV3Type type, String stockId) { + WechatPayProperties.V3 v3 = wechatMetaBean.getWechatPayProperties().getV3(); + + String httpUrl = type.uri(WeChatServer.CHINA); + + MultiValueMap queryParams = new LinkedMultiValueMap<>(); + queryParams.add("stock_creator_mchid", v3.getMchId()); + URI uri = UriComponentsBuilder.fromHttpUrl(httpUrl).queryParams(queryParams).build().expand(stockId).toUri(); + return RequestEntity.get(uri).build(); + + } + /** * 查询该代金券可用的商户