Skip to content

fix: WxSignQueryResult 缺少 change_type 和 operate_time 字段导致签约回调无法判断类型#3942

Open
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-change-type-field-parsing
Open

fix: WxSignQueryResult 缺少 change_type 和 operate_time 字段导致签约回调无法判断类型#3942
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-change-type-field-parsing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

WxEntrustPapService.parseSignNotifyResult() 返回 WxSignQueryResult,但该类缺少 change_type 字段,导致调用方无法区分签约(ADD)和解约(DELETE)回调。

Changes

  • WxSignQueryResult:新增 changeTypechange_type)和 operateTimeoperate_time)字段,并在 loadXml() 中补充解析逻辑
WxSignQueryResult result = wxEntrustPapService.parseSignNotifyResult(xmlData);

// 现在可以正确获取变更类型
if ("ADD".equals(result.getChangeType())) {
    // 签约回调
} else if ("DELETE".equals(result.getChangeType())) {
    // 解约回调
}

此改动向后兼容,WxSignQueryResult 的查询场景不受影响。

Original prompt

This section details on the original issue you should resolve

<issue_title>委托代扣签约回调 缺少change_type字段解析</issue_title>
<issue_description>

简要描述

委托代扣签约回调 缺少change_type字段解析,无法判断类型

Image

模块版本情况

  <dependency>
        <groupId>com.github.binarywang</groupId>
        <artifactId>weixin-java-pay</artifactId>
        <version>4.8.0</version>
    </dependency>

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix missing change_type field parsing in callback fix: WxSignQueryResult 缺少 change_type 和 operate_time 字段导致签约回调无法判断类型 Mar 26, 2026
Copilot AI requested a review from binarywang March 26, 2026 13:30
@binarywang binarywang marked this pull request as ready for review March 29, 2026 13:52
Copilot AI review requested due to automatic review settings March 29, 2026 13:52
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Mar 29, 2026

🤖 Augment PR Summary

Summary: Fixes entrust (PAP) sign/un-sign callback parsing by adding missing fields to WxSignQueryResult.
Changes: Adds changeType (change_type) and operateTime (operate_time) and parses them in loadXml() so callers can distinguish ADD vs DELETE callbacks.

🤖 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

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

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: a8afc1d3c6

ℹ️ 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 +109 to +110
@XStreamAlias("change_type")
private String changeType;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve all-args constructor binary compatibility

Adding new fields to this class changes the Lombok-generated @AllArgsConstructor signature, so downstream code compiled against the previous 11-argument constructor will hit NoSuchMethodError at runtime after upgrading this library jar. This is a backward-compatibility regression for consumers who instantiate WxSignQueryResult directly; consider keeping the old constructor explicitly (or avoiding a public all-args API) before adding new constructor parameters.

Useful? React with 👍 / 👎.

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 修复微信支付委托代扣「签约/解约结果通知」解析结果中缺少 change_typeoperate_time 的问题,使调用方能够区分签约(ADD)与解约(DELETE)回调类型,符合 SDK 在回调处理场景的字段完整性预期(关联 #3941)。

Changes:

  • WxSignQueryResult 新增 changeType(change_type)operateTime(operate_time) 字段
  • WxSignQueryResult#loadXml() 中补充对上述字段的解析(覆盖 XmlConfig.fastMode=true 分支)

*/
@XStreamAlias("operate_time")
private String operateTime;

Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

该类使用了 Lombok 的 @AllArgsConstructor;新增 changeType/operateTime 字段会改变全参构造函数签名,导致依赖旧构造函数的调用方在编译期或运行期出现不兼容(NoSuchMethodError)。为保持向后兼容,建议显式补一个与旧字段列表一致的构造函数并标注 @deprecated(内部委托到新的全参构造),或移除/限制全参构造函数的对外暴露(例如改为 Builder)。

Suggested change
/**
* 兼容旧版本的构造函数不包含 changeTypeoperateTime 字段)。
* <p>
* 新增字段后为保持向后兼容而保留旧签名内部委托到新的全参构造函数
*
* @deprecated 建议使用包含所有字段的新构造函数或其他构建方式
*/
@Deprecated
public WxSignQueryResult(String contractId,
String planId,
Long requestSerial,
String contractCode,
String contractDisplayAccount,
Integer contractState,
String contractSignedTime,
String contractExpiredTime,
String contractTerminatedTime,
Integer contractTerminatedMode,
String contractTerminationRemark,
String openId) {
this(contractId, planId, requestSerial, contractCode, contractDisplayAccount,
contractState, contractSignedTime, contractExpiredTime, contractTerminatedTime,
contractTerminatedMode, contractTerminationRemark, openId, null, null);
}

Copilot uses AI. Check for mistakes.
Comment on lines 131 to +135
contractTerminatedMode = readXmlInteger(d, "contract_termination_mode");
contractTerminationRemark = readXmlString(d, "contract_termination_remark");
openId = readXmlString(d, "openid");
changeType = readXmlString(d, "change_type");
operateTime = readXmlString(d, "operate_time");
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

新增字段的 XML 解析逻辑(change_type/operate_time)目前没有对应的单元测试覆盖。仓库中已存在 WxSignQueryResultTest 且会开启 XmlConfig.fastMode 覆盖 loadXml 分支,建议补充包含 change_type/operate_time 的回调 XML 样例并断言 changeType/operateTime 能被正确解析(同时可保留字段缺失时为 null 的断言)。

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.

委托代扣签约回调 缺少change_type字段解析

3 participants