فهرست منبع

:bug: #2338 【微信支付】营销代金券接口修复pause和restart实现的问题

Lucas 3 سال پیش
والد
کامیت
3c4e749ea9

+ 37 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksPauseResult.java

@@ -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;
+}

+ 37 - 0
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/FavorStocksRestartResult.java

@@ -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;
+}

+ 4 - 4
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MarketingFavorService.java

@@ -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>
@@ -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;
 

+ 6 - 6
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImpl.java

@@ -154,19 +154,19 @@ public class MarketingFavorServiceImpl implements MarketingFavorService {
   }
 
   @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);
   }
 
   /**

+ 2 - 2
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImplTest.java

@@ -175,7 +175,7 @@ public class MarketingFavorServiceImplTest {
   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));
   }
@@ -184,7 +184,7 @@ public class MarketingFavorServiceImplTest {
   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));
   }