package svc import ( "applet/app/e" "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 DataCenterGenerateDataList(c *gin.Context, req md.DataCenterGenerateDataReq) md.DataCenterGenerateDataRes { engine := db.Db NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(engine) appId := GetAppletId(c, req.Name, req.Platform) slotId := GetSlotId(c, req.State) MediumList, total, _ := NewGenerateWxAdDataDb.FindGenerateWxAdDataList("", appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) data := make([]md.DataCenterGenerateDataData, 0) if len(MediumList) > 0 { NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine) for _, v := range MediumList { wxData, _ := NewOriginalWxAdDataDb.GetOriginalWxAdData(v.Id) var tmp = md.DataCenterGenerateDataData{ Id: utils.IntToStr(v.Id), ExposureCount: utils.IntToStr(v.ExposureCount), ClickCount: utils.IntToStr(v.ClickCount), ClickRate: v.ClickRate, Ecpm: utils.Float64ToStr(utils.StrToFloat64(v.Ecpm) / 100), IsGenerateReport: utils.IntToStr(v.IsGenerateReport), Date: v.Date, PlatformRetention: utils.Float64ToStr(float64(v.PlatformRetention) / 100), CommissionRetention: utils.Float64ToStr(float64(v.CommissionRetention) / 100), PriceAdjustmentRetention: utils.Float64ToStr(float64(v.PriceAdjustmentRetention) / 100), MediaRevenue: utils.Float64ToStr(float64(v.MediaRevenue) / 100), AgentRevenue: utils.Float64ToStr(float64(v.AgentRevenue) / 100), ExtraRevenue: utils.Float64ToStr(float64(v.ExtraRevenue) / 100), AgreementSharing: utils.Float64ToStr(float64(v.AgreementSharing) / 100), AgreementSharingTotal: utils.Float64ToStr(float64(v.AgreementSharingTotal) / 100), } if wxData != nil { tmp.OldClickRate = wxData.ClickRate tmp.OldClickCount = utils.IntToStr(wxData.ClickCount) tmp.OldEcpm = utils.Float64ToStr(utils.StrToFloat64(wxData.Ecpm) / 100) tmp.OldExposureCount = utils.IntToStr(wxData.ExposureCount) } 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.DataCenterGenerateDataRes{ List: data, Total: total, State: md.AdState, Platform: md.AdPlatform, } return res } func DataCenterGenerateDataDetail(c *gin.Context, req md.DataCenterGenerateDataCommReq) { NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(db.Db) data, _ := NewGenerateWxAdDataDb.GetGenerateWxAdData(utils.StrToInt(req.Id)) if data == nil { e.OutErr(c, 400, e.NewErr(400, "记录不存在")) return } agentReward := make([]md.DataCenterGenerateDataDetailAgentReward, 0) NewGenerateWxAdDataWithAgentFlowDb := implement.NewGenerateWxAdDataWithAgentFlowDb(db.Db) agent, _ := NewGenerateWxAdDataWithAgentFlowDb.FindGenerateWxAdDataWithAgentFlowByStrategyId(data.Id) if agent != nil { for _, v := range *agent { tmp := md.DataCenterGenerateDataDetailAgentReward{ Name: "", Account: "", AgentRevenue: utils.Float64ToStr(float64(v.AgentRevenue) / 100), AgentRevenueRate: utils.IntToStr(data.AgentRevenueRate), ExtraRevenue: utils.Float64ToStr(float64(v.ExtraRevenue) / 100), ExtraRevenueRate: utils.IntToStr(data.ExtraRevenueRate), } tmpApplet := GetAgentInfo(c, v.AgentId) if tmpApplet["name"] != "" { tmp.Name = tmpApplet["name"] } if tmpApplet["account"] != "" { tmp.Account = tmpApplet["account"] } agentReward = append(agentReward, tmp) } } res := md.DataCenterGenerateDataDetailData{ PlatformRetentionRate: utils.IntToStr(data.PlatformRetentionRate), CommissionRetentionRate: utils.IntToStr(data.CommissionRetentionRate), MediaRevenueRate: utils.IntToStr(data.MediaRevenueRate), AgentRevenueRate: utils.IntToStr(data.AgentRevenueRate), ExtraRevenueRate: utils.IntToStr(data.ExtraRevenueRate), AgreementSharingRate: utils.IntToStr(data.AgreementSharingRate), AgentReward: agentReward, } e.OutSuc(c, res, nil) return }