boweniac 3 месяцев назад
Родитель
Сommit
c7de2025fa
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      internal/logic/dashboard/get_wxs_logic.go

+ 9 - 4
internal/logic/dashboard/get_wxs_logic.go

@@ -4,7 +4,6 @@ import (
 	"context"
 	"fmt"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
-	"github.com/suyuan32/simple-admin-common/utils/pointy"
 	"time"
 	"wechat-api/ent"
 	"wechat-api/ent/usagestatisticday"
@@ -78,7 +77,7 @@ func (l *GetWxsLogic) GetWxs(req *types.WxReq) (resp *types.WxResp, err error) {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
-	resp := &types.WxResp{}
+	resp = &types.WxResp{}
 	resp.Msg = errormsg.Success
 	resp.Data.Total = wxs.PageDetails.Total
 
@@ -132,6 +131,7 @@ func (l *GetWxsLogic) GetWxs(req *types.WxReq) (resp *types.WxResp, err error) {
 			).
 			Order(ent.Desc(usagestatisticday.FieldAddtime)).
 			First(l.ctx)
+		l.Infof("----------------lastDayData--------------: %+v", lastDayData)
 		if err != nil {
 			return nil, err
 		}
@@ -148,15 +148,20 @@ func (l *GetWxsLogic) GetWxs(req *types.WxReq) (resp *types.WxResp, err error) {
 			return nil, err
 		}
 		for _, dayData := range usageStatisticDay {
+			l.Infof("----------------dayData--------------: %+v", dayData)
+			rate := float32(0)
+			if dayData.TotalFriend != 0 {
+				rate = float32(dayData.ActiveUser) / float32(dayData.TotalFriend)
+			}
 			wxList = append(wxList, types.WxData{
 				Nickname:        wxSet[dayData.BotID].Nickname,
-				InteractionRate: float32(dayData.ActiveUser) / float32(dayData.TotalFriend),
+				InteractionRate: rate,
 				TotalFriend:     dayData.TotalFriend,
 				TotalGroup:      dayData.TotalGroup,
 			})
 		}
 	}
-
+	l.Infof("----------------wxList--------------: %+v", wxList)
 	resp.Data.Data = wxList
 
 	return resp, nil