|
@@ -1,13 +1,14 @@ |
|
|
package svc |
|
|
package svc |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"applet/app/db" |
|
|
md "applet/app/md/institutional_management/public_platoon" |
|
|
md "applet/app/md/institutional_management/public_platoon" |
|
|
"applet/app/utils" |
|
|
"applet/app/utils" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"strconv" |
|
|
|
|
|
|
|
|
"strings" |
|
|
"xorm.io/xorm" |
|
|
"xorm.io/xorm" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@@ -157,9 +158,9 @@ func GetSonUserDailyActivity(engine *xorm.Engine, fatherUID int64, startDate, en |
|
|
if sonRelations == nil { |
|
|
if sonRelations == nil { |
|
|
return 0, nil, nil |
|
|
return 0, nil, nil |
|
|
} |
|
|
} |
|
|
userIDs := make([]int64, 0) |
|
|
|
|
|
|
|
|
userIDs := make([]string, 0) |
|
|
for _, relation := range *sonRelations { |
|
|
for _, relation := range *sonRelations { |
|
|
userIDs = append(userIDs, relation.Uid) |
|
|
|
|
|
|
|
|
userIDs = append(userIDs, utils.Int64ToStr(int64(relation.Uid))) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
userDb := implement.NewUserDb(engine) |
|
|
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) |
|
|
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 { |
|
|
if err != nil { |
|
|
return 0, nil, zhios_order_relate_logx.Error(err) |
|
|
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) |
|
|
sons = make([]md.SonUserDailyActivityAnalysisNode, 0) |
|
|
for _, user := range users { |
|
|
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{ |
|
|
sons = append(sons, md.SonUserDailyActivityAnalysisNode{ |
|
|
Uid: user.Id, |
|
|
Uid: user.Id, |
|
|
Nickname: user.Nickname, |
|
|
Nickname: user.Nickname, |
|
|
Phone: user.Phone, |
|
|
Phone: user.Phone, |
|
|
ActivityDayNums: activityDayNums, |
|
|
|
|
|
|
|
|
ActivityDayNums: utils.StrToInt64(resMap[utils.Int64ToStr(user.Id)]), |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
return total, sons, nil |
|
|
return total, sons, nil |
|
|