|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640 |
- package svc
-
- import (
- "applet/app/e"
- "applet/app/enum"
- "applet/app/md"
- "applet/app/utils"
- md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
- db "code.fnuoos.com/zhimeng/model.git/src"
- "code.fnuoos.com/zhimeng/model.git/src/implement"
- model2 "code.fnuoos.com/zhimeng/model.git/src/model"
- "fmt"
- "github.com/gin-gonic/gin"
- "github.com/jinzhu/copier"
- "strings"
- )
-
- func DataCenterRecordTotal(c *gin.Context, req md.DataCenterTableReq) md.DataCenterTotalData {
- appId := GetAppletId(c, req.AppId, req.Platform)
- sql := `
- SELECT
- 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
- `
- mediumId := GetAgentMediumId(c)
- where := "uuid=" + c.GetString("mid") + " and medium_id in(" + mediumId + ")"
- if req.AppId != "" || req.Platform != "" {
- where += " and app_id in(" + appId + ")"
- }
- if req.AdType != "" {
- where += " and ad_slot='" + req.AdType + "'"
- }
- if req.StartDate != "" {
- where += " and date>='" + req.StartDate + "'"
- }
- if req.EndDate != "" {
- where += " and date<='" + req.EndDate + "'"
- }
- sql = fmt.Sprintf(sql, where)
- nativeString, _ := db.QueryNativeString(db.Db, sql)
- res := md.DataCenterTotalData{}
- for _, v := range nativeString {
- res = md.DataCenterTotalData{
- Date: "-",
- AppName: "-",
- PlatformName: "-",
- AdvName: "-",
- ExposureCount: v["exposure_count"],
- MediaRevenue: utils.Float64ToStr(utils.StrToFloat64(v["media_revenue"]) / 100),
- Ecpm: utils.Float64ToStr(utils.StrToFloat64(v["ecpm"]) / 100),
- ClickRate: utils.GetPrec(v["click_rate"], "2") + "%",
- ClickCount: v["click_count"],
- }
- }
- return res
- }
- func DataCenterRecordList(c *gin.Context, req md.DataCenterRecordReq) md.DataCenterRecordRes {
- nativeString, total := comm(c, 1, req)
- list := make([]md.DataCenterTotalData, 0)
- for _, v := range nativeString {
- NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c))
- app, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(v["app_id"])
- platform := ""
- name := ""
- if app != nil {
- name = app.Name
- platform = app.Platform
- }
- NewAppletApplicationAdSpaceListDb := implement.NewAppletApplicationAdSpaceListDb(MasterDb(c))
- adData, _ := NewAppletApplicationAdSpaceListDb.GetAppletApplicationAdSpaceListByAdId(v["slot_id"])
- adName := enum.AdunitType(v["ad_slot"]).String()
- if adData != nil {
- adName = adData.Name
- }
- tmp := md.DataCenterTotalData{
- Date: v["date"],
- AppName: name,
- PlatformName: md.AppletPlatformMap[platform],
- AdvName: adName,
- ExposureCount: v["exposure_count"],
- MediaRevenue: utils.Float64ToStr(utils.StrToFloat64(v["media_revenue"]) / 100),
- Ecpm: utils.Float64ToStr(utils.StrToFloat64(v["ecpm"]) / 100),
- ClickRate: v["click_rate"] + "%",
- ClickCount: v["click_count"],
- }
- list = append(list, tmp)
- }
- res := md.DataCenterRecordRes{
- List: list,
- Total: total,
- }
- return res
- }
- func DataCenterRecordOutPut(c *gin.Context, req md.DataCenterRecordOutPutReq) {
- var req1 md.DataCenterRecordReq
- copier.Copy(&req1, &req)
- req.Limit = "10000"
- nativeString, _ := comm(c, 0, req1)
- appId := make([]string, 0)
- adId := make([]string, 0)
- for _, v := range nativeString {
- appId = append(appId, v["app_id"])
- adId = append(adId, v["slot_id"])
- }
- var app []model2.AppletApplication
- appMap := make(map[string]model2.AppletApplication)
- MasterDb(c).In("app_id=?", appId).Find(&app)
- for _, v := range app {
- appMap[v.AppId] = v
- }
- var ad []model2.AppletApplicationAdSpaceList
- adMap := make(map[string]model2.AppletApplicationAdSpaceList)
- MasterDb(c).In("ad_id=?", adId).Find(&adMap)
- for _, v := range ad {
- adMap[v.AdId] = v
- }
- name := req.StartDate + "~" + req.EndDate + "(第" + req.Page + "页 " + utils.IntToStr(len(nativeString)) + "条)"
- //写入数据
- data := map[string]string{
- "A1": "日期",
- "B1": "应用名称",
- "C1": "平台类型",
- "D1": "广告位",
- "E1": "曝光量",
- "F1": "点击量",
- "G1": "ECPM",
- "H1": "预估收益",
- }
- for k, v := range nativeString {
- i := utils.IntToStr(k + 2)
- data["A"+i] = v["date"]
- data["B"+i] = appMap[v["app_id"]].Name
- data["C"+i] = md.AppletPlatformMap[appMap[v["app_id"]].Platform]
- data["D"+i] = adMap[v["slot_id"]].Name
- data["E"+i] = v["exposure_count"]
- data["F"+i] = v["click_count"]
- data["G"+i] = utils.Float64ToStr(utils.StrToFloat64(v["ecpm"]) / 100)
- data["H"+i] = utils.Float64ToStr(utils.StrToFloat64(v["media_revenue"]) / 100)
- }
-
- file := utils.Output(c, name, data)
- filename := name + ".xlsx"
- r := map[string]string{
- "file": file,
- "filename": filename,
- }
- e.OutSuc(c, r, nil)
- return
- }
- func DataCenterCommissionRecordTotal(c *gin.Context, req md.DataCenterTableReq) md.DataCenterCommissionTotalData {
- appId := GetAppletId(c, req.AppId, req.Platform)
- sql := `
- SELECT
- 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
- `
- mediumId := GetAgentMediumId(c)
- where := "uuid=" + c.GetString("mid")
- if req.AppId != "" || req.Platform != "" {
- where += " and app_id in(" + appId + ")"
- }
- if req.AdType != "" {
- where += " and ad_slot='" + req.AdType + "'"
- }
- if req.StartDate != "" {
- where += " and date>='" + req.StartDate + "'"
- }
- if req.EndDate != "" {
- where += " and date<='" + req.EndDate + "'"
- }
- whereMedium := where + " and medium_id in(" + mediumId + ")"
- sql = fmt.Sprintf(sql, whereMedium)
- nativeString, _ := db.QueryNativeString(db.Db, sql)
- res := md.DataCenterCommissionTotalData{}
- for _, v := range nativeString {
- res = md.DataCenterCommissionTotalData{
- Date: "-",
- AppName: "-",
- PlatformName: "-",
- AdvName: "-",
- ExposureCount: v["exposure_count"],
- Ecpm: utils.Float64ToStr(utils.StrToFloat64(v["ecpm"]) / 100),
- ClickRate: utils.GetPrec(v["click_rate"], "2") + "%",
- ClickCount: v["click_count"],
- AllCommission: "0",
- OtherCommission: "0",
- Commission: "0",
- }
- }
- sqlAgent := `
- SELECT
- SUM(agent_revenue) as agent_revenue,
- SUM(extra_revenue) as extra_revenue
- FROM generate_wx_ad_data_with_agent_flow
- where %s
- `
- user := GetUser(c)
- whereAgent := where + " and agent_id=" + utils.IntToStr(user.AgentId)
- sqlAgent = fmt.Sprintf(sqlAgent, whereAgent)
- nativeStringAgent, _ := db.QueryNativeString(db.Db, sqlAgent)
- for _, v := range nativeStringAgent {
- res.Commission = utils.Float64ToStr(utils.StrToFloat64(v["agent_revenue"]) / 100)
- res.OtherCommission = utils.Float64ToStr(utils.StrToFloat64(v["extra_revenue"]) / 100)
- res.AllCommission = utils.Float64ToStr(utils.StrToFloat64(res.Commission) + utils.StrToFloat64(res.OtherCommission))
- }
- return res
- }
- func DataCenterCommissionRecordList(c *gin.Context, req md.DataCenterRecordReq) md.DataCenterCommissionRecordRes {
- nativeString, total := commAgent(c, 1, req)
- list := make([]md.DataCenterCommissionTotalData, 0)
-
- for _, v := range nativeString {
- NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c))
- app, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(v["app_id"])
- platform := ""
- name := ""
- if app != nil {
- name = app.Name
- platform = app.Platform
- }
- NewAppletApplicationAdSpaceListDb := implement.NewAppletApplicationAdSpaceListDb(MasterDb(c))
- adData, _ := NewAppletApplicationAdSpaceListDb.GetAppletApplicationAdSpaceListByAdId(v["slot_id"])
- adName := enum.AdunitType(v["ad_slot"]).String()
- if adData != nil {
- adName = adData.Name
- }
- tmp := md.DataCenterCommissionTotalData{
- Date: v["date"],
- AppName: name,
- PlatformName: md.AppletPlatformMap[platform],
- AdvName: adName,
- ExposureCount: v["exposure_count"],
- Ecpm: utils.Float64ToStr(utils.StrToFloat64(v["ecpm"]) / 100),
- ClickRate: v["click_rate"] + "%",
- ClickCount: v["click_count"],
- AllCommission: v["all_commission"],
- OtherCommission: v["other_commission"],
- Commission: v["commission"],
- }
- list = append(list, tmp)
- }
- res := md.DataCenterCommissionRecordRes{
- List: list,
- Total: total,
- }
- return res
- }
- func DataCenterCommissionRecordOutPut(c *gin.Context, req md.DataCenterRecordOutPutReq) {
- var req1 md.DataCenterRecordReq
- copier.Copy(&req1, &req)
- req.Limit = "10000"
- nativeString, _ := commAgent(c, 0, req1)
- appId := make([]string, 0)
- adId := make([]string, 0)
- for _, v := range nativeString {
- appId = append(appId, v["app_id"])
- adId = append(adId, v["slot_id"])
- }
- var app []model2.AppletApplication
- appMap := make(map[string]model2.AppletApplication)
- MasterDb(c).In("app_id=?", appId).Find(&app)
- for _, v := range app {
- appMap[v.AppId] = v
- }
- var ad []model2.AppletApplicationAdSpaceList
- adMap := make(map[string]model2.AppletApplicationAdSpaceList)
- MasterDb(c).In("ad_id=?", adId).Find(&adMap)
- for _, v := range ad {
- adMap[v.AdId] = v
- }
- name := req.StartDate + "~" + req.EndDate + "(第" + req.Page + "页 " + utils.IntToStr(len(nativeString)) + "条)"
- //写入数据
- data := map[string]string{
- "A1": "日期",
- "B1": "应用名称",
- "C1": "平台类型",
- "D1": "广告位",
- "E1": "曝光量",
- "F1": "点击量",
- "G1": "ECPM",
- "H1": "预估佣金",
- "I1": "额外奖励",
- "J1": "预估总收益",
- }
- for k, v := range nativeString {
- i := utils.IntToStr(k + 2)
- data["A"+i] = v["date"]
- data["B"+i] = appMap[v["app_id"]].Name
- data["C"+i] = md.AppletPlatformMap[appMap[v["app_id"]].Platform]
- data["D"+i] = adMap[v["slot_id"]].Name
- data["E"+i] = v["exposure_count"]
- data["F"+i] = v["click_count"]
- data["G"+i] = utils.Float64ToStr(utils.StrToFloat64(v["ecpm"]) / 100)
- data["H"+i] = v["commission"]
- data["I"+i] = v["other_commission"]
- data["J"+i] = v["all_commission"]
- }
-
- file := utils.Output(c, name, data)
- filename := name + ".xlsx"
- r := map[string]string{
- "file": file,
- "filename": filename,
- }
- e.OutSuc(c, r, nil)
- return
- }
- func DataCenterProfitRecordOutPut(c *gin.Context, req md.DataCenterProfitRecordOutPutReq) {
- var req1 md.DataCenterProfitRecordReq
- copier.Copy(&req1, &req)
- req.Limit = "10000"
- nativeString, _ := commAgentProfit(c, 0, req1)
- appId := make([]string, 0)
- for _, v := range nativeString {
- appId = append(appId, v["app_id"])
- }
- var app []model2.AppletApplication
- appMap := make(map[string]model2.AppletApplication)
- MasterDb(c).In("app_id=?", appId).Find(&app)
- for _, v := range app {
- appMap[v.AppId] = v
- }
-
- name := req.StartDate + "~" + req.EndDate + "(第" + req.Page + "页 " + utils.IntToStr(len(nativeString)) + "条)"
- //写入数据
- data := map[string]string{
- "A1": "日期",
- "B1": "应用名称",
- "C1": "平台类型",
- "D1": "预估佣金",
- "E1": "额外奖励",
- "F1": "预估总收益",
- }
- for k, v := range nativeString {
- i := utils.IntToStr(k + 2)
- data["A"+i] = v["date"]
- data["B"+i] = appMap[v["app_id"]].Name
- data["C"+i] = md.AppletPlatformMap[appMap[v["app_id"]].Platform]
- data["D"+i] = v["commission"]
- data["E"+i] = v["other_commission"]
- data["F"+i] = v["all_commission"]
- }
-
- file := utils.Output(c, name, data)
- filename := name + ".xlsx"
- r := map[string]string{
- "file": file,
- "filename": filename,
- }
- e.OutSuc(c, r, nil)
- return
- }
- func DataCenterProfitRecordList(c *gin.Context, req md.DataCenterProfitRecordReq) md.DataCenterProfitRecordRes {
- data, total := commAgentProfit(c, 1, req)
- list := make([]md.DataCenterProfitRecordData, 0)
- for _, v := range data {
- NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c))
- app, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(v["app_id"])
- platform := ""
- name := ""
- if app != nil {
- name = app.Name
- platform = app.Platform
- }
- tmp := md.DataCenterProfitRecordData{
- Date: v["date"],
- AppName: name,
- PlatformName: md2.PlatformMap[platform],
- Commission: utils.Float64ToStr(utils.StrToFloat64(v["agent_revenue"]) / 100),
- OtherCommission: utils.Float64ToStr(utils.StrToFloat64(v["extra_revenue"]) / 100),
- }
- tmp.AllCommission = utils.Float64ToStr(utils.StrToFloat64(tmp.Commission) + utils.StrToFloat64(tmp.OtherCommission))
- list = append(list, tmp)
- }
- res := md.DataCenterProfitRecordRes{
- List: list,
- Total: total,
- }
- return res
- }
-
- func comm(c *gin.Context, isTotal int, req md.DataCenterRecordReq) ([]map[string]string, int64) {
- appId := GetAppletId(c, req.AppId, req.Platform)
- sql := `
- SELECT
- %s
- FROM generate_wx_ad_data
- where %s %s
- `
- mediumId := GetAgentMediumId(c)
- where := "uuid=" + c.GetString("mid") + " and medium_id in(" + mediumId + ")"
- if req.AppId != "" || req.Platform != "" {
- where += " and app_id in(" + appId + ")"
- }
- if req.AdType != "" {
- where += " and ad_slot='" + req.AdType + "'"
- }
- if req.StartDate != "" {
- where += " and date>='" + req.StartDate + "'"
- }
- if req.EndDate != "" {
- where += " and date<='" + req.EndDate + "'"
- }
- field := `*`
- start := (utils.StrToInt(req.Page) - 1) * utils.StrToInt(req.Limit)
- groupBy := " order by date desc,id desc"
- if req.Page != "" {
- groupBy += " limit " + utils.IntToStr(start) + "," + req.Limit
- } else {
- groupBy = " order by date asc,id asc"
- }
-
- sql1 := fmt.Sprintf(sql, field, where, groupBy)
- nativeString, _ := db.QueryNativeString(db.Db, sql1)
-
- var total int64 = 0
- if isTotal == 1 {
- sqlTotal := fmt.Sprintf(sql, "COUNT(*) as count ", where, "")
- nativeStringTotal, _ := db.QueryNativeString(db.Db, sqlTotal)
- for _, v := range nativeStringTotal {
- total = utils.StrToInt64(v["count"])
- }
- }
- return nativeString, total
- }
- func commAgentProfit(c *gin.Context, isTotal int, req md.DataCenterProfitRecordReq) ([]map[string]string, int64) {
- appId := GetAppletId(c, req.AppId, req.Platform)
- sql := `
- SELECT
- %s
- FROM generate_wx_ad_data_with_agent_flow
- where %s %s
- `
- user := GetUser(c)
- where := "uuid=" + c.GetString("mid") + " and agent_id =" + utils.IntToStr(user.AgentId)
- if req.AppId != "" || req.Platform != "" {
- where += " and app_id in(" + appId + ")"
- }
- if req.StartDate != "" {
- where += " and date>='" + req.StartDate + "'"
- }
- if req.EndDate != "" {
- where += " and date<='" + req.EndDate + "'"
- }
- field := `%s,app_id,SUM(agent_revenue) as agent_revenue,SUM(extra_revenue) as extra_revenue`
- start := (utils.StrToInt(req.Page) - 1) * utils.StrToInt(req.Limit)
- groupBy := " group by %s,app_id order by date desc,id desc"
- if req.Page != "" {
- groupBy += " limit " + utils.IntToStr(start) + "," + req.Limit
- } else {
- groupBy = " group by %s,app_id order by date asc,id asc"
- }
- timeStr := "date"
- if req.Type == "1" {
- timeStr = "DATE_FORMAT(date, '%Y-%m')"
- }
- if req.Type == "2" {
- timeStr = "DATE_FORMAT(date, '%Y')"
- }
- field = fmt.Sprintf(field, timeStr)
- groupBy = fmt.Sprintf(groupBy, timeStr+" as date")
-
- sql1 := fmt.Sprintf(sql, field, where, groupBy)
- nativeString, _ := db.QueryNativeString(db.Db, sql1)
- var total int64 = 0
- if isTotal == 1 {
- sqlTotal := fmt.Sprintf(sql, field, where, "")
- sqlTotal1 := `select COUNT(*) as count from (%s) as tmp`
- sqlTotal1 = fmt.Sprintf(sqlTotal1, sqlTotal)
- nativeStringTotal, _ := db.QueryNativeString(db.Db, sqlTotal1)
- for _, v := range nativeStringTotal {
- total = utils.StrToInt64(v["count"])
- }
- }
- return nativeString, total
- }
-
- func commAgent(c *gin.Context, isTotal int, req md.DataCenterRecordReq) ([]map[string]string, int64) {
- appId := GetAppletId(c, req.AppId, req.Platform)
- sql := `
- SELECT
- %s
- FROM generate_wx_ad_data
- where %s %s
- `
- mediumId := GetAgentMediumId(c)
- where := "uuid=" + c.GetString("mid") + " and medium_id in(" + mediumId + ")"
- if req.AppId != "" || req.Platform != "" {
- where += " and app_id in(" + appId + ")"
- }
- if req.AdType != "" {
- where += " and ad_slot='" + req.AdType + "'"
- }
- if req.StartDate != "" {
- where += " and date>='" + req.StartDate + "'"
- }
- if req.EndDate != "" {
- where += " and date<='" + req.EndDate + "'"
- }
- field := `*`
- start := (utils.StrToInt(req.Page) - 1) * utils.StrToInt(req.Limit)
- groupBy := " order by date desc,id desc"
- if req.Page != "" {
- groupBy += " limit " + utils.IntToStr(start) + "," + req.Limit
- } else {
- groupBy = " order by date asc,id asc"
- }
-
- sql1 := fmt.Sprintf(sql, field, where, groupBy)
- nativeString, _ := db.QueryNativeString(db.Db, sql1)
-
- var total int64 = 0
- if isTotal == 1 {
- sqlTotal := fmt.Sprintf(sql, "COUNT(*) as count ", where, "")
- nativeStringTotal, _ := db.QueryNativeString(db.Db, sqlTotal)
- for _, v := range nativeStringTotal {
- total = utils.StrToInt64(v["count"])
- }
- }
- var ids []string
- for _, v := range nativeString {
- ids = append(ids, v["id"])
- }
- if len(ids) > 0 {
- sqlAgent := `
- SELECT
- SUM(agent_revenue) as agent_revenue,
- SUM(extra_revenue) as extra_revenue
- FROM generate_wx_ad_data_with_agent_flow
- where %s
- `
- user := GetUser(c)
- whereAgent := "original_data_id in(" + strings.Join(ids, ",") + ") and agent_id=" + utils.IntToStr(user.AgentId)
- sqlAgent = fmt.Sprintf(sqlAgent, whereAgent)
- nativeStringAgent, _ := db.QueryNativeString(db.Db, sqlAgent)
- agentMap := make(map[string]map[string]string)
- for _, v := range nativeStringAgent {
- _, ok := agentMap[v["uid"]]
- if ok == false {
- agentMap[v["uid"]] = make(map[string]string)
- }
- agentMap[v["uid"]] = v
- }
- for k, v := range nativeString {
- _, ok := agentMap[v["uid"]]
- if ok {
- nativeString[k]["commission"] = utils.Float64ToStr(utils.StrToFloat64(v["agent_revenue"]) / 100)
- nativeString[k]["other_commission"] = utils.Float64ToStr(utils.StrToFloat64(v["extra_revenue"]) / 100)
- nativeString[k]["all_commission"] = utils.Float64ToStr(utils.StrToFloat64(nativeString[k]["commission"]) + utils.StrToFloat64(nativeString[k]["other_commission"]))
- } else {
- nativeString[k]["commission"] = "0"
- nativeString[k]["other_commission"] = "0"
- nativeString[k]["all_commission"] = "0"
- }
- }
- }
- return nativeString, total
- }
- func DataCenterSelectData(c *gin.Context) {
- NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c))
- appList, _ := NewAppletApplicationDb.FindAllAppletApplicationList()
- appMap := make(map[string][]map[string]interface{})
- mediumId := GetAgentMediumId(c)
- for _, v := range appList {
- if strings.Contains(","+mediumId+",", ","+utils.IntToStr(v.MediumId)+",") == false {
- continue
- }
- _, ok := appMap[v.Platform]
- if ok == false {
- appMap[v.Platform] = make([]map[string]interface{}, 0)
- }
- tmp := map[string]interface{}{
- "name": v.Name,
- "app_id": v.AppId,
- "ad_type": enum.AdTypeList,
- }
- appMap[v.Platform] = append(appMap[v.Platform], tmp)
- }
- platform := []map[string]interface{}{
- {
- "name": "微信小程序",
- "platform": "wx_applet",
- "app_list": appMap["wx_applet"],
- },
- }
- e.OutSuc(c, platform, nil)
- return
- }
-
- // 应用
- func GetAppletId(c *gin.Context, appId, platform string) string {
- mediumId := ""
- sess := MasterDb(c).Where("1=1")
- var ids = make([]string, 0)
- if appId != "" || platform != "" {
- ids = append(ids, "-1")
- }
- if platform != "" {
- var tmp []model2.AppletApplication
- if platform != "" {
- sess.And("platform = ? ", platform)
- }
- sess.Find(&tmp)
- for _, v := range tmp {
- ids = append(ids, utils.IntToStr(v.MediumId))
- }
- }
- if appId != "" {
- ids = []string{appId}
- }
- if appId != "" || platform != "" {
- mediumId = strings.Join(ids, ",")
- }
- return mediumId
- }
- func GetAppletInfo(c *gin.Context, id string) map[string]string {
- var res = map[string]string{
- "platform": "",
- "name": "",
- "logo": "",
- }
- NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c))
- data, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(id)
- if data != nil {
- res["platform"] = data.Platform
- res["name"] = data.Name
- res["logo"] = data.Logo
- }
- return res
- }
|