package video import ( "time" "91porn-server/common/timeutil/timerange" "91porn-server/models/l/payvidlgmod" "91porn-server/models/l/playlgmod" "91porn-server/models/s/statvidmod" "go.mongodb.org/mongo-driver/bson/primitive" ) type ObjectID = primitive.ObjectID type TimeRange = timerange.TimeRange type VideoStatIncDoc = statvidmod.VideoStatIncDoc type VideoStatSetDoc = statvidmod.VideoStatSetDoc type VideoStatDoc = statvidmod.VideoStatDoc type VideoStatDocMap = statvidmod.VideoStatDocMap //ObjectID->VideoStatDoc // fillPayCoin func fillPayCoin(timeRange TimeRange, docMap *VideoStatDocMap) error { incomeMap, err := payvidlgmod.PayCoinMapByTime(timeRange.Head, timeRange.Tail) if err != nil { return err } docM := *docMap for vid, v := range incomeMap { if _, existed := docM[vid]; !existed { docM[vid] = &VideoStatDoc{} } val := v docM[vid].Income = &val } return nil } // fillPayCount func fillPayCount(timeRange TimeRange, docMap *VideoStatDocMap) error { payCountMap, err := payvidlgmod.PayCountMapByTime(timeRange.Head, timeRange.Tail) if err != nil { return err } docM := *docMap for vid, v := range payCountMap { if _, existed := docM[vid]; !existed { docM[vid] = &VideoStatDoc{} } val := v docM[vid].PayCount = &val } return nil } // fillPlayCount func fillPlayCount(timeRange TimeRange, docMap *VideoStatDocMap) error { playCountMap, err := playlgmod.PlayCountMapByTime(timeRange.Head, timeRange.Tail, []int{0, 1, 2}) //0,免费 1付费 2.试看 if err != nil { return err } docM := *docMap for vid, v := range playCountMap { if _, existed := docM[vid]; !existed { docM[vid] = &VideoStatDoc{} } val := v docM[vid].PlayCount = &val } return nil } // fillPayPlayCount func fillPayPlayCount(timeRange TimeRange, docMap *VideoStatDocMap) error { payPlayCountMap, err := playlgmod.PlayCountMapByTime(timeRange.Head, timeRange.Tail, []int{1}) //0,免费 1付费 2.试看 if err != nil { return err } docM := *docMap for vid, v := range payPlayCountMap { if _, existed := docM[vid]; !existed { docM[vid] = &VideoStatDoc{} } val := v docM[vid].PayPlayCount = &val } return nil } func fillTax(timeRange TimeRange, docMap *VideoStatDocMap) error { payPlayCountMap, err := payvidlgmod.TaxAmountMapByTime(timeRange.Head, timeRange.Tail) //0,免费 1付费 2.试看 if err != nil { return err } docM := *docMap for vid, v := range payPlayCountMap { if _, existed := docM[vid]; !existed { docM[vid] = &VideoStatDoc{} } val := v docM[vid].Tax = &val } return nil } // fillStatDocMap func fillStatDocMap(sumDate time.Time, timeRange TimeRange, docMap *VideoStatDocMap) error { //收入 if err := fillPayCoin(timeRange, docMap); err != nil { return err } //购买次数 if err := fillPayCount(timeRange, docMap); err != nil { return err } //视屏播放次数 if err := fillPlayCount(timeRange, docMap); err != nil { return err } //付费视屏播放次数 if err := fillPayPlayCount(timeRange, docMap); err != nil { return err } //税 return fillTax(timeRange, docMap) }