|
@@ -33,15 +33,7 @@ func NewSynthesis() *Synthesis {
|
|
|
|
|
|
// 统计用户相关信息
|
|
// 统计用户相关信息
|
|
func (s *Synthesis) UserList(req entity.UserListReq) (*entity.UserListResp, *code.Result) {
|
|
func (s *Synthesis) UserList(req entity.UserListReq) (*entity.UserListResp, *code.Result) {
|
|
- // 验证参数
|
|
|
|
- page := req.Page
|
|
|
|
- if req.Page <= 0 {
|
|
|
|
- page = 1
|
|
|
|
- }
|
|
|
|
- pageSize := req.Size
|
|
|
|
- if req.Size <= 0 {
|
|
|
|
- pageSize = 10
|
|
|
|
- }
|
|
|
|
|
|
+ page, pageSize := checkPageParam(req.Page, req.Size)
|
|
|
|
|
|
// 构建查询条件
|
|
// 构建查询条件
|
|
filter := bson.M{}
|
|
filter := bson.M{}
|
|
@@ -58,7 +50,11 @@ func (s *Synthesis) UserList(req entity.UserListReq) (*entity.UserListResp, *cod
|
|
findOptions.SetLimit(int64(pageSize))
|
|
findOptions.SetLimit(int64(pageSize))
|
|
findOptions.SetSort(bson.D{{"createTime", -1}})
|
|
findOptions.SetSort(bson.D{{"createTime", -1}})
|
|
|
|
|
|
|
|
+ ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
|
|
+ defer cancel()
|
|
|
|
+
|
|
collection := mdb.MDB.Collection(constant.CNamePlayer)
|
|
collection := mdb.MDB.Collection(constant.CNamePlayer)
|
|
|
|
+
|
|
// 获取总数total
|
|
// 获取总数total
|
|
count, err := collection.CountDocuments(ctx, filter)
|
|
count, err := collection.CountDocuments(ctx, filter)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -69,8 +65,6 @@ func (s *Synthesis) UserList(req entity.UserListReq) (*entity.UserListResp, *cod
|
|
// TODO UserList 统计用户相关信息
|
|
// TODO UserList 统计用户相关信息
|
|
// 查询数据
|
|
// 查询数据
|
|
var results []*entity.UserListDetail
|
|
var results []*entity.UserListDetail
|
|
- ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
|
|
- defer cancel()
|
|
|
|
cursor, err := collection.Find(ctx, filter, findOptions)
|
|
cursor, err := collection.Find(ctx, filter, findOptions)
|
|
if err != nil {
|
|
if err != nil {
|
|
mhayaLogger.Warnf("UserList Find error:%v", err)
|
|
mhayaLogger.Warnf("UserList Find error:%v", err)
|
|
@@ -100,6 +94,8 @@ func (s *Synthesis) UserList(req entity.UserListReq) (*entity.UserListResp, *cod
|
|
}
|
|
}
|
|
|
|
|
|
func (s *Synthesis) FindMDBUserLogDaily(req entity.UserLogDailyReq) (*entity.UserLogDailyResp, *code.Result) {
|
|
func (s *Synthesis) FindMDBUserLogDaily(req entity.UserLogDailyReq) (*entity.UserLogDailyResp, *code.Result) {
|
|
|
|
+ page, pageSize := checkPageParam(req.Page, req.Size)
|
|
|
|
+
|
|
// 定义上下文
|
|
// 定义上下文
|
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
defer cancel()
|
|
defer cancel()
|
|
@@ -125,8 +121,6 @@ func (s *Synthesis) FindMDBUserLogDaily(req entity.UserLogDailyReq) (*entity.Use
|
|
filter["channel"] = req.Channel
|
|
filter["channel"] = req.Channel
|
|
}
|
|
}
|
|
|
|
|
|
- // 分页参数
|
|
|
|
- skip := (req.Page - 1) * req.Size
|
|
|
|
// 计算总数
|
|
// 计算总数
|
|
count, err := collection.CountDocuments(ctx, filter)
|
|
count, err := collection.CountDocuments(ctx, filter)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -136,8 +130,8 @@ func (s *Synthesis) FindMDBUserLogDaily(req entity.UserLogDailyReq) (*entity.Use
|
|
|
|
|
|
// 执行查询
|
|
// 执行查询
|
|
opts := options.Find()
|
|
opts := options.Find()
|
|
- opts.SetSkip(int64(skip))
|
|
|
|
- opts.SetLimit(int64(req.Size))
|
|
|
|
|
|
+ opts.SetSkip(int64((page - 1) * pageSize))
|
|
|
|
+ opts.SetLimit(int64(pageSize))
|
|
opts.SetSort(bson.D{{"daily", -1}})
|
|
opts.SetSort(bson.D{{"daily", -1}})
|
|
|
|
|
|
cursor, err := collection.Find(ctx, filter, opts)
|
|
cursor, err := collection.Find(ctx, filter, opts)
|
|
@@ -197,6 +191,8 @@ func (s *Synthesis) FindMDBUserLogDaily(req entity.UserLogDailyReq) (*entity.Use
|
|
|
|
|
|
// FindWithdrawal 根据请求查询提现记录
|
|
// FindWithdrawal 根据请求查询提现记录
|
|
func (s *Synthesis) FindWithdrawal(req entity.UserWithdrawalReq) (*entity.UserWithdrawalResp, *code.Result) {
|
|
func (s *Synthesis) FindWithdrawal(req entity.UserWithdrawalReq) (*entity.UserWithdrawalResp, *code.Result) {
|
|
|
|
+ page, pageSize := checkPageParam(req.Page, req.Size)
|
|
|
|
+
|
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
defer cancel()
|
|
defer cancel()
|
|
collection := mdb.MDB.Collection(constant.CNameCashOutRecord)
|
|
collection := mdb.MDB.Collection(constant.CNameCashOutRecord)
|
|
@@ -242,8 +238,8 @@ func (s *Synthesis) FindWithdrawal(req entity.UserWithdrawalReq) (*entity.UserWi
|
|
|
|
|
|
// 设置分页选项
|
|
// 设置分页选项
|
|
findOptions := options.Find()
|
|
findOptions := options.Find()
|
|
- findOptions.SetSkip(int64((req.Page - 1) * req.Size))
|
|
|
|
- findOptions.SetLimit(int64(req.Size))
|
|
|
|
|
|
+ findOptions.SetSkip(int64((page - 1) * pageSize))
|
|
|
|
+ findOptions.SetLimit(int64(pageSize))
|
|
findOptions.SetSort(bson.D{{"createAt", -1}})
|
|
findOptions.SetSort(bson.D{{"createAt", -1}})
|
|
|
|
|
|
// 获取总数total
|
|
// 获取总数total
|
|
@@ -658,6 +654,8 @@ func (s *Synthesis) InsertRecord(param model.UserOperationLog) {
|
|
}
|
|
}
|
|
|
|
|
|
func (s *Synthesis) RecordList(req entity.RecordListReq) (*entity.RecordListResp, *code.Result) {
|
|
func (s *Synthesis) RecordList(req entity.RecordListReq) (*entity.RecordListResp, *code.Result) {
|
|
|
|
+ page, pageSize := checkPageParam(req.Page, req.Size)
|
|
|
|
+
|
|
record := new(model.UserOperationLog)
|
|
record := new(model.UserOperationLog)
|
|
collection := mdb.MDB.Collection(record.TableName())
|
|
collection := mdb.MDB.Collection(record.TableName())
|
|
|
|
|
|
@@ -689,8 +687,8 @@ func (s *Synthesis) RecordList(req entity.RecordListReq) (*entity.RecordListResp
|
|
|
|
|
|
// 设置分页选项
|
|
// 设置分页选项
|
|
findOptions := options.Find()
|
|
findOptions := options.Find()
|
|
- findOptions.SetSkip(int64((req.Page - 1) * req.Size))
|
|
|
|
- findOptions.SetLimit(int64(req.Size))
|
|
|
|
|
|
+ findOptions.SetSkip(int64((page - 1) * pageSize))
|
|
|
|
+ findOptions.SetLimit(int64(pageSize))
|
|
findOptions.SetSort(bson.D{{"created_at", -1}})
|
|
findOptions.SetSort(bson.D{{"created_at", -1}})
|
|
|
|
|
|
// 获取总数total
|
|
// 获取总数total
|