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(); + + } + /** * 查询该代金券可用的商户