From cae7d4fbf221144cfaa7c55810ec6e2a5af3cf9f Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 6 Jun 2026 20:27:21 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20#4024=20=E3=80=90=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E3=80=91=E8=A1=A5=E9=BD=90=20V3=20=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E9=80=9A=E7=9F=A5=E5=9B=9E=E8=B0=83=E4=B8=AD=20amount?= =?UTF-8?q?=20=E5=AF=B9=E8=B1=A1=E7=9A=84=E5=AE=98=E6=96=B9=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=B9=B6=E5=85=BC=E5=AE=B9=E6=97=A7=20refund=20?= =?UTF-8?q?=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notify/WxPayRefundNotifyV3Result.java | 116 +++++++++++++++++- .../notify/WxPayRefundNotifyV3ResultTest.java | 61 +++++++++ 2 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3ResultTest.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java index c3473ee46..f9a68de68 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3Result.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; +import java.util.List; /** * 退款结果通知. @@ -175,7 +176,7 @@ public class WxPayRefundNotifyV3Result implements Serializable, WxPayBaseNotifyV /** *
* 字段名:退款金额
- * 变量名:refund
+ * 变量名:refund_fee
* 是否必填:是
* 类型:int
* 描述:
@@ -183,8 +184,21 @@ public class WxPayRefundNotifyV3Result implements Serializable, WxPayBaseNotifyV
* 示例值:999
*
*/
- @SerializedName(value = "refund")
- private Integer refund;
+ @SerializedName(value = "refund_fee", alternate = {"refund"})
+ private Integer refundFee;
+ /**
+ * + * 字段名:退款结算金额 + * 变量名:settlement_refund + * 是否必填:否 + * 类型:int + * 描述: + * 退款结算金额,单位为分。 + * 示例值:999 + *+ */ + @SerializedName(value = "settlement_refund") + private Integer settlementRefund; /** *
* 字段名:用户支付金额
@@ -211,5 +225,101 @@ public class WxPayRefundNotifyV3Result implements Serializable, WxPayBaseNotifyV
*/
@SerializedName(value = "payer_refund")
private Integer payerRefund;
+ /**
+ *
+ * 字段名:币种
+ * 变量名:currency
+ * 是否必填:否
+ * 类型:string[1,16]
+ * 描述:
+ * 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
+ * 示例值:CNY
+ *
+ */
+ @SerializedName(value = "currency")
+ private String currency;
+ /**
+ *
+ * 字段名:结算金额
+ * 变量名:settlement_total
+ * 是否必填:否
+ * 类型:int
+ * 描述:
+ * 结算金额,单位为分。
+ * 示例值:999
+ *
+ */
+ @SerializedName(value = "settlement_total")
+ private Integer settlementTotal;
+ /**
+ *
+ * 字段名:优惠券退款金额
+ * 变量名:discount_refund
+ * 是否必填:否
+ * 类型:int
+ * 描述:
+ * 优惠券退款金额,单位为分。
+ * 示例值:0
+ *
+ */
+ @SerializedName(value = "discount_refund")
+ private Integer discountRefund;
+ /**
+ *
+ * 字段名:退款账户来源
+ * 变量名:from
+ * 是否必填:否
+ * 类型:array
+ * 描述:
+ * 退款出资的账户类型及金额信息
+ *
+ */
+ @SerializedName(value = "from")
+ private List from;
+
+ @Deprecated
+ public Integer getRefund() {
+ return this.refundFee;
+ }
+
+ @Deprecated
+ public void setRefund(Integer refund) {
+ this.refundFee = refund;
+ }
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class FromItem implements Serializable {
+ private static final long serialVersionUID = 1L;
+ /**
+ *
+ * 字段名:退款账户类型
+ * 变量名:account
+ * 是否必填:是
+ * 类型:string[1,32]
+ * 描述:
+ * 下面枚举值多选一。
+ * 枚举值:
+ * AVAILABLE : 可用余额
+ * UNAVAILABLE : 不可用余额
+ * 示例值:AVAILABLE
+ *
+ */
+ @SerializedName(value = "account")
+ private String account;
+ /**
+ *
+ * 字段名:退款账户金额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 对应账户退款金额
+ * 示例值:444
+ *
+ */
+ @SerializedName(value = "amount")
+ private Integer amount;
}
}
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3ResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3ResultTest.java
new file mode 100644
index 000000000..8b3487c51
--- /dev/null
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyV3ResultTest.java
@@ -0,0 +1,61 @@
+package com.github.binarywang.wxpay.bean.notify;
+
+import com.google.gson.Gson;
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class WxPayRefundNotifyV3ResultTest {
+
+ private static final Gson GSON = new Gson();
+
+ @Test
+ public void shouldDeserializeOfficialAmountFields() {
+ String json = "{"
+ + "\"mchid\":\"1900000100\","
+ + "\"out_trade_no\":\"1217752501201407033233368018\","
+ + "\"transaction_id\":\"4200000000000000000000000000\","
+ + "\"out_refund_no\":\"1217752501201407033233368019\","
+ + "\"refund_id\":\"50000000382019052709732678859\","
+ + "\"refund_status\":\"SUCCESS\","
+ + "\"success_time\":\"2020-12-01T12:00:00+08:00\","
+ + "\"user_received_account\":\"支付用户零钱\","
+ + "\"amount\":{"
+ + "\"refund_fee\":10,"
+ + "\"settlement_refund\":9,"
+ + "\"total\":100,"
+ + "\"currency\":\"CNY\","
+ + "\"payer_total\":90,"
+ + "\"payer_refund\":10,"
+ + "\"settlement_total\":90,"
+ + "\"discount_refund\":1,"
+ + "\"from\":[{\"account\":\"AVAILABLE\",\"amount\":10}]"
+ + "}"
+ + "}";
+
+ WxPayRefundNotifyV3Result.DecryptNotifyResult result =
+ GSON.fromJson(json, WxPayRefundNotifyV3Result.DecryptNotifyResult.class);
+
+ assertThat(result.getAmount().getRefundFee()).isEqualTo(10);
+ assertThat(result.getAmount().getRefund()).isEqualTo(10);
+ assertThat(result.getAmount().getSettlementRefund()).isEqualTo(9);
+ assertThat(result.getAmount().getTotal()).isEqualTo(100);
+ assertThat(result.getAmount().getCurrency()).isEqualTo("CNY");
+ assertThat(result.getAmount().getPayerTotal()).isEqualTo(90);
+ assertThat(result.getAmount().getPayerRefund()).isEqualTo(10);
+ assertThat(result.getAmount().getSettlementTotal()).isEqualTo(90);
+ assertThat(result.getAmount().getDiscountRefund()).isEqualTo(1);
+ assertThat(result.getAmount().getFrom()).hasSize(1);
+ assertThat(result.getAmount().getFrom().get(0).getAccount()).isEqualTo("AVAILABLE");
+ assertThat(result.getAmount().getFrom().get(0).getAmount()).isEqualTo(10);
+ }
+
+ @Test
+ public void shouldKeepBackwardCompatibilityForRefundAlias() {
+ WxPayRefundNotifyV3Result.Amount amount =
+ GSON.fromJson("{\"refund\":88}", WxPayRefundNotifyV3Result.Amount.class);
+
+ assertThat(amount.getRefundFee()).isEqualTo(88);
+ assertThat(amount.getRefund()).isEqualTo(88);
+ }
+}