|
@@ -15,23 +15,37 @@ func IndexTotal(c *gin.Context) { |
|
|
//昨天 |
|
|
//昨天 |
|
|
yesterday := utils.GetTimeRange("yesterday") |
|
|
yesterday := utils.GetTimeRange("yesterday") |
|
|
yesterdayTotal := commTotal(c, time.Unix(yesterday["start"], 0).Format("2006-01-02"), time.Unix(yesterday["end"]-3600, 0).Format("2006-01-02")) |
|
|
yesterdayTotal := commTotal(c, time.Unix(yesterday["start"], 0).Format("2006-01-02"), time.Unix(yesterday["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
yesterdayTotalAgent := commTotalAgent(c, time.Unix(yesterday["start"], 0).Format("2006-01-02"), time.Unix(yesterday["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
|
|
|
//前天 |
|
|
//前天 |
|
|
beforeYesterDayTotal := commTotal(c, time.Unix(yesterday["start"]-86400, 0).Format("2006-01-02"), time.Unix(yesterday["start"]-3600, 0).Format("2006-01-02")) |
|
|
beforeYesterDayTotal := commTotal(c, time.Unix(yesterday["start"]-86400, 0).Format("2006-01-02"), time.Unix(yesterday["start"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
beforeYesterDayTotalAgent := commTotalAgent(c, time.Unix(yesterday["start"]-86400, 0).Format("2006-01-02"), time.Unix(yesterday["start"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
|
|
|
//7天 |
|
|
//7天 |
|
|
withinSevenDays := utils.GetTimeRange("new_within_seven_days") |
|
|
withinSevenDays := utils.GetTimeRange("new_within_seven_days") |
|
|
withinSevenDaysTotal := commTotal(c, time.Unix(withinSevenDays["start"], 0).Format("2006-01-02"), time.Unix(withinSevenDays["end"]-3600, 0).Format("2006-01-02")) |
|
|
withinSevenDaysTotal := commTotal(c, time.Unix(withinSevenDays["start"], 0).Format("2006-01-02"), time.Unix(withinSevenDays["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
withinSevenDaysTotalAgent := commTotalAgent(c, time.Unix(withinSevenDays["start"], 0).Format("2006-01-02"), time.Unix(withinSevenDays["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
|
|
|
//7天前的 7天 |
|
|
//7天前的 7天 |
|
|
beforeWithinSevenDaysTotal := commTotal(c, time.Unix(withinSevenDays["start"]-3600-7*86400, 0).Format("2006-01-02"), time.Unix(withinSevenDays["start"]-3600, 0).Format("2006-01-02")) |
|
|
beforeWithinSevenDaysTotal := commTotal(c, time.Unix(withinSevenDays["start"]-3600-7*86400, 0).Format("2006-01-02"), time.Unix(withinSevenDays["start"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
beforeWithinSevenDaysTotalAgent := commTotalAgent(c, time.Unix(withinSevenDays["start"]-3600-7*86400, 0).Format("2006-01-02"), time.Unix(withinSevenDays["start"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
|
|
|
//本月 |
|
|
//本月 |
|
|
currentMonth := utils.GetTimeRange("current_month") |
|
|
currentMonth := utils.GetTimeRange("current_month") |
|
|
currentMonthTotal := commTotal(c, time.Unix(currentMonth["start"], 0).Format("2006-01-02"), time.Unix(currentMonth["end"]-3600, 0).Format("2006-01-02")) |
|
|
currentMonthTotal := commTotal(c, time.Unix(currentMonth["start"], 0).Format("2006-01-02"), time.Unix(currentMonth["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
currentMonthTotalAgent := commTotalAgent(c, time.Unix(currentMonth["start"], 0).Format("2006-01-02"), time.Unix(currentMonth["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
|
|
|
//上月 |
|
|
//上月 |
|
|
lastMonth := utils.GetTimeRange("last_month") |
|
|
lastMonth := utils.GetTimeRange("last_month") |
|
|
lastMonthTotal := commTotal(c, time.Unix(lastMonth["start"], 0).Format("2006-01-02"), time.Unix(lastMonth["end"]-3600, 0).Format("2006-01-02")) |
|
|
lastMonthTotal := commTotal(c, time.Unix(lastMonth["start"], 0).Format("2006-01-02"), time.Unix(lastMonth["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
lastMonthTotalAgent := commTotalAgent(c, time.Unix(lastMonth["start"], 0).Format("2006-01-02"), time.Unix(lastMonth["end"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
|
|
|
//上上月 |
|
|
//上上月 |
|
|
beforeLastMonth := time.Unix(lastMonth["start"]-86400, 0) |
|
|
beforeLastMonth := time.Unix(lastMonth["start"]-86400, 0) |
|
|
beforeLastMonthStr := time.Date(beforeLastMonth.Year(), beforeLastMonth.Month(), 1, 0, 0, 0, 0, beforeLastMonth.Location()) |
|
|
beforeLastMonthStr := time.Date(beforeLastMonth.Year(), beforeLastMonth.Month(), 1, 0, 0, 0, 0, beforeLastMonth.Location()) |
|
|
beforeLastMonthTotal := commTotal(c, beforeLastMonthStr.Format("2006-01-02"), time.Unix(lastMonth["start"]-3600, 0).Format("2006-01-02")) |
|
|
beforeLastMonthTotal := commTotal(c, beforeLastMonthStr.Format("2006-01-02"), time.Unix(lastMonth["start"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
beforeLastMonthTotalAgent := commTotalAgent(c, beforeLastMonthStr.Format("2006-01-02"), time.Unix(lastMonth["start"]-3600, 0).Format("2006-01-02")) |
|
|
|
|
|
|
|
|
res := []md.IndexAppListDataList{ |
|
|
res := []md.IndexAppListDataList{ |
|
|
{Name: "昨日收益(媒体)", Type: "yesterday", Bili: commBili(c, beforeYesterDayTotal, yesterdayTotal, "media_revenue"), Value: utils.Float64ToStr(utils.StrToFloat64(yesterdayTotal[0]["media_revenue"]) / 100)}, |
|
|
{Name: "昨日收益(媒体)", Type: "yesterday", Bili: commBili(c, beforeYesterDayTotal, yesterdayTotal, "media_revenue"), Value: utils.Float64ToStr(utils.StrToFloat64(yesterdayTotal[0]["media_revenue"]) / 100)}, |
|
|
{Name: "七日收益(媒体)", Type: "within_seven_days", Bili: commBili(c, beforeWithinSevenDaysTotal, withinSevenDaysTotal, "media_revenue"), Value: utils.Float64ToStr(utils.StrToFloat64(withinSevenDaysTotal[0]["media_revenue"]) / 100)}, |
|
|
{Name: "七日收益(媒体)", Type: "within_seven_days", Bili: commBili(c, beforeWithinSevenDaysTotal, withinSevenDaysTotal, "media_revenue"), Value: utils.Float64ToStr(utils.StrToFloat64(withinSevenDaysTotal[0]["media_revenue"]) / 100)}, |
|
@@ -41,6 +55,10 @@ func IndexTotal(c *gin.Context) { |
|
|
{Name: "七日收益(曝光量)", Type: "within_seven_days", Bili: commBili(c, beforeWithinSevenDaysTotal, withinSevenDaysTotal, "exposure_count"), Value: withinSevenDaysTotal[0]["exposure_count"]}, |
|
|
{Name: "七日收益(曝光量)", Type: "within_seven_days", Bili: commBili(c, beforeWithinSevenDaysTotal, withinSevenDaysTotal, "exposure_count"), Value: withinSevenDaysTotal[0]["exposure_count"]}, |
|
|
{Name: "本月收益(曝光量)", Type: "current_month", Bili: commBili(c, lastMonthTotal, currentMonthTotal, "exposure_count"), Value: currentMonthTotal[0]["exposure_count"]}, |
|
|
{Name: "本月收益(曝光量)", Type: "current_month", Bili: commBili(c, lastMonthTotal, currentMonthTotal, "exposure_count"), Value: currentMonthTotal[0]["exposure_count"]}, |
|
|
{Name: "上月收益(曝光量)", Type: "last_month", Bili: commBili(c, beforeLastMonthTotal, lastMonthTotal, "exposure_count"), Value: lastMonthTotal[0]["exposure_count"]}, |
|
|
{Name: "上月收益(曝光量)", Type: "last_month", Bili: commBili(c, beforeLastMonthTotal, lastMonthTotal, "exposure_count"), Value: lastMonthTotal[0]["exposure_count"]}, |
|
|
|
|
|
{Name: "昨日收益(佣金)", Type: "yesterday", Bili: commBili(c, beforeYesterDayTotalAgent, yesterdayTotalAgent, "media_revenue"), Value: yesterdayTotalAgent[0]["media_revenue"]}, |
|
|
|
|
|
{Name: "七日收益(佣金)", Type: "within_seven_days", Bili: commBili(c, beforeWithinSevenDaysTotalAgent, withinSevenDaysTotalAgent, "media_revenue"), Value: withinSevenDaysTotalAgent[0]["media_revenue"]}, |
|
|
|
|
|
{Name: "本月收益(佣金)", Type: "current_month", Bili: commBili(c, lastMonthTotalAgent, currentMonthTotalAgent, "media_revenue"), Value: currentMonthTotalAgent[0]["media_revenue"]}, |
|
|
|
|
|
{Name: "上月收益(佣金)", Type: "last_month", Bili: commBili(c, beforeLastMonthTotalAgent, lastMonthTotalAgent, "media_revenue"), Value: lastMonthTotalAgent[0]["media_revenue"]}, |
|
|
} |
|
|
} |
|
|
e.OutSuc(c, res, nil) |
|
|
e.OutSuc(c, res, nil) |
|
|
return |
|
|
return |
|
@@ -57,6 +75,32 @@ func commBili(c *gin.Context, before, after []map[string]string, types string) s |
|
|
} |
|
|
} |
|
|
return bili |
|
|
return bili |
|
|
} |
|
|
} |
|
|
|
|
|
func commTotalAgent(c *gin.Context, startDate, endDate string) []map[string]string { |
|
|
|
|
|
sql := ` |
|
|
|
|
|
SELECT |
|
|
|
|
|
SUM(agent_revenue+extra_revenue) as media_revenue |
|
|
|
|
|
FROM generate_wx_ad_data_with_agent_flow |
|
|
|
|
|
where %s |
|
|
|
|
|
` |
|
|
|
|
|
where := "uuid=" + c.GetString("mid") |
|
|
|
|
|
if startDate != "" { |
|
|
|
|
|
where += " and date>='" + startDate + "'" |
|
|
|
|
|
} |
|
|
|
|
|
if endDate != "" { |
|
|
|
|
|
where += " and date<='" + endDate + "'" |
|
|
|
|
|
} |
|
|
|
|
|
sql = fmt.Sprintf(sql, where) |
|
|
|
|
|
nativeString, _ := db.QueryNativeString(db.Db, sql) |
|
|
|
|
|
if len(nativeString) == 0 { |
|
|
|
|
|
nativeString = []map[string]string{ |
|
|
|
|
|
{ |
|
|
|
|
|
"media_revenue": "0", |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return nativeString |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func BeforeSevenPoint(c *gin.Context, req md.IndexAppListTableReq) map[string][]string { |
|
|
func BeforeSevenPoint(c *gin.Context, req md.IndexAppListTableReq) map[string][]string { |
|
|
|
|
|
|
|
|
start := utils.TimeStdParseUnix(req.StartDate + " 00:00:00") |
|
|
start := utils.TimeStdParseUnix(req.StartDate + " 00:00:00") |
|
|