完善订单兜底处理
This commit is contained in:
@@ -28,7 +28,7 @@ func (s *userService) Get(q *q.Query, uid int32) (*m.User, error) {
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (s *userService) UpdateBalanceByAdmin(user *m.User, newBalance decimal.Decimal, adminId *int32) error {
|
||||
func (s *userService) UpdateBalanceByAdmin(user *m.User, newBalance decimal.Decimal, remark string, adminId *int32) error {
|
||||
if user == nil {
|
||||
return core.NewServErr("用户不存在")
|
||||
}
|
||||
@@ -39,14 +39,14 @@ func (s *userService) UpdateBalanceByAdmin(user *m.User, newBalance decimal.Deci
|
||||
}
|
||||
|
||||
return q.Q.Transaction(func(q *q.Query) error {
|
||||
return s.UpdateBalance(q, user, amount, "管理员修改余额", adminId, nil)
|
||||
return s.UpdateBalance(q, user, amount, remark, adminId, nil)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *userService) UpdateBalance(q *q.Query, user *m.User, amount decimal.Decimal, remark string, adminId *int32, billId *int32) error {
|
||||
balance := user.Balance.Add(amount)
|
||||
if balance.IsNegative() {
|
||||
return core.NewServErr("用户余额不足")
|
||||
return core.NewBizErr("用户余额不足")
|
||||
}
|
||||
|
||||
// 更新余额
|
||||
|
||||
Reference in New Issue
Block a user