Browse Source

更新

master
huangjiajun 1 month ago
parent
commit
4347c7cfda
4 changed files with 68 additions and 3 deletions
  1. +7
    -0
      app/hdl/hdl_set_center.go
  2. +8
    -2
      app/md/md_index.go
  3. +41
    -1
      app/svc/svc_index.go
  4. +12
    -0
      app/svc/svc_redis.go

+ 7
- 0
app/hdl/hdl_set_center.go View File

@@ -45,6 +45,11 @@ func SetOss(c *gin.Context) {
sysCfgDb.SysCfgUpdate(enum.FileBucketHost, req.FileBucketHost) sysCfgDb.SysCfgUpdate(enum.FileBucketHost, req.FileBucketHost)
sysCfgDb.SysCfgUpdate(enum.FileBucketRegion, req.FileBucketRegion) sysCfgDb.SysCfgUpdate(enum.FileBucketRegion, req.FileBucketRegion)
sysCfgDb.SysCfgUpdate(enum.FileBucket, req.FileBucket) sysCfgDb.SysCfgUpdate(enum.FileBucket, req.FileBucket)
svc.ClearRedis(c, enum.FileAccessKey)
svc.ClearRedis(c, enum.FileSecretKey)
svc.ClearRedis(c, enum.FileBucketHost)
svc.ClearRedis(c, enum.FileBucketRegion)
svc.ClearRedis(c, enum.FileBucket)
e.OutSuc(c, "success", nil) e.OutSuc(c, "success", nil)
return return
} }
@@ -495,6 +500,8 @@ func SetMob(c *gin.Context) {
sysCfgDb := implement2.NewSysCfgDb(engine, masterId) sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
sysCfgDb.SysCfgUpdate("mob_app_key", req.MobAppKey) sysCfgDb.SysCfgUpdate("mob_app_key", req.MobAppKey)
sysCfgDb.SysCfgUpdate("mob_app_secret", req.MobAppSecret) sysCfgDb.SysCfgUpdate("mob_app_secret", req.MobAppSecret)
svc.ClearRedis(c, "mob_app_key")
svc.ClearRedis(c, "mob_app_secret")
e.OutSuc(c, "success", nil) e.OutSuc(c, "success", nil)
return return
} }


+ 8
- 2
app/md/md_index.go View File

@@ -6,9 +6,15 @@ type IndexAppListReq struct {
Sort string `json:"sort" example:"排序"` Sort string `json:"sort" example:"排序"`
Name string `json:"name" ` Name string `json:"name" `
} }
type IndexAppListTableReq struct {
StartDate string `json:"start_date" example:"2024-08-30"`
EndDate string `json:"end_date" example:"2024-08-30"`
AppId []string `json:"app_id"`
}
type IndexAppListRes struct { type IndexAppListRes struct {
List []IndexAppListData `json:"list" `
Sort []SelectData `json:"sort"`
List []IndexAppListData `json:"list" `
Sort []SelectData `json:"sort"`
AppId []string `json:"app_id"`
} }


type IndexAppListData struct { type IndexAppListData struct {


+ 41
- 1
app/svc/svc_index.go View File

@@ -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
}

+ 12
- 0
app/svc/svc_redis.go View File

@@ -0,0 +1,12 @@
package svc

import (
"applet/app/utils/cache"
"fmt"
"github.com/gin-gonic/gin"
)

func ClearRedis(c *gin.Context, key string) {
key1 := fmt.Sprintf("%s:cfg_cache:%s", c.GetString("mid"), key)
cache.Del(key1)
}

Loading…
Cancel
Save