diff --git a/src/dao/user_dao.go b/src/dao/user_dao.go index 5065ea8..133b114 100644 --- a/src/dao/user_dao.go +++ b/src/dao/user_dao.go @@ -6,4 +6,5 @@ type UserDao interface { UserGetOneByParams(params map[string]interface{}) (*model.User, error) UserFindByParams(params map[string]interface{}) ([]model.User, error) UserUpdate(id interface{}, user *model.User, forceColumns ...string) (int64, error) + UserFindAndCount(uid int64, phone string, nickname string, level int, page, limit int) (*[]model.User, int64, error) } diff --git a/src/dao/user_relate_dao.go b/src/dao/user_relate_dao.go index bedce51..4be9b20 100644 --- a/src/dao/user_relate_dao.go +++ b/src/dao/user_relate_dao.go @@ -8,4 +8,5 @@ type UserRelateDao interface { FindUserRelateByParentUid(uid int64, level int) (*[]model.UserRelate, error) SumUserRelateByParentUid(parentUid string) (total int64, userRelate []*model.UserRelate, err error) PageFindUserRelateByParentUid(uid int64, page, pageSize int) (*[]model.UserRelate, int64, error) + PageFindUserRelateByParentUidAndLevel(uid int64, page, limit int, level int) (*[]model.UserRelate, int64, error) } diff --git a/src/dao/user_virtual_amount_dao.go b/src/dao/user_virtual_amount_dao.go index 202f68a..9101123 100644 --- a/src/dao/user_virtual_amount_dao.go +++ b/src/dao/user_virtual_amount_dao.go @@ -8,4 +8,5 @@ type UserVirtualAmountDao interface { GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error) UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error) + GetUserVirtualAllWallets(uid int64) (*[]model.UserVirtualAmount, error) } diff --git a/src/implement/user_implement.go b/src/implement/user_implement.go index 4a1da12..f9fb997 100644 --- a/src/implement/user_implement.go +++ b/src/implement/user_implement.go @@ -59,3 +59,25 @@ func (u UserDb) UserUpdate(id interface{}, user *model.User, forceColumns ...str } return affected, nil } + +func (u UserDb) UserFindAndCount(uid int64, phone string, nickname string, level int, page, limit int) (*[]model.User, int64, error) { + var m []model.User + session := u.Db.NewSession() + if uid != 0 { + session = session.Where("uid=?", uid) + } + if phone != "" { + session = session.Where("phone = ?", phone) + } + if nickname != "" { + session = session.Where("nickname like ? ", "%"+nickname+"%") + } + if level != 0 { + session = session.Where("level=?", level) + } + total, err := session.FindAndCount(&m) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err) + } + return &m, total, nil +} diff --git a/src/implement/user_relate_implement.go b/src/implement/user_relate_implement.go index 14ab81c..5ea9944 100644 --- a/src/implement/user_relate_implement.go +++ b/src/implement/user_relate_implement.go @@ -68,3 +68,20 @@ func (u UserRelateDb) PageFindUserRelateByParentUid(uid int64, page, pageSize in } return &userRelate, count, nil } + +func (u UserRelateDb) PageFindUserRelateByParentUidAndLevel(uid int64, page, limit int, level int) (*[]model.UserRelate, int64, error) { + var userRelate []model.UserRelate + sess := u.Db.Where("parent_uid = ?", uid) + if level == 1 || level == 2 { + sess.And("level=?", level) + } else if level == 0 { + + } else { + sess.And("level != 1").And("level != 2") + } + total, err := sess.Limit(limit, (page-1)*page).Asc("uid").FindAndCount(&userRelate) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err) + } + return &userRelate, total, nil +} diff --git a/src/implement/user_virtual_amount_implement.go b/src/implement/user_virtual_amount_implement.go index 236555f..aea7605 100644 --- a/src/implement/user_virtual_amount_implement.go +++ b/src/implement/user_virtual_amount_implement.go @@ -52,3 +52,13 @@ func (u UserVirtualAmountDb) UserVirtualAmountGetSumByCoinKind(coinId int) (floa } return sum, nil } + +func (u UserVirtualAmountDb) GetUserVirtualAllWallets(uid int64) (*[]model.UserVirtualAmount, error) { + var m []model.UserVirtualAmount + err := u.Db.Where("uid = ?", uid).Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err.Error()) + } + return &m, nil + +}