fix: move withdrawal commission deduction from application to approval
Build docker and publish / build (20.15.1) (push) Failing after 8m28s

- commissionWithdrawLogic: remove upfront commission deduction;
  balance check now includes sum of all pending withdrawals to prevent
  double-spending; transaction only creates the withdrawal record (status=0)
- approveWithdrawal: add FOR UPDATE lock on user row, balance check before
  deducting, atomic commission decrement and commission log inside one
  transaction; clear user cache after commit
- rejectWithdrawal: remove commission refund and log — commission was never
  deducted on application under the new flow
- add migration 02150: refund commission for existing status=0 withdrawals
  that were deducted under the old logic; includes rollback script

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-05-24 19:38:59 -07:00
parent 3bbce5ce84
commit 80751eb8ef
7 changed files with 243 additions and 58 deletions
+1
View File
@@ -46,6 +46,7 @@ func init() {
FamilyNotExist: "家庭组不存在",
FamilyStatusInvalid: "家庭组状态无效",
FamilyOwnerOperationForbidden: "家庭组所有者不允许此操作",
WithdrawalStatusInvalid: "提现状态无效",
// Node error
NodeExist: "Node already exists",