fix: some api bug

This commit is contained in:
wwweww
2026-03-31 22:12:06 +08:00
parent c5ff4f0216
commit e7970ac25f
219 changed files with 16195 additions and 2126 deletions
@@ -70,7 +70,6 @@ func (l *AddWalletTransactionsLogic) AddWalletTransactions(in *pb.AddWalletTrans
SetDescription([]string{in.Description}).
SetOrderID(in.OrderId).
SetCreatedAt(createdAt).
SetSearchText(searchText).
Save(l.ctx)
if err != nil {
_ = tx.Rollback()
@@ -50,7 +50,7 @@ func (l *AddWalletsLogic) AddWallets(in *pb.AddWalletsReq) (*pb.AddWalletsResp,
}
_, err = tx.Wallet.Create().
SetUserID(in.UserId).
SetID(in.UserId).
SetBalance(balance).
SetFrozenBalance(frozenBalance).
SetVersion(1).
@@ -26,10 +26,13 @@ func NewGetWalletsByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
func (l *GetWalletsByIdLogic) GetWalletsById(in *pb.GetWalletsByIdReq) (*pb.GetWalletsByIdResp, error) {
item, err := l.svcCtx.WalletModelsRO.Wallet.Query().
Where(wallet.UserIDEQ(in.Id)).
Where(wallet.IDEQ(in.Id)).
First(l.ctx)
if err != nil {
if models.IsNotFound(err) {
if _, e := l.svcCtx.WalletModelsRO.Wallet.Create().SetID(in.Id).Save(l.ctx); e != nil {
return nil, e
}
return &pb.GetWalletsByIdResp{}, nil
}
return nil, err
@@ -42,7 +45,7 @@ func (l *GetWalletsByIdLogic) GetWalletsById(in *pb.GetWalletsByIdReq) (*pb.GetW
return &pb.GetWalletsByIdResp{
Wallets: &pb.Wallets{
UserId: item.UserID,
UserId: item.ID,
Balance: item.Balance.String(),
FrozenBalance: item.FrozenBalance.String(),
UpdatedAt: updatedAt,
@@ -39,9 +39,8 @@ func (l *UpdateWalletsLogic) UpdateWallets(in *pb.UpdateWalletsReq) (*pb.UpdateW
}
updater := tx.Wallet.Update().
Where(wallet.UserIDEQ(in.UserId), wallet.VersionEQ(int(in.GetVersion()))).
Where(wallet.IDEQ(in.UserId), wallet.VersionEQ(int(in.GetVersion()))).
AddVersion(1)
if in.Balance != nil {
parsedBalance, perr := decimal.NewFromString(in.GetBalance())
if perr != nil {
@@ -70,7 +69,7 @@ func (l *UpdateWalletsLogic) UpdateWallets(in *pb.UpdateWalletsReq) (*pb.UpdateW
return nil, err
}
if affected == 0 {
exist, qerr := tx.Wallet.Query().Where(wallet.UserIDEQ(in.UserId)).Exist(l.ctx)
exist, qerr := tx.Wallet.Query().Where(wallet.IDEQ(in.UserId)).Exist(l.ctx)
_ = tx.Rollback()
if qerr != nil {
return nil, qerr