修复(#140): 去掉 cancelWithdrawalLogic 在新流程下的重复退款
HIF-22 把申请提现扣 commission 的逻辑移到审批时执行,但 cancel 路径漏改, 撤销 pending 提现仍调 UpdateCommission(+amount) 凭空给用户加佣金,并写出 一条 338 退佣金日志污染对账。 参照 rejectWithdrawal 的处理方式(withdrawalCommon.go:80-87),事务体只保留 withdrawal.status -> Cancelled 的更新,删除 UpdateCommission 与误导性的 WriteCommissionLog 调用。补单测覆盖 happy path、非 pending 状态短路、跨用户 撤销拒绝、与审批并发时 FOR UPDATE 行锁让 cancel 输掉 race 这四类场景。 Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
|
||||
logicCommon "github.com/perfect-panel/server/internal/logic/common"
|
||||
"github.com/perfect-panel/server/internal/model/log"
|
||||
"github.com/perfect-panel/server/internal/model/user"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
"github.com/perfect-panel/server/internal/types"
|
||||
@@ -57,13 +56,10 @@ func (l *CancelWithdrawalLogic) CancelWithdrawal(req *types.CancelWithdrawalRequ
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DatabaseUpdateError), "cancel withdrawal failed: %v", txErr)
|
||||
}
|
||||
|
||||
if txErr = l.svcCtx.UserModel.UpdateCommission(l.ctx, withdrawal.UserId, withdrawal.Amount, tx); txErr != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DatabaseUpdateError), "refund commission failed: %v", txErr)
|
||||
}
|
||||
|
||||
if txErr = logicCommon.WriteCommissionLog(tx, withdrawal.UserId, log.CommissionTypeWithdrawCancel, withdrawal.Amount, ""); txErr != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DatabaseInsertError), "write commission log failed: %v", txErr)
|
||||
}
|
||||
// Commission was NOT deducted at application time under the HIF-22
|
||||
// approval flow, so cancellation requires no refund — only a status
|
||||
// update. Refunding here would mint phantom commission and pollute
|
||||
// reconciliation (mirrors rejectWithdrawal in admin/user/withdrawalCommon.go).
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user