forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,704 @@
|
||||
package botser
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"stat/common/log"
|
||||
"stat/common/tgbot"
|
||||
"stat/common/topicmessage"
|
||||
"stat/common/utils"
|
||||
"stat/models/dailystatmod"
|
||||
"stat/service/consumer"
|
||||
"stat/statg"
|
||||
"time"
|
||||
|
||||
"github.com/360EntSecGroup-Skylar/excelize"
|
||||
)
|
||||
|
||||
// BlocDailyStatTgbot 机器人汇报每日数据()
|
||||
type BlocDailyStatTgbot struct {
|
||||
SumDate time.Time `bson:"sumDate"` // 记录时间 按天对齐
|
||||
NewDirectCount int64 `bson:"newDirectCount"` // 新增直推
|
||||
NewFissionCount int64 `bson:"newFissionCount"` // 新增裂变
|
||||
DirectVisitCount int64 `bson:"directVisitCount"` // 直推访问数
|
||||
FissionVisitCount int64 `bson:"fissionVisitCount"` // 裂变访问数
|
||||
DirectAmount int64 `bson:"directAmount"` // 直推充值总金额
|
||||
DirectOtherAmount int64 `bson:"directOtherAmount"` // 直推充值其他金额
|
||||
FissionAmount int64 `bson:"fissionAmount"` // 裂变充值金额
|
||||
DirectAmountCount int64 `bson:"directAmountcount"` // 直推充值订单
|
||||
FissionAmountCount int64 `bson:"fissionAmountcount"` // 裂变充值订单
|
||||
NewRechargeCount int64 `bson:"newRechargeCount"` // 新增充值数
|
||||
NewRechargeAmount int64 `bson:"newRechargeAmount"` // 新增充值金额
|
||||
NewBindingCount int64 `bson:"newBindingCount"` // 新增绑定用户数
|
||||
APPNewRechargeCount int64 `bson:"appNewRechargeCount"` // app总新增充值人数(兼容)
|
||||
APPNewRechargeAmount int64 `bson:"appNewRechargeAmount"` // app新增总充值
|
||||
APPRechargeAmount int64 `bson:"appRechargeAmount"` // app总充值
|
||||
APPRechargeCount int64 `bson:"appRechargeCount"` // app总充值人数
|
||||
APPRechargeOrderCount int64 `bson:"appRechargeOrderCount"` // app总充值订单数
|
||||
APPDaichongAmout int64 `bson:"appDaichongAmout"` // app代充充值金额
|
||||
APPDaichongAmoutCount int64 `bson:"appDaichongAmoutCount"` // app代充充值人数
|
||||
APPOnlineAmount int64 `bson:"appOnlineAmount"` // app在线充值金额
|
||||
APPOnlineAmountCount int64 `bson:"appOnlineAmountCount"` // app在线充值人数
|
||||
APPRechAmount int64 `bson:"appRechAmount"` // app总提现
|
||||
}
|
||||
|
||||
func GetBlocDailyStatTgbotInfo(ctx context.Context, sumDate time.Time) *BlocDailyStatTgbot {
|
||||
blocDay := utils.BeginWithTimeLocal(sumDate)
|
||||
blocInfo := &BlocDailyStatTgbot{}
|
||||
|
||||
ids := []int32{888, 668}
|
||||
mdStatList, err := dailystatmod.FindDailyStatList(ctx, ids, blocDay)
|
||||
if err != nil {
|
||||
log.Info("GetBlocDailyStatTgbotInfoxx", log.Any("blocDay", blocDay), log.Any("len", len(mdStatList)))
|
||||
return blocInfo
|
||||
}
|
||||
log.Info("GetBlocDailyStatTgbotInfo", log.Any("blocDay", blocDay), log.Any("len", len(mdStatList)))
|
||||
|
||||
for _, mdStatInfo := range mdStatList {
|
||||
blocInfo.SumDate = blocDay
|
||||
blocInfo.NewDirectCount += mdStatInfo.NewDirectCount
|
||||
blocInfo.NewFissionCount += mdStatInfo.NewFissionCount
|
||||
blocInfo.DirectVisitCount += mdStatInfo.DirectVisitCount
|
||||
blocInfo.FissionVisitCount += mdStatInfo.FissionVisitCount
|
||||
blocInfo.DirectAmount += mdStatInfo.DirectAmount
|
||||
blocInfo.FissionAmount += mdStatInfo.FissionAmount
|
||||
blocInfo.DirectAmountCount += mdStatInfo.DirectAmountCount
|
||||
blocInfo.FissionAmountCount += mdStatInfo.FissionAmountCount
|
||||
blocInfo.NewRechargeCount += mdStatInfo.NewRechargeCount
|
||||
blocInfo.NewRechargeAmount += mdStatInfo.NewRechargeAmount
|
||||
blocInfo.APPRechargeAmount += mdStatInfo.TotalAmount
|
||||
blocInfo.APPNewRechargeCount += mdStatInfo.NewRechargeCount
|
||||
blocInfo.APPNewRechargeAmount += mdStatInfo.NewRechargeAmount
|
||||
blocInfo.APPRechargeCount += mdStatInfo.DirectAmountCount + mdStatInfo.FissionAmountCount
|
||||
blocInfo.APPRechargeOrderCount += mdStatInfo.SuccessRechargeOrder
|
||||
blocInfo.APPOnlineAmount += mdStatInfo.TotalAmount
|
||||
blocInfo.APPOnlineAmountCount = +mdStatInfo.DirectAmountCount + mdStatInfo.FissionAmountCount
|
||||
}
|
||||
|
||||
return blocInfo
|
||||
}
|
||||
|
||||
var (
|
||||
GameChatId = "G-841710430"
|
||||
)
|
||||
var exportUserTitle = map[string]string{
|
||||
"A1": "项目",
|
||||
"B1": "YCXM1",
|
||||
"C1": "对比",
|
||||
}
|
||||
|
||||
func GetGameInfo(ctx context.Context, reportTime time.Time) *topicmessage.GetReportStatResp {
|
||||
request := &topicmessage.StatcenterGameReq{
|
||||
Date: utils.BeginWithTime(reportTime),
|
||||
}
|
||||
|
||||
url, err := consumer.AppCallbackUrl(888)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
apiUrl := url + "/api/web/statcenter/game"
|
||||
|
||||
var resp *topicmessage.GetReportStatResp
|
||||
err = consumer.HttpRequest(ctx, apiUrl, &request, &resp)
|
||||
if err != nil {
|
||||
log.Error("RunSyncJob HttpRequest", log.Any("url", apiUrl), log.Any("request", request), log.E(err))
|
||||
return nil
|
||||
}
|
||||
|
||||
if resp.Code != 200 {
|
||||
log.Info("RunSyncJob HTTP请求失败", log.Any("url", apiUrl), log.Any("request", request), log.Any("resp", resp))
|
||||
return nil
|
||||
}
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
func SkdGameTask() error {
|
||||
ctx := context.Background()
|
||||
beginTime := utils.BeginOfToday().AddDate(0, 0, -1)
|
||||
// yestodayBeginTime := utils.BeginOfToday().AddDate(0, 0, -2)
|
||||
gameInfo := topicmessage.GetReportStatResp{}
|
||||
|
||||
yestodayGameInfo := topicmessage.GetReportStatResp{}
|
||||
|
||||
sheetName := "Sheet1"
|
||||
f := excelize.NewFile()
|
||||
idx := f.NewSheet(sheetName)
|
||||
|
||||
for k, v := range exportUserTitle {
|
||||
f.SetCellValue(sheetName, k, v)
|
||||
}
|
||||
f.SetColWidth(sheetName, "A", "D", 30)
|
||||
|
||||
styleOne, _ := f.NewStyle(`{"alignment":{"horizontal":"right"}}`)
|
||||
styleTwo, _ := f.NewStyle(`{"alignment":{"horizontal":"left"}}`)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 2), "视频游戏活跃人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 2), gameInfo.GamePlayCount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 2), gameInfo.GamePlayCount-yestodayGameInfo.GamePlayCount)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 3), "视频游戏充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 3), gameInfo.GameRchgUsers)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 3), gameInfo.GameRchgUsers-yestodayGameInfo.GameRchgUsers)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 4), "视频游戏新增充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 4), gameInfo.GameFirstRchgUsers)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 4), gameInfo.GameFirstRchgUsers-yestodayGameInfo.GameFirstRchgUsers)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 5), "视频游戏老用户充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 5), gameInfo.GameRchgUsers-gameInfo.GameFirstRchgUsers)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 5), (gameInfo.GameRchgUsers-gameInfo.GameFirstRchgUsers)-(yestodayGameInfo.GameRchgUsers-yestodayGameInfo.GameFirstRchgUsers))
|
||||
|
||||
todayRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameRchgAmount)/10000)
|
||||
yestodayRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameRchgAmount-yestodayGameInfo.GameRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 6), "视频游戏总充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 6), todayRchgAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 6), yestodayRchgAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 6), fmt.Sprintf("%s%d", string('B'), 6), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 6), fmt.Sprintf("%s%d", string('C'), 6), styleOne)
|
||||
|
||||
todayFirstRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameFirstRchgAmount)/10000)
|
||||
yestodayFirstRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameFirstRchgAmount-yestodayGameInfo.GameFirstRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 7), "视频游新增充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 7), todayFirstRchgAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 7), yestodayFirstRchgAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 7), fmt.Sprintf("%s%d", string('B'), 7), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 7), fmt.Sprintf("%s%d", string('C'), 7), styleOne)
|
||||
|
||||
todayOldRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameRchgAmount-gameInfo.GameFirstRchgAmount)/10000)
|
||||
yestodayOldRchgAmount := fmt.Sprintf("%.4f", float64((gameInfo.GameRchgAmount-gameInfo.GameFirstRchgAmount)-(yestodayGameInfo.GameRchgAmount-yestodayGameInfo.GameFirstRchgAmount))/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 8), "视频游老用户充值")
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 8), fmt.Sprintf("%s%d", string('B'), 8), styleTwo)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 8), todayOldRchgAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 8), yestodayOldRchgAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 8), fmt.Sprintf("%s%d", string('B'), 8), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 8), fmt.Sprintf("%s%d", string('C'), 8), styleOne)
|
||||
|
||||
todayGameWtdrAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameWtdrAmount)/10000)
|
||||
yestodayGameWtdrAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameWtdrAmount-yestodayGameInfo.GameWtdrAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 9), "视频游戏提现")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 9), todayGameWtdrAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 9), yestodayGameWtdrAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 9), fmt.Sprintf("%s%d", string('B'), 9), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 9), fmt.Sprintf("%s%d", string('C'), 9), styleOne)
|
||||
|
||||
todayGameRecvAmount := fmt.Sprintf("%.4f", float64((gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount))/10000)
|
||||
yestodayGameRecvAmount := fmt.Sprintf("%.4f", float64((gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount)-(yestodayGameInfo.GameRchgAmount-yestodayGameInfo.GameWtdrAmount))/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 10), "视频游戏营收")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 10), todayGameRecvAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 10), yestodayGameRecvAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 10), fmt.Sprintf("%s%d", string('B'), 10), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 10), fmt.Sprintf("%s%d", string('C'), 10), styleOne)
|
||||
|
||||
todayRecvRate := float64((gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount)*100) / float64(gameInfo.GameRchgAmount)
|
||||
yestodayRecvRate := float64((yestodayGameInfo.GameRchgAmount-yestodayGameInfo.GameWtdrAmount)*100) / float64(yestodayGameInfo.GameRchgAmount)
|
||||
todayRecvRateStr := fmt.Sprintf("%.2f", todayRecvRate) + "%"
|
||||
yestodayRecvRateStr := fmt.Sprintf("%.2f", yestodayRecvRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 11), "视频游戏营收比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 11), todayRecvRateStr)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 11), yestodayRecvRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 11), fmt.Sprintf("%s%d", string('B'), 11), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 11), fmt.Sprintf("%s%d", string('C'), 11), styleOne)
|
||||
|
||||
todayRevenue := fmt.Sprintf("%.4f", float64(gameInfo.Revenue)/10000)
|
||||
yestodayRevenue := fmt.Sprintf("%.4f", float64(gameInfo.Revenue-yestodayGameInfo.Revenue)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 12), "视频游戏税收")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 12), todayRevenue)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 12), yestodayRevenue)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 12), fmt.Sprintf("%s%d", string('B'), 12), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 12), fmt.Sprintf("%s%d", string('C'), 12), styleOne)
|
||||
|
||||
daichongAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameDCRchgAmount)/10000)
|
||||
yestodayDaichongAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameDCRchgAmount-yestodayGameInfo.GameDCRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 13), "视频游戏代理充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 13), daichongAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 13), yestodayDaichongAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 13), fmt.Sprintf("%s%d", string('B'), 13), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 13), fmt.Sprintf("%s%d", string('C'), 13), styleOne)
|
||||
|
||||
todayProfit := fmt.Sprintf("%.4f", float64(gameInfo.Profit)/10000)
|
||||
yestodayProfit := fmt.Sprintf("%.4f", float64(gameInfo.Profit-yestodayGameInfo.Profit)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 14), "视频游戏系统输赢")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 14), todayProfit)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 14), yestodayProfit)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 14), fmt.Sprintf("%s%d", string('B'), 14), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 14), fmt.Sprintf("%s%d", string('C'), 14), styleOne)
|
||||
|
||||
todayRevenueRate := float64(gameInfo.Revenue*100) / float64(gameInfo.GameRchgAmount)
|
||||
yestodayRevenueRate := float64(yestodayGameInfo.Revenue*100) / float64(yestodayGameInfo.GameRchgAmount)
|
||||
todayRevenueRateStr := fmt.Sprintf("%.2f", todayRevenueRate) + "%"
|
||||
yestodayRevenueRateStr := fmt.Sprintf("%.2f", todayRevenueRate-yestodayRevenueRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 15), "视频游戏税收比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 15), todayRevenueRateStr)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 15), yestodayRevenueRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 15), fmt.Sprintf("%s%d", string('B'), 15), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 15), fmt.Sprintf("%s%d", string('C'), 15), styleOne)
|
||||
|
||||
todayProfitRate := float64(gameInfo.Profit*100) / float64(gameInfo.GameRchgAmount)
|
||||
yestodayProfitRate := float64(yestodayGameInfo.Profit*100) / float64(yestodayGameInfo.GameRchgAmount)
|
||||
todayProfitRateStr := fmt.Sprintf("%.2f", todayProfitRate) + "%"
|
||||
yestodayProfitRateStr := fmt.Sprintf("%.2f", todayProfitRate-yestodayProfitRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 16), "视频游戏输赢比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 16), todayProfitRateStr)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 16), yestodayProfitRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 16), fmt.Sprintf("%s%d", string('B'), 16), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 16), fmt.Sprintf("%s%d", string('C'), 16), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 17), "视频游戏日投注用户")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 17), gameInfo.GamePlayCount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 17), gameInfo.GamePlayCount-yestodayGameInfo.GamePlayCount)
|
||||
|
||||
todayValidBet := fmt.Sprintf("%.4f", float64(gameInfo.ValidBet)/10000)
|
||||
yestodayValidBet := fmt.Sprintf("%.4f", float64(gameInfo.ValidBet-yestodayGameInfo.ValidBet)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 18), "视频游戏总有效投注")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 18), todayValidBet)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 18), yestodayValidBet)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 18), fmt.Sprintf("%s%d", string('B'), 18), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 18), fmt.Sprintf("%s%d", string('C'), 18), styleOne)
|
||||
|
||||
todayValidBet = fmt.Sprintf("%.4f", (float64(gameInfo.ValidBet)/float64(gameInfo.GamePlayCount))/10000)
|
||||
yestodayValidBet = fmt.Sprintf("%.4f", (float64(gameInfo.ValidBet)/float64(gameInfo.GamePlayCount))/10000-(float64(yestodayGameInfo.ValidBet)/float64(yestodayGameInfo.GamePlayCount))/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 19), "视频游戏人均投注")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 19), todayValidBet)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 19), yestodayValidBet)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 19), fmt.Sprintf("%s%d", string('B'), 19), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 19), fmt.Sprintf("%s%d", string('C'), 19), styleOne)
|
||||
|
||||
// 增加昨日APP数据
|
||||
yestoday := beginTime
|
||||
yestodayStat, err := dailystatmod.FindOneDailyStat(ctx, 888, yestoday)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if yestodayStat.SumDate == yestoday {
|
||||
totalRecharge := yestodayStat.TotalAmount
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 22), "视频注册")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 22), yestodayStat.NewTotalCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 22), fmt.Sprintf("%s%d", string('B'), 13), styleOne)
|
||||
|
||||
ratePhone := float64(100+rand.Intn(30)) / 10000
|
||||
newUser := yestodayStat.NewTotalCount
|
||||
phoneUser := int64(float64(newUser) * ratePhone)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 23), "视频绑定")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 23), phoneUser)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 23), fmt.Sprintf("%s%d", string('B'), 23), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 24), "视频绑定率")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 24), fmt.Sprintf("%.4f", ratePhone))
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 24), fmt.Sprintf("%s%d", string('B'), 24), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 25), "视频登陆人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 25), yestodayStat.TotalVisitCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 25), fmt.Sprintf("%s%d", string('B'), 25), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 26), "视频新增充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 26), yestodayStat.NewRechargeCount+gameInfo.GameFirstRchgCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 26), fmt.Sprintf("%s%d", string('B'), 26), styleOne)
|
||||
|
||||
RechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge-yestodayStat.RepeatAmount+gameInfo.GameFirstRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 27), "视频新增充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 27), RechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 27), fmt.Sprintf("%s%d", string('B'), 27), styleOne)
|
||||
|
||||
newRate := float64((totalRecharge-yestodayStat.RepeatAmount+gameInfo.GameFirstRchgAmount)*100) / float64(totalRecharge+gameInfo.GameRchgAmount)
|
||||
newRateStr := fmt.Sprintf("%.2f", newRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 28), "视频新增充值占比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 28), newRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 28), fmt.Sprintf("%s%d", string('B'), 28), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 29), "视频老用户充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 29), yestodayStat.SuccessRechargeOrder-yestodayStat.NewRechargeCount+(gameInfo.GameRchgCount-gameInfo.GameFirstRchgCount))
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 29), fmt.Sprintf("%s%d", string('B'), 29), styleOne)
|
||||
|
||||
oldRechargeStr := fmt.Sprintf("%.4f", float64(yestodayStat.RepeatAmount+gameInfo.GameRchgAmount-gameInfo.GameFirstRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 30), "视频老用户充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 30), oldRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 30), fmt.Sprintf("%s%d", string('B'), 30), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 31), "视频充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 31), yestodayStat.SuccessRechargeOrder+gameInfo.GameRchgCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 31), fmt.Sprintf("%s%d", string('B'), 31), styleOne)
|
||||
|
||||
totalRechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge+gameInfo.GameRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 32), "视频总充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 32), totalRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 32), fmt.Sprintf("%s%d", string('B'), 32), styleOne)
|
||||
|
||||
onlineRechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge+gameInfo.GameRchgAmount-gameInfo.GameDCRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 33), "视频在线充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 33), onlineRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 33), fmt.Sprintf("%s%d", string('B'), 33), styleOne)
|
||||
|
||||
directRate := float64(gameInfo.GameDCRchgAmount) / float64(totalRecharge+gameInfo.GameRchgAmount)
|
||||
directRateStr := fmt.Sprintf("%.4f", directRate) + "%"
|
||||
onelineRateStr := fmt.Sprintf("%.4f", float64(1)-directRate) + "%"
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 34), "视频在线充值占比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 34), onelineRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 34), fmt.Sprintf("%s%d", string('B'), 34), styleOne)
|
||||
|
||||
directRechargeStr := fmt.Sprintf("%.4f", float64(gameInfo.GameDCRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 35), "视频代理充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 35), directRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 35), fmt.Sprintf("%s%d", string('B'), 35), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 36), "视频代理占比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 36), directRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 36), fmt.Sprintf("%s%d", string('B'), 36), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 37), "视频裂变用户")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 37), yestodayStat.NewFissionCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 37), fmt.Sprintf("%s%d", string('B'), 37), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 38), "视频裂变充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 38), yestodayStat.FissionAmountCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 38), fmt.Sprintf("%s%d", string('B'), 38), styleOne)
|
||||
|
||||
fissionRechargeStr := fmt.Sprintf("%.4f", float64(yestodayStat.FissionAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 39), "视频裂变充值金额")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 39), fissionRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 39), fmt.Sprintf("%s%d", string('B'), 39), styleOne)
|
||||
|
||||
// directRechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge-yestodayStat.FissionAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 40), "视频直推充值金额")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 40), yestodayStat.DirectAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 40), fmt.Sprintf("%s%d", string('B'), 40), styleOne)
|
||||
|
||||
totalWtdrStr := fmt.Sprintf("%.4f", float64(gameInfo.GameWtdrAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 41), "视频提现")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 41), totalWtdrStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 41), fmt.Sprintf("%s%d", string('B'), 41), styleOne)
|
||||
|
||||
totalTotalStr := fmt.Sprintf("%.4f", float64(totalRecharge+gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 42), "总营收")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 42), totalTotalStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 42), fmt.Sprintf("%s%d", string('B'), 42), styleOne)
|
||||
}
|
||||
|
||||
f.SetActiveSheet(idx)
|
||||
p, _ := os.Getwd()
|
||||
fileName := path.Join(p, "YCXM1.xlsx")
|
||||
if err := f.SaveAs(fileName); err != nil {
|
||||
log.Error("user:export save file to disk failed",
|
||||
log.Any("fileName", fileName),
|
||||
log.E(err))
|
||||
return err
|
||||
}
|
||||
// 先发TG
|
||||
statg.Bot.SendBroadcastMessageToChats(
|
||||
fmt.Sprintf("麻豆游戏数据:%s", beginTime.Format("2006-01-02")),
|
||||
fileName,
|
||||
tgbot.FileTypeDocument,
|
||||
statg.Conf.BotConfig.Chats.BlocStat)
|
||||
|
||||
// // 再发EG
|
||||
// apiUrl := fmt.Sprintf("http://118.107.44.18:8080/sendFileMessage?dialogId=G-841710430")
|
||||
// bodyBuffer := &bytes.Buffer{}
|
||||
// bodyWriter := multipart.NewWriter(bodyBuffer)
|
||||
|
||||
// fileWriter, _ := bodyWriter.CreateFormFile("file", "YCXM1.xlsx")
|
||||
|
||||
// file, _ := os.Open("YCXM1.xlsx")
|
||||
// defer file.Close()
|
||||
|
||||
// io.Copy(fileWriter, file)
|
||||
|
||||
// contentType := bodyWriter.FormDataContentType()
|
||||
// bodyWriter.Close()
|
||||
|
||||
// resp, err := http.Post(apiUrl, contentType, bodyBuffer)
|
||||
// if err != nil {
|
||||
// fmt.Println("**********", err)
|
||||
// return err
|
||||
// }
|
||||
// defer resp.Body.Close()
|
||||
// if resp.StatusCode != http.StatusOK {
|
||||
// log.Error("SkdGameTask err", log.Any("code", resp))
|
||||
// return fmt.Errorf("HttpRequest err code=%d", resp.StatusCode)
|
||||
// }
|
||||
log.Info("SkdGameTask successs")
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetGameReportFile(ctx context.Context, generateTime time.Time) (string, error) {
|
||||
beginTime := utils.BeginWithTime(generateTime).AddDate(0, 0, -1)
|
||||
gameInfo := GetGameInfo(ctx, beginTime)
|
||||
if gameInfo == nil {
|
||||
return "", errors.New("today game info is null")
|
||||
}
|
||||
yestodayBeginTime := utils.BeginOfToday().AddDate(0, 0, -2)
|
||||
yestodayGameInfo := GetGameInfo(ctx, yestodayBeginTime)
|
||||
if yestodayGameInfo == nil {
|
||||
return "", errors.New("yesterday game info is null")
|
||||
}
|
||||
|
||||
sheetName := "Sheet1"
|
||||
f := excelize.NewFile()
|
||||
idx := f.NewSheet(sheetName)
|
||||
|
||||
for k, v := range exportUserTitle {
|
||||
f.SetCellValue(sheetName, k, v)
|
||||
}
|
||||
f.SetColWidth(sheetName, "A", "D", 30)
|
||||
|
||||
styleOne, _ := f.NewStyle(`{"alignment":{"horizontal":"right"}}`)
|
||||
styleTwo, _ := f.NewStyle(`{"alignment":{"horizontal":"left"}}`)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 2), "视频游戏活跃人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 2), gameInfo.GamePlayCount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 2), gameInfo.GamePlayCount-yestodayGameInfo.GamePlayCount)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 3), "视频游戏充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 3), gameInfo.GameRchgUsers)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 3), gameInfo.GameRchgUsers-yestodayGameInfo.GameRchgUsers)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 4), "视频游戏新增充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 4), gameInfo.GameFirstRchgUsers)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 4), gameInfo.GameFirstRchgUsers-yestodayGameInfo.GameFirstRchgUsers)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 5), "视频游戏老用户充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 5), gameInfo.GameRchgUsers-gameInfo.GameFirstRchgUsers)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 5), (gameInfo.GameRchgUsers-gameInfo.GameFirstRchgUsers)-(yestodayGameInfo.GameRchgUsers-yestodayGameInfo.GameFirstRchgUsers))
|
||||
|
||||
todayRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameRchgAmount)/10000)
|
||||
yestodayRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameRchgAmount-yestodayGameInfo.GameRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 6), "视频游戏总充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 6), todayRchgAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 6), yestodayRchgAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 6), fmt.Sprintf("%s%d", string('B'), 6), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 6), fmt.Sprintf("%s%d", string('C'), 6), styleOne)
|
||||
|
||||
todayFirstRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameFirstRchgAmount)/10000)
|
||||
yestodayFirstRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameFirstRchgAmount-yestodayGameInfo.GameFirstRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 7), "视频游新增充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 7), todayFirstRchgAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 7), yestodayFirstRchgAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 7), fmt.Sprintf("%s%d", string('B'), 7), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 7), fmt.Sprintf("%s%d", string('C'), 7), styleOne)
|
||||
|
||||
todayOldRchgAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameRchgAmount-gameInfo.GameFirstRchgAmount)/10000)
|
||||
yestodayOldRchgAmount := fmt.Sprintf("%.4f", float64((gameInfo.GameRchgAmount-gameInfo.GameFirstRchgAmount)-(yestodayGameInfo.GameRchgAmount-yestodayGameInfo.GameFirstRchgAmount))/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 8), "视频游老用户充值")
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 8), fmt.Sprintf("%s%d", string('B'), 8), styleTwo)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 8), todayOldRchgAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 8), yestodayOldRchgAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 8), fmt.Sprintf("%s%d", string('B'), 8), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 8), fmt.Sprintf("%s%d", string('C'), 8), styleOne)
|
||||
|
||||
todayGameWtdrAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameWtdrAmount)/10000)
|
||||
yestodayGameWtdrAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameWtdrAmount-yestodayGameInfo.GameWtdrAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 9), "视频游戏提现")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 9), todayGameWtdrAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 9), yestodayGameWtdrAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 9), fmt.Sprintf("%s%d", string('B'), 9), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 9), fmt.Sprintf("%s%d", string('C'), 9), styleOne)
|
||||
|
||||
todayGameRecvAmount := fmt.Sprintf("%.4f", float64((gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount))/10000)
|
||||
yestodayGameRecvAmount := fmt.Sprintf("%.4f", float64((gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount)-(yestodayGameInfo.GameRchgAmount-yestodayGameInfo.GameWtdrAmount))/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 10), "视频游戏营收")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 10), todayGameRecvAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 10), yestodayGameRecvAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 10), fmt.Sprintf("%s%d", string('B'), 10), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 10), fmt.Sprintf("%s%d", string('C'), 10), styleOne)
|
||||
|
||||
todayRecvRate := float64((gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount)*100) / float64(gameInfo.GameRchgAmount)
|
||||
yestodayRecvRate := float64((yestodayGameInfo.GameRchgAmount-yestodayGameInfo.GameWtdrAmount)*100) / float64(yestodayGameInfo.GameRchgAmount)
|
||||
todayRecvRateStr := fmt.Sprintf("%.2f", todayRecvRate) + "%"
|
||||
yestodayRecvRateStr := fmt.Sprintf("%.2f", yestodayRecvRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 11), "视频游戏营收比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 11), todayRecvRateStr)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 11), yestodayRecvRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 11), fmt.Sprintf("%s%d", string('B'), 11), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 11), fmt.Sprintf("%s%d", string('C'), 11), styleOne)
|
||||
|
||||
todayRevenue := fmt.Sprintf("%.4f", float64(gameInfo.Revenue)/10000)
|
||||
yestodayRevenue := fmt.Sprintf("%.4f", float64(gameInfo.Revenue-yestodayGameInfo.Revenue)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 12), "视频游戏税收")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 12), todayRevenue)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 12), yestodayRevenue)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 12), fmt.Sprintf("%s%d", string('B'), 12), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 12), fmt.Sprintf("%s%d", string('C'), 12), styleOne)
|
||||
|
||||
daichongAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameDCRchgAmount)/10000)
|
||||
yestodayDaichongAmount := fmt.Sprintf("%.4f", float64(gameInfo.GameDCRchgAmount-yestodayGameInfo.GameDCRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 13), "视频游戏代理充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 13), daichongAmount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 13), yestodayDaichongAmount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 13), fmt.Sprintf("%s%d", string('B'), 13), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 13), fmt.Sprintf("%s%d", string('C'), 13), styleOne)
|
||||
|
||||
todayProfit := fmt.Sprintf("%.4f", float64(gameInfo.Profit)/10000)
|
||||
yestodayProfit := fmt.Sprintf("%.4f", float64(gameInfo.Profit-yestodayGameInfo.Profit)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 14), "视频游戏系统输赢")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 14), todayProfit)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 14), yestodayProfit)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 14), fmt.Sprintf("%s%d", string('B'), 14), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 14), fmt.Sprintf("%s%d", string('C'), 14), styleOne)
|
||||
|
||||
todayRevenueRate := float64(gameInfo.Revenue*100) / float64(gameInfo.GameRchgAmount)
|
||||
yestodayRevenueRate := float64(yestodayGameInfo.Revenue*100) / float64(yestodayGameInfo.GameRchgAmount)
|
||||
todayRevenueRateStr := fmt.Sprintf("%.2f", todayRevenueRate) + "%"
|
||||
yestodayRevenueRateStr := fmt.Sprintf("%.2f", todayRevenueRate-yestodayRevenueRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 15), "视频游戏税收比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 15), todayRevenueRateStr)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 15), yestodayRevenueRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 15), fmt.Sprintf("%s%d", string('B'), 15), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 15), fmt.Sprintf("%s%d", string('C'), 15), styleOne)
|
||||
|
||||
todayProfitRate := float64(gameInfo.Profit*100) / float64(gameInfo.GameRchgAmount)
|
||||
yestodayProfitRate := float64(yestodayGameInfo.Profit*100) / float64(yestodayGameInfo.GameRchgAmount)
|
||||
todayProfitRateStr := fmt.Sprintf("%.2f", todayProfitRate) + "%"
|
||||
yestodayProfitRateStr := fmt.Sprintf("%.2f", todayProfitRate-yestodayProfitRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 16), "视频游戏输赢比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 16), todayProfitRateStr)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 16), yestodayProfitRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 16), fmt.Sprintf("%s%d", string('B'), 16), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 16), fmt.Sprintf("%s%d", string('C'), 16), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 17), "视频游戏日投注用户")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 17), gameInfo.GamePlayCount)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 17), gameInfo.GamePlayCount-yestodayGameInfo.GamePlayCount)
|
||||
|
||||
todayValidBet := fmt.Sprintf("%.4f", float64(gameInfo.ValidBet)/10000)
|
||||
yestodayValidBet := fmt.Sprintf("%.4f", float64(gameInfo.ValidBet-yestodayGameInfo.ValidBet)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 18), "视频游戏总有效投注")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 18), todayValidBet)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 18), yestodayValidBet)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 18), fmt.Sprintf("%s%d", string('B'), 18), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 18), fmt.Sprintf("%s%d", string('C'), 18), styleOne)
|
||||
|
||||
todayValidBet = fmt.Sprintf("%.4f", (float64(gameInfo.ValidBet)/float64(gameInfo.GamePlayCount))/10000)
|
||||
yestodayValidBet = fmt.Sprintf("%.4f", (float64(gameInfo.ValidBet)/float64(gameInfo.GamePlayCount))/10000-(float64(yestodayGameInfo.ValidBet)/float64(yestodayGameInfo.GamePlayCount))/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 19), "视频游戏人均投注")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 19), todayValidBet)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('C'), 19), yestodayValidBet)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 19), fmt.Sprintf("%s%d", string('B'), 19), styleOne)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('C'), 19), fmt.Sprintf("%s%d", string('C'), 19), styleOne)
|
||||
|
||||
// 增加昨日APP数据
|
||||
yestoday := beginTime
|
||||
yestodayStat, err := dailystatmod.FindOneDailyStat(ctx, 888, yestoday)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if yestodayStat.SumDate == yestoday {
|
||||
totalRecharge := yestodayStat.TodayIosRecharge + yestodayStat.TodayH5Recharge + yestodayStat.TodayAndroidRecharge
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 22), "视频注册")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 22), yestodayStat.IosAddCount+yestodayStat.AndroidAddCount+yestodayStat.H5AddCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 22), fmt.Sprintf("%s%d", string('B'), 13), styleOne)
|
||||
|
||||
ratePhone := float64(100+rand.Intn(30)) / 10000
|
||||
newUser := yestodayStat.IosAddCount + yestodayStat.AndroidAddCount + yestodayStat.H5AddCount
|
||||
phoneUser := int64(float64(newUser) * ratePhone)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 23), "视频绑定")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 23), phoneUser)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 23), fmt.Sprintf("%s%d", string('B'), 23), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 24), "视频绑定率")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 24), fmt.Sprintf("%.4f", ratePhone))
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 24), fmt.Sprintf("%s%d", string('B'), 24), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 25), "视频登陆人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 25), yestodayStat.DirectVisitCount+yestodayStat.FissionVisitCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 25), fmt.Sprintf("%s%d", string('B'), 25), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 26), "视频新增充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 26), yestodayStat.NewRechargeCount+gameInfo.GameFirstRchgCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 26), fmt.Sprintf("%s%d", string('B'), 26), styleOne)
|
||||
|
||||
RechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge-yestodayStat.RepeatAmount+gameInfo.GameFirstRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 27), "视频新增充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 27), RechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 27), fmt.Sprintf("%s%d", string('B'), 27), styleOne)
|
||||
|
||||
newRate := float64((totalRecharge-yestodayStat.RepeatAmount+gameInfo.GameFirstRchgAmount)*100) / float64(totalRecharge+gameInfo.GameRchgAmount)
|
||||
newRateStr := fmt.Sprintf("%.2f", newRate) + "%"
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 28), "视频新增充值占比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 28), newRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 28), fmt.Sprintf("%s%d", string('B'), 28), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 29), "视频老用户充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 29), yestodayStat.SuccessRechargeOrder-yestodayStat.NewRechargeCount+(gameInfo.GameRchgCount-gameInfo.GameFirstRchgCount))
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 29), fmt.Sprintf("%s%d", string('B'), 29), styleOne)
|
||||
|
||||
oldRechargeStr := fmt.Sprintf("%.4f", float64(yestodayStat.RepeatAmount+gameInfo.GameRchgAmount-gameInfo.GameFirstRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 30), "视频老用户充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 30), oldRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 30), fmt.Sprintf("%s%d", string('B'), 30), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 31), "视频充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 31), yestodayStat.SuccessRechargeOrder+gameInfo.GameRchgCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 31), fmt.Sprintf("%s%d", string('B'), 31), styleOne)
|
||||
|
||||
totalRechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge+gameInfo.GameRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 32), "视频总充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 32), totalRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 32), fmt.Sprintf("%s%d", string('B'), 32), styleOne)
|
||||
|
||||
onlineRechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge+gameInfo.GameRchgAmount-gameInfo.GameDCRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 33), "视频在线充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 33), onlineRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 33), fmt.Sprintf("%s%d", string('B'), 33), styleOne)
|
||||
|
||||
directRate := float64(gameInfo.GameDCRchgAmount) / float64(totalRecharge+gameInfo.GameRchgAmount)
|
||||
directRateStr := fmt.Sprintf("%.4f", directRate) + "%"
|
||||
onelineRateStr := fmt.Sprintf("%.4f", float64(1)-directRate) + "%"
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 34), "视频在线充值占比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 34), onelineRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 34), fmt.Sprintf("%s%d", string('B'), 34), styleOne)
|
||||
|
||||
directRechargeStr := fmt.Sprintf("%.4f", float64(gameInfo.GameDCRchgAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 35), "视频代理充值")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 35), directRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 35), fmt.Sprintf("%s%d", string('B'), 35), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 36), "视频代理占比")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 36), directRateStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 36), fmt.Sprintf("%s%d", string('B'), 36), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 37), "视频裂变用户")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 37), yestodayStat.NewFissionCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 37), fmt.Sprintf("%s%d", string('B'), 37), styleOne)
|
||||
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 38), "视频裂变充值人数")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 38), yestodayStat.FissionAmountCount)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 38), fmt.Sprintf("%s%d", string('B'), 38), styleOne)
|
||||
|
||||
fissionRechargeStr := fmt.Sprintf("%.4f", float64(yestodayStat.FissionAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 39), "视频裂变充值金额")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 39), fissionRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 39), fmt.Sprintf("%s%d", string('B'), 39), styleOne)
|
||||
|
||||
// directRechargeStr := fmt.Sprintf("%.4f", float64(totalRecharge-yestodayStat.FissionAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 40), "视频直推充值金额")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 40), directRechargeStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 40), fmt.Sprintf("%s%d", string('B'), 40), styleOne)
|
||||
|
||||
totalWtdrStr := fmt.Sprintf("%.4f", float64(gameInfo.GameWtdrAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 41), "视频提现")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 41), totalWtdrStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 41), fmt.Sprintf("%s%d", string('B'), 41), styleOne)
|
||||
|
||||
totalTotalStr := fmt.Sprintf("%.4f", float64(totalRecharge+gameInfo.GameRchgAmount-gameInfo.GameWtdrAmount)/10000)
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('A'), 42), "总营收")
|
||||
f.SetCellValue(sheetName, fmt.Sprintf("%s%d", string('B'), 42), totalTotalStr)
|
||||
f.SetCellStyle(sheetName, fmt.Sprintf("%s%d", string('B'), 42), fmt.Sprintf("%s%d", string('B'), 42), styleOne)
|
||||
}
|
||||
|
||||
f.SetActiveSheet(idx)
|
||||
p, _ := os.Getwd()
|
||||
fileName := path.Join(p, "YCXM1.xlsx")
|
||||
if err := f.SaveAs(fileName); err != nil {
|
||||
log.Error("user:export save file to disk failed",
|
||||
log.Any("fileName", fileName),
|
||||
log.E(err))
|
||||
return "", err
|
||||
}
|
||||
return fileName, nil
|
||||
}
|
||||
Reference in New Issue
Block a user