mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 #3659 【微信支付】新增BaseWxPayV3Result基类,提供rawJsonString字段保存原始API响应
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.github.binarywang.wxpay.bean.marketing;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayV3Result;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -13,7 +14,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class FavorCouponsGetResult implements Serializable {
|
||||
public class FavorCouponsGetResult extends BaseWxPayV3Result {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.github.binarywang.wxpay.bean.marketing;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayV3Result;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -13,7 +14,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class FavorStocksCreateResult implements Serializable {
|
||||
public class FavorStocksCreateResult extends BaseWxPayV3Result {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.github.binarywang.wxpay.bean.marketing;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayV3Result;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class FavorStocksGetResult implements Serializable {
|
||||
public class FavorStocksGetResult extends BaseWxPayV3Result {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.github.binarywang.wxpay.bean.result;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信支付v3结果共用属性类.
|
||||
* 用于保存原始JSON响应内容,便于访问API返回的新增字段.
|
||||
* </pre>
|
||||
*
|
||||
* @author Binary Wang
|
||||
*/
|
||||
@Data
|
||||
public abstract class BaseWxPayV3Result implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 原始JSON字符串.
|
||||
* 保存微信支付v3 API返回的原始JSON内容,便于访问未在Result类中定义的字段.
|
||||
*/
|
||||
private String rawJsonString;
|
||||
|
||||
/**
|
||||
* 获取原始JSON响应内容.
|
||||
*
|
||||
* @return 原始JSON字符串
|
||||
*/
|
||||
public String getRawJsonString() {
|
||||
return rawJsonString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置原始JSON响应内容.
|
||||
*
|
||||
* @param rawJsonString 原始JSON字符串
|
||||
*/
|
||||
public void setRawJsonString(String rawJsonString) {
|
||||
this.rawJsonString = rawJsonString;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,9 @@ public class MarketingFavorServiceImpl implements MarketingFavorService {
|
||||
String url = String.format("%s/v3/marketing/favor/coupon-stocks", this.payService.getPayBaseUrl());
|
||||
RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
|
||||
String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
|
||||
return GSON.fromJson(result, FavorStocksCreateResult.class);
|
||||
FavorStocksCreateResult favorStocksCreateResult = GSON.fromJson(result, FavorStocksCreateResult.class);
|
||||
favorStocksCreateResult.setRawJsonString(result);
|
||||
return favorStocksCreateResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +77,9 @@ public class MarketingFavorServiceImpl implements MarketingFavorService {
|
||||
String url = String.format("%s/v3/marketing/favor/stocks/%s", this.payService.getPayBaseUrl(), stockId);
|
||||
String query = String.format("?stock_creator_mchid=%s", stockCreatorMchid);
|
||||
String result = this.payService.getV3(url + query);
|
||||
return GSON.fromJson(result, FavorStocksGetResult.class);
|
||||
FavorStocksGetResult favorStocksGetResult = GSON.fromJson(result, FavorStocksGetResult.class);
|
||||
favorStocksGetResult.setRawJsonString(result);
|
||||
return favorStocksGetResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +87,9 @@ public class MarketingFavorServiceImpl implements MarketingFavorService {
|
||||
String url = String.format("%s/v3/marketing/favor/users/%s/coupons/%s", this.payService.getPayBaseUrl(), openid, couponId);
|
||||
String query = String.format("?appid=%s", appid);
|
||||
String result = this.payService.getV3(url + query);
|
||||
return GSON.fromJson(result, FavorCouponsGetResult.class);
|
||||
FavorCouponsGetResult favorCouponsGetResult = GSON.fromJson(result, FavorCouponsGetResult.class);
|
||||
favorCouponsGetResult.setRawJsonString(result);
|
||||
return favorCouponsGetResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user