|
@@ -57,6 +57,18 @@ func commBili(c *gin.Context, before, after []map[string]string, types string) s |
|
|
} |
|
|
} |
|
|
return bili |
|
|
return bili |
|
|
} |
|
|
} |
|
|
|
|
|
func beforeSevenPoint(c *gin.Context, req md.IndexAppListTableReq) { |
|
|
|
|
|
//start := utils.TimeStdParseUnix(req.StartDate + " 00:00:00") |
|
|
|
|
|
//day := (utils.TimeStdParseUnix(req.EndDate+" 00:00:00") - start) / 86400 |
|
|
|
|
|
//firstTime := time.Unix(start-1-day*86400*7, 0).Format("2006-01-02") |
|
|
|
|
|
//list := make([]map[string]interface{}, 0) |
|
|
|
|
|
//if len(req.AppId) > 0 { |
|
|
|
|
|
// commTotalByDate(c, firstTime, req.EndDate, req.AppId) |
|
|
|
|
|
//} |
|
|
|
|
|
//{Name: "广告预估收益", Type: "media_revenue", Bili: commBili(c, dataLastMap[v["app_id"]], tmpList, "media_revenue"), Value: utils.Float64ToStr(utils.StrToFloat64(v["media_revenue"]) / 100)}, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func IndexAppList(c *gin.Context, req md.IndexAppListReq) md.IndexAppListRes { |
|
|
func IndexAppList(c *gin.Context, req md.IndexAppListReq) md.IndexAppListRes { |
|
|
appId := make([]string, 0) |
|
|
appId := make([]string, 0) |
|
|
data := commTotalByApp(c, req, appId) |
|
|
data := commTotalByApp(c, req, appId) |
|
@@ -101,7 +113,8 @@ func IndexAppList(c *gin.Context, req md.IndexAppListReq) md.IndexAppListRes { |
|
|
list = append(list, tmp) |
|
|
list = append(list, tmp) |
|
|
} |
|
|
} |
|
|
res := md.IndexAppListRes{ |
|
|
res := md.IndexAppListRes{ |
|
|
List: list, |
|
|
|
|
|
|
|
|
List: list, |
|
|
|
|
|
AppId: appId, |
|
|
Sort: []md.SelectData{ |
|
|
Sort: []md.SelectData{ |
|
|
{Name: "按收益最高", Value: "media_revenue desc"}, |
|
|
{Name: "按收益最高", Value: "media_revenue desc"}, |
|
|
{Name: "按ECPM最高", Value: "ecpm desc"}, |
|
|
{Name: "按ECPM最高", Value: "ecpm desc"}, |
|
@@ -172,3 +185,30 @@ func commTotalByApp(c *gin.Context, req md.IndexAppListReq, appId []string) []ma |
|
|
nativeString, _ := db.QueryNativeString(db.Db, sql) |
|
|
nativeString, _ := db.QueryNativeString(db.Db, sql) |
|
|
return nativeString |
|
|
return nativeString |
|
|
} |
|
|
} |
|
|
|
|
|
func commTotalByDate(c *gin.Context, startDate, endDate string, appId []string) []map[string]string { |
|
|
|
|
|
sql := ` |
|
|
|
|
|
SELECT |
|
|
|
|
|
app_id as app_id, |
|
|
|
|
|
date as date, |
|
|
|
|
|
SUM(exposure_count) as exposure_count, |
|
|
|
|
|
SUM(click_count) as click_count, |
|
|
|
|
|
SUM(click_count)/SUM(exposure_count)*100 as click_rate, |
|
|
|
|
|
SUM(ecpm) as ecpm, |
|
|
|
|
|
SUM(media_revenue) as media_revenue |
|
|
|
|
|
FROM generate_wx_ad_data |
|
|
|
|
|
where %s group by date,app_id |
|
|
|
|
|
` |
|
|
|
|
|
where := "uuid=" + c.GetString("mid") |
|
|
|
|
|
if startDate != "" { |
|
|
|
|
|
where += " and date>='" + startDate + "'" |
|
|
|
|
|
} |
|
|
|
|
|
if endDate != "" { |
|
|
|
|
|
where += " and date<='" + endDate + "'" |
|
|
|
|
|
} |
|
|
|
|
|
if len(appId) > 0 { |
|
|
|
|
|
where += " and app_id in(" + strings.Join(appId, ",") + ")" |
|
|
|
|
|
} |
|
|
|
|
|
sql = fmt.Sprintf(sql, where) |
|
|
|
|
|
nativeString, _ := db.QueryNativeString(db.Db, sql) |
|
|
|
|
|
return nativeString |
|
|
|
|
|
} |