package statser import ( "91porn-server/common/maths" "fmt" "math" "time" ) type DailyRecord struct { Date time.Time `json:"date"` //日期 //日常 NewUserCount float64 `json:"newUserCount"` //新增用户数 SumUserCount float64 `json:"sumUserCount"` //用户数合计 sum = NewUserCount_1 + NewUserCount_2 + ... + NewUserCount_n BindUserCount float64 `json:"bindUserCount"` //绑定用户数 SumBindUserCount float64 `json:"sumBindUserCount"` //绑定用户数合计 sum = BindUserCount_1 + BindUserCount_2 + ... + BindUserCount_n NewBindUserCount float64 `json:"newBindUserCount"` //新增绑定用户数 VisitUserCount float64 `json:"visitUserCount"` //访问用户数 SumVisitUserCount float64 `json:"sumVisitUserCount"` //访问用户数合计 sum = VisitUserCount_1 + VisitUserCount_2 + ... + VisitUserCount_n AveVisitUserCount float64 `json:"aveVisitUserCount"` //平均访问用户数 = SumVisitUserCount / n IOSRetainUserRate2Day string `json:"iosRetainUserRate2Day"` //IOS次日用户留存率 ANDRetainUserRate2Day string `json:"andRetainUserRate2Day"` //安卓次日用户留存率 H5RetainUserRate2Day string `json:"h5RetainUserRate2Day"` //H5次日用户留存率 RetainUserRate2Day string `json:"retainUserRate2Day"` //次日用户留存率 RetainUserRate3Day string `json:"retainUserRate3Day"` //3日用户留存率 RetainUserRate7Day string `json:"retainUserRate7Day"` //7日用户留存率 RetainUserRate15Day string `json:"retainUserRate15Day"` //15日用户留存率 RetainUserRate30Day string `json:"retainUserRate30Day"` //30日用户留存率 //视屏 NewVideoCount int64 `json:"newVideoCount"` //新增短视屏数 PlayUserCount float64 `json:"playUserCount"` //播放视屏人数 PeakViewCount int64 `json:"peakViewCount"` //[未完成]峰值观看数 PeakViewTime int64 `json:"peakViewTime"` //[未完成]峰值观看时长 EffecViewCount int64 `json:"effecViewCount"` //[未完成]有效观看数 AveEffecViewTime int64 `json:"aveEffecViewTime"` //[未完成]平均有效观看时长 //消费 PayGold int64 `json:"payAmount"` //消费金币 = 消费付费视屏金额 + 消费vip金额 PayVipGold int64 `json:"payVipAmount"` //购买VIP金币 PayVidGold int64 `json:"payVidAmount"` //视频消费金币 PayVipUserCount float64 `json:"payVipUserCount"` //购买VIP人数 PayUserCount float64 `json:"payUserCount"` //消费人数 NewAndPayUserCount float64 `json:"newAndPayUserCount"` //新增并消费人数 SumPayGold float64 `json:"sumPayAmount"` //消费金币合计 = PayAmount_1 + PayAmount_2 + ... + PayAmount_n AvePayGold int64 `json:"avePayAmount"` //平均消费金币 = SumPayGold / n //充值 MerchantRechargeAmount float64 `json:"merchantRechargeAmount"` //[未完成]商人充值额度 OnlineRechargeAmount float64 `json:"onlineRechargeAmount"` //在线用户充值金额 TotalRechargeAmount float64 `json:"totalRechargeAmount"` //总充值金额 = //在线用户充值金额 + 商人充值额度 RechargeUserCount float64 `json:"rechargeUserCount"` //充值用户数 NewAndRechargeUserCount float64 `json:"newAndRechargeUserCount"` //新增充值用户数 ARPU int64 `json:"arpu"` //Average Revenue Per User 每用户平均收入=总收入(总充值)/访问用户数 ARPPU int64 `json:"arppu"` //Average Revenue Per Paying User 每充值用户平均收益=总收入(总充值)/充值用户数 SumRechargeAmount float64 `json:"sumRechargeAmount"` //充值金额合计 sum = RechargeUserCount_1 + RechargeUserCount_2 + ... + RechargeUserCount_n AveRechargeAmount int64 `json:"aveRechargeAmount"` //平均充值金额 = SumRechargeAmount / n //提现 GoldWithdrawAmount float64 `json:"goldWithdrawAmount"` //金币提现金额 ProxyWithdrawAmount float64 `json:"proxyWithdrawAmount"` //全民代理提现金额 } func (this *DailyRecord) BaiYuan() *DailyRecord { this.MerchantRechargeAmount = maths.ToFloat64_b2(this.MerchantRechargeAmount / 100) this.OnlineRechargeAmount = maths.ToFloat64_b2(this.OnlineRechargeAmount / 100) this.TotalRechargeAmount = maths.ToFloat64_b2(this.TotalRechargeAmount / 100) this.SumRechargeAmount = maths.ToFloat64_b2(this.SumRechargeAmount / 100) this.GoldWithdrawAmount = maths.ToFloat64_b2(this.GoldWithdrawAmount / 100) this.ProxyWithdrawAmount = maths.ToFloat64_b2(this.ProxyWithdrawAmount / 100) this.NewUserCount = maths.ToFloat64_b2(this.NewUserCount / 100) this.SumUserCount = maths.ToFloat64_b2(this.SumUserCount / 100) this.BindUserCount = maths.ToFloat64_b2(this.BindUserCount / 100) this.SumBindUserCount = maths.ToFloat64_b2(this.SumBindUserCount / 100) this.NewBindUserCount = maths.ToFloat64_b2(this.NewBindUserCount / 100) this.VisitUserCount = maths.ToFloat64_b2(this.VisitUserCount / 100) this.SumVisitUserCount = maths.ToFloat64_b2(this.SumVisitUserCount / 100) this.AveVisitUserCount = maths.ToFloat64_b2(this.AveVisitUserCount / 100) this.PlayUserCount = maths.ToFloat64_b2(this.PlayUserCount / 100) this.PayVipUserCount = maths.ToFloat64_b2(this.PayVipUserCount / 100) this.PayUserCount = maths.ToFloat64_b2(this.PayUserCount / 100) this.NewAndPayUserCount = maths.ToFloat64_b2(this.NewAndPayUserCount / 100) this.RechargeUserCount = maths.ToFloat64_b2(this.RechargeUserCount / 100) this.NewAndRechargeUserCount = maths.ToFloat64_b2(this.NewAndRechargeUserCount / 100) return this } type DailyPages struct { Total int64 `json:"total"` List []*DailyRecord `json:"list"` } // 四舍五入 func Rounding(v float64) int64 { return int64(math.Floor(v + 0.5)) } func Percentage(v float64) string { return fmt.Sprintf("%.3f%%", v*100) } func Divide(a, b int64) float64 { if b == 0 { return 0 } return float64(a) / float64(b) } func toInt64(v *int64) int64 { if v == nil { return 0 } return *v }