feat(miniapp): Add xpay_subscribe_ios_refund_query_notify event support#3974
feat(miniapp): Add xpay_subscribe_ios_refund_query_notify event support#3974
Conversation
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/bf33fa74-c952-4beb-ae60-2e66235e7fa5 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
🤖 Augment PR SummarySummary: Adds MiniApp support for the WeChat virtual payment iOS refund query push event ( Changes:
Technical Notes: Field mappings are added via 🤖 Was this summary useful? React with 👍 or 👎 |
| @SerializedName("provide_status") | ||
| @XStreamAlias("provide_status") | ||
| @XStreamConverter(value = XStreamCDataConverter.class) | ||
| private String provideStatus; |
There was a problem hiding this comment.
WxMaMessage.java:539 — The WeChat spec for WxaVirtualPayIosRefundQueryNotifyEvent also includes pay_order_id (退款对应支付订单号), but there’s no corresponding field here, so callers can’t read that value.
Severity: medium
Other Locations
weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java:479weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java:504weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java:516
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Pull request overview
该 PR 为小程序虚拟支付 iOS 退款查询通知事件 xpay_subscribe_ios_refund_query_notify 增加事件类型常量,并在 WxMaMessage 中补齐该事件推送报文的缺失字段,同时新增对应的 XML/JSON 解析测试,以完善 miniapp 消息推送解析能力。
Changes:
- 在
WxConsts.EventType中新增XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY事件常量 - 在
WxMaMessage中新增 8 个与该事件对应的字段映射(XML/JSON) - 在
WxMaMessageTest中新增 XML 与 JSON 两种格式的解析测试覆盖新字段与新常量
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java | 新增该事件的 XML/JSON 解析测试与字段断言 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java | 为 iOS 退款查询通知事件补齐字段定义与序列化注解 |
| weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java | 新增事件类型常量 XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY |
| @XStreamConverter(value = XStreamCDataConverter.class) | ||
| private String refundTime; |
There was a problem hiding this comment.
这里的 refund_time 在文档中是 Unix 时间戳(数值语义),但当前用 String + XStreamCDataConverter 建模,会导致调用方需要自行解析且与本类里其他时间戳字段(如 ComplaintTime/RefundStartTimestamp 等 Long 类型)不一致。建议将 refundTime 改为 Long(或 Integer/Long 统一口径),并移除该字段上的 XStreamCDataConverter(数值字段通常不需要 CDATA converter),同时相应更新测试断言。
| @XStreamConverter(value = XStreamCDataConverter.class) | |
| private String refundTime; | |
| private Long refundTime; |
| @XStreamConverter(value = XStreamCDataConverter.class) | ||
| private String orderTime; |
There was a problem hiding this comment.
order_time 同样是 Unix 时间戳字段,目前用 String 表达会弱化类型信息且与本类既有的 Long 时间戳字段不一致。建议将 orderTime 改为 Long,并去掉 XStreamCDataConverter(如果需要兼容字符串/数值两种 JSON 表达,可保留 Long 并依赖 Gson/XStream 的数值解析能力),同时调整对应测试。
| @XStreamConverter(value = XStreamCDataConverter.class) | |
| private String orderTime; | |
| private Long orderTime; |
| @XStreamConverter(value = XStreamCDataConverter.class) | ||
| private String pCount; |
There was a problem hiding this comment.
p_count 是数量字段(数值语义),目前用 String 建模不利于后续做数值比较/计算,也与本类中类似字段(如 RefundFee/RetryTimes 等 Integer)不一致。建议将 pCount 改为 Integer,并移除 XStreamCDataConverter,同时更新解析测试断言。
| @XStreamConverter(value = XStreamCDataConverter.class) | |
| private String pCount; | |
| private Integer pCount; |
| @XStreamConverter(value = XStreamCDataConverter.class) | ||
| private String provideStatus; |
There was a problem hiding this comment.
provide_status 表示枚举状态(0/1/2),建议用 Integer 而不是 String 来建模,避免调用方自行解析且与本类其它状态字段(如 retCode/teamType 等 Integer)保持一致;相应可移除 XStreamCDataConverter 并更新测试断言。
| @XStreamConverter(value = XStreamCDataConverter.class) | |
| private String provideStatus; | |
| private Integer provideStatus; |
| /** | ||
| * 虚拟支付 iOS 退款查询通知 | ||
| * 文档:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/virtual-payment/ios.html | ||
| */ | ||
| public static final String XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY = "xpay_subscribe_ios_refund_query_notify"; |
There was a problem hiding this comment.
仓库里小程序虚拟支付通知事件名已在 WxMaConstants.XPayNotifyEvent 中集中维护(含 xpay_refund_notify/xpay_complaint_notify 等)。这里单独在 WxConsts.EventType 新增一个 XPAY_* 常量会造成事件常量来源分散;建议要么把该事件也补充到 WxMaConstants.XPayNotifyEvent 并在 miniapp 场景统一使用它,要么在 WxConsts 中补齐同类 XPAY 通知常量以保持一致。
WxMaMessagewas missing all fields for the WeChat virtual payment iOS refund query push notification (xpay_subscribe_ios_refund_query_notify), andWxConsts.EventTypehad no constant for this event type.Changes
WxConsts.EventType— addXPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY = "xpay_subscribe_ios_refund_query_notify"WxMaMessage— add 8 fields matching theWxaVirtualPayIosRefundQueryNotifyEventspec:refund_timerefundTimeorder_timeorderTimechannel_billchannelBillbundleidbundleidproduct_idxpayProductIdp_countpCountrefund_request_reasonrefundRequestReasonprovide_statusprovideStatusWxMaMessageTest— add XML and JSON parsing tests covering all new fields, asserting against the newWxConsts.EventType.XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFYconstant