Skip to content

Commit 913b5c0

Browse files
Copilotbinarywang
andcommitted
修复:在WxPayPartnerRefundV3Request中添加sp_appid和sub_appid字段
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
1 parent 2e3ac76 commit 913b5c0

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayPartnerRefundV3Request.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,39 @@
1111
* 微信支付服务商退款请求
1212
* 文档见:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_9.shtml
1313
*
14-
* @author Pursuer
15-
* @version 1.0
16-
* @date 2023/3/2
14+
* @author GitHub Copilot
1715
*/
1816
@Data
1917
@NoArgsConstructor
2018
@Accessors(chain = true)
2119
public class WxPayPartnerRefundV3Request extends WxPayRefundV3Request implements Serializable {
2220
private static final long serialVersionUID = -1L;
21+
/**
22+
* <pre>
23+
* 字段名:服务商应用ID
24+
* 变量名:sp_appid
25+
* 是否必填:是
26+
* 类型:string[1, 32]
27+
* 描述:
28+
* 服务商申请的公众号或移动应用appid。
29+
* 示例值:wx8888888888888888
30+
* </pre>
31+
*/
32+
@SerializedName(value = "sp_appid")
33+
private String spAppid;
34+
/**
35+
* <pre>
36+
* 字段名:子商户应用ID
37+
* 变量名:sub_appid
38+
* 是否必填:否
39+
* 类型:string[1, 32]
40+
* 描述:
41+
* 子商户申请的公众号或移动应用appid。如果传了sub_appid,那sub_appid对应的订单必须存在。
42+
* 示例值:wx8888888888888888
43+
* </pre>
44+
*/
45+
@SerializedName(value = "sub_appid")
46+
private String subAppid;
2347
/**
2448
* <pre>
2549
* 字段名:退款资金来源
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.github.binarywang.wxpay.bean.request;
2+
3+
import com.google.gson.Gson;
4+
import com.google.gson.JsonObject;
5+
import org.testng.annotations.Test;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
9+
/**
10+
* {@link WxPayPartnerRefundV3Request} 单元测试
11+
*
12+
* @author GitHub Copilot
13+
*/
14+
public class WxPayPartnerRefundV3RequestTest {
15+
16+
@Test
17+
public void testSpAppidAndSubAppidSerialization() {
18+
WxPayPartnerRefundV3Request request = new WxPayPartnerRefundV3Request();
19+
request.setSpAppid("wx8888888888888888");
20+
request.setSubAppid("wxd678efh567hg6999");
21+
request.setSubMchid("1230000109");
22+
request.setOutRefundNo("1217752501201407033233368018");
23+
request.setFundsAccount("AVAILABLE");
24+
25+
Gson gson = new Gson();
26+
String json = gson.toJson(request);
27+
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
28+
29+
assertThat(jsonObject.get("sp_appid").getAsString()).isEqualTo("wx8888888888888888");
30+
assertThat(jsonObject.get("sub_appid").getAsString()).isEqualTo("wxd678efh567hg6999");
31+
assertThat(jsonObject.get("sub_mchid").getAsString()).isEqualTo("1230000109");
32+
assertThat(jsonObject.get("out_refund_no").getAsString()).isEqualTo("1217752501201407033233368018");
33+
assertThat(jsonObject.get("funds_account").getAsString()).isEqualTo("AVAILABLE");
34+
}
35+
36+
@Test
37+
public void testSubAppidIsOptional() {
38+
WxPayPartnerRefundV3Request request = new WxPayPartnerRefundV3Request();
39+
request.setSpAppid("wx8888888888888888");
40+
request.setSubMchid("1230000109");
41+
request.setOutRefundNo("1217752501201407033233368018");
42+
43+
Gson gson = new Gson();
44+
String json = gson.toJson(request);
45+
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
46+
47+
assertThat(jsonObject.get("sp_appid").getAsString()).isEqualTo("wx8888888888888888");
48+
assertThat(jsonObject.has("sub_appid")).isFalse();
49+
}
50+
}

0 commit comments

Comments
 (0)