From 7647ab5e5bb8b269a5003bd7cb3228f6c3a66fb2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 12:52:09 +0000 Subject: [PATCH 1/2] Initial plan From 8bb197374f7e2f16527948b048fe257ca2e0d303 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 13:02:24 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E9=80=9A=E7=9F=A5V3=E9=87=91=E9=A2=9D=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= 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 c3473ee465..f9a68de684 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.NoArgsConstructor; import java.io.Serializable; +import java.util.List; /** * 退款结果通知. @@ -175,7 +176,7 @@ public static class Amount implements Serializable { /** *
      * 字段名:退款金额
-     * 变量名:refund
+     * 变量名:refund_fee
      * 是否必填:是
      * 类型:int
      * 描述:
@@ -183,8 +184,21 @@ public static class Amount implements Serializable {
      *  示例值: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 static class Amount implements Serializable {
      */
     @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 0000000000..8b3487c51c --- /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); + } +}