forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,699 @@
|
||||
package botdailyhourstat
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"stat/common/statutils"
|
||||
)
|
||||
|
||||
func LineCount(iTemp string, iValue int64, permilValue int64) string {
|
||||
if permilValue > 1000000 || permilValue < -1000000 {
|
||||
s1 := fmt.Sprintf("%d", iValue)
|
||||
str1 := fmt.Sprintf(iTemp, s1)
|
||||
return str1 + "\n"
|
||||
} else {
|
||||
s1 := fmt.Sprintf("%d", iValue)
|
||||
str1 := fmt.Sprintf(iTemp, s1)
|
||||
v := float64(permilValue) / 10
|
||||
str2 := ""
|
||||
if v < 0 {
|
||||
str2 = fmt.Sprintf("⬇%.2f%%", v)
|
||||
} else if v > 0 {
|
||||
str2 = fmt.Sprintf("⬆+️%.2f%%", v)
|
||||
} else {
|
||||
str2 = fmt.Sprintf(" %.2f%%", v)
|
||||
}
|
||||
return str1 + str2 + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
func LineMoneyOne(iTemp string, iValue int64) string {
|
||||
return LineCountOne(iTemp, iValue/100)
|
||||
}
|
||||
|
||||
func LineCountOne(iTemp string, iValue int64) string {
|
||||
s1 := fmt.Sprintf("%d", iValue)
|
||||
str1 := fmt.Sprintf(iTemp, s1)
|
||||
return str1 + "\n"
|
||||
}
|
||||
|
||||
func LineMoney(iTemp string, iValue int64, permilValue int64) string {
|
||||
return LineCount(iTemp, iValue/100, permilValue)
|
||||
}
|
||||
|
||||
func (s *StatItem) Display(prefix string) string {
|
||||
var text string
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┣", "充值总计:")
|
||||
//text += s.Recharge.DisplayDayHourText(prefix+"┃", 100)
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┣", "老用户充值:")
|
||||
//text += s.RechargeOldUser.DisplayDayHourText(prefix+"┃", 100)
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┣", "新用户充值:")
|
||||
//text += s.RechargeNewUser.DisplayDayHourText(prefix+"┃", 100)
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┣", "[会员购买]:")
|
||||
//text += s.RechargeVip.DisplayDayHourText(prefix+"┃", 100)
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┣", "[金币购买]:")
|
||||
//text += s.RechargeGold.DisplayDayHourText(prefix+"┃", 100)
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┣", "[订单统计]:")
|
||||
//text += s.Order.DisplayDayHourText(prefix+"┃", 1)
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┣", "[注册统计]:")
|
||||
//text += s.Register.DisplayDayHourText(prefix+"┃", 1)
|
||||
//text += fmt.Sprintf("%s%s\n", prefix+"┗", "[访问统计]:")
|
||||
//text += s.Visit.DisplayDayHourText(prefix+" ", 1)
|
||||
return text
|
||||
}
|
||||
|
||||
func (s *BotHourStat) DisplayDayHourText(appName string, compare *BotHourStat) string {
|
||||
calc := func(curr, hist *statutils.Stat) (*statutils.Stat, *statutils.Stat) {
|
||||
diff := curr.Sub(hist)
|
||||
rate := diff.Permil(hist)
|
||||
return curr, rate
|
||||
}
|
||||
rate := func(currValue, histValue int64) int64 {
|
||||
if histValue != 0 {
|
||||
return (currValue - histValue) * 1000 / histValue
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
var text string
|
||||
text += fmt.Sprintf("应用名称:【%s】\n", appName) //🆚
|
||||
text += fmt.Sprintf("统计时间:%s\n", s.SumDate.Format("2006-01-02T15:04:05"))
|
||||
if compare != nil {
|
||||
func() {
|
||||
reCurr, reRate := calc(&s.TodayStat.Recharge, &compare.TodayStat.Recharge)
|
||||
text += "1️⃣当日充值:\n"
|
||||
text += LineMoney("┣充值合计:%s", reCurr.Value(), reRate.Value())
|
||||
text += LineMoney("┃┏安卓充值:%s", reCurr.Android.Value(), reRate.Android.Value())
|
||||
text += LineMoney("┣╋苹果充值:%s", reCurr.Ios.Value(), reRate.Ios.Value())
|
||||
text += LineMoney("┃┣轻量充值:%s", reCurr.Light.Value(), reRate.Light.Value())
|
||||
text += LineMoney("┃┗H5充值 :%s", reCurr.H5.Value(), reRate.H5.Value())
|
||||
text += LineMoney("┃┏渠道充值:%s", reCurr.Total.District.Value, reRate.Total.District.Value)
|
||||
text += LineMoney("┣╋官网充值:%s", reCurr.Total.Web.Value, reRate.Total.Web.Value)
|
||||
text += LineMoney("┃┣自来充值:%s", reCurr.Total.Normal.Value, reRate.Total.Normal.Value)
|
||||
text += LineMoney("┃┗分享充值:%s", reCurr.Total.Share.Value, reRate.Total.Share.Value)
|
||||
oldCurr, oldRate := calc(&s.TodayStat.RechargeOld, &compare.TodayStat.RechargeOld)
|
||||
text += LineMoney("┃┏老用户充:%s", oldCurr.Value(), oldRate.Value())
|
||||
newCurr, newRate := calc(&s.TodayStat.RechargeNew, &compare.TodayStat.RechargeNew)
|
||||
text += LineMoney("┣╋新用户充:%s", newCurr.Value(), newRate.Value())
|
||||
v0, v00 := calc(newCurr.Percentage(reCurr), compare.TodayStat.RechargeNew.Percentage(&compare.TodayStat.Recharge))
|
||||
text += LineCount("┃┗新充占比:%s%%", v0.Value(), v00.Value())
|
||||
memCurr, memRate := calc(&s.TodayStat.RechargeVip, &compare.TodayStat.RechargeVip)
|
||||
text += LineMoney("┃┏会员充值:%s", memCurr.Value(), memRate.Value())
|
||||
coinCurr, coinRate := calc(&s.TodayStat.RechargeGold, &compare.TodayStat.RechargeGold)
|
||||
text += LineMoney("┣╋金币充值:%s", coinCurr.Value(), coinRate.Value())
|
||||
v2, v22 := calc(memCurr.Percentage(reCurr), compare.TodayStat.RechargeVip.Percentage(&compare.TodayStat.Recharge))
|
||||
text += LineCount("┃┗会员占比:%s%%", v2.Value(), v22.Value())
|
||||
orderCurr, orderRate := calc(&s.TodayStat.Order, &compare.TodayStat.Order)
|
||||
text += LineCount("┃┏订单拉起:%s", orderCurr.Count(), orderRate.Count())
|
||||
succCurr, succRate := calc(&s.TodayStat.OrderSucc, &compare.TodayStat.OrderSucc)
|
||||
text += LineCount("┣╋订单成功:%s", succCurr.Count(), succRate.Count())
|
||||
v1, v11 := calc(succCurr.Percentage(orderCurr), compare.TodayStat.OrderSucc.Percentage(&compare.TodayStat.Order))
|
||||
text += LineCount("┃┗成功比率:%s%%", v1.Count(), v11.Count())
|
||||
text += "2️⃣当日新增:\n"
|
||||
|
||||
regCurr, regRate := calc(&s.TodayStat.Register, &compare.TodayStat.Register)
|
||||
text += LineCount("┣新增用户:%s", regCurr.Count(), regRate.Count())
|
||||
text += LineCount("┃┏安卓新增:%s", regCurr.Android.Count(), regRate.Android.Count())
|
||||
text += LineCount("┣╋苹果新增:%s", regCurr.Ios.Count(), regRate.Ios.Count())
|
||||
text += LineCount("┃┣轻量新增:%s", regCurr.Light.Count(), regRate.Light.Count())
|
||||
text += LineCount("┃┗H5新增 :%s", regCurr.H5.Count(), regRate.H5.Count())
|
||||
text += LineCount("┃┏渠道新增:%s", regCurr.Total.District.Count, regRate.Total.District.Count)
|
||||
text += LineCount("┣╋有效新增:%s", regCurr.Total.Direct.Value()-regCurr.Total.Direct.Natural.Value,
|
||||
regRate.Total.Direct.Value()-regRate.Total.Direct.Natural.Value)
|
||||
text += LineCount("┣╋官网新增:%s", regCurr.Total.Web.Count, regRate.Total.Web.Count)
|
||||
text += LineCount("┃┣自来新增:%s", regCurr.Total.Normal.Count, regRate.Total.Normal.Count)
|
||||
text += LineCount("┃┗分享新增:%s", regCurr.Total.Share.Count, regRate.Total.Share.Count)
|
||||
text += "3️⃣当日日活:\n"
|
||||
visitCurr, visitRate := calc(&s.TodayStat.Visit, &compare.TodayStat.Visit)
|
||||
text += LineCount("┣日活总数:%s", visitCurr.Count(), visitRate.Count())
|
||||
text += LineCount("┃┏安卓日活:%s", visitCurr.Android.Count(), visitRate.Android.Count())
|
||||
text += LineCount("┣╋苹果日活:%s", visitCurr.Ios.Count(), visitRate.Ios.Count())
|
||||
text += LineCount("┃┣轻量日活:%s", visitCurr.Light.Count(), visitRate.Light.Count())
|
||||
text += LineCount("┃┗H5日活 :%s", visitCurr.H5.Count(), visitRate.H5.Count())
|
||||
text += LineCount("┃┏渠道日活:%s", visitCurr.Total.District.Count, visitRate.Total.District.Count)
|
||||
text += LineCount("┣╋官网日活:%s", visitCurr.Total.Web.Count, visitRate.Total.Web.Count)
|
||||
text += LineCount("┃┣自来日活:%s", visitCurr.Total.Normal.Count, visitRate.Total.Normal.Count)
|
||||
text += LineCount("┃┗分享日活:%s", visitCurr.Total.Share.Count, visitRate.Total.Share.Count)
|
||||
text += "4️⃣落地页点击:\n"
|
||||
text += LineCount("┣总数:%s", s.TodayLandPage.LandPageTotalClick, rate(s.TodayLandPage.LandPageTotalClick, compare.TodayLandPage.LandPageTotalClick))
|
||||
text += LineCount("┃┏安卓:%s", s.TodayLandPage.LandPageAndroidClick, rate(s.TodayLandPage.LandPageAndroidClick, compare.TodayLandPage.LandPageAndroidClick))
|
||||
text += LineCount("┣╋商店:%s", s.TodayLandPage.LandPageIosAppstoreClick, rate(s.TodayLandPage.LandPageIosAppstoreClick, compare.TodayLandPage.LandPageIosAppstoreClick))
|
||||
text += LineCount("┃┣企业:%s", s.TodayLandPage.LandPageIosFirmClick, rate(s.TodayLandPage.LandPageIosFirmClick, compare.TodayLandPage.LandPageIosFirmClick))
|
||||
text += LineCount("┃┗轻量:%s", s.TodayLandPage.LandPageIosLightClick, rate(s.TodayLandPage.LandPageIosLightClick, compare.TodayLandPage.LandPageIosLightClick))
|
||||
}()
|
||||
func() {
|
||||
reCurr, reRate := calc(&s.HourStat.Recharge, &compare.HourStat.Recharge)
|
||||
text += "5️⃣小时充值:\n"
|
||||
text += LineMoney("┣充值合计:%s", reCurr.Value(), reRate.Value())
|
||||
text += LineMoney("┃┏安卓充值:%s", reCurr.Android.Value(), reRate.Android.Value())
|
||||
text += LineMoney("┣╋苹果充值:%s", reCurr.Ios.Value(), reRate.Ios.Value())
|
||||
text += LineMoney("┃┣轻量充值:%s", reCurr.Light.Value(), reRate.Light.Value())
|
||||
text += LineMoney("┃┗H5充值 :%s", reCurr.H5.Value(), reRate.H5.Value())
|
||||
text += LineMoney("┃┏渠道充值:%s", reCurr.Total.District.Value, reRate.Total.District.Value)
|
||||
text += LineMoney("┣╋官网充值:%s", reCurr.Total.Web.Value, reRate.Total.Web.Value)
|
||||
text += LineMoney("┃┣自来充值:%s", reCurr.Total.Normal.Value, reRate.Total.Normal.Value)
|
||||
text += LineMoney("┃┗分享充值:%s", reCurr.Total.Share.Value, reRate.Total.Share.Value)
|
||||
oldCurr, oldRate := calc(&s.HourStat.RechargeOld, &compare.HourStat.RechargeOld)
|
||||
text += LineMoney("┃┏老用户充:%s", oldCurr.Value(), oldRate.Value())
|
||||
newCurr, newRate := calc(&s.HourStat.RechargeNew, &compare.HourStat.RechargeNew)
|
||||
text += LineMoney("┣╋新用户充:%s", newCurr.Value(), newRate.Value())
|
||||
v0, v00 := calc(newCurr.Percentage(reCurr), compare.HourStat.RechargeNew.Percentage(&compare.HourStat.Recharge))
|
||||
text += LineCount("┃┗新充占比:%s%%", v0.Value(), v00.Value())
|
||||
memCurr, memRate := calc(&s.HourStat.RechargeVip, &compare.HourStat.RechargeVip)
|
||||
text += LineMoney("┃┏会员充值:%s", memCurr.Value(), memRate.Value())
|
||||
coinCurr, coinRate := calc(&s.HourStat.RechargeGold, &compare.HourStat.RechargeGold)
|
||||
text += LineMoney("┣╋金币充值:%s", coinCurr.Value(), coinRate.Value())
|
||||
v2, v22 := calc(memCurr.Percentage(reCurr), compare.HourStat.RechargeVip.Percentage(&compare.HourStat.Recharge))
|
||||
text += LineCount("┃┗会员占比:%s%%", v2.Value(), v22.Value())
|
||||
orderCurr, orderRate := calc(&s.HourStat.Order, &compare.HourStat.Order)
|
||||
text += LineCount("┃┏订单拉起:%s", orderCurr.Count(), orderRate.Count())
|
||||
succCurr, succRate := calc(&s.HourStat.OrderSucc, &compare.HourStat.OrderSucc)
|
||||
text += LineCount("┣╋订单成功:%s", succCurr.Count(), succRate.Count())
|
||||
v1, v11 := calc(succCurr.Percentage(orderCurr), compare.HourStat.OrderSucc.Percentage(&compare.HourStat.Order))
|
||||
text += LineCount("┃┗订单成功率:%s%%", v1.Count(), v11.Count())
|
||||
text += "6️⃣小时新增:\n"
|
||||
regCurr, regRate := calc(&s.HourStat.Register, &compare.HourStat.Register)
|
||||
text += LineCount("┣新增用户:%s", regCurr.Count(), regRate.Count())
|
||||
text += LineCount("┃┏安卓新增:%s", regCurr.Android.Count(), regRate.Android.Count())
|
||||
text += LineCount("┣╋苹果新增:%s", regCurr.Ios.Count(), regRate.Ios.Count())
|
||||
text += LineCount("┃┣轻量新增:%s", regCurr.Light.Count(), regRate.Light.Count())
|
||||
text += LineCount("┃┗H5新增 :%s", regCurr.H5.Count(), regRate.H5.Count())
|
||||
text += LineCount("┃┏渠道新增:%s", regCurr.Total.District.Count, regRate.Total.District.Count)
|
||||
text += LineCount("┣╋有效新增:%s", regCurr.Total.Direct.Value()-regCurr.Total.Direct.Natural.Value,
|
||||
regRate.Total.Direct.Value()-regRate.Total.Direct.Natural.Value)
|
||||
text += LineCount("┣╋官网新增:%s", regCurr.Total.Web.Count, regRate.Total.Web.Count)
|
||||
text += LineCount("┃┣自来新增:%s", regCurr.Total.Normal.Count, regRate.Total.Normal.Count)
|
||||
text += LineCount("┃┗分享新增:%s", regCurr.Total.Share.Count, regRate.Total.Share.Count)
|
||||
text += "7️⃣小时落地页点击:\n"
|
||||
text += LineCount("┣总数:%s", s.HourLandPage.LandPageTotalClick, rate(s.HourLandPage.LandPageTotalClick, compare.HourLandPage.LandPageTotalClick))
|
||||
text += LineCount("┃┏安卓:%s", s.HourLandPage.LandPageAndroidClick, rate(s.HourLandPage.LandPageAndroidClick, compare.HourLandPage.LandPageAndroidClick))
|
||||
text += LineCount("┣╋商店:%s", s.HourLandPage.LandPageIosAppstoreClick, rate(s.HourLandPage.LandPageIosAppstoreClick, compare.HourLandPage.LandPageIosAppstoreClick))
|
||||
text += LineCount("┃┣企业:%s", s.HourLandPage.LandPageIosFirmClick, rate(s.HourLandPage.LandPageIosFirmClick, compare.HourLandPage.LandPageIosFirmClick))
|
||||
text += LineCount("┃┗轻量:%s", s.HourLandPage.LandPageIosLightClick, rate(s.HourLandPage.LandPageIosLightClick, compare.HourLandPage.LandPageIosLightClick))
|
||||
|
||||
}()
|
||||
func() {
|
||||
if s.TodayGame != nil {
|
||||
text += "8️⃣游戏数据:\n"
|
||||
text += fmt.Sprintf("┣游戏充值: %d\n", s.TodayGame.RchgAmount)
|
||||
text += fmt.Sprintf("┣代充充值: %d\n", s.TodayGame.DcRchgAmount)
|
||||
text += fmt.Sprintf("┣有效投注: %d\n", s.TodayGame.ValidBet)
|
||||
text += fmt.Sprintf("┣系统盈利: %d\n", s.TodayGame.Profit)
|
||||
text += fmt.Sprintf("┣提现金额: %d\n", s.TodayGame.WtdrRealAmount)
|
||||
text += fmt.Sprintf("┣游戏上分: %d\n", s.TodayGame.IncAmount)
|
||||
text += fmt.Sprintf("┗游戏下分: %d\n", s.TodayGame.DecAmount)
|
||||
}
|
||||
}()
|
||||
text += fmt.Sprintf("🆚%s同比数据:当日的昨天%d点\n", appName, compare.SumDate.Hour())
|
||||
} else {
|
||||
func() {
|
||||
reCurr := &s.TodayStat.Recharge
|
||||
text += "1️⃣当日充值:\n"
|
||||
text += LineMoneyOne("┣充值合计: %s", reCurr.Value())
|
||||
text += LineMoneyOne("┃┏安卓充值: %s", reCurr.Android.Value())
|
||||
text += LineMoneyOne("┣╋苹果充值: %s", reCurr.Ios.Value())
|
||||
text += LineMoneyOne("┃┣轻量充值: %s", reCurr.Light.Value())
|
||||
text += LineMoneyOne("┃┗H5充值: %s", reCurr.H5.Value())
|
||||
text += LineMoneyOne("┃┏渠道充值: %s", reCurr.Total.District.Value)
|
||||
text += LineMoneyOne("┣╋官网充值: %s", reCurr.Total.Web.Value)
|
||||
text += LineMoneyOne("┃┣自来充值: %s", reCurr.Total.Normal.Value)
|
||||
text += LineMoneyOne("┃┗分享充值: %s", reCurr.Total.Share.Value)
|
||||
|
||||
oldCurr := &s.TodayStat.RechargeOld
|
||||
text += LineMoneyOne("┃┏老用户充: %s", oldCurr.Value())
|
||||
newCurr := &s.TodayStat.RechargeNew
|
||||
text += LineMoneyOne("┣╋新用户充: %s", newCurr.Value())
|
||||
v0 := newCurr.Percentage(reCurr)
|
||||
text += LineCountOne("┃┗新充占比: %s%%", v0.Value())
|
||||
|
||||
memCurr := &s.TodayStat.RechargeVip
|
||||
text += LineMoneyOne("┃┏会员充值: %s", memCurr.Value())
|
||||
coinCurr := &s.TodayStat.RechargeGold
|
||||
text += LineMoneyOne("┣╋金币充值: %s", coinCurr.Value())
|
||||
v1 := memCurr.Percentage(reCurr)
|
||||
text += LineCountOne("┃┗会员占比: %s%%", v1.Value())
|
||||
|
||||
orderCurr := &s.TodayStat.Order
|
||||
text += LineCountOne("┃┏订单拉起: %s", orderCurr.Count())
|
||||
succCurr := &s.TodayStat.OrderSucc
|
||||
text += LineCountOne("┣╋订单成功: %s", succCurr.Count())
|
||||
v2 := succCurr.Percentage(orderCurr)
|
||||
text += LineCountOne("┃┗成功占比: %s%%", v2.Count())
|
||||
text += "2️⃣当日新增:\n"
|
||||
regCurr := &s.TodayStat.Register
|
||||
text += LineCountOne("┣新增用户: %s", regCurr.Count())
|
||||
text += LineCountOne("┃┏安卓新增: %s", regCurr.Android.Count())
|
||||
text += LineCountOne("┣╋苹果新增: %s", regCurr.Ios.Count())
|
||||
text += LineCountOne("┃┣轻量新增: %s", regCurr.Light.Count())
|
||||
text += LineCountOne("┃┗H5新增: %s", regCurr.H5.Count())
|
||||
text += LineCountOne("┃┏渠道新增: %s", regCurr.Total.District.Count)
|
||||
text += LineCountOne("┣╋官网新增: %s", regCurr.Total.Web.Count)
|
||||
text += LineCountOne("┃┣自来新增: %s", regCurr.Total.Normal.Count)
|
||||
text += LineCountOne("┃┗分享新增: %s", regCurr.Total.Share.Count)
|
||||
text += "3️⃣当日日活:\n"
|
||||
visitCurr := &s.TodayStat.Visit
|
||||
text += LineCountOne("┣日活总数: %s", visitCurr.Count())
|
||||
text += LineCountOne("┃┏安卓日活: %s", visitCurr.Android.Count())
|
||||
text += LineCountOne("┣╋苹果日活: %s", visitCurr.Ios.Count())
|
||||
text += LineCountOne("┃┣轻量日活: %s", visitCurr.Light.Count())
|
||||
text += LineCountOne("┃┗H5日活: %s", visitCurr.H5.Count())
|
||||
text += LineCountOne("┃┏渠道日活: %s", visitCurr.Total.District.Count)
|
||||
text += LineCountOne("┣╋官网日活: %s", visitCurr.Total.Web.Count)
|
||||
text += LineCountOne("┃┣自来日活: %s", visitCurr.Total.Normal.Count)
|
||||
text += LineCountOne("┃┗分享日活: %s", visitCurr.Total.Share.Count)
|
||||
}()
|
||||
func() {
|
||||
reCurr := &s.HourStat.Recharge
|
||||
text += "4️⃣小时充值:\n"
|
||||
text += LineMoneyOne(" ┣充值合计: %s", reCurr.Value())
|
||||
text += LineMoneyOne(" ┣安卓充值: %s", reCurr.Android.Value())
|
||||
text += LineMoneyOne(" ┣苹果充值: %s", reCurr.Ios.Value())
|
||||
text += LineMoneyOne(" ┣轻量充值: %s", reCurr.Light.Value())
|
||||
text += LineMoneyOne(" ┣H5充值: %s", reCurr.H5.Value())
|
||||
text += LineMoneyOne(" ┣渠道充值: %s", reCurr.Total.District.Value)
|
||||
text += LineMoneyOne(" ┣官网充值: %s", reCurr.Total.Web.Value)
|
||||
text += LineMoneyOne(" ┣自来充值: %s", reCurr.Total.Normal.Value)
|
||||
oldCurr := &s.HourStat.RechargeOld
|
||||
text += LineMoneyOne(" ┣老用户充: %s", oldCurr.Value())
|
||||
newCurr := &s.HourStat.RechargeNew
|
||||
text += LineMoneyOne(" ┣新用户充: %s", newCurr.Value())
|
||||
memCurr := &s.HourStat.RechargeVip
|
||||
text += LineMoneyOne(" ┣会员充值: %s", memCurr.Value())
|
||||
coinCurr := &s.HourStat.RechargeGold
|
||||
text += LineMoneyOne(" ┣金币充值: %s", coinCurr.Value())
|
||||
orderCurr := &s.HourStat.Order
|
||||
text += LineCountOne(" ┣订单拉起: %s", orderCurr.Count())
|
||||
succCurr := &s.HourStat.OrderSucc
|
||||
text += LineCountOne(" ┣订单成功: %s", succCurr.Count())
|
||||
v1 := succCurr.Percentage(orderCurr)
|
||||
text += LineCountOne(" ┗订单成功率: %s%%", v1.Count())
|
||||
text += "5️⃣小时新增:\n"
|
||||
regCurr := &s.HourStat.Register
|
||||
text += LineCountOne(" ┣新增用户: %s", regCurr.Count())
|
||||
text += LineCountOne(" ┣安卓新增: %s", regCurr.Android.Count())
|
||||
text += LineCountOne(" ┣苹果新增: %s", regCurr.Ios.Count())
|
||||
text += LineCountOne(" ┣轻量新增: %s", regCurr.Light.Count())
|
||||
text += LineCountOne(" ┣H5新增: %s", regCurr.H5.Count())
|
||||
text += LineCountOne(" ┣渠道新增: %s", regCurr.Total.District.Count)
|
||||
text += LineCountOne(" ┣官网新增: %s", regCurr.Total.Web.Count)
|
||||
text += LineCountOne(" ┗自来新增: %s", regCurr.Total.Normal.Count)
|
||||
}()
|
||||
func() {
|
||||
if s.TodayGame != nil {
|
||||
text += "5️⃣游戏数据:\n"
|
||||
text += fmt.Sprintf(" ┣游戏充值: %d\n", s.TodayGame.RchgAmount)
|
||||
text += fmt.Sprintf(" ┣代充充值: %d\n", s.TodayGame.DcRchgAmount)
|
||||
text += fmt.Sprintf(" ┣有效投注: %d\n", s.TodayGame.ValidBet)
|
||||
text += fmt.Sprintf(" ┣系统盈利: %d\n", s.TodayGame.Profit)
|
||||
text += fmt.Sprintf(" ┣提现金额: %d\n", s.TodayGame.WtdrRealAmount)
|
||||
text += fmt.Sprintf(" ┣游戏上分: %d\n", s.TodayGame.IncAmount)
|
||||
text += fmt.Sprintf(" ┗游戏下分: %d\n", s.TodayGame.DecAmount)
|
||||
}
|
||||
}()
|
||||
text += fmt.Sprintf("🆚【%s】同比数据未找到\n", appName)
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
func (s *BotHourStat) DisplaySummaryText(title string) string {
|
||||
var text string
|
||||
text += fmt.Sprintf("统计标题:%s\n", title) //
|
||||
func() {
|
||||
reCurr := &s.TodayStat.Recharge
|
||||
text += "1️⃣充值合计:\n"
|
||||
text += LineMoneyOne("┣充值合计: %s元", reCurr.Value())
|
||||
text += LineMoneyOne("┃┏安卓充值: %s元", reCurr.Android.Value())
|
||||
text += LineMoneyOne("┣╋苹果充值: %s元", reCurr.Ios.Value())
|
||||
text += LineMoneyOne("┃┣轻量充值: %s元", reCurr.Light.Value())
|
||||
text += LineMoneyOne("┃┗H5充值: %s元", reCurr.H5.Value())
|
||||
text += LineMoneyOne("┃┏渠道充值: %s元", reCurr.Total.District.Value)
|
||||
text += LineMoneyOne("┣╋官网充值: %s元", reCurr.Total.Web.Value)
|
||||
text += LineMoneyOne("┃┣自来充值: %s元", reCurr.Total.Normal.Value)
|
||||
text += LineMoneyOne("┃┗分享充值: %s元", reCurr.Total.Share.Value)
|
||||
|
||||
oldCurr := &s.TodayStat.RechargeOld
|
||||
text += LineMoneyOne("┃┏老用户充: %s元", oldCurr.Value())
|
||||
newCurr := &s.TodayStat.RechargeNew
|
||||
text += LineMoneyOne("┣╋新用户充: %s元", newCurr.Value())
|
||||
v0 := newCurr.Percentage(reCurr)
|
||||
text += LineCountOne("┃┗新充占比: %s%%", v0.Value())
|
||||
|
||||
memCurr := &s.TodayStat.RechargeVip
|
||||
text += LineMoneyOne("┃┏会员充值: %s元", memCurr.Value())
|
||||
coinCurr := &s.TodayStat.RechargeGold
|
||||
text += LineMoneyOne("┣╋金币充值: %s元", coinCurr.Value())
|
||||
v1 := memCurr.Percentage(reCurr)
|
||||
text += LineCountOne("┃┗会员占比: %s%%", v1.Value())
|
||||
|
||||
orderCurr := &s.TodayStat.Order
|
||||
text += LineCountOne("┃┏订单拉起: %s", orderCurr.Count())
|
||||
succCurr := &s.TodayStat.OrderSucc
|
||||
text += LineCountOne("┣╋订单成功: %s", succCurr.Count())
|
||||
v2 := succCurr.Percentage(orderCurr)
|
||||
text += LineCountOne("┃┗成功占比: %s%%", v2.Count())
|
||||
text += "2️⃣新增合计:\n"
|
||||
regCurr := &s.TodayStat.Register
|
||||
text += LineCountOne("┣新增用户: %s", regCurr.Count())
|
||||
text += LineCountOne("┃┏安卓新增: %s", regCurr.Android.Count())
|
||||
text += LineCountOne("┣╋苹果新增: %s", regCurr.Ios.Count())
|
||||
text += LineCountOne("┃┣轻量新增: %s", regCurr.Light.Count())
|
||||
text += LineCountOne("┃┗H5新增: %s", regCurr.H5.Count())
|
||||
text += LineCountOne("┃┏渠道新增: %s", regCurr.Total.District.Count)
|
||||
text += LineCountOne("┣╋官网新增: %s", regCurr.Total.Web.Count)
|
||||
text += LineCountOne("┃┣自来新增: %s", regCurr.Total.Normal.Count)
|
||||
text += LineCountOne("┃┗分享新增: %s", regCurr.Total.Share.Count)
|
||||
text += "3️⃣日活合计:\n"
|
||||
visitCurr := &s.TodayStat.Visit
|
||||
text += LineCountOne("┣日活总数: %s", visitCurr.Count())
|
||||
text += LineCountOne("┃┏安卓日活: %s", visitCurr.Android.Count())
|
||||
text += LineCountOne("┣╋苹果日活: %s", visitCurr.Ios.Count())
|
||||
text += LineCountOne("┃┣轻量日活: %s", visitCurr.Light.Count())
|
||||
text += LineCountOne("┃┗H5日活: %s", visitCurr.H5.Count())
|
||||
text += LineCountOne("┃┏渠道日活: %s", visitCurr.Total.District.Count)
|
||||
text += LineCountOne("┣╋官网日活: %s", visitCurr.Total.Web.Count)
|
||||
text += LineCountOne("┃┣自来日活: %s", visitCurr.Total.Normal.Count)
|
||||
text += LineCountOne("┃┗分享日活: %s", visitCurr.Total.Share.Count)
|
||||
}()
|
||||
func() {
|
||||
if s.AppId == 888 && s.TodayGame != nil {
|
||||
text += "5️⃣游戏合计:\n"
|
||||
text += fmt.Sprintf("┃┏游戏充值: %d\n", s.TodayGame.RchgAmount)
|
||||
text += fmt.Sprintf("┃┣代充充值: %d\n", s.TodayGame.DcRchgAmount)
|
||||
text += fmt.Sprintf("┃┣有效投注: %d\n", s.TodayGame.ValidBet)
|
||||
text += fmt.Sprintf("┣╋系统盈利: %d\n", s.TodayGame.Profit)
|
||||
text += fmt.Sprintf("┃┣提现金额: %d\n", s.TodayGame.WtdrRealAmount)
|
||||
text += fmt.Sprintf("┃┣游戏上分: %d\n", s.TodayGame.IncAmount)
|
||||
text += fmt.Sprintf("┃┗游戏下分: %d\n", s.TodayGame.DecAmount)
|
||||
}
|
||||
}()
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
func (s *BotHourStat) GenerateTodayTable(title string, statName string, filepath string, compare *BotHourStat) (string, error) {
|
||||
var text string
|
||||
text += fmt.Sprintf("报告时间:%s\n", s.SumDate.Format("2006-01-02T15:04:05"))
|
||||
if _, exists := statutils.StatProjectNameDict[statName]; exists {
|
||||
if compare != nil {
|
||||
switch statName {
|
||||
case statutils.StatProjectRecharge:
|
||||
return text, s.TodayStat.Recharge.Table(title, 100, &compare.TodayStat.Recharge, filepath)
|
||||
case statutils.StatProjectRechargeOld:
|
||||
return text, s.TodayStat.RechargeOld.Table(title, 100, &compare.TodayStat.RechargeOld, filepath)
|
||||
case statutils.StatProjectRechargeNew:
|
||||
return text, s.TodayStat.RechargeNew.Table(title, 100, &compare.TodayStat.RechargeNew, filepath)
|
||||
case statutils.StatProjectRechargeGold:
|
||||
return text, s.TodayStat.RechargeGold.Table(title, 100, &compare.TodayStat.RechargeGold, filepath)
|
||||
case statutils.StatProjectRechargeVip:
|
||||
return text, s.TodayStat.RechargeVip.Table(title, 100, &compare.TodayStat.RechargeVip, filepath)
|
||||
case statutils.StatProjectOrder:
|
||||
return text, s.TodayStat.Order.Table(title, 1, &compare.TodayStat.Order, filepath)
|
||||
case statutils.StatProjectRegister:
|
||||
return text, s.TodayStat.Register.Table(title, 1, &compare.TodayStat.Register, filepath)
|
||||
case statutils.StatProjectVisit:
|
||||
return text, s.TodayStat.Visit.Table(title, 1, &compare.TodayStat.Visit, filepath)
|
||||
default:
|
||||
return "", errors.New("没有指定统计项目")
|
||||
}
|
||||
} else {
|
||||
switch statName {
|
||||
case statutils.StatProjectRecharge:
|
||||
return text, s.TodayStat.Recharge.Table(title, 100, nil, filepath)
|
||||
case statutils.StatProjectRechargeOld:
|
||||
return text, s.TodayStat.RechargeOld.Table(title, 100, nil, filepath)
|
||||
case statutils.StatProjectRechargeNew:
|
||||
return text, s.TodayStat.RechargeNew.Table(title, 100, nil, filepath)
|
||||
case statutils.StatProjectRechargeGold:
|
||||
return text, s.TodayStat.RechargeGold.Table(title, 100, nil, filepath)
|
||||
case statutils.StatProjectRechargeVip:
|
||||
return text, s.TodayStat.RechargeVip.Table(title, 100, nil, filepath)
|
||||
case statutils.StatProjectOrder:
|
||||
return text, s.TodayStat.Order.Table(title, 1, nil, filepath)
|
||||
case statutils.StatProjectRegister:
|
||||
return text, s.TodayStat.Register.Table(title, 1, nil, filepath)
|
||||
case statutils.StatProjectVisit:
|
||||
return text, s.TodayStat.Visit.Table(title, 1, nil, filepath)
|
||||
default:
|
||||
return "", errors.New("没有指定统计项目")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return "", errors.New("没有指定统计项目")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *BotHourStat) DisplayDayHourTextWithTitle(appName string, compare *BotHourStat) (text string, title string, descript string) {
|
||||
calc := func(curr, hist *statutils.Stat) (*statutils.Stat, *statutils.Stat) {
|
||||
diff := curr.Sub(hist)
|
||||
rate := diff.Permil(hist)
|
||||
return curr, rate
|
||||
}
|
||||
rate := func(currValue, histValue int64) int64 {
|
||||
if histValue != 0 {
|
||||
return (currValue - histValue) * 1000 / histValue
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
title = fmt.Sprintf("%s", appName)
|
||||
descript = fmt.Sprintf("统计时间: %s\n", s.SumDate.Format("2006-01-02T15"))
|
||||
if compare != nil {
|
||||
func() {
|
||||
reCurr, reRate := calc(&s.TodayStat.Recharge, &compare.TodayStat.Recharge)
|
||||
text += "1️⃣当日充值:\n"
|
||||
text += LineMoney("┣充值合计:%s", reCurr.Value(), reRate.Value())
|
||||
descript += LineMoney(" 今日充值:%s", reCurr.Value(), reRate.Value())
|
||||
text += LineMoney("┃┏安卓充值:%s", reCurr.Android.Value(), reRate.Android.Value())
|
||||
text += LineMoney("┣╋苹果充值:%s", reCurr.Ios.Value(), reRate.Ios.Value())
|
||||
text += LineMoney("┃┣轻量充值:%s", reCurr.Light.Value(), reRate.Light.Value())
|
||||
text += LineMoney("┃┗H5充值 :%s", reCurr.H5.Value(), reRate.H5.Value())
|
||||
text += LineMoney("┃┏渠道充值:%s", reCurr.Total.District.Value, reRate.Total.District.Value)
|
||||
text += LineMoney("┣╋官网充值:%s", reCurr.Total.Web.Value, reRate.Total.Web.Value)
|
||||
text += LineMoney("┃┣自来充值:%s", reCurr.Total.Normal.Value, reRate.Total.Normal.Value)
|
||||
text += LineMoney("┃┗分享充值:%s", reCurr.Total.Share.Value, reRate.Total.Share.Value)
|
||||
oldCurr, oldRate := calc(&s.TodayStat.RechargeOld, &compare.TodayStat.RechargeOld)
|
||||
text += LineMoney("┃┏老用户充:%s", oldCurr.Value(), oldRate.Value())
|
||||
newCurr, newRate := calc(&s.TodayStat.RechargeNew, &compare.TodayStat.RechargeNew)
|
||||
text += LineMoney("┣╋新用户充:%s", newCurr.Value(), newRate.Value())
|
||||
v0, v00 := calc(newCurr.Percentage(reCurr), compare.TodayStat.RechargeNew.Percentage(&compare.TodayStat.Recharge))
|
||||
text += LineCount("┃┗新充占比:%s%%", v0.Value(), v00.Value())
|
||||
memCurr, memRate := calc(&s.TodayStat.RechargeVip, &compare.TodayStat.RechargeVip)
|
||||
text += LineMoney("┃┏会员充值:%s", memCurr.Value(), memRate.Value())
|
||||
coinCurr, coinRate := calc(&s.TodayStat.RechargeGold, &compare.TodayStat.RechargeGold)
|
||||
text += LineMoney("┣╋金币充值:%s", coinCurr.Value(), coinRate.Value())
|
||||
v2, v22 := calc(memCurr.Percentage(reCurr), compare.TodayStat.RechargeVip.Percentage(&compare.TodayStat.Recharge))
|
||||
text += LineCount("┃┗会员占比:%s%%", v2.Value(), v22.Value())
|
||||
orderCurr, orderRate := calc(&s.TodayStat.Order, &compare.TodayStat.Order)
|
||||
text += LineCount("┃┏订单拉起:%s", orderCurr.Count(), orderRate.Count())
|
||||
succCurr, succRate := calc(&s.TodayStat.OrderSucc, &compare.TodayStat.OrderSucc)
|
||||
text += LineCount("┣╋订单成功:%s", succCurr.Count(), succRate.Count())
|
||||
v1, v11 := calc(succCurr.Percentage(orderCurr), compare.TodayStat.OrderSucc.Percentage(&compare.TodayStat.Order))
|
||||
text += LineCount("┃┗成功比率:%s%%", v1.Count(), v11.Count())
|
||||
text += "2️⃣当日新增:\n"
|
||||
|
||||
regCurr, regRate := calc(&s.TodayStat.Register, &compare.TodayStat.Register)
|
||||
text += LineCount("┣新增用户:%s", regCurr.Count(), regRate.Count())
|
||||
descript += LineCount(" 今日新增:%s", regCurr.Count(), regRate.Count())
|
||||
text += LineCount("┃┏安卓新增:%s", regCurr.Android.Count(), regRate.Android.Count())
|
||||
text += LineCount("┣╋苹果新增:%s", regCurr.Ios.Count(), regRate.Ios.Count())
|
||||
text += LineCount("┃┣轻量新增:%s", regCurr.Light.Count(), regRate.Light.Count())
|
||||
text += LineCount("┃┗H5新增 :%s", regCurr.H5.Count(), regRate.H5.Count())
|
||||
text += LineCount("┃┏渠道新增:%s", regCurr.Total.District.Count, regRate.Total.District.Count)
|
||||
text += LineCount("┣╋有效新增:%s", regCurr.Total.Direct.Value()-regCurr.Total.Direct.Natural.Value,
|
||||
regRate.Total.Direct.Value()-regRate.Total.Direct.Natural.Value)
|
||||
text += LineCount("┣╋官网新增:%s", regCurr.Total.Web.Count, regRate.Total.Web.Count)
|
||||
text += LineCount("┃┣自来新增:%s", regCurr.Total.Normal.Count, regRate.Total.Normal.Count)
|
||||
text += LineCount("┃┗分享新增:%s", regCurr.Total.Share.Count, regRate.Total.Share.Count)
|
||||
text += "3️⃣当日日活:\n"
|
||||
visitCurr, visitRate := calc(&s.TodayStat.Visit, &compare.TodayStat.Visit)
|
||||
text += LineCount("┣日活总数:%s", visitCurr.Count(), visitRate.Count())
|
||||
text += LineCount("┃┏安卓日活:%s", visitCurr.Android.Count(), visitRate.Android.Count())
|
||||
text += LineCount("┣╋苹果日活:%s", visitCurr.Ios.Count(), visitRate.Ios.Count())
|
||||
text += LineCount("┃┣轻量日活:%s", visitCurr.Light.Count(), visitRate.Light.Count())
|
||||
text += LineCount("┃┗H5日活 :%s", visitCurr.H5.Count(), visitRate.H5.Count())
|
||||
text += LineCount("┃┏渠道日活:%s", visitCurr.Total.District.Count, visitRate.Total.District.Count)
|
||||
text += LineCount("┣╋官网日活:%s", visitCurr.Total.Web.Count, visitRate.Total.Web.Count)
|
||||
text += LineCount("┃┣自来日活:%s", visitCurr.Total.Normal.Count, visitRate.Total.Normal.Count)
|
||||
text += LineCount("┃┗分享日活:%s", visitCurr.Total.Share.Count, visitRate.Total.Share.Count)
|
||||
text += "4️⃣落地页点击:\n"
|
||||
text += LineCount("┣总数:%s", s.TodayLandPage.LandPageTotalClick, rate(s.TodayLandPage.LandPageTotalClick, compare.TodayLandPage.LandPageTotalClick))
|
||||
text += LineCount("┃┏安卓:%s", s.TodayLandPage.LandPageAndroidClick, rate(s.TodayLandPage.LandPageAndroidClick, compare.TodayLandPage.LandPageAndroidClick))
|
||||
text += LineCount("┣╋商店:%s", s.TodayLandPage.LandPageIosAppstoreClick, rate(s.TodayLandPage.LandPageIosAppstoreClick, compare.TodayLandPage.LandPageIosAppstoreClick))
|
||||
text += LineCount("┃┣企业:%s", s.TodayLandPage.LandPageIosFirmClick, rate(s.TodayLandPage.LandPageIosFirmClick, compare.TodayLandPage.LandPageIosFirmClick))
|
||||
text += LineCount("┃┗轻量:%s", s.TodayLandPage.LandPageIosLightClick, rate(s.TodayLandPage.LandPageIosLightClick, compare.TodayLandPage.LandPageIosLightClick))
|
||||
}()
|
||||
func() {
|
||||
reCurr, reRate := calc(&s.HourStat.Recharge, &compare.HourStat.Recharge)
|
||||
text += "5️⃣小时充值:\n"
|
||||
text += LineMoney("┣充值合计:%s", reCurr.Value(), reRate.Value())
|
||||
descript += LineMoney(" 小时充值:%s", reCurr.Value(), reRate.Value())
|
||||
text += LineMoney("┃┏安卓充值:%s", reCurr.Android.Value(), reRate.Android.Value())
|
||||
text += LineMoney("┣╋苹果充值:%s", reCurr.Ios.Value(), reRate.Ios.Value())
|
||||
text += LineMoney("┃┣轻量充值:%s", reCurr.Light.Value(), reRate.Light.Value())
|
||||
text += LineMoney("┃┗H5充值 :%s", reCurr.H5.Value(), reRate.H5.Value())
|
||||
text += LineMoney("┃┏渠道充值:%s", reCurr.Total.District.Value, reRate.Total.District.Value)
|
||||
text += LineMoney("┣╋官网充值:%s", reCurr.Total.Web.Value, reRate.Total.Web.Value)
|
||||
text += LineMoney("┃┣自来充值:%s", reCurr.Total.Normal.Value, reRate.Total.Normal.Value)
|
||||
text += LineMoney("┃┗分享充值:%s", reCurr.Total.Share.Value, reRate.Total.Share.Value)
|
||||
oldCurr, oldRate := calc(&s.HourStat.RechargeOld, &compare.HourStat.RechargeOld)
|
||||
text += LineMoney("┃┏老用户充:%s", oldCurr.Value(), oldRate.Value())
|
||||
newCurr, newRate := calc(&s.HourStat.RechargeNew, &compare.HourStat.RechargeNew)
|
||||
text += LineMoney("┣╋新用户充:%s", newCurr.Value(), newRate.Value())
|
||||
v0, v00 := calc(newCurr.Percentage(reCurr), compare.HourStat.RechargeNew.Percentage(&compare.HourStat.Recharge))
|
||||
text += LineCount("┃┗新充占比:%s%%", v0.Value(), v00.Value())
|
||||
memCurr, memRate := calc(&s.HourStat.RechargeVip, &compare.HourStat.RechargeVip)
|
||||
text += LineMoney("┃┏会员充值:%s", memCurr.Value(), memRate.Value())
|
||||
coinCurr, coinRate := calc(&s.HourStat.RechargeGold, &compare.HourStat.RechargeGold)
|
||||
text += LineMoney("┣╋金币充值:%s", coinCurr.Value(), coinRate.Value())
|
||||
v2, v22 := calc(memCurr.Percentage(reCurr), compare.HourStat.RechargeVip.Percentage(&compare.HourStat.Recharge))
|
||||
text += LineCount("┃┗会员占比:%s%%", v2.Value(), v22.Value())
|
||||
orderCurr, orderRate := calc(&s.HourStat.Order, &compare.HourStat.Order)
|
||||
text += LineCount("┃┏订单拉起:%s", orderCurr.Count(), orderRate.Count())
|
||||
succCurr, succRate := calc(&s.HourStat.OrderSucc, &compare.HourStat.OrderSucc)
|
||||
text += LineCount("┣╋订单成功:%s", succCurr.Count(), succRate.Count())
|
||||
v1, v11 := calc(succCurr.Percentage(orderCurr), compare.HourStat.OrderSucc.Percentage(&compare.HourStat.Order))
|
||||
text += LineCount("┃┗订单成功率:%s%%", v1.Count(), v11.Count())
|
||||
text += "6️⃣小时新增:\n"
|
||||
regCurr, regRate := calc(&s.HourStat.Register, &compare.HourStat.Register)
|
||||
text += LineCount("┣新增用户:%s", regCurr.Count(), regRate.Count())
|
||||
descript += LineCount(" 小时新增:%s", regCurr.Count(), regRate.Count())
|
||||
text += LineCount("┃┏安卓新增:%s", regCurr.Android.Count(), regRate.Android.Count())
|
||||
text += LineCount("┣╋苹果新增:%s", regCurr.Ios.Count(), regRate.Ios.Count())
|
||||
text += LineCount("┃┣轻量新增:%s", regCurr.Light.Count(), regRate.Light.Count())
|
||||
text += LineCount("┃┗H5新增 :%s", regCurr.H5.Count(), regRate.H5.Count())
|
||||
text += LineCount("┃┏渠道新增:%s", regCurr.Total.District.Count, regRate.Total.District.Count)
|
||||
text += LineCount("┣╋有效新增:%s", regCurr.Total.Direct.Value()-regCurr.Total.Direct.Natural.Value,
|
||||
regRate.Total.Direct.Value()-regRate.Total.Direct.Natural.Value)
|
||||
text += LineCount("┣╋官网新增:%s", regCurr.Total.Web.Count, regRate.Total.Web.Count)
|
||||
text += LineCount("┃┣自来新增:%s", regCurr.Total.Normal.Count, regRate.Total.Normal.Count)
|
||||
text += LineCount("┃┗分享新增:%s", regCurr.Total.Share.Count, regRate.Total.Share.Count)
|
||||
text += "7️⃣小时落地页点击:\n"
|
||||
text += LineCount("┣总数:%s", s.HourLandPage.LandPageTotalClick, rate(s.HourLandPage.LandPageTotalClick, compare.HourLandPage.LandPageTotalClick))
|
||||
text += LineCount("┃┏安卓:%s", s.HourLandPage.LandPageAndroidClick, rate(s.HourLandPage.LandPageAndroidClick, compare.HourLandPage.LandPageAndroidClick))
|
||||
text += LineCount("┣╋商店:%s", s.HourLandPage.LandPageIosAppstoreClick, rate(s.HourLandPage.LandPageIosAppstoreClick, compare.HourLandPage.LandPageIosAppstoreClick))
|
||||
text += LineCount("┃┣企业:%s", s.HourLandPage.LandPageIosFirmClick, rate(s.HourLandPage.LandPageIosFirmClick, compare.HourLandPage.LandPageIosFirmClick))
|
||||
text += LineCount("┃┗轻量:%s", s.HourLandPage.LandPageIosLightClick, rate(s.HourLandPage.LandPageIosLightClick, compare.HourLandPage.LandPageIosLightClick))
|
||||
|
||||
}()
|
||||
func() {
|
||||
if s.TodayGame != nil {
|
||||
text += "8️⃣游戏数据:\n"
|
||||
text += fmt.Sprintf("┣游戏充值: %d\n", s.TodayGame.RchgAmount)
|
||||
text += fmt.Sprintf("┣代充充值: %d\n", s.TodayGame.DcRchgAmount)
|
||||
text += fmt.Sprintf("┣有效投注: %d\n", s.TodayGame.ValidBet)
|
||||
text += fmt.Sprintf("┣系统盈利: %d\n", s.TodayGame.Profit)
|
||||
text += fmt.Sprintf("┣提现金额: %d\n", s.TodayGame.WtdrRealAmount)
|
||||
text += fmt.Sprintf("┣游戏上分: %d\n", s.TodayGame.IncAmount)
|
||||
text += fmt.Sprintf("┗游戏下分: %d\n", s.TodayGame.DecAmount)
|
||||
}
|
||||
}()
|
||||
text += fmt.Sprintf("🆚%s同比数据:当日的昨天%d点\n", appName, compare.SumDate.Hour())
|
||||
} else {
|
||||
func() {
|
||||
reCurr := &s.TodayStat.Recharge
|
||||
text += "1️⃣当日充值:\n"
|
||||
text += LineMoneyOne("┣充值合计: %s", reCurr.Value())
|
||||
text += LineMoneyOne("┃┏安卓充值: %s", reCurr.Android.Value())
|
||||
text += LineMoneyOne("┣╋苹果充值: %s", reCurr.Ios.Value())
|
||||
text += LineMoneyOne("┃┣轻量充值: %s", reCurr.Light.Value())
|
||||
text += LineMoneyOne("┃┗H5充值: %s", reCurr.H5.Value())
|
||||
text += LineMoneyOne("┃┏渠道充值: %s", reCurr.Total.District.Value)
|
||||
text += LineMoneyOne("┣╋官网充值: %s", reCurr.Total.Web.Value)
|
||||
text += LineMoneyOne("┃┣自来充值: %s", reCurr.Total.Normal.Value)
|
||||
text += LineMoneyOne("┃┗分享充值: %s", reCurr.Total.Share.Value)
|
||||
|
||||
oldCurr := &s.TodayStat.RechargeOld
|
||||
text += LineMoneyOne("┃┏老用户充: %s", oldCurr.Value())
|
||||
newCurr := &s.TodayStat.RechargeNew
|
||||
text += LineMoneyOne("┣╋新用户充: %s", newCurr.Value())
|
||||
v0 := newCurr.Percentage(reCurr)
|
||||
text += LineCountOne("┃┗新充占比: %s%%", v0.Value())
|
||||
|
||||
memCurr := &s.TodayStat.RechargeVip
|
||||
text += LineMoneyOne("┃┏会员充值: %s", memCurr.Value())
|
||||
coinCurr := &s.TodayStat.RechargeGold
|
||||
text += LineMoneyOne("┣╋金币充值: %s", coinCurr.Value())
|
||||
v1 := memCurr.Percentage(reCurr)
|
||||
text += LineCountOne("┃┗会员占比: %s%%", v1.Value())
|
||||
|
||||
orderCurr := &s.TodayStat.Order
|
||||
text += LineCountOne("┃┏订单拉起: %s", orderCurr.Count())
|
||||
succCurr := &s.TodayStat.OrderSucc
|
||||
text += LineCountOne("┣╋订单成功: %s", succCurr.Count())
|
||||
v2 := succCurr.Percentage(orderCurr)
|
||||
text += LineCountOne("┃┗成功占比: %s%%", v2.Count())
|
||||
text += "2️⃣当日新增:\n"
|
||||
regCurr := &s.TodayStat.Register
|
||||
text += LineCountOne("┣新增用户: %s", regCurr.Count())
|
||||
text += LineCountOne("┃┏安卓新增: %s", regCurr.Android.Count())
|
||||
text += LineCountOne("┣╋苹果新增: %s", regCurr.Ios.Count())
|
||||
text += LineCountOne("┃┣轻量新增: %s", regCurr.Light.Count())
|
||||
text += LineCountOne("┃┗H5新增: %s", regCurr.H5.Count())
|
||||
text += LineCountOne("┃┏渠道新增: %s", regCurr.Total.District.Count)
|
||||
text += LineCountOne("┣╋官网新增: %s", regCurr.Total.Web.Count)
|
||||
text += LineCountOne("┃┣自来新增: %s", regCurr.Total.Normal.Count)
|
||||
text += LineCountOne("┃┗分享新增: %s", regCurr.Total.Share.Count)
|
||||
text += "3️⃣当日日活:\n"
|
||||
visitCurr := &s.TodayStat.Visit
|
||||
text += LineCountOne("┣日活总数: %s", visitCurr.Count())
|
||||
text += LineCountOne("┃┏安卓日活: %s", visitCurr.Android.Count())
|
||||
text += LineCountOne("┣╋苹果日活: %s", visitCurr.Ios.Count())
|
||||
text += LineCountOne("┃┣轻量日活: %s", visitCurr.Light.Count())
|
||||
text += LineCountOne("┃┗H5日活: %s", visitCurr.H5.Count())
|
||||
text += LineCountOne("┃┏渠道日活: %s", visitCurr.Total.District.Count)
|
||||
text += LineCountOne("┣╋官网日活: %s", visitCurr.Total.Web.Count)
|
||||
text += LineCountOne("┃┣自来日活: %s", visitCurr.Total.Normal.Count)
|
||||
text += LineCountOne("┃┗分享日活: %s", visitCurr.Total.Share.Count)
|
||||
}()
|
||||
func() {
|
||||
reCurr := &s.HourStat.Recharge
|
||||
text += "4️⃣小时充值:\n"
|
||||
text += LineMoneyOne(" ┣充值合计: %s", reCurr.Value())
|
||||
text += LineMoneyOne(" ┣安卓充值: %s", reCurr.Android.Value())
|
||||
text += LineMoneyOne(" ┣苹果充值: %s", reCurr.Ios.Value())
|
||||
text += LineMoneyOne(" ┣轻量充值: %s", reCurr.Light.Value())
|
||||
text += LineMoneyOne(" ┣H5充值: %s", reCurr.H5.Value())
|
||||
text += LineMoneyOne(" ┣渠道充值: %s", reCurr.Total.District.Value)
|
||||
text += LineMoneyOne(" ┣官网充值: %s", reCurr.Total.Web.Value)
|
||||
text += LineMoneyOne(" ┣自来充值: %s", reCurr.Total.Normal.Value)
|
||||
oldCurr := &s.HourStat.RechargeOld
|
||||
text += LineMoneyOne(" ┣老用户充: %s", oldCurr.Value())
|
||||
newCurr := &s.HourStat.RechargeNew
|
||||
text += LineMoneyOne(" ┣新用户充: %s", newCurr.Value())
|
||||
memCurr := &s.HourStat.RechargeVip
|
||||
text += LineMoneyOne(" ┣会员充值: %s", memCurr.Value())
|
||||
coinCurr := &s.HourStat.RechargeGold
|
||||
text += LineMoneyOne(" ┣金币充值: %s", coinCurr.Value())
|
||||
orderCurr := &s.HourStat.Order
|
||||
text += LineCountOne(" ┣订单拉起: %s", orderCurr.Count())
|
||||
succCurr := &s.HourStat.OrderSucc
|
||||
text += LineCountOne(" ┣订单成功: %s", succCurr.Count())
|
||||
v1 := succCurr.Percentage(orderCurr)
|
||||
text += LineCountOne(" ┗订单成功率: %s%%", v1.Count())
|
||||
text += "5️⃣小时新增:\n"
|
||||
regCurr := &s.HourStat.Register
|
||||
text += LineCountOne(" ┣新增用户: %s", regCurr.Count())
|
||||
text += LineCountOne(" ┣安卓新增: %s", regCurr.Android.Count())
|
||||
text += LineCountOne(" ┣苹果新增: %s", regCurr.Ios.Count())
|
||||
text += LineCountOne(" ┣轻量新增: %s", regCurr.Light.Count())
|
||||
text += LineCountOne(" ┣H5新增: %s", regCurr.H5.Count())
|
||||
text += LineCountOne(" ┣渠道新增: %s", regCurr.Total.District.Count)
|
||||
text += LineCountOne(" ┣官网新增: %s", regCurr.Total.Web.Count)
|
||||
text += LineCountOne(" ┗自来新增: %s", regCurr.Total.Normal.Count)
|
||||
}()
|
||||
func() {
|
||||
if s.TodayGame != nil {
|
||||
text += "5️⃣游戏数据:\n"
|
||||
text += fmt.Sprintf(" ┣游戏充值: %d\n", s.TodayGame.RchgAmount)
|
||||
text += fmt.Sprintf(" ┣代充充值: %d\n", s.TodayGame.DcRchgAmount)
|
||||
text += fmt.Sprintf(" ┣有效投注: %d\n", s.TodayGame.ValidBet)
|
||||
text += fmt.Sprintf(" ┣系统盈利: %d\n", s.TodayGame.Profit)
|
||||
text += fmt.Sprintf(" ┣提现金额: %d\n", s.TodayGame.WtdrRealAmount)
|
||||
text += fmt.Sprintf(" ┣游戏上分: %d\n", s.TodayGame.IncAmount)
|
||||
text += fmt.Sprintf(" ┗游戏下分: %d\n", s.TodayGame.DecAmount)
|
||||
}
|
||||
}()
|
||||
text += fmt.Sprintf("🆚【%s】同比数据未找到\n", appName)
|
||||
}
|
||||
return text, title, descript
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package botdailyhourstat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
var db *mongos.MongoTool
|
||||
|
||||
func Init(ctx context.Context) {
|
||||
// 获取数据库表
|
||||
db = mongos.New(mongos.MgoManager, CollName)
|
||||
// 初始化索引
|
||||
indexes := []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: "appId", Value: 1},
|
||||
{Key: "sumDate", Value: 1},
|
||||
},
|
||||
Options: options.Index().SetUnique(true),
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: "appId", Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: "sumDate", Value: 1},
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, err := db.CreateIndex(ctx, indexes); err != nil {
|
||||
panic(fmt.Sprintf("(BotHourStat:Init) Create BotHourStat Index failed! err:%+v:", err))
|
||||
}
|
||||
}
|
||||
|
||||
// InsertOneBotHourStat 插入一个机器人小时统计
|
||||
func InsertOneBotHourStat(ctx context.Context, botHourStat *BotHourStat) error {
|
||||
if _, err := db.InsertOne(ctx, botHourStat); err != nil {
|
||||
log.Warn("botHourStat:InsertOneBotHourStat db.InsertOne failed", log.E(err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindOneBotHourStat 查找一个机器人小时统计
|
||||
func FindOneBotHourStat(ctx context.Context, filter bson.M) (*BotHourStat, error) {
|
||||
var botHourStat BotHourStat
|
||||
if err := db.FindOne(ctx, &botHourStat, filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &botHourStat, nil
|
||||
}
|
||||
|
||||
// FindOneBotHourStatEx 查找一个机器人小时统计
|
||||
func FindOneBotHourStatEx(ctx context.Context, filter bson.M) (*BotHourStat, error) {
|
||||
var botHourStat BotHourStat
|
||||
if err := db.FindOneEx(ctx, &botHourStat, filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &botHourStat, nil
|
||||
}
|
||||
|
||||
// DelOneBotHourStat 删除一个机器人小时统计
|
||||
func DelOneBotHourStat(ctx context.Context, filter bson.M) (
|
||||
int64, error) {
|
||||
count, err := db.DeleteOne(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("BotHourStat:DelOneBotHourStat db.DeleteOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// UpdateOneBotHourStat 更新一个机器人小时统计
|
||||
func UpdateOneBotHourStat(ctx context.Context, filter bson.M, update bson.M) error {
|
||||
_, err := db.UpdateOne(ctx, filter, update)
|
||||
if err != nil {
|
||||
log.Warn("user:UpdateOneBotHourStat db.UpdateOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CountBotHourStats 统计机器人小时统计数量
|
||||
func CountBotHourStats(ctx context.Context, filter bson.M) (
|
||||
int64, error) {
|
||||
count, err := db.Count(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("BotHourStat:CountBotHourStats db.Count failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// UpdateManyBotHourStat 更新满足条件的机器人小时统计
|
||||
func UpdateManyBotHourStat(ctx context.Context, filter bson.M, update bson.M) error {
|
||||
_, err := db.UpdateMany(ctx, filter, update)
|
||||
if err != nil {
|
||||
log.Warn("user:UpdateManyBotHourStat db.UpdateMany failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindManyBotHourStat 查找一批机器人小时统计数据
|
||||
func FindManyBotHourStat(ctx context.Context, filter bson.M,
|
||||
opts ...*options.FindOptions) (BotHourStatList, error) {
|
||||
data := make(BotHourStatList, 0)
|
||||
if err := db.Find(ctx, &data, filter, opts...); err != nil {
|
||||
log.Warn("BotHourStat:FindManyBotHourStat db.Find failed", log.E(err), log.Any("filter", filter))
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// FindManyBotHourStatWithBind 用自己定义结构查找一批机器人小时统计数据
|
||||
func FindManyBotHourStatWithBind(ctx context.Context, bind interface{}, filter bson.M,
|
||||
opts ...*options.FindOptions) error {
|
||||
if err := db.Find(ctx, bind, filter, opts...); err != nil {
|
||||
log.Warn("BotHourStat:FindManyBotHourStatWithBind db.Find failed", log.E(err), log.Any("filter", filter))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AggregateBotHourStats 聚合查找一批机器人小时统计信息
|
||||
func AggregateBotHourStats(ctx context.Context, bind interface{}, pipeline []bson.M) error {
|
||||
if err := db.Aggregate(ctx, bind, pipeline); err != nil {
|
||||
log.Warn("feedback:AggregateBotHourStats db.Aggregate failed",
|
||||
log.E(err), log.Any("pipeline", pipeline))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package botdailyhourstat
|
||||
|
||||
import (
|
||||
"stat/common/statutils"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const CollName = "bot_daily_hour_stat"
|
||||
|
||||
type GameItem struct {
|
||||
RchgAmount int64 `json:"rchgAmount" bson:"rchg_amount"` //充值总金额
|
||||
DcRchgAmount int64 `json:"dcRchgAmount" bson:"dcRchgAmount"` //代充总金额
|
||||
WtdrAmount int64 `json:"wtdrAmount" bson:"wtdrAmount"` //游戏提现总金额
|
||||
WtdrRealAmount int64 `json:"wtdrRealAmount" bson:"wtdrRealAmount"` //游戏实际提现总金额
|
||||
IncAmount int64 `json:"incAmount" bson:"incAmount"` //游戏上分总金额
|
||||
DecAmount int64 `json:"decAmount" bson:"decAmount"` //游戏下分总金额
|
||||
ValidBet int64 `json:"validBet" bson:"validBet"` //有效投注金额
|
||||
Profit int64 `json:"profit" bson:"profit"` //系统盈利
|
||||
}
|
||||
|
||||
func (g *GameItem) ACC(d *GameItem) {
|
||||
if g == nil || d == nil {
|
||||
return
|
||||
}
|
||||
g.RchgAmount += d.RchgAmount
|
||||
g.DcRchgAmount += d.DcRchgAmount
|
||||
g.WtdrAmount += d.WtdrAmount
|
||||
g.WtdrRealAmount += d.WtdrRealAmount
|
||||
g.IncAmount += d.IncAmount
|
||||
g.DecAmount += d.DecAmount
|
||||
g.ValidBet += d.ValidBet
|
||||
g.Profit += d.Profit
|
||||
}
|
||||
|
||||
type LandPage struct {
|
||||
LandPageTotalClick int64 `bson:"landPageTotalClick,omitempty" json:"landPageTotalClick"` // 落地页访问总次数
|
||||
LandPageAndroidClick int64 `bson:"landPageAndroidClick,omitempty" json:"landPageAndroidClick"` // 落地页android访问次数
|
||||
LandPageIosAppstoreClick int64 `bson:"landPageIosAppstoreClick,omitempty" json:"landPageIosAppstoreClick"` // 落地页iOS商店包访问次数
|
||||
LandPageIosFirmClick int64 `bson:"landPageIosFirmClick,omitempty" json:"landPageIosFirmClick"` // 落地页iOS企业包访问次数
|
||||
LandPageIosLightClick int64 `bson:"landPageIosLightClick,omitempty" json:"landPageIosLightClick"` // 落地页iOS轻量版访问次数
|
||||
}
|
||||
|
||||
func (s *LandPage) ACC(d *LandPage) {
|
||||
s.LandPageTotalClick += d.LandPageTotalClick
|
||||
s.LandPageAndroidClick += d.LandPageAndroidClick
|
||||
s.LandPageIosAppstoreClick += d.LandPageIosAppstoreClick
|
||||
s.LandPageIosFirmClick += d.LandPageIosFirmClick
|
||||
s.LandPageIosLightClick += d.LandPageIosLightClick
|
||||
}
|
||||
|
||||
type StatItem struct {
|
||||
// 充值
|
||||
Recharge statutils.Stat `json:"recharge" bson:"recharge"` // 充值
|
||||
RechargeOld statutils.Stat `json:"rechargeOld" bson:"rechargeOld"` // 老用户充值
|
||||
RechargeNew statutils.Stat `json:"rechargeNew" bson:"rechargeNew"` // 新用户充值
|
||||
RechargeGold statutils.Stat `json:"rechargeGold" bson:"rechargeGold"` // 金币充值
|
||||
RechargeVip statutils.Stat `json:"rechargeVip" bson:"rechargeVip"` // 会员充值
|
||||
// 订单
|
||||
Order statutils.Stat `json:"order" bson:"order"` // 所有订单
|
||||
OrderSucc statutils.Stat `json:"orderSucc" bson:"orderSucc"` // 成功订单
|
||||
// 注册
|
||||
Register statutils.Stat `json:"register" bson:"register"` // 注册
|
||||
// 访问
|
||||
Visit statutils.Stat `json:"visit" bson:"visit"` // 访问
|
||||
}
|
||||
|
||||
func (s *StatItem) ACC(d *StatItem) {
|
||||
s.Recharge.ACC(&d.Recharge)
|
||||
s.RechargeOld.ACC(&d.RechargeOld)
|
||||
s.RechargeNew.ACC(&d.RechargeNew)
|
||||
s.RechargeGold.ACC(&d.RechargeGold)
|
||||
s.RechargeVip.ACC(&d.RechargeVip)
|
||||
s.Order.ACC(&d.Order)
|
||||
s.OrderSucc.ACC(&d.OrderSucc)
|
||||
s.Register.ACC(&d.Register)
|
||||
s.Visit.ACC(&d.Visit)
|
||||
}
|
||||
|
||||
// @table:bot_hour_stat
|
||||
type BotHourStat struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` // ID
|
||||
AppId int32 `json:"appId" bson:"appId"` // appId,唯一id
|
||||
Reported bool `json:"reported" bson:"reported"` // 是否已汇报
|
||||
ReportTime time.Time `json:"reportTime" bson:"reportTime"` // 汇报时间
|
||||
SumDate time.Time `json:"sumDate" bson:"sumDate"` // 记录时间 按小时对齐
|
||||
TodayStat StatItem `json:"todayStat" bson:"todayStat"` // 今日
|
||||
HourStat StatItem `json:"hourStat" bson:"hourStat"` // 小时
|
||||
TodayGame *GameItem `json:"todayGame" bson:"todayGame,omitempty"` // 游戏
|
||||
TodayLandPage LandPage `json:"todayLandPage" bson:"todayLandPage"` // 今日落地页
|
||||
HourLandPage LandPage `json:"hourLandPage" bson:"hourLandPage"` // 小时落地页
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` // 修改时间
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
|
||||
}
|
||||
|
||||
func (s *BotHourStat) ACC(d *BotHourStat) {
|
||||
s.TodayStat.ACC(&d.TodayStat)
|
||||
s.HourStat.ACC(&d.HourStat)
|
||||
s.TodayGame.ACC(d.TodayGame)
|
||||
s.TodayLandPage.ACC(&d.TodayLandPage)
|
||||
s.HourLandPage.ACC(&d.HourLandPage)
|
||||
}
|
||||
|
||||
type BotHourStatList []*BotHourStat
|
||||
Reference in New Issue
Block a user