Repository navigation
fix(payment): propagate paid status update errors - #199
Merged
Merged
Conversation
yyg-max
approved these changes
Sep 18, 2026
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.
例行检查
关联信息
Related to #192。该报告涉及支付成功但未发放内容,维护者曾指出机器网络异常;本 PR 修复其中一个可确定复现的数据库错误路径,但不声称覆盖该报告的所有可能原因。
变更内容
PENDING → PAIDCAS 更新提取为可测试函数。fail。变更原因
原代码只读取
RowsAffected,丢弃了Updates返回的Error。数据库或网络瞬时失败时,RowsAffected为 0,代码会误走“并发或非待支付”分支并向支付网关返回success。网关因此停止重试,而订单仍是待支付状态,后续发放不会执行。修复后,数据库写入失败会返回
fail,保留支付网关的重试机会;无错误但影响 0 行的并发/幂等行为保持不变。验证
TestMarkOrderPaidReturnsUpdateError失败,注入写错误后得到err = nilgo test -race ./internal/apps/payment -run TestMarkOrderPaidReturnsUpdateError -count=1go test ./...go vet ./...go build ./...git diff --check