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()) }