|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- package svc
-
- import (
- "applet/app/md"
- "applet/app/utils"
- db "code.fnuoos.com/zhimeng/model.git/src"
- "code.fnuoos.com/zhimeng/model.git/src/super/implement"
- "github.com/gin-gonic/gin"
- )
-
- func DataCenterOriginalDataList(c *gin.Context, req md.DataCenterOriginalDataReq) md.DataCenterOriginalDataRes {
- engine := db.Db
- NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine)
- appId := GetAppletId(c, req.Name, req.Platform)
- slotId := GetSlotId(c, req.State)
- MediumList, total, _ := NewOriginalWxAdDataDb.FindOriginalWxAdDataList("", appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
- data := make([]md.DataCenterOriginalDataData, 0)
- if len(MediumList) > 0 {
- for _, v := range MediumList {
- var tmp = md.DataCenterOriginalDataData{
- Id: utils.IntToStr(v.Id),
- ReqSuccCount: utils.IntToStr(v.ReqSuccCount),
- ExposureCount: utils.IntToStr(v.ExposureCount),
- ExposureRate: v.ExposureRate,
- ClickCount: utils.IntToStr(v.ClickCount),
- ClickRate: v.ClickRate,
- Date: v.Date,
- PublisherIncome: utils.Float64ToStr(float64(v.PublisherIncome) / 100),
- Ecpm: utils.Float64ToStr(utils.StrToFloat64(v.Ecpm) / 100),
- IsApply: utils.IntToStr(v.IsApply),
- }
- tmpApplet := GetAppletInfo(c, v.AppId)
- if tmpApplet["platform"] != "" {
- tmp.Platform = tmpApplet["platform"]
- }
- if tmpApplet["name"] != "" {
- tmp.Name = tmpApplet["name"]
- }
- tmpSlot := GetSlotInfo(c, v.SlotId)
- if tmpSlot["state"] != "" {
- tmp.State = tmpSlot["state"]
- }
- if tmpSlot["name"] != "" {
- tmp.AdvName = tmpSlot["name"]
- }
- data = append(data, tmp)
- }
- }
- res := md.DataCenterOriginalDataRes{
- List: data,
- Total: total,
- State: md.AdState,
- Platform: md.AdPlatform,
- }
- return res
- }
-
- // 应用
- func GetAppletId(c *gin.Context, name, platform string) string {
- mediumId := ""
- // sess := MasterDb(c).Where("1=1")
- // if name != "" || platform != "" {
- // ids := []string{"-1"}
- // var tmp []model2.AppletApplication
- // if name != "" {
- // sess.And("name like ? ", "%"+name+"%")
- // }
- // if platform != "" {
- // sess.And("platform = ? ", platform)
- // }
- // sess.Find(&tmp)
- // for _, v := range tmp {
- // ids = append(ids, utils.IntToStr(v.MediumId))
- // }
- // mediumId = strings.Join(ids, ",")
- // }
- return mediumId
- }
-
- // 广告位
- func GetSlotId(c *gin.Context, state string) string {
- mediumId := ""
- // if state != "" {
- // ids := []string{"-1"}
- // var tmp []model2.AppletApplicationAdSpaceList
- // MasterDb(c).Where("state=?", state).Find(&tmp)
- // for _, v := range tmp {
- // ids = append(ids, utils.IntToStr(v.MediumId))
- // }
- // mediumId = strings.Join(ids, ",")
- // }
- return mediumId
- }
-
- // 应用
- func GetAppletInfo(c *gin.Context, id string) map[string]string {
- var res = map[string]string{
- "platform": "",
- "name": "",
- }
- // NewAppletApplicationDb := implement2.NewAppletApplicationDb(MasterDb(c))
- // data, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(id)
- // if data != nil {
- // res["platform"] = data.Platform
- // res["name"] = data.Name
- // }
- return res
- }
-
- // 广告位
- func GetSlotInfo(c *gin.Context, id string) map[string]string {
- var res = map[string]string{
- "state": "",
- "name": "",
- }
- // NewAppletApplicationAdSpaceListDb := implement2.NewAppletApplicationAdSpaceListDb(MasterDb(c))
- // data, _ := NewAppletApplicationAdSpaceListDb.GetAppletApplicationAdSpaceListByAdId(id)
- // if data != nil {
- // res["name"] = data.Name
- // res["state"] = utils.IntToStr(data.State)
- // }
- return res
- }
|