广告平台(总站长使用)
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.

svc_data_center_generate_data.go 4.5 KiB

3 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package svc
  2. import (
  3. "applet/app/e"
  4. "applet/app/md"
  5. "applet/app/utils"
  6. db "code.fnuoos.com/zhimeng/model.git/src"
  7. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func DataCenterGenerateDataList(c *gin.Context, req md.DataCenterGenerateDataReq) md.DataCenterGenerateDataRes {
  11. engine := db.Db
  12. NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(engine)
  13. appId := GetAppletId(c, req.Name, req.Platform)
  14. slotId := GetSlotId(c, req.State)
  15. MediumList, total, _ := NewGenerateWxAdDataDb.FindGenerateWxAdDataList("", appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
  16. data := make([]md.DataCenterGenerateDataData, 0)
  17. if len(MediumList) > 0 {
  18. NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine)
  19. for _, v := range MediumList {
  20. wxData, _ := NewOriginalWxAdDataDb.GetOriginalWxAdData(v.Id)
  21. var tmp = md.DataCenterGenerateDataData{
  22. Id: utils.IntToStr(v.Id),
  23. ExposureCount: utils.IntToStr(v.ExposureCount),
  24. ClickCount: utils.IntToStr(v.ClickCount),
  25. ClickRate: v.ClickRate,
  26. Ecpm: utils.Float64ToStr(utils.StrToFloat64(v.Ecpm) / 100),
  27. IsGenerateReport: utils.IntToStr(v.IsGenerateReport),
  28. Date: v.Date,
  29. PlatformRetention: utils.Float64ToStr(float64(v.PlatformRetention) / 100),
  30. CommissionRetention: utils.Float64ToStr(float64(v.CommissionRetention) / 100),
  31. PriceAdjustmentRetention: utils.Float64ToStr(float64(v.PriceAdjustmentRetention) / 100),
  32. MediaRevenue: utils.Float64ToStr(float64(v.MediaRevenue) / 100),
  33. AgentRevenue: utils.Float64ToStr(float64(v.AgentRevenue) / 100),
  34. ExtraRevenue: utils.Float64ToStr(float64(v.ExtraRevenue) / 100),
  35. AgreementSharing: utils.Float64ToStr(float64(v.AgreementSharing) / 100),
  36. AgreementSharingTotal: utils.Float64ToStr(float64(v.AgreementSharingTotal) / 100),
  37. }
  38. if wxData != nil {
  39. tmp.OldClickRate = wxData.ClickRate
  40. tmp.OldClickCount = utils.IntToStr(wxData.ClickCount)
  41. tmp.OldEcpm = utils.Float64ToStr(utils.StrToFloat64(wxData.Ecpm) / 100)
  42. tmp.OldExposureCount = utils.IntToStr(wxData.ExposureCount)
  43. }
  44. tmpApplet := GetAppletInfo(c, v.AppId)
  45. if tmpApplet["platform"] != "" {
  46. tmp.Platform = tmpApplet["platform"]
  47. }
  48. if tmpApplet["name"] != "" {
  49. tmp.Name = tmpApplet["name"]
  50. }
  51. tmpSlot := GetSlotInfo(c, v.SlotId)
  52. if tmpSlot["state"] != "" {
  53. tmp.State = tmpSlot["state"]
  54. }
  55. if tmpSlot["name"] != "" {
  56. tmp.AdvName = tmpSlot["name"]
  57. }
  58. data = append(data, tmp)
  59. }
  60. }
  61. res := md.DataCenterGenerateDataRes{
  62. List: data,
  63. Total: total,
  64. State: md.AdState,
  65. Platform: md.AdPlatform,
  66. }
  67. return res
  68. }
  69. func DataCenterGenerateDataDetail(c *gin.Context, req md.DataCenterGenerateDataCommReq) {
  70. NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(db.Db)
  71. data, _ := NewGenerateWxAdDataDb.GetGenerateWxAdData(utils.StrToInt(req.Id))
  72. if data == nil {
  73. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  74. return
  75. }
  76. agentReward := make([]md.DataCenterGenerateDataDetailAgentReward, 0)
  77. NewGenerateWxAdDataWithAgentFlowDb := implement.NewGenerateWxAdDataWithAgentFlowDb(db.Db)
  78. agent, _ := NewGenerateWxAdDataWithAgentFlowDb.FindGenerateWxAdDataWithAgentFlowByStrategyId(data.Id)
  79. if agent != nil {
  80. for _, v := range *agent {
  81. tmp := md.DataCenterGenerateDataDetailAgentReward{
  82. Name: "",
  83. Account: "",
  84. AgentRevenue: utils.Float64ToStr(float64(v.AgentRevenue) / 100),
  85. AgentRevenueRate: utils.IntToStr(data.AgentRevenueRate),
  86. ExtraRevenue: utils.Float64ToStr(float64(v.ExtraRevenue) / 100),
  87. ExtraRevenueRate: utils.IntToStr(data.ExtraRevenueRate),
  88. }
  89. tmpApplet := GetAgentInfo(c, v.AgentId)
  90. if tmpApplet["name"] != "" {
  91. tmp.Name = tmpApplet["name"]
  92. }
  93. if tmpApplet["account"] != "" {
  94. tmp.Account = tmpApplet["account"]
  95. }
  96. agentReward = append(agentReward, tmp)
  97. }
  98. }
  99. res := md.DataCenterGenerateDataDetailData{
  100. PlatformRetentionRate: utils.IntToStr(data.PlatformRetentionRate),
  101. CommissionRetentionRate: utils.IntToStr(data.CommissionRetentionRate),
  102. MediaRevenueRate: utils.IntToStr(data.MediaRevenueRate),
  103. AgentRevenueRate: utils.IntToStr(data.AgentRevenueRate),
  104. ExtraRevenueRate: utils.IntToStr(data.ExtraRevenueRate),
  105. AgreementSharingRate: utils.IntToStr(data.AgreementSharingRate),
  106. AgentReward: agentReward,
  107. }
  108. e.OutSuc(c, res, nil)
  109. return
  110. }