mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
完善注释
This commit is contained in:
@@ -65,7 +65,7 @@ public class PayConfig {
|
||||
WechatMarketingApi wchatMarketingApi;
|
||||
```
|
||||
###### V3
|
||||
例如V3 APP 支付
|
||||
例如V3 查询商户下的优惠券
|
||||
|
||||
```java
|
||||
// 查询商户下的优惠券
|
||||
@@ -74,7 +74,7 @@ public class PayConfig {
|
||||
StocksQueryParams params = new StocksQueryParams();
|
||||
params.setOffset(0);
|
||||
params.setLimit(10);
|
||||
WechatResponseEntity<ObjectNode> objectNodeWechatResponseEntity = wechatPayV3Api.queryStocksByMch(params);
|
||||
WechatResponseEntity<ObjectNode> objectNodeWechatResponseEntity = wchatMarketingApi.queryStocksByMch(params);
|
||||
System.out.println("objectNodeWechatResponseEntity = " + objectNodeWechatResponseEntity);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -58,7 +58,7 @@ public class WechatPayConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wechat pay v3 api.
|
||||
* 微信支付API.
|
||||
*
|
||||
* @param wechatPayClient the wechat pay v 3 client
|
||||
* @param wechatMetaBean the wechat meta bean
|
||||
@@ -70,7 +70,7 @@ public class WechatPayConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wechat marketing api wechat marketing api.
|
||||
* 微信营销API.
|
||||
*
|
||||
* @param wechatPayClient the wechat pay client
|
||||
* @param wechatMetaBean the wechat meta bean
|
||||
@@ -82,7 +82,7 @@ public class WechatPayConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wechat pay callback.
|
||||
* 微信支付回调工具.
|
||||
*
|
||||
* @param signatureProvider the signature provider
|
||||
* @return the wechat pay callback
|
||||
|
||||
@@ -44,13 +44,18 @@ public enum WechatPayV3Type {
|
||||
*/
|
||||
MARKETING_FAVOR_STOCKS_START(HttpMethod.POST,"%s/v3/marketing/favor/stocks/{stock_id}/start"),
|
||||
/**
|
||||
* 重启代金券
|
||||
* 暂停代金券批次API.
|
||||
*/
|
||||
MARKETING_FAVOR_STOCKS_RESTART(HttpMethod.POST,"%s/v3/marketing/favor/stocks/{stock_id}/restart"),
|
||||
MARKETING_FAVOR_STOCKS_PAUSE(HttpMethod.POST,"%s/v3/marketing/favor/stocks/{stock_id}/pause"),
|
||||
|
||||
/**
|
||||
* 发放代金券API & 根据商户号查用户的券.
|
||||
*/
|
||||
MARKETING_FAVOR_USERS_COUPONS(HttpMethod.POST,"%s/v3/marketing/favor/users/{openid}/coupons"),
|
||||
/**
|
||||
* 重启代金券
|
||||
*/
|
||||
MARKETING_FAVOR_STOCKS_RESTART(HttpMethod.POST,"%s/v3/marketing/favor/stocks/{stock_id}/restart"),
|
||||
/**
|
||||
* 查询代金券可用商户.
|
||||
*/
|
||||
|
||||
@@ -79,12 +79,54 @@ public class WechatMarketingApi extends AbstractApi {
|
||||
public WechatResponseEntity<ObjectNode> startStock(String stockId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_START, stockId)
|
||||
.function(this::startAndRestartStockFunction)
|
||||
.function(this::startAndRestartAndPauseStockFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发放代金券API.
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> sendStock(StocksSendParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_FAVOR_USERS_COUPONS, params)
|
||||
.function(this::sendStocksFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
|
||||
private RequestEntity<?> sendStocksFunction(WechatPayV3Type type, StocksSendParams params) {
|
||||
WechatPayProperties.V3 v3 = this.meta().getWechatPayProperties().getV3();
|
||||
// 服务号
|
||||
params.setAppid(v3.getMp().getAppId());
|
||||
params.setStockCreatorMchid(v3.getMchId());
|
||||
String httpUrl = type.uri(WeChatServer.CHINA);
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(httpUrl).build().expand(params.getOpenid()).toUri();
|
||||
params.setOpenid(null);
|
||||
return post(uri, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停代金券批次API.
|
||||
*
|
||||
* @param stockId the stock id
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> pauseStock(String stockId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_PAUSE, stockId)
|
||||
.function(this::startAndRestartAndPauseStockFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
/**
|
||||
* 重启代金券批次API.
|
||||
*
|
||||
@@ -94,13 +136,13 @@ public class WechatMarketingApi extends AbstractApi {
|
||||
public WechatResponseEntity<ObjectNode> restartStock(String stockId) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_FAVOR_STOCKS_RESTART, stockId)
|
||||
.function(this::startAndRestartStockFunction)
|
||||
.function(this::startAndRestartAndPauseStockFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
private RequestEntity<?> startAndRestartStockFunction(WechatPayV3Type type, String stockId) {
|
||||
private RequestEntity<?> startAndRestartAndPauseStockFunction(WechatPayV3Type type, String stockId) {
|
||||
WechatPayProperties.V3 v3 = this.meta().getWechatPayProperties().getV3();
|
||||
String mchId = v3.getMchId();
|
||||
Map<String, String> body = new HashMap<>();
|
||||
@@ -212,33 +254,6 @@ public class WechatMarketingApi extends AbstractApi {
|
||||
return RequestEntity.get(uri).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放代金券API.
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> sendStock(StocksSendParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.MARKETING_FAVOR_USERS_COUPONS, params)
|
||||
.function(this::sendStocksFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
|
||||
private RequestEntity<?> sendStocksFunction(WechatPayV3Type type, StocksSendParams params) {
|
||||
WechatPayProperties.V3 v3 = this.meta().getWechatPayProperties().getV3();
|
||||
// 服务号
|
||||
params.setAppid(v3.getMp().getAppId());
|
||||
params.setStockCreatorMchid(v3.getMchId());
|
||||
String httpUrl = type.uri(WeChatServer.CHINA);
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(httpUrl).build().expand(params.getOpenid()).toUri();
|
||||
params.setOpenid(null);
|
||||
return post(uri, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销图片上传API.
|
||||
*
|
||||
|
||||
@@ -16,8 +16,10 @@ import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* The type Wechat pay callback.
|
||||
*
|
||||
* @author Dax
|
||||
* @since 10:21
|
||||
* @since 10 :21
|
||||
*/
|
||||
@Slf4j
|
||||
public class WechatPayCallback {
|
||||
@@ -29,11 +31,23 @@ public class WechatPayCallback {
|
||||
MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Wechat pay callback.
|
||||
*
|
||||
* @param signatureProvider the signature provider
|
||||
*/
|
||||
public WechatPayCallback(SignatureProvider signatureProvider) {
|
||||
this.signatureProvider = signatureProvider;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信支付代金券核销回调工具.
|
||||
*
|
||||
* @param params the params
|
||||
* @param couponConsumeDataConsumer the coupon consume data consumer
|
||||
* @return the map
|
||||
*/
|
||||
@SneakyThrows
|
||||
public Map<String, ?> wechatPayCouponCallback(ResponseSignVerifyParams params, Consumer<CouponConsumeData> couponConsumeDataConsumer) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user