dengbiao пре 1 недеља
родитељ
комит
a6ec1f6659
2 измењених фајлова са 17 додато и 30 уклоњено
  1. +5
    -19
      app/hdl/institutional_management/public_platoon/hdl_basic.go
  2. +12
    -11
      app/svc/public_platoon/svc_relation_ship_map.go

+ 5
- 19
app/hdl/institutional_management/public_platoon/hdl_basic.go Прегледај датотеку

@@ -5,12 +5,11 @@ import (
"applet/app/e"
md "applet/app/md/institutional_management/public_platoon"
svc "applet/app/svc/public_platoon"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"strconv"
"time"
)

@@ -562,35 +561,22 @@ func UserDailyActivityAnalysis(c *gin.Context) {
return
}

platoonUserRelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db)
parentRelation, err := platoonUserRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{
"key": "uid",
"value": req.Uid,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

total, sons, err := svc.GetSonUserDailyActivity(db.Db, req.Uid, req.StartDate, req.EndDate, req.Page, req.PageSize)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

sql1 := "SELECT COUNT(*) AS total, uid FROM `egg_enery_user_activity` WHERE uid IN (SELECT uid FROM `user_relate` WHERE parent_uid = ?) GROUP BY uid"
res1, err := db.Db.QueryInterface(sql1, parentRelation.Uid)
sql1 := "SELECT COUNT(*) AS total, uid FROM `egg_energy_user_activity` WHERE uid IN (SELECT uid FROM `user_relate` WHERE parent_uid = ?) GROUP BY uid"
results, err := db.Db.QueryString(sql1, req.Uid)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

var activityCount, activityUserCount int64
for _, value := range res1 {
tempCount, err := strconv.ParseInt(fmt.Sprintf("%v", value), 10, 64)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
}
for _, result := range results {
tempCount := utils.StrToInt64(result["total"])
activityCount += tempCount
activityUserCount++
}


+ 12
- 11
app/svc/public_platoon/svc_relation_ship_map.go Прегледај датотеку

@@ -1,13 +1,14 @@
package svc

import (
"applet/app/db"
md "applet/app/md/institutional_management/public_platoon"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"fmt"
"strconv"
"strings"
"xorm.io/xorm"
)

@@ -157,9 +158,9 @@ func GetSonUserDailyActivity(engine *xorm.Engine, fatherUID int64, startDate, en
if sonRelations == nil {
return 0, nil, nil
}
userIDs := make([]int64, 0)
userIDs := make([]string, 0)
for _, relation := range *sonRelations {
userIDs = append(userIDs, relation.Uid)
userIDs = append(userIDs, utils.Int64ToStr(int64(relation.Uid)))
}

userDb := implement.NewUserDb(engine)
@@ -171,24 +172,24 @@ func GetSonUserDailyActivity(engine *xorm.Engine, fatherUID int64, startDate, en
return 0, nil, zhios_order_relate_logx.Error(err)
}

sql1 := "SELECT COUNT(*) AS total, uid FROM `egg_enery_user_activity` WHERE uid IN ? AND date >= ? AND date <= ? GROUP BY uid"
res, err := engine.QueryInterface(sql1, utils.AnyToString(userIDs), startDate, endDate)
sql := "SELECT COUNT(*) AS total, uid FROM `egg_energy_user_activity` WHERE uid IN (%s) AND date >= '%s' AND date <= '%s' GROUP BY uid"
results, err := db.QueryNativeString(engine, fmt.Sprintf(sql, strings.Join(userIDs, ","), startDate, endDate))
if err != nil {
return 0, nil, zhios_order_relate_logx.Error(err)
}

var resMap = map[string]string{}
for _, res := range results {
resMap[res["uid"]] = res["total"]
}

sons = make([]md.SonUserDailyActivityAnalysisNode, 0)
for _, user := range users {
value := res[user.Id]
activityDayNums, err := strconv.ParseInt(fmt.Sprintf("%v", value), 10, 64)
if err != nil {
return 0, nil, zhios_order_relate_logx.Error(err)
}
sons = append(sons, md.SonUserDailyActivityAnalysisNode{
Uid: user.Id,
Nickname: user.Nickname,
Phone: user.Phone,
ActivityDayNums: activityDayNums,
ActivityDayNums: utils.StrToInt64(resMap[utils.Int64ToStr(user.Id)]),
})
}
return total, sons, nil


Loading…
Откажи
Сачувај