|
@@ -4,6 +4,7 @@ import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
|
+ "math"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -112,7 +113,6 @@ func (l *GetWxsLogic) GetWxs(req *types.WxReq) (resp *types.WxResp, err error) {
|
|
|
Where(predicatesH...).
|
|
|
Order(ent.Desc(usagestatistichour.FieldAddtime)).
|
|
|
First(l.ctx)
|
|
|
- l.Infof("----------------l.svcCtx.DB.UsageStatisticHour 1--------------: %+v", err)
|
|
|
if err != nil {
|
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
}
|
|
@@ -127,17 +127,18 @@ func (l *GetWxsLogic) GetWxs(req *types.WxReq) (resp *types.WxResp, err error) {
|
|
|
predicatesHour = append(predicatesHour, usagestatistichour.BotIDIn(wxIds...))
|
|
|
predicatesHour = append(predicatesHour, usagestatistichour.Addtime(lastHourData.Addtime))
|
|
|
usageStatisticHour, err := l.svcCtx.DB.UsageStatisticHour.Query().Where(predicatesHour...).Page(l.ctx, req.Page, req.PageSize)
|
|
|
- l.Infof("----------------l.svcCtx.DB.UsageStatisticHour 2--------------: %+v", err)
|
|
|
if err != nil {
|
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
}
|
|
|
if usageStatisticHour != nil && usageStatisticHour.List != nil {
|
|
|
+ l.Infof("----------------usageStatisticHour 1--------------: %+v", usageStatisticHour)
|
|
|
resp.Data.Total = usageStatisticHour.PageDetails.Total
|
|
|
for _, hourData := range usageStatisticHour.List {
|
|
|
if wxSet[hourData.BotID] != nil {
|
|
|
rate := float32(0)
|
|
|
if hourData.TotalFriend != 0 {
|
|
|
- rate = float32(hourData.ActiveUser) / float32(hourData.TotalFriend)
|
|
|
+ rate = float32(float64(hourData.ActiveUser)) / float32(float64(hourData.TotalFriend))
|
|
|
+ rate = float32(math.Round(float64(rate)*100) / 100)
|
|
|
}
|
|
|
wxList = append(wxList, types.WxData{
|
|
|
Nickname: wxSet[hourData.BotID].Nickname,
|
|
@@ -167,12 +168,14 @@ func (l *GetWxsLogic) GetWxs(req *types.WxReq) (resp *types.WxResp, err error) {
|
|
|
return nil, err
|
|
|
}
|
|
|
if usageStatisticDay != nil && usageStatisticDay.List != nil {
|
|
|
+ l.Infof("----------------usageStatisticDay 2--------------: %+v", usageStatisticDay)
|
|
|
resp.Data.Total = usageStatisticDay.PageDetails.Total
|
|
|
for _, dayData := range usageStatisticDay.List {
|
|
|
if wxSet[dayData.BotID] != nil {
|
|
|
rate := float32(0)
|
|
|
if dayData.TotalFriend != 0 {
|
|
|
- rate = float32(dayData.ActiveUser) / float32(dayData.TotalFriend)
|
|
|
+ rate = float32(float64(dayData.ActiveUser)) / float32(float64(dayData.TotalFriend))
|
|
|
+ rate = float32(math.Round(float64(rate)*100) / 100)
|
|
|
}
|
|
|
wxList = append(wxList, types.WxData{
|
|
|
Nickname: wxSet[dayData.BotID].Nickname,
|