Skip to content

Commit a23429c

Browse files
authored
🎨 #3859 【企业微信】审批详情接口增加总费用金额字段
1 parent 28a0d6e commit a23429c

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpApprovalDetailResult.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public static class WxCpApprovalDetail implements Serializable {
9191
@SerializedName("comments")
9292
private List<WxCpApprovalComment> comments;
9393

94+
/**
95+
* 审批单据的总金额(单位:分),当审批单包含费用相关控件时返回
96+
*/
97+
@SerializedName("sum_money")
98+
private Long sumMoney;
99+
94100
}
95101

96102
}

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,80 @@ public void testGetApprovalDetail() throws WxErrorException {
443443
System.out.println(gson.toJson(result));
444444
}
445445

446+
/**
447+
* Test sum_money field deserialization in approval detail.
448+
* 测试审批详情中总费用金额字段的反序列化
449+
*/
450+
@Test
451+
public void testApprovalDetailSumMoney() {
452+
// 测试包含总费用金额的审批详情JSON
453+
String jsonWithSumMoney = "{\n" +
454+
" \"errcode\": 0,\n" +
455+
" \"errmsg\": \"ok\",\n" +
456+
" \"info\": {\n" +
457+
" \"sp_no\": \"202601140001\",\n" +
458+
" \"sp_name\": \"报销申请\",\n" +
459+
" \"sp_status\": 2,\n" +
460+
" \"template_id\": \"test_template_id\",\n" +
461+
" \"apply_time\": 1610000000,\n" +
462+
" \"applyer\": {\n" +
463+
" \"userid\": \"test_user\",\n" +
464+
" \"partyid\": \"1\"\n" +
465+
" },\n" +
466+
" \"sp_record\": [],\n" +
467+
" \"notifyer\": [],\n" +
468+
" \"apply_data\": {\n" +
469+
" \"contents\": []\n" +
470+
" },\n" +
471+
" \"comments\": [],\n" +
472+
" \"sum_money\": 100000\n" +
473+
" }\n" +
474+
"}";
475+
476+
WxCpApprovalDetailResult result = WxCpGsonBuilder.create().fromJson(jsonWithSumMoney, WxCpApprovalDetailResult.class);
477+
assertThat(result).isNotNull();
478+
assertThat(result.getErrCode()).isEqualTo(0);
479+
assertThat(result.getInfo()).isNotNull();
480+
assertThat(result.getInfo().getSpNo()).isEqualTo("202601140001");
481+
assertThat(result.getInfo().getSpName()).isEqualTo("报销申请");
482+
assertThat(result.getInfo().getSumMoney()).isNotNull();
483+
assertThat(result.getInfo().getSumMoney()).isEqualTo(100000L);
484+
485+
System.out.println("成功解析总费用金额字段 sum_money: " + result.getInfo().getSumMoney());
486+
487+
// 测试不包含 sum_money 字段的情况(向后兼容)
488+
String jsonWithoutSumMoney = "{\n" +
489+
" \"errcode\": 0,\n" +
490+
" \"errmsg\": \"ok\",\n" +
491+
" \"info\": {\n" +
492+
" \"sp_no\": \"202601140002\",\n" +
493+
" \"sp_name\": \"请假申请\",\n" +
494+
" \"sp_status\": 1,\n" +
495+
" \"template_id\": \"test_template_id\",\n" +
496+
" \"apply_time\": 1610000000,\n" +
497+
" \"applyer\": {\n" +
498+
" \"userid\": \"test_user\",\n" +
499+
" \"partyid\": \"1\"\n" +
500+
" },\n" +
501+
" \"sp_record\": [],\n" +
502+
" \"notifyer\": [],\n" +
503+
" \"apply_data\": {\n" +
504+
" \"contents\": []\n" +
505+
" },\n" +
506+
" \"comments\": []\n" +
507+
" }\n" +
508+
"}";
509+
510+
WxCpApprovalDetailResult resultWithoutMoney = WxCpGsonBuilder.create().fromJson(jsonWithoutSumMoney, WxCpApprovalDetailResult.class);
511+
assertThat(resultWithoutMoney).isNotNull();
512+
assertThat(resultWithoutMoney.getInfo()).isNotNull();
513+
assertThat(resultWithoutMoney.getInfo().getSpNo()).isEqualTo("202601140002");
514+
assertThat(resultWithoutMoney.getInfo().getSumMoney()).isNull();
515+
516+
System.out.println("成功处理不包含 sum_money 字段的情况(向后兼容)");
517+
System.out.println("完整测试通过!");
518+
}
519+
446520
/**
447521
* Test get template detail.
448522
*

0 commit comments

Comments
 (0)