fix(payment): EasyPay 查单以 trade_status 判定支付成功,避免未付订单误判到账#2975
Merged
Wei-Shaw merged 1 commit intoJun 5, 2026
Conversation
Contributor
Author
|
CI 失败看起来是 runner 外部网络问题,不是本 PR 的 EasyPay 逻辑失败:unit tests 已通过,包含 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
背景
EasyPay 主动查单此前只按
status == 1判定已支付,未读取trade_status。部分 EasyPay 兼容接口在等待支付或查询失败场景也可能返回status=1,会导致 sub2api 在轮询/恢复订单时把未付款订单标记为 completed 并给用户充值,而商户侧实际未收款。本修复将主动查单与 webhook 路径的
trade_status == TRADE_SUCCESS口径对齐,作为资金安全修复,防止未付订单误充值。改动
QueryOrder解析顶层与嵌套data下的trade_status、status、money、trade_no。trade_status == TRADE_SUCCESS判定支付成功;WAITING、空值或其它非成功值均保持 pending。data均缺失trade_status时,才回退旧版status == 1兼容逻辑。data.money/data.trade_no返回格式。测试
trade_status=TRADE_SUCCESS→ paidtrade_status=WAITING且status=1→ pendingtrade_status=""且status=1→ pendingdata.trade_status=TRADE_SUCCESS/data.money/data.trade_no→ paid 并正确读取嵌套字段status=1(无trade_status)→ paidstatus!=1且无trade_status→ pendinggo test -tags=unit ./internal/payment/...go test -tags=unit ./...golangci-lint run ./...Fixes #2958