Fix validation logic in WxMaIntracityServiceImpl.balanceQuery for PayMode handling#3707
Merged
binarywang merged 2 commits intodevelopfrom Nov 15, 2025
Merged
Fix validation logic in WxMaIntracityServiceImpl.balanceQuery for PayMode handling#3707binarywang merged 2 commits intodevelopfrom
binarywang merged 2 commits intodevelopfrom
Conversation
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] WxMaIntracityServiceImpl.balanceQuery 的判断条件写的有问题
Fix validation logic in WxMaIntracityServiceImpl.balanceQuery for PayMode handling
Sep 22, 2025
|
LGTM @binarywang |
Owner
|
@copilot 请用中文重新描述问题和处理过程 |
Contributor
Author
已将 PR 描述更新为中文版本。主要说明了:
|
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.
问题描述
WxMaIntracityServiceImpl.balanceQuery方法中的验证逻辑存在错误,当wxStoreId为 null 且payMode为APP或COMPONENT时,会错误地阻止合法的 API 调用。原始错误代码
这个条件判断是反的,导致在以下情况下抛出异常:
wxStoreId为 null 且payMode为APP或COMPONENT但根据 API 文档和
BasicWxMaStoreChargeRefundRequest.java中的注释说明,wxStoreId只有在payMode为STORE或null(默认为STORE)时才是必需的。问题示例
修复前,以下合法调用会错误地抛出异常:
用户不得不通过传入一个虚假的
wxStoreId值来绕过这个问题。解决方案
修正了验证条件,使其正确地仅在
payMode为STORE或null时才要求wxStoreId:修复后的行为
balanceQuery(null, serviceId, null)→ 抛出异常(默认 STORE 模式需要 wxStoreId)balanceQuery(null, serviceId, PayMode.STORE)→ 抛出异常(STORE 模式需要 wxStoreId)balanceQuery(null, serviceId, PayMode.APP)→ 通过验证(不需要 wxStoreId)balanceQuery(null, serviceId, PayMode.COMPONENT)→ 通过验证(不需要 wxStoreId)balanceQuery("store123", serviceId, 任意模式)→ 通过验证(已提供 wxStoreId)影响说明
无破坏性变更 - 原本能正常工作的代码继续正常工作,之前被错误阻止的合法用法现在可以正常使用了。
修复 #3704
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.