dengbiao 1 week ago
parent
commit
b95767bdc1
17 changed files with 369 additions and 21 deletions
  1. +12
    -0
      app/hdl/hdl_data_center_generate_data.go
  2. +5
    -0
      app/hdl/hdl_index.go
  3. +83
    -0
      app/hdl/hdl_role.go
  4. +24
    -0
      app/md/admin.go
  5. +1
    -0
      app/md/md_data_center_original_data.go
  6. +10
    -6
      app/router/router.go
  7. +11
    -1
      app/svc/svc_applet_application.go
  8. +11
    -1
      app/svc/svc_applet_application_ad_space.go
  9. +82
    -2
      app/svc/svc_data_center_generate_data.go
  10. +30
    -1
      app/svc/svc_data_center_original_data.go
  11. +32
    -1
      app/svc/svc_medium_agent.go
  12. +9
    -3
      app/svc/svc_medium_qualification.go
  13. +9
    -3
      app/svc/svc_operator_index.go
  14. +9
    -1
      app/svc/svc_role.go
  15. +2
    -1
      app/svc/svc_settle_center_medium.go
  16. +36
    -0
      app/utils/xls.go
  17. +3
    -1
      go.mod

+ 12
- 0
app/hdl/hdl_data_center_generate_data.go View File

@@ -58,6 +58,18 @@ func IncomeDataList(c *gin.Context) {
e.OutSuc(c, res, nil) e.OutSuc(c, res, nil)
return return
} }
func IncomeDataListOutPut(c *gin.Context) {
var req md.DataCenterGenerateDataReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
svc.DataCenterIncomeDataListOutput(c, req)

}


// IncomeDataDetail // IncomeDataDetail
// @Summary 收益报表-详情 // @Summary 收益报表-详情


+ 5
- 0
app/hdl/hdl_index.go View File

@@ -26,12 +26,17 @@ func Base(c *gin.Context) {
res := map[string]string{ res := map[string]string{
"account_id": utils.IntToStr(user.AdmId), "account_id": utils.IntToStr(user.AdmId),
"name": name, "name": name,
"is_super": "0",
"account": user.Username, "account": user.Username,
"logo": "", "logo": "",
"memo": user.Memo,
"label": "", "label": "",
"seo_logo": "", "seo_logo": "",
"seo_title": "", "seo_title": "",
} }
if user.IsSuperAdministrator == 1 {
res["is_super"] = "1"
}
NewAdminRoleDb := implement.NewAdminRoleDb(svc.MasterDb(c)) NewAdminRoleDb := implement.NewAdminRoleDb(svc.MasterDb(c))
role, _ := NewAdminRoleDb.GetAdminRoleByAdminId(user.AdmId) role, _ := NewAdminRoleDb.GetAdminRoleByAdminId(user.AdmId)
if role != nil { if role != nil {


+ 83
- 0
app/hdl/hdl_role.go View File

@@ -10,6 +10,7 @@ import (
db "code.fnuoos.com/zhimeng/model.git/src" db "code.fnuoos.com/zhimeng/model.git/src"
"code.fnuoos.com/zhimeng/model.git/src/implement" "code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/model" "code.fnuoos.com/zhimeng/model.git/src/model"
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"time" "time"
) )
@@ -655,3 +656,85 @@ func AdminInfo(c *gin.Context) {
}, nil) }, nil)
return return
} }
func RoleMediumList(c *gin.Context) {
var req md.AdminBindMediumListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := svc.MasterDb(c)
NewMediumDb := implement.NewMediumDb(engine)
appId := svc.GetMediumIdStr(c, 0, req.Name, req.Account)
list, total, _ := NewMediumDb.FindSuperAdminByMediumId(appId, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AdminBindMediumListData, 0)
if len(list) > 0 {
for _, v := range list {
var tmp = md.AdminBindMediumListData{
MediumId: utils.IntToStr(v.MediumId),
Name: v.Memo,
IsBind: "0",
Account: v.Username,
}
NewMediumListDb := implement2.NewMediumListDb(db.Db)
GetMediumList, _ := NewMediumListDb.GetMediumList(v.MediumId)
if GetMediumList != nil {
tmp.Name = GetMediumList.CompanyName
if GetMediumList.CompanyAbbreviation != "" {
tmp.Name = GetMediumList.CompanyAbbreviation
}
}
count, _ := engine.Where("medium_id=? and admin_id=?", v.MediumId, req.AdminId).Count(&model.AdminBindMedium{})
if count > 0 {
tmp.IsBind = "1"
}
data = append(data, tmp)
}
}
res := md.AdminBindMediumListRes{
List: data,
Total: total,
}
e.OutSuc(c, res, nil)
return
}
func RoleBindMedium(c *gin.Context) {
var req md.AdminBindMediumListSaveReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
NewAdminBindMediumDb := implement.NewAdminBindMediumDb(svc.MasterDb(c))
data := NewAdminBindMediumDb.GetAdminByMediumId(utils.StrToInt(req.AdminId), utils.StrToInt(req.MediumId))
if data != nil {
e.OutErr(c, 400, e.NewErr(400, "已绑定该媒体"))
return
}
tmp := model.AdminBindMedium{
AdminId: utils.StrToInt(req.AdminId),
MediumId: utils.StrToInt(req.MediumId),
CreateAt: time.Now(),
UpdateAt: time.Now(),
}
svc.MasterDb(c).Insert(&tmp)
e.OutSuc(c, "success", nil)
return
}
func RoleDelMedium(c *gin.Context) {
var req md.AdminBindMediumListSaveReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
svc.MasterDb(c).Where("medium_id=? and admin_id=?", req.MediumId, req.AdminId).Delete(&model.AdminBindMedium{})
e.OutSuc(c, "success", nil)
return
}

+ 24
- 0
app/md/admin.go View File

@@ -0,0 +1,24 @@
package md

type AdminBindMediumListData struct {
MediumId string `json:"medium_id" example:"媒体id"`
Name string `json:"name" example:""`
Account string `json:"account" example:""`
IsBind string `json:"is_bind"`
}
type AdminBindMediumListRes struct {
List []AdminBindMediumListData `json:"list"`
Total int64 `json:"total"`
}

type AdminBindMediumListSaveReq struct {
MediumId string `json:"medium_id"`
AdminId string `json:"admin_id"`
}
type AdminBindMediumListReq struct {
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name" example:"媒体名称"`
Account string `json:"account" example:"媒体账号"`
AdminId string `json:"admin_id"`
}

+ 1
- 0
app/md/md_data_center_original_data.go View File

@@ -10,6 +10,7 @@ var AdState = []SelectData{
var AdPlatform = []SelectData{ var AdPlatform = []SelectData{
{Name: "微信小程序", Value: "wx_applet"}, {Name: "微信小程序", Value: "wx_applet"},
} }
var AdPlatformMap = map[string]string{"wx_applet": "微信小程序"}


type DataCenterOriginalDataReq struct { type DataCenterOriginalDataReq struct {
Limit string `json:"limit"` Limit string `json:"limit"`


+ 10
- 6
app/router/router.go View File

@@ -135,6 +135,9 @@ func rRole(r *gin.RouterGroup) {
r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) // 删除管理员 r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) // 删除管理员
r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息 r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息
r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色 r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色
r.POST("/mediumList", hdl.RoleMediumList) // 管理员列表-媒体列表
r.POST("/bindMedium", hdl.RoleBindMedium) // 管理员列表-关联媒体
r.POST("/mediumDel", hdl.RoleDelMedium) // 管理员列表-删除关联媒体
} }


func rAgentQualification(r *gin.RouterGroup) { func rAgentQualification(r *gin.RouterGroup) {
@@ -238,12 +241,13 @@ func rDataCenter(r *gin.RouterGroup) {
r.POST("/original/data/one/application/doing", hdl.OriginalDataOneApplicationDoing) // 数据中心-原始数据-单个应用数据操作 r.POST("/original/data/one/application/doing", hdl.OriginalDataOneApplicationDoing) // 数据中心-原始数据-单个应用数据操作
r.GET("/original/data/one/application/state", hdl.OriginalDataOneApplicationState) // 数据中心-原始数据-单个应用数据操作后的完成状态 r.GET("/original/data/one/application/state", hdl.OriginalDataOneApplicationState) // 数据中心-原始数据-单个应用数据操作后的完成状态


r.POST("/generate/data/list", hdl.GenerateDataList) // 数据中心-分成数据
r.POST("/generate/data/del", hdl.GenerateDataDel) // 数据中心-分成数据-删除
r.POST("/generate/data/detail", hdl.GenerateDataDetail) // 数据中心-分成数据-详情
r.POST("/generate/data/doing", hdl.GenerateDataDoing) // 数据中心-分成数据-报表生成操作
r.POST("/income/data/list", hdl.IncomeDataList) // 数据中心-收益报表
r.POST("/income/data/detail", hdl.IncomeDataDetail) // 数据中心-收益报表-详情
r.POST("/generate/data/list", hdl.GenerateDataList) // 数据中心-分成数据
r.POST("/generate/data/del", hdl.GenerateDataDel) // 数据中心-分成数据-删除
r.POST("/generate/data/detail", hdl.GenerateDataDetail) // 数据中心-分成数据-详情
r.POST("/generate/data/doing", hdl.GenerateDataDoing) // 数据中心-分成数据-报表生成操作
r.POST("/income/data/list", hdl.IncomeDataList) // 数据中心-收益报表
r.POST("/income/data/list/output", hdl.IncomeDataListOutPut) // 数据中心-收益报表
r.POST("/income/data/detail", hdl.IncomeDataDetail) // 数据中心-收益报表-详情


} }




+ 11
- 1
app/svc/svc_applet_application.go View File

@@ -27,8 +27,10 @@ func AppletApplicationMediumList(c *gin.Context) {
} }
engine := MasterDb(c) engine := MasterDb(c)
NewMediumDb := implement.NewMediumDb(engine) NewMediumDb := implement.NewMediumDb(engine)
user := GetUser(c)
appId := GetMediumIdStr(c, user.AdmId, req.Name, req.Account)


list, total, _ := NewMediumDb.FindSuperAdmin(req.Account, req.Name, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
list, total, _ := NewMediumDb.FindSuperAdminByMediumId(appId, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AppletApplicationMediumListData, 0) data := make([]md.AppletApplicationMediumListData, 0)
if len(list) > 0 { if len(list) > 0 {
for _, v := range list { for _, v := range list {
@@ -47,6 +49,14 @@ func AppletApplicationMediumList(c *gin.Context) {
tmp.ContactName = infoList.Name tmp.ContactName = infoList.Name
tmp.Phone = infoList.Phone tmp.Phone = infoList.Phone
} }
NewMediumListDb := implement2.NewMediumListDb(db.Db)
GetMediumList, _ := NewMediumListDb.GetMediumList(v.MediumId)
if GetMediumList != nil {
tmp.Name = GetMediumList.CompanyName
if GetMediumList.CompanyAbbreviation != "" {
tmp.Name = GetMediumList.CompanyAbbreviation
}
}
count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplication{}) count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplication{})
tmp.Count = utils.Int64ToStr(count) tmp.Count = utils.Int64ToStr(count)
data = append(data, tmp) data = append(data, tmp)


+ 11
- 1
app/svc/svc_applet_application_ad_space.go View File

@@ -26,8 +26,10 @@ func AppletApplicationAdSpaceMediumList(c *gin.Context) {
} }
engine := MasterDb(c) engine := MasterDb(c)
NewMediumDb := implement.NewMediumDb(engine) NewMediumDb := implement.NewMediumDb(engine)
user := GetUser(c)
appId := GetMediumIdStr(c, user.AdmId, req.Name, req.Account)


list, total, _ := NewMediumDb.FindSuperAdmin(req.Account, req.Name, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
list, total, _ := NewMediumDb.FindSuperAdminByMediumId(appId, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AppletApplicationAdSpaceMediumListData, 0) data := make([]md.AppletApplicationAdSpaceMediumListData, 0)
if len(list) > 0 { if len(list) > 0 {
for _, v := range list { for _, v := range list {
@@ -46,6 +48,14 @@ func AppletApplicationAdSpaceMediumList(c *gin.Context) {
tmp.ContactName = infoList.Name tmp.ContactName = infoList.Name
tmp.Phone = infoList.Phone tmp.Phone = infoList.Phone
} }
NewMediumListDb := implement2.NewMediumListDb(db.Db)
GetMediumList, _ := NewMediumListDb.GetMediumList(v.MediumId)
if GetMediumList != nil {
tmp.Name = GetMediumList.CompanyName
if GetMediumList.CompanyAbbreviation != "" {
tmp.Name = GetMediumList.CompanyAbbreviation
}
}
count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplicationAdSpaceList{}) count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplicationAdSpaceList{})
tmp.Count = utils.Int64ToStr(count) tmp.Count = utils.Int64ToStr(count)
data = append(data, tmp) data = append(data, tmp)


+ 82
- 2
app/svc/svc_data_center_generate_data.go View File

@@ -17,9 +17,11 @@ import (
func DataCenterIncomeDataList(c *gin.Context, req md.DataCenterGenerateDataReq) md.DataCenterIncomeDataRes { func DataCenterIncomeDataList(c *gin.Context, req md.DataCenterGenerateDataReq) md.DataCenterIncomeDataRes {
engine := db.Db engine := db.Db
NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(engine) NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(engine)
user := GetUser(c)
appId := GetAppletId(c, req.Name, req.Platform) appId := GetAppletId(c, req.Name, req.Platform)
mediumId := GetMediumIdStr(c, user.AdmId, "", "")
slotId := GetSlotId(c, req.State) slotId := GetSlotId(c, req.State)
MediumList, total, _ := NewGenerateWxAdDataDb.FindGenerateWxAdDataListMedium(c.GetString("mid"), appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
MediumList, total, _ := NewGenerateWxAdDataDb.FindGenerateWxAdDataListMedium(c.GetString("mid"), appId, mediumId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.DataCenterIncomeDataData, 0) data := make([]md.DataCenterIncomeDataData, 0)
if len(MediumList) > 0 { if len(MediumList) > 0 {
for _, v := range MediumList { for _, v := range MediumList {
@@ -60,6 +62,82 @@ func DataCenterIncomeDataList(c *gin.Context, req md.DataCenterGenerateDataReq)
} }
return res return res
} }
func DataCenterIncomeDataListOutput(c *gin.Context, req md.DataCenterGenerateDataReq) {
engine := db.Db
NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(engine)
user := GetUser(c)
appId := GetAppletId(c, req.Name, req.Platform)
mediumId := GetMediumIdStr(c, user.AdmId, "", "")
slotId := GetSlotId(c, req.State)
req.Limit = "3000"
MediumList, _ := NewGenerateWxAdDataDb.FindGenerateWxAdDataListMediumAll(c.GetString("mid"), appId, mediumId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := map[string]string{
"A1": "名称",
"B1": "日期",
"C1": "广告位",
"D1": "曝光量",
"E1": "点击率(%)",
"F1": "点击量",
"G1": "结算平台",
"H1": "媒体-ECPM",
"I1": "媒体收益(元)",
"J1": "代理收益(元)",
"K1": "平台收益(元)",
}
name := "运营报表第" + req.Page + "页"

if len(MediumList) > 0 {
for k, v := range MediumList {
var tmp = md.DataCenterIncomeDataData{
AgreementSharing: utils.Float64ToStr(float64(v.AgreementSharing) / 100),
AgentRevenue: utils.Float64ToStr(float64(v.AgentRevenue) / 100),
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),
Date: v.Date,
MediaRevenue: utils.Float64ToStr(float64(v.MediaRevenue) / 100),
SettleAmount: utils.Float64ToStr(float64(v.MediaRevenue+v.AgentRevenue+v.AgreementSharing) / 100),
}
tmpApplet := GetAppletInfo(c, v.AppId)
if tmpApplet["platform"] != "" {
tmp.Platform = md.AdPlatformMap[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"]
}
i := utils.IntToStr(k + 2)
data["A"+i] = tmp.Name
data["B"+i] = tmp.Date
data["C"+i] = tmp.AdvName
data["D"+i] = tmp.ExposureCount
data["E"+i] = tmp.ClickRate
data["F"+i] = tmp.ClickCount
data["G"+i] = tmp.Platform
data["H"+i] = tmp.Ecpm
data["I"+i] = tmp.MediaRevenue
data["J"+i] = tmp.AgentRevenue
data["K"+i] = tmp.AgreementSharing
}
}

file := utils.Output(c, name, data)
filename := name + ".xlsx"
r := map[string]string{
"file": file,
"filename": filename,
}
e.OutSuc(c, r, nil)
return
}
func DataCenterIncomeDataDetail(c *gin.Context, req md.DataCenterGenerateDataCommReq) { func DataCenterIncomeDataDetail(c *gin.Context, req md.DataCenterGenerateDataCommReq) {
NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(db.Db) NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(db.Db)
data, _ := NewGenerateWxAdDataDb.GetGenerateWxAdData(utils.StrToInt(req.Id)) data, _ := NewGenerateWxAdDataDb.GetGenerateWxAdData(utils.StrToInt(req.Id))
@@ -120,9 +198,11 @@ func DataCenterIncomeDataDetail(c *gin.Context, req md.DataCenterGenerateDataCom
func DataCenterGenerateDataList(c *gin.Context, req md.DataCenterGenerateDataReq) md.DataCenterGenerateDataRes { func DataCenterGenerateDataList(c *gin.Context, req md.DataCenterGenerateDataReq) md.DataCenterGenerateDataRes {
engine := db.Db engine := db.Db
NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(engine) NewGenerateWxAdDataDb := implement.NewGenerateWxAdDataDb(engine)
user := GetUser(c)
appId := GetAppletId(c, req.Name, req.Platform) appId := GetAppletId(c, req.Name, req.Platform)
mediumId := GetMediumIdStr(c, user.AdmId, "", "")
slotId := GetSlotId(c, req.State) slotId := GetSlotId(c, req.State)
MediumList, total, _ := NewGenerateWxAdDataDb.FindGenerateWxAdDataList(c.GetString("mid"), appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
MediumList, total, _ := NewGenerateWxAdDataDb.FindGenerateWxAdDataList(c.GetString("mid"), appId, mediumId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.DataCenterGenerateDataData, 0) data := make([]md.DataCenterGenerateDataData, 0)
if len(MediumList) > 0 { if len(MediumList) > 0 {
NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine) NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine)


+ 30
- 1
app/svc/svc_data_center_original_data.go View File

@@ -21,7 +21,8 @@ import (
func DataCenterOriginalDataList(c *gin.Context, req md.DataCenterOriginalDataReq) md.DataCenterOriginalDataRes { func DataCenterOriginalDataList(c *gin.Context, req md.DataCenterOriginalDataReq) md.DataCenterOriginalDataRes {
engine := db.Db engine := db.Db
NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine) NewOriginalWxAdDataDb := implement.NewOriginalWxAdDataDb(engine)
appId := GetAppletId(c, req.Name, req.Platform)
user := GetUser(c)
appId := GetAppletIdByAdminId(c, user.AdmId, req.Name, req.Platform)
slotId := GetSlotId(c, req.State) slotId := GetSlotId(c, req.State)
MediumList, total, _ := NewOriginalWxAdDataDb.FindOriginalWxAdDataList(c.GetString("mid"), appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) MediumList, total, _ := NewOriginalWxAdDataDb.FindOriginalWxAdDataList(c.GetString("mid"), appId, slotId, req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.DataCenterOriginalDataData, 0) data := make([]md.DataCenterOriginalDataData, 0)
@@ -376,6 +377,34 @@ func GetAppletId(c *gin.Context, name, platform string) string {
} }
return mediumId return mediumId
} }
func GetAppletIdByAdminId(c *gin.Context, admId int, name, platform string) string {
appId := GetAppletId(c, name, platform)
appIds := []string{"-1"}
NewAdminBindMediumDb := implement2.NewAdminBindMediumDb(MasterDb(c))
list := NewAdminBindMediumDb.FindAll(admId)
ids := make([]string, 0)
for _, v := range list {
appIds = append(appIds, utils.IntToStr(v.MediumId))
ids = append(ids, utils.IntToStr(v.MediumId))
}
if len(list) == 0 { //为空就查全部
appIds = []string{}
}
if appId != "" { //不为空就判断 有没有在列表里面
appIds = []string{"-1"}
ex := strings.Split(appId, ",")
for _, v := range ex {
if utils.InArr(v, ids) || len(list) == 0 {
appIds = append(appIds, v)
}
}
}
str := ""
if len(appIds) > 0 {
str = strings.Join(appIds, ",")
}
return str
}


// 广告位 // 广告位
func GetSlotId(c *gin.Context, state string) string { func GetSlotId(c *gin.Context, state string) string {


+ 32
- 1
app/svc/svc_medium_agent.go View File

@@ -190,7 +190,7 @@ func GetMediumByAccountId(c *gin.Context, name, account string) string {
if name != "" { if name != "" {
sess.And("memo like ?", "%"+name+"%") sess.And("memo like ?", "%"+name+"%")
var tmp1 []model.MediumList var tmp1 []model.MediumList
MasterDb(c).Where("company_name like ? or company_abbreviation like ?", "%"+name+"%", "%"+name+"%").Find(&tmp1)
db.Db.Where("company_name like ? or company_abbreviation like ?", "%"+name+"%", "%"+name+"%").Find(&tmp1)
for _, v := range tmp1 { for _, v := range tmp1 {
ids = append(ids, utils.IntToStr(v.MediumId)) ids = append(ids, utils.IntToStr(v.MediumId))
} }
@@ -299,3 +299,34 @@ func GetAgentInfo(c *gin.Context, mediumId int) map[string]string {
} }
return res return res
} }

func GetMediumIdStr(c *gin.Context, admId int, name, account string) string {
appId := GetMediumByAccountId(c, name, account)
appIds := []string{"-1"}
NewAdminBindMediumDb := implement2.NewAdminBindMediumDb(MasterDb(c))
list := NewAdminBindMediumDb.FindAll(admId)
ids := make([]string, 0)
for _, v := range list {
appIds = append(appIds, utils.IntToStr(v.MediumId))
ids = append(ids, utils.IntToStr(v.MediumId))
}
NewAdminDb := implement2.NewAdminDb(MasterDb(c))
super, _ := NewAdminDb.GetSuperAdmin()
if admId == 0 || admId == super.AdmId { //为空就查全部
appIds = []string{}
}
if appId != "" { //不为空就判断 有没有在列表里面
appIds = []string{"-1"}
ex := strings.Split(appId, ",")
for _, v := range ex {
if utils.InArr(v, ids) || admId == super.AdmId {
appIds = append(appIds, v)
}
}
}
str := ""
if len(appIds) > 0 {
str = strings.Join(appIds, ",")
}
return str
}

+ 9
- 3
app/svc/svc_medium_qualification.go View File

@@ -16,7 +16,9 @@ func MediumQualificationEnterprise(c *gin.Context, minState int, req md.MediumQu


engine := db.Db engine := db.Db
MediumListDb := implement.NewMediumListDb(engine) MediumListDb := implement.NewMediumListDb(engine)
MediumList, total, _ := MediumListDb.FindMediumList(c.GetString("mid"), req.Name, req.State, minState, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
user := GetUser(c)
appIds := GetMediumIdStr(c, user.AdmId, req.Name, "")
MediumList, total, _ := MediumListDb.FindMediumList(c.GetString("mid"), "", appIds, req.State, minState, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.MediumQualificationEnterpriseData, 0) data := make([]md.MediumQualificationEnterpriseData, 0)
if len(MediumList) > 0 { if len(MediumList) > 0 {
NewMediumDb := implement2.NewMediumDb(MasterDb(c)) NewMediumDb := implement2.NewMediumDb(MasterDb(c))
@@ -92,7 +94,9 @@ func MediumQualificationEnterpriseAudit(c *gin.Context, req md.MediumQualificati
func MediumQualificationBank(c *gin.Context, req md.MediumQualificationEnterpriseReq) md.MediumQualificationBankRes { func MediumQualificationBank(c *gin.Context, req md.MediumQualificationEnterpriseReq) md.MediumQualificationBankRes {
engine := db.Db engine := db.Db
MediumListDb := implement.NewMediumBankInfoDb(engine) MediumListDb := implement.NewMediumBankInfoDb(engine)
MediumList, total, _ := MediumListDb.FindMediumBankInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
user := GetUser(c)
appIds := GetMediumIdStr(c, user.AdmId, req.Name, "")
MediumList, total, _ := MediumListDb.FindMediumBankInfoList(c.GetString("mid"), "", appIds, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))


list := make([]md.MediumQualificationBankData, 0) list := make([]md.MediumQualificationBankData, 0)
if MediumList != nil { if MediumList != nil {
@@ -175,7 +179,9 @@ func MediumQualificationContactInfo(c *gin.Context, req md.MediumQualificationEn


engine := db.Db engine := db.Db
MediumListDb := implement.NewMediumContactInfoDb(engine) MediumListDb := implement.NewMediumContactInfoDb(engine)
MediumList, total, _ := MediumListDb.FindMediumContactInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
user := GetUser(c)
appIds := GetMediumIdStr(c, user.AdmId, req.Name, "")
MediumList, total, _ := MediumListDb.FindMediumContactInfoList(c.GetString("mid"), "", appIds, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))


list := make([]md.MediumQualificationContactData, 0) list := make([]md.MediumQualificationContactData, 0)
if MediumList != nil { if MediumList != nil {


+ 9
- 3
app/svc/svc_operator_index.go View File

@@ -166,6 +166,11 @@ func commOperatorTotal(c *gin.Context, startDate, endDate string) []map[string]s
if endDate != "" { if endDate != "" {
where += " and date<='" + endDate + "'" where += " and date<='" + endDate + "'"
} }
user := GetUser(c)
appId := GetMediumIdStr(c, user.AdmId, "", "")
if appId != "" {
where += " and medium_id in(" + appId + ")"
}
sql = fmt.Sprintf(sql, where) sql = fmt.Sprintf(sql, where)
nativeString, _ := db.QueryNativeString(db.Db, sql) nativeString, _ := db.QueryNativeString(db.Db, sql)
if len(nativeString) == 0 { if len(nativeString) == 0 {
@@ -197,9 +202,10 @@ func commOperatorTotalByApp(c *gin.Context, req md.IndexAppListReq, appId []stri
if req.EndDate != "" { if req.EndDate != "" {
where += " and date<='" + req.EndDate + "'" where += " and date<='" + req.EndDate + "'"
} }
if req.Name != "" {
mediumId := GetMediumId(c, req.Name)
where += " and medium_id in(" + mediumId + ")"
user := GetUser(c)
appIds := GetMediumIdStr(c, user.AdmId, req.Name, "")
if appIds != "" {
where += " and medium_id in(" + appIds + ")"
} }
if len(appId) > 0 { if len(appId) > 0 {
where += " and app_id in('" + strings.Join(appId, ",") + "')" where += " and app_id in('" + strings.Join(appId, ",") + "')"


+ 9
- 1
app/svc/svc_role.go View File

@@ -9,6 +9,7 @@ import (
"code.fnuoos.com/zhimeng/model.git/src/model" "code.fnuoos.com/zhimeng/model.git/src/model"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"regexp" "regexp"
"strings" "strings"
@@ -139,7 +140,14 @@ func RoleBindPermissionGroup(c *gin.Context, req md.RoleBindPermissionGroupReq)
return return
} }


return session.Commit()
session.Commit()
var data []model.AdminRole
MasterDb(c).Where("role_id=?", role.Id).Find(&data)
for _, v := range data {
rolePermissionKey := fmt.Sprintf(md.AdminRolePermissionKey, c.GetString("mid"), utils.AnyToString(v.AdmId))
cache.Del(rolePermissionKey)
}
return nil
} }


func BindAdminRole(c *gin.Context, req md.BindAdminRoleReq) (err error) { func BindAdminRole(c *gin.Context, req md.BindAdminRoleReq) (err error) {


+ 2
- 1
app/svc/svc_settle_center_medium.go View File

@@ -12,7 +12,8 @@ import (
func SettleCenterMediumList(c *gin.Context, req md.SettleCenterDataReq) md.SettleCenterDataRes { func SettleCenterMediumList(c *gin.Context, req md.SettleCenterDataReq) md.SettleCenterDataRes {
engine := db.Db engine := db.Db
NewOriginalWxAdDataDb := implement.NewMediumListDb(engine) NewOriginalWxAdDataDb := implement.NewMediumListDb(engine)
appId := GetMediumByAccountId(c, req.Name, req.Account)
user := GetUser(c)
appId := GetMediumIdStr(c, user.AdmId, req.Name, req.Account)
MediumList, total, _ := NewOriginalWxAdDataDb.FindMediumListBySettleType(c.GetString("mid"), appId, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) MediumList, total, _ := NewOriginalWxAdDataDb.FindMediumListBySettleType(c.GetString("mid"), appId, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.SettleCenterDataData, 0) data := make([]md.SettleCenterDataData, 0)
if len(MediumList) > 0 { if len(MediumList) > 0 {


+ 36
- 0
app/utils/xls.go View File

@@ -0,0 +1,36 @@
package utils

import (
"bytes"
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"github.com/gin-gonic/gin"
"io/ioutil"
)

func Output(c *gin.Context, name string, data map[string]string) string {
//创建excel文件
xlsx := excelize.NewFile()
//创建新表单
index := xlsx.NewSheet(name)
for k, v := range data {
//设置单元格的值
xlsx.SetCellValue(name, k, v)
}
//设置默认打开的表单
xlsx.SetActiveSheet(index)
////保存文件到指定路径
//err := xlsx.SaveAs("./" + name + ".xlsx")
//if err != nil {
// log.Fatal(err)
//}
//_ = file.Save(fileName)
c.Header("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, name+".xlsx"))
c.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
var buffer bytes.Buffer
_ = xlsx.Write(&buffer)
r := bytes.NewReader(buffer.Bytes())
fSrc, _ := ioutil.ReadAll(r)
str := "data:application/vnd.ms-excel;base64," + Base64RawStdEncode(string(fSrc))
return str
}

+ 3
- 1
go.mod View File

@@ -36,7 +36,8 @@ require (
require ( require (
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240830072333-a1980ffb256e code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240830072333-a1980ffb256e
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20241009095023-24f5079bb959
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20241025084129-8b263ebe9032
github.com/360EntSecGroup-Skylar/excelize v1.4.1
github.com/jinzhu/copier v0.4.0 github.com/jinzhu/copier v0.4.0
) )


@@ -67,6 +68,7 @@ require (
github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/streadway/amqp v1.0.0 // indirect github.com/streadway/amqp v1.0.0 // indirect


Loading…
Cancel
Save