This commit is contained in:
liangzai 2025-05-06 22:45:24 +08:00
parent 67da859830
commit c7f99143e0

View File

@ -3,16 +3,17 @@ package agent
import (
"context"
"fmt"
"github.com/cenkalti/backoff/v4"
"github.com/pkg/errors"
"github.com/smartwalle/alipay/v3"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"time"
"tydata-server/app/user/model"
"tydata-server/common/ctxdata"
"tydata-server/common/xerr"
"tydata-server/pkg/lzkit/lzUtils"
"github.com/cenkalti/backoff/v4"
"github.com/pkg/errors"
"github.com/smartwalle/alipay/v3"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
@ -73,8 +74,7 @@ func (l *AgentWithdrawalLogic) AgentWithdrawal(req *types.WithdrawalReq) (*types
}
// 校验可提现金额
withdrawableAmount := agentWallet.Balance - agentWallet.FrozenBalance
if req.Amount > withdrawableAmount {
if req.Amount > agentWallet.Balance {
return errors.Wrapf(xerr.NewErrMsg("您可提现的余额不足"), "获取用户ID失败")
}
@ -267,7 +267,17 @@ func (l *AgentWithdrawalLogic) updateWithdrawalStatus(outBizNo string, status in
return err
}
}
if status == StatusSuccess {
wallet, err := l.svcCtx.AgentWalletModel.FindOneByAgentId(ctx, record.AgentId)
if err != nil {
return err
}
wallet.FrozenBalance -= record.Amount
if err := l.svcCtx.AgentWalletModel.UpdateWithVersion(ctx, session, wallet); err != nil {
return err
}
}
return nil
})