32 lines
1.3 KiB
Go
32 lines
1.3 KiB
Go
// refund.go Day 48:全流程失败回款——各环节(落库失败/拦截退费/审核拒绝/消费失败)
|
|
// 统一经 RefundTask 原子加回余额并记流水,口径与 Day43 审核超时回退一致
|
|
// (balance 整型条数;Amount 负=扣款 正=退款)。
|
|
// Day 54 R1:预扣/退款统一走 balance.Store(mysql 行锁|redis Lua+异步流水,
|
|
// 评审 docs/review/r1-balance.md);本文件保留 MySQL 原路径实现,
|
|
// 由 balance.MySQLStore 与回退路径复用。
|
|
package submit
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go-sms/internal/service/balance"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// RefundTask 退款兼容壳(Day54 起资金操作归口 balance.Store;外部历史调用零破坏)。
|
|
func RefundTask(ctx context.Context, db *gorm.DB, accountID, amount int64,
|
|
taskNo, reason string) error {
|
|
return balance.NewMySQLStore(db).Refund(ctx, accountID, amount, taskNo, reason)
|
|
}
|
|
|
|
// holdFee 预扣壳:经 s.bal(R1:flag=redis 时 Lua 原子扣,基础设施错自动回退 MySQL)。
|
|
func (s *SubmitService) holdFee(ctx context.Context, accountID, fee int64, taskNo string) error {
|
|
return s.bal.Hold(ctx, accountID, fee, taskNo)
|
|
}
|
|
|
|
// refund 退款壳:经 s.bal(R1:redis 模式 Lua 加回+异步流水)。
|
|
func (s *SubmitService) refund(ctx context.Context, accountID, amount int64,
|
|
taskNo, reason string) error {
|
|
return s.bal.Refund(ctx, accountID, amount, taskNo, reason)
|
|
}
|