@@ -6,4 +6,5 @@ type UserDao interface { | |||||
UserGetOneByParams(params map[string]interface{}) (*model.User, error) | UserGetOneByParams(params map[string]interface{}) (*model.User, error) | ||||
UserFindByParams(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) | 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) | |||||
} | } |
@@ -8,4 +8,5 @@ type UserRelateDao interface { | |||||
FindUserRelateByParentUid(uid int64, level int) (*[]model.UserRelate, error) | FindUserRelateByParentUid(uid int64, level int) (*[]model.UserRelate, error) | ||||
SumUserRelateByParentUid(parentUid string) (total int64, userRelate []*model.UserRelate, err error) | SumUserRelateByParentUid(parentUid string) (total int64, userRelate []*model.UserRelate, err error) | ||||
PageFindUserRelateByParentUid(uid int64, page, pageSize int) (*[]model.UserRelate, int64, error) | PageFindUserRelateByParentUid(uid int64, page, pageSize int) (*[]model.UserRelate, int64, error) | ||||
PageFindUserRelateByParentUidAndLevel(uid int64, page, limit int, level int) (*[]model.UserRelate, int64, error) | |||||
} | } |
@@ -8,4 +8,5 @@ type UserVirtualAmountDao interface { | |||||
GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error) | GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error) | ||||
UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) | UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) | ||||
UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error) | UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error) | ||||
GetUserVirtualAllWallets(uid int64) (*[]model.UserVirtualAmount, error) | |||||
} | } |
@@ -59,3 +59,25 @@ func (u UserDb) UserUpdate(id interface{}, user *model.User, forceColumns ...str | |||||
} | } | ||||
return affected, nil | 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 | |||||
} |
@@ -68,3 +68,20 @@ func (u UserRelateDb) PageFindUserRelateByParentUid(uid int64, page, pageSize in | |||||
} | } | ||||
return &userRelate, count, nil | 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 | |||||
} |
@@ -52,3 +52,13 @@ func (u UserVirtualAmountDb) UserVirtualAmountGetSumByCoinKind(coinId int) (floa | |||||
} | } | ||||
return sum, nil | 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 | |||||
} |