huangjiajun 2 mesi fa
parent
commit
22d92ea7d5
5 ha cambiato i file con 138 aggiunte e 15 eliminazioni
  1. +25
    -0
      app/hdl/hdl_index.go
  2. +57
    -0
      app/hdl/hdl_set_center.go
  3. +7
    -0
      app/md/md_set_center.go
  4. +6
    -3
      app/router/router.go
  5. +43
    -12
      app/svc/svc_index.go

+ 25
- 0
app/hdl/hdl_index.go Vedi File

@@ -69,3 +69,28 @@ func IndexAppList(c *gin.Context) {
e.OutSuc(c, res, nil)
return
}

// IndexAppListTable
// @Summary 应用数据-每个应用的折线图
// @Tags 首页------嘉俊
// @Description 首页-应用数据-每个应用的折线图
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.IndexAppListTableReq true "请求参数"
// @Success 200 {string} "具体看返回内容 "
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/index/app/list/table [POST]
func IndexAppListTable(c *gin.Context) {
var req md.IndexAppListTableReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
res := svc.BeforeSevenPoint(c, req)
e.OutSuc(c, res, nil)
return
}

+ 57
- 0
app/hdl/hdl_set_center.go Vedi File

@@ -536,3 +536,60 @@ func GetMob(c *gin.Context) {
}, nil)
return
}

// SetLogo
// @Summary logo设置
// @Tags 设置中心-基础设置
// @Description 基础设置-logo设置
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.SetLogoReq true "请求参数"
// @Success 200 {string} "success"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/setCenter/basic/setLogo [POST]
func SetLogo(c *gin.Context) {
var req md.SetLogoReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
masterId := svc.GetMasterId(c)
engine := db.DBs[masterId]
sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
sysCfgDb.SysCfgUpdate("medium_logo", req.MediumLogo)
sysCfgDb.SysCfgUpdate("agent_logo", req.AgentLogo)
svc.ClearRedis(c, masterId, "medium_logo")
svc.ClearRedis(c, masterId, "agent_logo")
svc.ClearAllRedis(c, masterId)
e.OutSuc(c, "success", nil)
return
}

// GetLogo
// @Summary logo获取
// @Tags 设置中心-基础设置
// @Description 基础设置-logo获取
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Success 200 {object} md.SetLogoResp
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/setCenter/basic/getLogo [GET]
func GetLogo(c *gin.Context) {
masterId := svc.GetMasterId(c)
engine := db.DBs[masterId]
sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
res := sysCfgDb.SysCfgFindWithDb("medium_logo", "agent_logo")

e.OutSuc(c, md.SetLogoResp{
Data: md.SetLogoReq{
MediumLogo: res["medium_logo"],
AgentLogo: res["agent_logo"],
},
}, nil)
return
}

+ 7
- 0
app/md/md_set_center.go Vedi File

@@ -55,3 +55,10 @@ type SetMobReq struct {
type SetMobResp struct {
Data SetMobReq `json:"data"` //数据内容
}
type SetLogoReq struct {
MediumLogo string `json:"medium_logo"`
AgentLogo string `json:"agent_logo"`
}
type SetLogoResp struct {
Data SetLogoReq `json:"data"` //数据内容
}

+ 6
- 3
app/router/router.go Vedi File

@@ -79,9 +79,10 @@ func route(r *gin.RouterGroup) {
rFinancialDynamics(r.Group("/financialDynamics")) //资产动态
}
func rIndex(r *gin.RouterGroup) {
r.GET("/base", hdl.Base) //首页-基本信息
r.GET("/total", hdl.IndexTotal) //首页-统计数据
r.POST("/app/list", hdl.IndexAppList) //首页-应用数据
r.GET("/base", hdl.Base) //首页-基本信息
r.GET("/total", hdl.IndexTotal) //首页-统计数据
r.POST("/app/list", hdl.IndexAppList) //首页-应用数据
r.POST("/app/list/table", hdl.IndexAppListTable) //首页-应用数据-每个应用的折线图
}
func rRole(r *gin.RouterGroup) {
r.GET("/roleList", hdl.RoleList) //角色列表
@@ -127,6 +128,8 @@ func rSetCenter(r *gin.RouterGroup) {
rBasicSetCenter.GET("/wxOpenGet", hdl.WxOpenGet)
rBasicSetCenter.POST("/setMob", hdl.SetMob)
rBasicSetCenter.GET("/getMob", hdl.GetMob)
rBasicSetCenter.POST("/setLogo", hdl.SetLogo)
rBasicSetCenter.GET("/getLogo", hdl.GetLogo)
}
rAppletSetCenter := r.Group("/applet")
{


+ 43
- 12
app/svc/svc_index.go Vedi File

@@ -57,16 +57,46 @@ func commBili(c *gin.Context, before, after []map[string]string, types string) s
}
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 BeforeSevenPoint(c *gin.Context, req md.IndexAppListTableReq) map[string][]string {

start := utils.TimeStdParseUnix(req.StartDate + " 00:00:00")
day := (utils.TimeStdParseUnix(req.EndDate+" 00:00:00")-start)/86400 + 1
first := start - day*86400*6
dayAll := (utils.TimeStdParseUnix(req.EndDate+" 00:00:00")-first)/86400 + 1

firstTime := time.Unix(first, 0).Format("2006-01-02")
appData := make(map[string][]string)
for _, v := range req.AppId {
appData[v] = make([]string, dayAll/day+1, dayAll/day+1)
}
dateList := make(map[int]string)
j := 1
for i := 0; i < int(dayAll); i++ {
if i >= (j-1)*int(day) && i < j*int(day) {
dateList[j-1] += "," + time.Unix(first+int64(i)*86400, 0).Format("2006-01-02")
continue
}
j++
dateList[j-1] += "," + time.Unix(first+int64(i)*86400, 0).Format("2006-01-02")
}
if len(req.AppId) > 0 {
date := commTotalByDate(c, firstTime, req.EndDate, req.AppId)
for _, v := range date {
for k1, v1 := range dateList {
if strings.Contains(v1, v["date"]) {
appData[v["app_id"]][k1] = utils.Float64ToStr(utils.StrToFloat64(appData[v["app_id"]][k1]) + utils.StrToFloat64(v["media_revenue"]))
}
}
}
}
for k, v := range appData {
for k1, v1 := range v {
if v1 == "" {
appData[k][k1] = "0"
}
}
}
return appData
}

func IndexAppList(c *gin.Context, req md.IndexAppListReq) md.IndexAppListRes {
@@ -176,7 +206,7 @@ func commTotalByApp(c *gin.Context, req md.IndexAppListReq, appId []string) []ma
where += " and medium_id in(" + mediumId + ")"
}
if len(appId) > 0 {
where += " and app_id in(" + strings.Join(appId, ",") + ")"
where += " and app_id in(" + strings.Join(appId, ",") + ")"
}
if req.Sort == "" {
req.Sort = "media_revenue desc"
@@ -206,9 +236,10 @@ func commTotalByDate(c *gin.Context, startDate, endDate string, appId []string)
where += " and date<='" + endDate + "'"
}
if len(appId) > 0 {
where += " and app_id in(" + strings.Join(appId, ",") + ")"
where += " and app_id in('" + strings.Join(appId, ",") + "')"
}
sql = fmt.Sprintf(sql, where)
nativeString, _ := db.QueryNativeString(db.Db, sql)
nativeString, err := db.QueryNativeString(db.Db, sql)
fmt.Println(err)
return nativeString
}

Caricamento…
Annulla
Salva