From bc6fb7b58ec9f35769714a2023c6fef3abfc4a1a Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:40:28 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20#3656=20=E3=80=90=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E3=80=91=20=E4=BF=AE=E5=A4=8D=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=94=B6=E4=BB=98=E9=80=9A=20-=20=E5=90=88=E5=8D=95?= =?UTF-8?q?=E6=94=AF=E4=BB=98=20-=20=E5=85=B3=E9=97=AD=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E7=9A=84=E4=B8=A4=E4=B8=AA=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/request/CombineCloseRequest.java | 28 +++++++++++ .../bean/request/CombineCloseRequestTest.java | 47 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequestTest.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequest.java index b397f0f1c..428878dc7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequest.java @@ -87,5 +87,33 @@ public class CombineCloseRequest implements Serializable { */ @SerializedName(value = "out_trade_no") private String outTradeNo; + /** + *
+     * 字段名:二级商户号
+     * 变量名:sub_mchid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  二级商户商户号,由微信支付生成并下发。服务商子商户的商户号,被合单方。直连商户不用传二级商户号。
+     *  示例值:1900000109
+     * 
+ */ + @SerializedName(value = "sub_mchid") + private String subMchid; + /** + *
+     * 字段名:子商户应用ID
+     * 变量名:sub_appid
+     * 是否必填:是
+     * 类型:string[1,32]
+     * 描述:
+     *  子商户申请的应用ID,全局唯一。请求基础下单接口时请注意APPID的应用属性,例如公众号场景下,
+     *  需使用应用属性为公众号的APPID 若sub_openid有传的情况下,
+     *  sub_appid必填,且sub_appid需与sub_openid对应
+     *  示例值:wxd678efh567hg6999
+     * 
+ */ + @SerializedName(value = "sub_appid") + private String subAppid; } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequestTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequestTest.java new file mode 100644 index 000000000..aaaa69332 --- /dev/null +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/request/CombineCloseRequestTest.java @@ -0,0 +1,47 @@ +package com.github.binarywang.wxpay.bean.request; + +import com.google.gson.Gson; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Binary Wang + * created on 2024-12-19 + */ +public class CombineCloseRequestTest { + + @Test + public void testSerialization() { + CombineCloseRequest request = new CombineCloseRequest(); + request.setCombineAppid("wxd678efh567hg6787"); + request.setCombineOutTradeNo("P20150806125346"); + + CombineCloseRequest.SubOrders subOrder = new CombineCloseRequest.SubOrders(); + subOrder.setMchid("1900000109"); + subOrder.setOutTradeNo("20150806125346"); + subOrder.setSubMchid("1230000109"); + subOrder.setSubAppid("wxd678efh567hg6999"); + + request.setSubOrders(Arrays.asList(subOrder)); + + Gson gson = new Gson(); + String json = gson.toJson(request); + + // Verify that the JSON contains the new fields + assertThat(json).contains("\"sub_mchid\":\"1230000109\""); + assertThat(json).contains("\"sub_appid\":\"wxd678efh567hg6999\""); + assertThat(json).contains("\"combine_appid\":\"wxd678efh567hg6787\""); + assertThat(json).contains("\"mchid\":\"1900000109\""); + assertThat(json).contains("\"out_trade_no\":\"20150806125346\""); + + // Verify deserialization works + CombineCloseRequest deserializedRequest = gson.fromJson(json, CombineCloseRequest.class); + assertThat(deserializedRequest.getCombineAppid()).isEqualTo("wxd678efh567hg6787"); + assertThat(deserializedRequest.getSubOrders()).hasSize(1); + assertThat(deserializedRequest.getSubOrders().get(0).getSubMchid()).isEqualTo("1230000109"); + assertThat(deserializedRequest.getSubOrders().get(0).getSubAppid()).isEqualTo("wxd678efh567hg6999"); + } +} \ No newline at end of file