Skip to content

Fix incorrect @SerializedName annotations in WxMaXPayQueryOrderResponse.OrderInfo#3956

Open
Copilot wants to merge 2 commits intodevelopfrom
copilot/update-gson-serialized-name
Open

Fix incorrect @SerializedName annotations in WxMaXPayQueryOrderResponse.OrderInfo#3956
Copilot wants to merge 2 commits intodevelopfrom
copilot/update-gson-serialized-name

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

WxMaXPayQueryOrderResponse.OrderInfo had two fields annotated with camelCase serialized names while the WeChat API returns snake_case JSON keys, causing those fields to always deserialize as null.

Changes

  • Fix serialization keys:
    • @SerializedName("leftFee")@SerializedName("left_fee")
    • @SerializedName("wxOrderId")@SerializedName("wx_order_id")
  • Update settState Javadoc to document the undocumented value 4 (Apple iOS order, pending Apple settlement)
// Before
@SerializedName("leftFee")
private Long leftFee;

@SerializedName("wxOrderId")
private String wxOrderId;

// After
/** 支付单类型时表示此单经过退款还剩余的金额,单位分 */
@SerializedName("left_fee")
private Long leftFee;

/** 微信内部单号 */
@SerializedName("wx_order_id")
private String wxOrderId;
  • Add WxMaXPayQueryOrderResponseTest covering GSON deserialization of left_fee, wx_order_id, and sett_state=4

Copilot AI changed the title [WIP] Fix GSON serialized name for order query response Fix incorrect @SerializedName annotations in WxMaXPayQueryOrderResponse.OrderInfo Apr 7, 2026
Copilot AI requested a review from binarywang April 7, 2026 09:19
@binarywang binarywang marked this pull request as ready for review April 7, 2026 13:17
Copilot AI review requested due to automatic review settings April 7, 2026 13:17
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 7, 2026

🤖 Augment PR Summary

Summary: This PR fixes GSON field mapping issues in WxMaXPayQueryOrderResponse.OrderInfo where camelCase @SerializedName values did not match the WeChat API’s snake_case JSON keys, causing deserialization to produce null.

Changes:

  • Update @SerializedName for leftFee to left_fee
  • Update @SerializedName for wxOrderId to wx_order_id
  • Expand settState Javadoc to include undocumented value 4 (Apple iOS order settlement in progress)
  • Add a unit test to validate deserialization of left_fee, wx_order_id, and sett_state=4

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 修复小程序 XPay 查询订单响应模型 WxMaXPayQueryOrderResponse.OrderInfo 中两个字段的 @SerializedName 键名与微信接口实际返回 JSON(snake_case)不一致的问题,避免反序列化后字段恒为 null,并补充单元测试验证反序列化行为。

Changes:

  • leftFeewxOrderId@SerializedName 从 camelCase 更正为 snake_case(left_feewx_order_id)。
  • 补充 sett_state Javadoc,新增说明未文档化的取值 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_feewx_order_idsett_state=4 能正确映射到字段。

import static org.testng.Assert.assertNotNull;

/**
* 验证 {@link WxMaXPayQueryOrderResponse} GSON 反序列化正确性的单元测试。
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类注释里写的是“GSON 反序列化”,项目中其余位置通常使用库名“Gson”(与 WxMaGsonBuilder 命名一致)。建议将这里的“GSON”改为“Gson”,避免专有名词大小写不一致。

Suggested change
* 验证 {@link WxMaXPayQueryOrderResponse} GSON 反序列化正确性的单元测试
* 验证 {@link WxMaXPayQueryOrderResponse} Gson 反序列化正确性的单元测试

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

微信小程序虚拟支付->订单查询->实体类->GSON序列化名称填写错误

3 participants