Skip to content

Commit

Permalink
🐛 Wechat-Group#2338 【微信支付】营销代金券接口修复pause和restart实现的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lcdevelop authored and aieyes committed Jan 17, 2022
1 parent 5ca1153 commit 79c839c
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.github.binarywang.wxpay.bean.marketing;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* 暂停代金券批次返回结果对象
*
* @author lichuang
*/
@NoArgsConstructor
@Data
public class FavorStocksPauseResult implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 生效时间
* <p>
* 生效时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
* 示例值:2015-05-20T13:29:35.120+08:00
*/
@SerializedName("pause_time")
private String pauseTime;

/**
* 批次号
* <p>
* 微信为每个代金券批次分配的唯一ID。
* 示例值:98065001
*/
@SerializedName("stock_id")
private String stockId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.github.binarywang.wxpay.bean.marketing;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* 重启代金券批次返回结果对象
*
* @author lichuang
*/
@NoArgsConstructor
@Data
public class FavorStocksRestartResult implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 生效时间
* <p>
* 生效时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
* 示例值:2015-05-20T13:29:35.120+08:00
*/
@SerializedName("restart_time")
private String restartTime;

/**
* 批次号
* <p>
* 微信为每个代金券批次分配的唯一ID。
* 示例值:98065001
*/
@SerializedName("stock_id")
private String stockId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ public interface MarketingFavorService {
* </pre>
*
* @param request 请求对象
* @return FavorCallbacksSaveResult 微信返回的结果信息。
* @return FavorStocksPauseResult 微信返回的结果信息。
* @throws WxPayException the wx pay exception
*/
FavorStocksStartResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException;
FavorStocksPauseResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException;

/**
* <pre>
Expand All @@ -200,10 +200,10 @@ public interface MarketingFavorService {
* </pre>
*
* @param request 请求对象
* @return FavorCallbacksSaveResult 微信返回的结果信息。
* @return FavorStocksRestartResult 微信返回的结果信息。
* @throws WxPayException the wx pay exception
*/
FavorStocksStartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException;
FavorStocksRestartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException;

UseNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@ public FavorCallbacksSaveResult saveFavorCallbacksV3(FavorCallbacksSaveRequest r
}

@Override
public FavorStocksStartResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException {
String url = String.format("%s/v3/marketing/favor/stocks/%s/start", this.payService.getPayBaseUrl(), stockId);
public FavorStocksPauseResult pauseFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException {
String url = String.format("%s/v3/marketing/favor/stocks/%s/pause", this.payService.getPayBaseUrl(), stockId);
RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(result, FavorStocksStartResult.class);
return GSON.fromJson(result, FavorStocksPauseResult.class);
}

@Override
public FavorStocksStartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException {
String url = String.format("%s/v3/marketing/favor/stocks/%s/start", this.payService.getPayBaseUrl(), stockId);
public FavorStocksRestartResult restartFavorStocksV3(String stockId, FavorStocksSetRequest request) throws WxPayException {
String url = String.format("%s/v3/marketing/favor/stocks/%s/restart", this.payService.getPayBaseUrl(), stockId);
RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(result, FavorStocksStartResult.class);
return GSON.fromJson(result, FavorStocksRestartResult.class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void testSaveFavorCallbacksV3() throws WxPayException {
public void testPauseFavorStocksV3() throws WxPayException {
FavorStocksSetRequest request = new FavorStocksSetRequest();
request.setStockCreatorMchid(wxPayService.getConfig().getMchId());
FavorStocksStartResult result = wxPayService.getMarketingFavorService().pauseFavorStocksV3(stockId, request);
FavorStocksPauseResult result = wxPayService.getMarketingFavorService().pauseFavorStocksV3(stockId, request);

log.info("result: {}", GSON.toJson(result));
}
Expand All @@ -184,7 +184,7 @@ public void testPauseFavorStocksV3() throws WxPayException {
public void testRestartFavorStocksV3() throws WxPayException {
FavorStocksSetRequest request = new FavorStocksSetRequest();
request.setStockCreatorMchid(wxPayService.getConfig().getMchId());
FavorStocksStartResult result = wxPayService.getMarketingFavorService().restartFavorStocksV3(stockId, request);
FavorStocksRestartResult result = wxPayService.getMarketingFavorService().restartFavorStocksV3(stockId, request);

log.info("result: {}", GSON.toJson(result));
}
Expand Down

0 comments on commit 79c839c

Please sign in to comment.