|
@@ -95,16 +95,29 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
isCurrentDay = endTime.Year() == now.Year() && endTime.Month() == now.Month() && endTime.Day() == now.Day()
|
|
|
}
|
|
|
|
|
|
+ aiResponseTip := "AI角色 + SOP 执行次数"
|
|
|
+ sopRunTip := "SOP 节点或阶段的触发次数"
|
|
|
+ totalFriendTip := "截止至各统计时点的好友数量"
|
|
|
+ totalGroupTip := "截止至各统计时点的群数量"
|
|
|
+ activeUserTip := "统计周期内回复sop 或触发了AI角色的微信用户"
|
|
|
+ newUserTip := "统计周期内好友的增减数量"
|
|
|
+
|
|
|
// 定义变量
|
|
|
aiResponse := types.ChartsUint{}
|
|
|
+ aiResponse.Tip = &aiResponseTip
|
|
|
sopRun := types.ChartsUint{}
|
|
|
+ sopRun.Tip = &sopRunTip
|
|
|
totalFriend := types.ChartsUint{}
|
|
|
+ totalFriend.Tip = &totalFriendTip
|
|
|
totalGroup := types.ChartsUint{}
|
|
|
+ totalGroup.Tip = &totalGroupTip
|
|
|
accountBalance := types.ChartsUint{}
|
|
|
accountBalance.LabelText = "积分"
|
|
|
consumeToken := types.ChartsUint{}
|
|
|
activeUser := types.ChartsUint{}
|
|
|
+ activeUser.Tip = &activeUserTip
|
|
|
newUser := types.ChartsInt{}
|
|
|
+ newUser.Tip = &newUserTip
|
|
|
var labelDists []custom_types.LabelDist
|
|
|
if layoutsType == 1 && *req.StartDate == *req.EndDate {
|
|
|
startAddTimeString := startTime.Format("2006010200")
|
|
@@ -123,10 +136,13 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
|
|
|
var predicates []predicate.UsageStatisticHour
|
|
|
- predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
if req.Wxid != nil {
|
|
|
+ if organizationId != 0 {
|
|
|
+ predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
+ }
|
|
|
predicates = append(predicates, usagestatistichour.BotID(*req.Wxid))
|
|
|
} else {
|
|
|
+ predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
predicates = append(predicates, usagestatistichour.BotID(""))
|
|
|
}
|
|
|
predicates = append(predicates, usagestatistichour.AddtimeGTE(startAddTime))
|
|
@@ -175,16 +191,20 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
hourLen := len(usageStatisticHour)
|
|
|
if hourLen > 0 {
|
|
|
if usageStatisticHour[0].TotalFriend > 0 {
|
|
|
- totalFriend.Rate = float32((usageStatisticHour[hourLen-1].TotalFriend - usageStatisticHour[0].TotalFriend) / usageStatisticHour[0].TotalFriend)
|
|
|
+ totalFriendRate := float32((usageStatisticHour[hourLen-1].TotalFriend - usageStatisticHour[0].TotalFriend) / usageStatisticHour[0].TotalFriend)
|
|
|
+ totalFriend.Rate = &totalFriendRate
|
|
|
}
|
|
|
if usageStatisticHour[0].TotalGroup > 0 {
|
|
|
- totalGroup.Rate = float32((usageStatisticHour[hourLen-1].TotalGroup - usageStatisticHour[0].TotalGroup) / usageStatisticHour[0].TotalGroup)
|
|
|
- }
|
|
|
- if usageStatisticHour[0].ActiveUser > 0 {
|
|
|
- activeUser.Rate = float32((usageStatisticHour[hourLen-1].ActiveUser - usageStatisticHour[0].ActiveUser) / usageStatisticHour[0].ActiveUser)
|
|
|
+ totalGroupRate := float32((usageStatisticHour[hourLen-1].TotalGroup - usageStatisticHour[0].TotalGroup) / usageStatisticHour[0].TotalGroup)
|
|
|
+ totalGroup.Rate = &totalGroupRate
|
|
|
}
|
|
|
+ //if usageStatisticHour[0].ActiveUser > 0 {
|
|
|
+ // activeUserRate := float32((usageStatisticHour[hourLen-1].ActiveUser - usageStatisticHour[0].ActiveUser) / usageStatisticHour[0].ActiveUser)
|
|
|
+ // activeUser.Rate = &activeUserRate
|
|
|
+ //}
|
|
|
if usageStatisticHour[0].NewUser > 0 {
|
|
|
- newUser.Rate = float32((usageStatisticHour[hourLen-1].NewUser - usageStatisticHour[0].NewUser) / usageStatisticHour[0].NewUser)
|
|
|
+ newUserRate := float32((usageStatisticHour[hourLen-1].NewUser - usageStatisticHour[0].NewUser) / usageStatisticHour[0].NewUser)
|
|
|
+ newUser.Rate = &newUserRate
|
|
|
}
|
|
|
labelDists = usageStatisticHour[hourLen-1].LabelDist
|
|
|
}
|
|
@@ -204,10 +224,13 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
|
|
|
var predicatesDay []predicate.UsageStatisticDay
|
|
|
- predicatesDay = append(predicatesDay, usagestatisticday.OrganizationID(organizationId))
|
|
|
if req.Wxid != nil {
|
|
|
+ if organizationId != 0 {
|
|
|
+ predicatesDay = append(predicatesDay, usagestatisticday.OrganizationID(organizationId))
|
|
|
+ }
|
|
|
predicatesDay = append(predicatesDay, usagestatisticday.BotID(*req.Wxid))
|
|
|
} else {
|
|
|
+ predicatesDay = append(predicatesDay, usagestatisticday.OrganizationID(organizationId))
|
|
|
predicatesDay = append(predicatesDay, usagestatisticday.BotID(""))
|
|
|
}
|
|
|
predicatesDay = append(predicatesDay, usagestatisticday.AddtimeGTE(startAddTime))
|
|
@@ -255,16 +278,20 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
dayLen := len(usageStatisticDay)
|
|
|
if dayLen > 0 {
|
|
|
if usageStatisticDay[0].TotalFriend > 0 {
|
|
|
- totalFriend.Rate = float32((usageStatisticDay[dayLen-1].TotalFriend - usageStatisticDay[0].TotalFriend) / usageStatisticDay[0].TotalFriend)
|
|
|
+ totalFriendRate := float32((usageStatisticDay[dayLen-1].TotalFriend - usageStatisticDay[0].TotalFriend) / usageStatisticDay[0].TotalFriend)
|
|
|
+ totalFriend.Rate = &totalFriendRate
|
|
|
}
|
|
|
if usageStatisticDay[0].TotalGroup > 0 {
|
|
|
- totalGroup.Rate = float32((usageStatisticDay[dayLen-1].TotalGroup - usageStatisticDay[0].TotalGroup) / usageStatisticDay[0].TotalGroup)
|
|
|
- }
|
|
|
- if usageStatisticDay[0].ActiveUser > 0 {
|
|
|
- activeUser.Rate = float32((usageStatisticDay[dayLen-1].ActiveUser - usageStatisticDay[0].ActiveUser) / usageStatisticDay[0].ActiveUser)
|
|
|
+ totalGroupRate := float32((usageStatisticDay[dayLen-1].TotalGroup - usageStatisticDay[0].TotalGroup) / usageStatisticDay[0].TotalGroup)
|
|
|
+ totalGroup.Rate = &totalGroupRate
|
|
|
}
|
|
|
+ //if usageStatisticDay[0].ActiveUser > 0 {
|
|
|
+ // activeUserRate := float32((usageStatisticDay[dayLen-1].ActiveUser - usageStatisticDay[0].ActiveUser) / usageStatisticDay[0].ActiveUser)
|
|
|
+ // activeUser.Rate = &activeUserRate
|
|
|
+ //}
|
|
|
if usageStatisticDay[0].NewUser > 0 {
|
|
|
- newUser.Rate = float32((usageStatisticDay[dayLen-1].NewUser - usageStatisticDay[0].NewUser) / usageStatisticDay[0].NewUser)
|
|
|
+ newUserRate := float32((usageStatisticDay[dayLen-1].NewUser - usageStatisticDay[0].NewUser) / usageStatisticDay[0].NewUser)
|
|
|
+ newUser.Rate = &newUserRate
|
|
|
}
|
|
|
labelDists = usageStatisticDay[dayLen-1].LabelDist
|
|
|
}
|
|
@@ -280,10 +307,13 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
}
|
|
|
|
|
|
var predicates []predicate.UsageStatisticHour
|
|
|
- predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
if req.Wxid != nil {
|
|
|
+ if organizationId != 0 {
|
|
|
+ predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
+ }
|
|
|
predicates = append(predicates, usagestatistichour.BotID(*req.Wxid))
|
|
|
} else {
|
|
|
+ predicates = append(predicates, usagestatistichour.OrganizationID(organizationId))
|
|
|
predicates = append(predicates, usagestatistichour.BotID(""))
|
|
|
}
|
|
|
predicates = append(predicates, usagestatistichour.AddtimeGTE(startOfDayAddTime))
|
|
@@ -326,7 +356,8 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
totalFriend.Label = append(totalFriend.Label, "今日")
|
|
|
tfLen := len(totalFriend.Val)
|
|
|
if tfLen > 0 && totalFriend.Val[0] > 0 {
|
|
|
- totalFriend.Rate = float32((totalFriend.Val[tfLen-1] - totalFriend.Val[0]) / totalFriend.Val[0])
|
|
|
+ totalFriendRate := float32((totalFriend.Val[tfLen-1] - totalFriend.Val[0]) / totalFriend.Val[0])
|
|
|
+ totalFriend.Rate = &totalFriendRate
|
|
|
}
|
|
|
totalFriend.LabelText = "个"
|
|
|
|
|
@@ -335,7 +366,8 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
totalGroup.Label = append(totalGroup.Label, "今日")
|
|
|
tgLen := len(totalGroup.Val)
|
|
|
if tgLen > 0 && totalGroup.Val[0] > 0 {
|
|
|
- totalGroup.Rate = float32((totalGroup.Val[tgLen-1] - totalGroup.Val[0]) / totalGroup.Val[0])
|
|
|
+ totalGroupRate := float32((totalGroup.Val[tgLen-1] - totalGroup.Val[0]) / totalGroup.Val[0])
|
|
|
+ totalGroup.Rate = &totalGroupRate
|
|
|
}
|
|
|
totalGroup.LabelText = "个"
|
|
|
|
|
@@ -347,10 +379,11 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
activeUser.Count = activeUserOfDay
|
|
|
activeUser.Val = append(activeUser.Val, activeUserOfDay)
|
|
|
activeUser.Label = append(activeUser.Label, "今日")
|
|
|
- auLen := len(activeUser.Val)
|
|
|
- if auLen > 0 && activeUser.Val[0] > 0 {
|
|
|
- activeUser.Rate = float32((activeUser.Val[auLen-1] - activeUser.Val[0]) / activeUser.Val[0])
|
|
|
- }
|
|
|
+ //auLen := len(activeUser.Val)
|
|
|
+ //if auLen > 0 && activeUser.Val[0] > 0 {
|
|
|
+ // activeUserRate := float32((activeUser.Val[auLen-1] - activeUser.Val[0]) / activeUser.Val[0])
|
|
|
+ // activeUser.Rate = &activeUserRate
|
|
|
+ //}
|
|
|
activeUser.LabelText = "个"
|
|
|
|
|
|
newUser.Count = newUserOfDay
|
|
@@ -358,7 +391,8 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
|
|
|
newUser.Label = append(newUser.Label, "今日")
|
|
|
nuLen := len(newUser.Val)
|
|
|
if nuLen > 0 && newUser.Val[0] > 0 {
|
|
|
- newUser.Rate = float32((newUser.Val[nuLen-1] - newUser.Val[0]) / newUser.Val[0])
|
|
|
+ newUserRate := float32((newUser.Val[nuLen-1] - newUser.Val[0]) / newUser.Val[0])
|
|
|
+ newUser.Rate = &newUserRate
|
|
|
}
|
|
|
newUser.LabelText = "个"
|
|
|
|