From ef2dbe4397903d63bbb3ebd87f026810b9bd0223 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 8 Jan 2025 15:22:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/user_virtual_amount_dao.go | 2 +- src/implement/user_virtual_amount_implement.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/dao/user_virtual_amount_dao.go b/src/dao/user_virtual_amount_dao.go index f642939..d924631 100644 --- a/src/dao/user_virtual_amount_dao.go +++ b/src/dao/user_virtual_amount_dao.go @@ -6,7 +6,7 @@ import ( type UserVirtualAmountDao interface { GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error) - UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) + UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int, startCoin, endCoin string, uid int) ([]model.UserVirtualAmount, int64, error) UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error) GetUserVirtualAllWallets(uid int64) (*[]model.UserVirtualAmount, error) UserVirtualAllWalletFindByParams(params map[string]interface{}) (*[]model.UserVirtualAmount, error) diff --git a/src/implement/user_virtual_amount_implement.go b/src/implement/user_virtual_amount_implement.go index e1ca945..96f8621 100644 --- a/src/implement/user_virtual_amount_implement.go +++ b/src/implement/user_virtual_amount_implement.go @@ -38,9 +38,19 @@ func (u UserVirtualAmountDb) GetUserVirtualWalletBySession(uid int64, coinId int } } -func (u UserVirtualAmountDb) UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) { +func (u UserVirtualAmountDb) UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int, startCoin, endCoin string, uid int) ([]model.UserVirtualAmount, int64, error) { var userVirtualWallets []model.UserVirtualAmount - total, err := u.Db.Where("coin_id = ?", coinID).Limit(pageSize, (page-1)*pageSize).Desc("amount").FindAndCount(&userVirtualWallets) + sess := u.Db.Where("coin_id = ?", coinID) + if startCoin != "" { + sess.And("amount>=?", startCoin) + } + if endCoin != "" { + sess.And("amount<=?", endCoin) + } + if uid == -1 || uid > 0 { + sess.And("uid=?", uid) + } + total, err := sess.Limit(pageSize, (page-1)*pageSize).Desc("amount").FindAndCount(&userVirtualWallets) if err != nil { return nil, 0, zhios_order_relate_logx.Error(err.Error()) }