Skip to content

fix: 兼容旧版退款提现通知解析 - #4095

Merged
binarywang merged 1 commit into
developfrom
agent/legacy-notify-header
Aug 18, 2026
Merged

fix: 兼容旧版退款提现通知解析#4095
binarywang merged 1 commit into
developfrom
agent/legacy-notify-header

Conversation

@binarywang

Copy link
Copy Markdown
Owner

背景

#4087 恢复旧版收付通模型和部分服务入口后,parseRefundNotifyResultparseWithdrawNotifyResult 仍只接受新的 bean.notify.SignatureHeader,旧项目使用 bean.ecommerce.SignatureHeader 时无法直接升级。

变更

  • 为退款通知解析增加已废弃的旧 SignatureHeader 重载
  • 为提现通知解析增加已废弃的旧 SignatureHeader 重载
  • 两个重载均复用既有 toUnifiedSignatureHeader 转换并委托新实现
  • 增加旧方法签名的兼容性测试

验证

  • git diff --check
  • 当前执行环境未提供可用 Maven 可执行文件,未能运行模块构建;请由 CI 验证 Maven 测试。

@binarywang
binarywang marked this pull request as ready for review August 18, 2026 04:43
Copilot AI lite review requested due to automatic review settings August 18, 2026 04:43
@binarywang
binarywang merged commit 6a4f0db into develop Aug 18, 2026
2 checks passed
@augmentcode

augmentcode Bot commented Aug 18, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

摘要:EcommerceService 的退款、提现通知解析补回接受旧 bean.ecommerce.SignatureHeader 的废弃重载,并复用 toUnifiedSignatureHeader 委托统一实现。
测试: 新增兼容性测试,通过反射确认两个旧方法签名仍可被发现。

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

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

*/
@Deprecated
default RefundNotifyResult parseRefundNotifyResult(String notifyData,
com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader header) throws WxPayException {

@augmentcode augmentcode Bot Aug 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

此重载会让原本可用的 parseRefundNotifyResult(notifyData, null) 变成二义性调用:两个 SignatureHeader 类型没有继承关系,而上方 Javadoc 又将 null 定义为跳过验签的支持用法,因此现有调用方升级后无法重新编译。其他位置也会发生相同问题:weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java:562

Severity: medium

Other Locations
  • weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java:562

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

已在后续 PR #4096 修复:旧 SignatureHeader 现继承新类型,使旧重载成为更具体的候选,parseRefundNotifyResult(notifyData, null) 与提现同类调用不再二义。

Comment on lines +25 to +26
Assert.assertNotNull(EcommerceService.class.getMethod("parseRefundNotifyResult", String.class, legacyHeader));
Assert.assertNotNull(EcommerceService.class.getMethod("parseWithdrawNotifyResult", String.class, legacyHeader));

@augmentcode augmentcode Bot Aug 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

这两项断言仅验证反射能发现方法,未执行 default 委托或校验旧头字段 signedserialNo 到新字段的映射;因此适配后验签失败、委托到错误方法等行为回归仍会测试通过。

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

已在后续 PR #4096 补充回归测试,验证旧头与新头的继承关系,以及 signed/serialNo 到 signature/serial 的字段映射。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e1d447f370

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +539 to +540
default RefundNotifyResult parseRefundNotifyResult(String notifyData,
com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader header) throws WxPayException {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 避免让允许的 null 调用产生重载歧义

新增参数类型互不相关的重载后,下游原本合法的 service.parseRefundNotifyResult(notifyData, null) 会因无法在两个 SignatureHeader 重载之间选择而编译失败;相邻 Javadoc 明确说明 null 表示不校验请求头。parseWithdrawNotifyResult 的新增重载也有相同问题,因此需要让两个参数类型具备明确的继承关系,或采用不会使现有 null 调用歧义的兼容方案;当前反射测试只能确认签名存在,无法发现此源码兼容性回归。

AGENTS.md reference: AGENTS.md:L47-L48

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

已在后续 PR #4096 修复。单参数重载不能消除原有的两参数 null 调用歧义,因此采用旧头继承新头的方案,使旧重载成为更具体的匹配。

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

该 PR 针对 weixin-java-pay 电商收付通(Ecommerce)通知解析 API 做向后兼容:在保留当前统一模型(bean.notify.SignatureHeader)实现的前提下,补充对旧模型(bean.ecommerce.SignatureHeader)方法签名的兼容入口,帮助旧项目更平滑升级。

Changes:

  • EcommerceService 为退款通知与提现通知解析新增已废弃的旧 bean.ecommerce.SignatureHeader 重载,并委托到统一实现(通过 toUnifiedSignatureHeader 转换)。
  • LegacyEcommerceApiCompatibilityTest 增加反射级别的签名存在性测试,确保旧方法签名不被移除。

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java 为退款/提现通知解析补充旧版 SignatureHeader 的兼容重载,并复用统一签名转换逻辑。
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/LegacyEcommerceApiCompatibilityTest.java 增加对旧版通知解析方法签名的兼容性测试(反射检查)。
Suppressed comments (1)

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java:563

  • 新增旧版 SignatureHeader 重载后,调用方如果传入 null(当前 Javadoc 允许不校验头)会在编译期出现方法重载歧义:parseWithdrawNotifyResult(String, SignatureHeader) 与 parseWithdrawNotifyResult(String, bean.ecommerce.SignatureHeader) 都可匹配 null,导致现有用户代码升级后无法编译。建议补充一个仅接收 notifyData 的 default 重载用于“不校验头”场景,提供无歧义的调用入口。
  default WithdrawNotifyResult parseWithdrawNotifyResult(String notifyData,
                                                         com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader header) throws WxPayException {
    return parseWithdrawNotifyResult(notifyData, toUnifiedSignatureHeader(header));

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 533 to +542
RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;

/**
* @deprecated 从 4.8.5.B 起,请改用使用 {@link SignatureHeader} 的同名方法;5.0 将移除。
*/
@Deprecated
default RefundNotifyResult parseRefundNotifyResult(String notifyData,
com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader header) throws WxPayException {
return parseRefundNotifyResult(notifyData, toUnifiedSignatureHeader(header));
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

已在后续 PR #4096 修复:采用旧头继承新头,而非增加单参数重载;这样保留原有两参数 null 调用且无歧义。

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.

2 participants