fix: 代金券批次详情无法解析body

This commit is contained in:
xiafang
2020-11-24 17:05:24 +08:00
parent 88abacb7cc
commit 3555a4aaa4

View File

@@ -97,29 +97,13 @@ public class WechatPayV3Api {
public WechatResponseEntity<ObjectNode> startStock(String stockId) { public WechatResponseEntity<ObjectNode> startStock(String stockId) {
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>(); WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
wechatPayV3Client.withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_START, stockId) wechatPayV3Client.withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_START, stockId)
.function(this::startStocksFunction) .function(this::startStockFunction)
.consumer(wechatResponseEntity::convert) .consumer(wechatResponseEntity::convert)
.request(); .request();
return wechatResponseEntity; return wechatResponseEntity;
} }
/** private RequestEntity<?> startStockFunction(WechatPayV3Type type, String stockId) {
* 查询批次详情API.
*
* @param stockId the stock id
* @return the wechat response entity
*/
public WechatResponseEntity<ObjectNode> stockDetail(String stockId) {
WechatResponseEntity<ObjectNode> 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) {
WechatPayProperties.V3 v3 = wechatMetaBean.getWechatPayProperties().getV3(); WechatPayProperties.V3 v3 = wechatMetaBean.getWechatPayProperties().getV3();
String mchId = v3.getMchId(); String mchId = v3.getMchId();
String httpUrl = type.uri(WeChatServer.CHINA); String httpUrl = type.uri(WeChatServer.CHINA);
@@ -136,6 +120,34 @@ public class WechatPayV3Api {
throw new PayException("wechat app pay json failed"); throw new PayException("wechat app pay json failed");
} }
/**
* 查询批次详情API.
*
* @param stockId the stock id
* @return the wechat response entity
*/
public WechatResponseEntity<ObjectNode> stockDetail(String stockId) {
WechatResponseEntity<ObjectNode> 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<String, String> 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();
}
/** /**
* 查询该代金券可用的商户 * 查询该代金券可用的商户