广告平台(总站长使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
3.6 KiB

  1. package svc
  2. import (
  3. "applet/app/md"
  4. "applet/app/utils"
  5. db "code.fnuoos.com/zhimeng/model.git/src"
  6. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  7. "github.com/gin-gonic/gin"
  8. )
  9. func DataCenterOriginalDataList(c *gin.Context, req md.DataCenterOriginalDataReq) md.DataCenterOriginalDataRes {
  10. engine := db.Db
  11. NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine)
  12. appId := GetAppletId(c, req.Name, req.Platform)
  13. slotId := GetSlotId(c, req.State)
  14. MediumList, total, _ := NewOriginalWxAdDataDb.FindOriginalWxAdDataList("", appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  15. data := make([]md.DataCenterOriginalDataData, 0)
  16. if len(MediumList) > 0 {
  17. for _, v := range MediumList {
  18. var tmp = md.DataCenterOriginalDataData{
  19. Id: utils.IntToStr(v.Id),
  20. ReqSuccCount: utils.IntToStr(v.ReqSuccCount),
  21. ExposureCount: utils.IntToStr(v.ExposureCount),
  22. ExposureRate: v.ExposureRate,
  23. ClickCount: utils.IntToStr(v.ClickCount),
  24. ClickRate: v.ClickRate,
  25. Date: v.Date,
  26. PublisherIncome: utils.Float64ToStr(float64(v.PublisherIncome) / 100),
  27. Ecpm: utils.Float64ToStr(utils.StrToFloat64(v.Ecpm) / 100),
  28. IsApply: utils.IntToStr(v.IsApply),
  29. }
  30. tmpApplet := GetAppletInfo(c, v.AppId)
  31. if tmpApplet["platform"] != "" {
  32. tmp.Platform = tmpApplet["platform"]
  33. }
  34. if tmpApplet["name"] != "" {
  35. tmp.Name = tmpApplet["name"]
  36. }
  37. tmpSlot := GetSlotInfo(c, v.SlotId)
  38. if tmpSlot["state"] != "" {
  39. tmp.State = tmpSlot["state"]
  40. }
  41. if tmpSlot["name"] != "" {
  42. tmp.AdvName = tmpSlot["name"]
  43. }
  44. data = append(data, tmp)
  45. }
  46. }
  47. res := md.DataCenterOriginalDataRes{
  48. List: data,
  49. Total: total,
  50. State: md.AdState,
  51. Platform: md.AdPlatform,
  52. }
  53. return res
  54. }
  55. // 应用
  56. func GetAppletId(c *gin.Context, name, platform string) string {
  57. mediumId := ""
  58. // sess := MasterDb(c).Where("1=1")
  59. // if name != "" || platform != "" {
  60. // ids := []string{"-1"}
  61. // var tmp []model2.AppletApplication
  62. // if name != "" {
  63. // sess.And("name like ? ", "%"+name+"%")
  64. // }
  65. // if platform != "" {
  66. // sess.And("platform = ? ", platform)
  67. // }
  68. // sess.Find(&tmp)
  69. // for _, v := range tmp {
  70. // ids = append(ids, utils.IntToStr(v.MediumId))
  71. // }
  72. // mediumId = strings.Join(ids, ",")
  73. // }
  74. return mediumId
  75. }
  76. // 广告位
  77. func GetSlotId(c *gin.Context, state string) string {
  78. mediumId := ""
  79. // if state != "" {
  80. // ids := []string{"-1"}
  81. // var tmp []model2.AppletApplicationAdSpaceList
  82. // MasterDb(c).Where("state=?", state).Find(&tmp)
  83. // for _, v := range tmp {
  84. // ids = append(ids, utils.IntToStr(v.MediumId))
  85. // }
  86. // mediumId = strings.Join(ids, ",")
  87. // }
  88. return mediumId
  89. }
  90. // 应用
  91. func GetAppletInfo(c *gin.Context, id string) map[string]string {
  92. var res = map[string]string{
  93. "platform": "",
  94. "name": "",
  95. }
  96. // NewAppletApplicationDb := implement2.NewAppletApplicationDb(MasterDb(c))
  97. // data, _ := NewAppletApplicationDb.GetAppletApplicationListByAppid(id)
  98. // if data != nil {
  99. // res["platform"] = data.Platform
  100. // res["name"] = data.Name
  101. // }
  102. return res
  103. }
  104. // 广告位
  105. func GetSlotInfo(c *gin.Context, id string) map[string]string {
  106. var res = map[string]string{
  107. "state": "",
  108. "name": "",
  109. }
  110. // NewAppletApplicationAdSpaceListDb := implement2.NewAppletApplicationAdSpaceListDb(MasterDb(c))
  111. // data, _ := NewAppletApplicationAdSpaceListDb.GetAppletApplicationAdSpaceListByAdId(id)
  112. // if data != nil {
  113. // res["name"] = data.Name
  114. // res["state"] = utils.IntToStr(data.State)
  115. // }
  116. return res
  117. }