Fix incorrect @SerializedName annotations in WxMaXPayQueryOrderResponse.OrderInfo#3956
Open
Fix incorrect @SerializedName annotations in WxMaXPayQueryOrderResponse.OrderInfo#3956
Conversation
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/cc05bdd4-0035-41f3-bc34-25b260888ce1 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix GSON serialized name for order query response
Fix incorrect @SerializedName annotations in WxMaXPayQueryOrderResponse.OrderInfo
Apr 7, 2026
🤖 Augment PR SummarySummary: This PR fixes GSON field mapping issues in Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
该 PR 修复小程序 XPay 查询订单响应模型 WxMaXPayQueryOrderResponse.OrderInfo 中两个字段的 @SerializedName 键名与微信接口实际返回 JSON(snake_case)不一致的问题,避免反序列化后字段恒为 null,并补充单元测试验证反序列化行为。
Changes:
- 将
leftFee、wxOrderId的@SerializedName从 camelCase 更正为 snake_case(left_fee、wx_order_id)。 - 补充
sett_stateJavadoc,新增说明未文档化的取值4(Apple iOS 订单结算中)。 - 新增
WxMaXPayQueryOrderResponseTest,覆盖上述字段及sett_state=4的 GSON 反序列化。
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryOrderResponse.java | 修正 @SerializedName 键名并完善 sett_state 文档说明,确保与接口返回字段一致。 |
| weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/xpay/WxMaXPayQueryOrderResponseTest.java | 新增反序列化测试用例,验证 left_fee、wx_order_id、sett_state=4 能正确映射到字段。 |
| import static org.testng.Assert.assertNotNull; | ||
|
|
||
| /** | ||
| * 验证 {@link WxMaXPayQueryOrderResponse} GSON 反序列化正确性的单元测试。 |
There was a problem hiding this comment.
类注释里写的是“GSON 反序列化”,项目中其余位置通常使用库名“Gson”(与 WxMaGsonBuilder 命名一致)。建议将这里的“GSON”改为“Gson”,避免专有名词大小写不一致。
Suggested change
| * 验证 {@link WxMaXPayQueryOrderResponse} GSON 反序列化正确性的单元测试。 | |
| * 验证 {@link WxMaXPayQueryOrderResponse} Gson 反序列化正确性的单元测试。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WxMaXPayQueryOrderResponse.OrderInfohad two fields annotated with camelCase serialized names while the WeChat API returns snake_case JSON keys, causing those fields to always deserialize asnull.Changes
@SerializedName("leftFee")→@SerializedName("left_fee")@SerializedName("wxOrderId")→@SerializedName("wx_order_id")settStateJavadoc to document the undocumented value4(Apple iOS order, pending Apple settlement)WxMaXPayQueryOrderResponseTestcovering GSON deserialization ofleft_fee,wx_order_id, andsett_state=4