Browse Source

advertise

master
linquan 2 days ago
parent
commit
85c3daca1b
  1. 13
      api/v1/game/advertisement.go
  2. 10
      internal/controller/game_pub.go
  3. 4
      internal/dao/internal/advertisement_oceanegine.go
  4. 4
      internal/dao/internal/server_battle_pass.go
  5. 2
      internal/model/do/advertisement_oceanegine.go
  6. 2
      internal/model/do/server_battle_pass.go
  7. 2
      internal/model/entity/advertisement_oceanegine.go
  8. 2
      internal/model/entity/server_battle_pass.go
  9. 20
      internal/serviceGame/advertisement.go
  10. 37
      internal/serviceGame/internal/advertisement.go
  11. 10
      internal/serviceGame/internal/server_battle_pass.go

13
api/v1/game/advertisement.go

@ -55,6 +55,7 @@ type ATHAReq struct {
AndroidId string `p:"android_id"` AndroidId string `p:"android_id"`
PackageName string `p:"package_name"` PackageName string `p:"package_name"`
UnitId string `p:"unitId"` UnitId string `p:"unitId"`
Caid string `p:"caid"`
} }
type HugeAmount struct { type HugeAmount struct {
@ -93,6 +94,7 @@ type CSHAReq struct {
Idfa string `p:"idfa"` Idfa string `p:"idfa"`
Properties string `p:"properties"` Properties string `p:"properties"`
UnitId string `p:"unitId"` UnitId string `p:"unitId"`
Caid string `p:"caid"`
} }
type CSHARes struct { type CSHARes struct {
@ -109,6 +111,7 @@ type AdvertiseHAReq struct {
PackageName string `p:"package_name"` PackageName string `p:"package_name"`
Properties string `p:"properties"` Properties string `p:"properties"`
UnitId string `p:"unitId"` UnitId string `p:"unitId"`
Caid string `p:"caid"`
} }
type AdvertiseHARes struct { type AdvertiseHARes struct {
@ -123,6 +126,8 @@ type AdvertiseHA1Req struct {
TIMESTAMP string `p:"TIMESTAMP"` TIMESTAMP string `p:"TIMESTAMP"`
Callback string `p:"callback"` Callback string `p:"callback"`
Androidid string `p:"androidid"` Androidid string `p:"androidid"`
Caid string `p:"caid"`
Ip string `p:"ip"`
} }
type AdvertiseHA1Res struct { type AdvertiseHA1Res struct {
@ -137,6 +142,8 @@ type AdvertiseHA2Req struct {
TIMESTAMP string `p:"TIMESTAMP"` TIMESTAMP string `p:"TIMESTAMP"`
Callback string `p:"callback"` Callback string `p:"callback"`
Androidid string `p:"androidid"` Androidid string `p:"androidid"`
Caid string `p:"caid"`
Ip string `p:"ip"`
} }
type AdvertiseHA2Res struct { type AdvertiseHA2Res struct {
@ -151,6 +158,8 @@ type AdvertiseHA3Req struct {
TIMESTAMP string `p:"TIMESTAMP"` TIMESTAMP string `p:"TIMESTAMP"`
Callback string `p:"callback"` Callback string `p:"callback"`
Androidid string `p:"androidid"` Androidid string `p:"androidid"`
Caid string `p:"caid"`
Ip string `p:"ip"`
} }
type AdvertiseHA3Res struct { type AdvertiseHA3Res struct {
@ -165,6 +174,8 @@ type AdvertiseHA4Req struct {
TIMESTAMP string `p:"TIMESTAMP"` TIMESTAMP string `p:"TIMESTAMP"`
Callback string `p:"callback"` Callback string `p:"callback"`
Androidid string `p:"androidid"` Androidid string `p:"androidid"`
Caid string `p:"caid"`
Ip string `p:"ip"`
} }
type AdvertiseHA4Res struct { type AdvertiseHA4Res struct {
@ -179,6 +190,8 @@ type AdvertiseHA5Req struct {
TIMESTAMP string `p:"TIMESTAMP"` TIMESTAMP string `p:"TIMESTAMP"`
Callback string `p:"callback"` Callback string `p:"callback"`
Androidid string `p:"androidid"` Androidid string `p:"androidid"`
Caid string `p:"caid"`
Ip string `p:"ip"`
} }
type AdvertiseHA5Res struct { type AdvertiseHA5Res struct {

10
internal/controller/game_pub.go

@ -145,35 +145,35 @@ func (c *pubController) AdvertiseHugeAmount(ctx context.Context, req *game.Adver
func (c *pubController) AdvertiseHugeAmount1(ctx context.Context, req *game.AdvertiseHA1Req) (res *game.AdvertiseHA1Res, err error) { func (c *pubController) AdvertiseHugeAmount1(ctx context.Context, req *game.AdvertiseHA1Req) (res *game.AdvertiseHA1Res, err error) {
//log.Print("AdvertiseHugeAmount1", gjson.MustEncodeString(req)) //log.Print("AdvertiseHugeAmount1", gjson.MustEncodeString(req))
res = new(game.AdvertiseHA1Res) res = new(game.AdvertiseHA1Res)
err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP) err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP, req.Caid, req.Ip)
return return
} }
func (c *pubController) AdvertiseHugeAmount2(ctx context.Context, req *game.AdvertiseHA2Req) (res *game.AdvertiseHA2Res, err error) { func (c *pubController) AdvertiseHugeAmount2(ctx context.Context, req *game.AdvertiseHA2Req) (res *game.AdvertiseHA2Res, err error) {
//log.Print("AdvertiseHugeAmount2", gjson.MustEncodeString(req)) //log.Print("AdvertiseHugeAmount2", gjson.MustEncodeString(req))
res = new(game.AdvertiseHA2Res) res = new(game.AdvertiseHA2Res)
err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP) err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP, req.Caid, req.Ip)
return return
} }
func (c *pubController) AdvertiseHugeAmount3(ctx context.Context, req *game.AdvertiseHA3Req) (res *game.AdvertiseHA3Res, err error) { func (c *pubController) AdvertiseHugeAmount3(ctx context.Context, req *game.AdvertiseHA3Req) (res *game.AdvertiseHA3Res, err error) {
//log.Print("AdvertiseHugeAmount3", gjson.MustEncodeString(req)) //log.Print("AdvertiseHugeAmount3", gjson.MustEncodeString(req))
res = new(game.AdvertiseHA3Res) res = new(game.AdvertiseHA3Res)
err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP) err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP, req.Caid, req.Ip)
return return
} }
func (c *pubController) AdvertiseHugeAmount4(ctx context.Context, req *game.AdvertiseHA4Req) (res *game.AdvertiseHA4Res, err error) { func (c *pubController) AdvertiseHugeAmount4(ctx context.Context, req *game.AdvertiseHA4Req) (res *game.AdvertiseHA4Res, err error) {
//log.Print("AdvertiseHugeAmount4", gjson.MustEncodeString(req)) //log.Print("AdvertiseHugeAmount4", gjson.MustEncodeString(req))
res = new(game.AdvertiseHA4Res) res = new(game.AdvertiseHA4Res)
err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP) err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP, req.Caid, req.Ip)
return return
} }
func (c *pubController) AdvertiseHugeAmount5(ctx context.Context, req *game.AdvertiseHA5Req) (res *game.AdvertiseHA5Res, err error) { func (c *pubController) AdvertiseHugeAmount5(ctx context.Context, req *game.AdvertiseHA5Req) (res *game.AdvertiseHA5Res, err error) {
//log.Print("AdvertiseHugeAmount5", gjson.MustEncodeString(req)) //log.Print("AdvertiseHugeAmount5", gjson.MustEncodeString(req))
res = new(game.AdvertiseHA5Res) res = new(game.AdvertiseHA5Res)
err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP) err = serviceGame.Advertisement().AdvertiseHugeAmount1(ctx, req.Androidid, req.Idfa, req.Os, req.Callback, req.TIMESTAMP, req.Caid, req.Ip)
return return
} }

4
internal/dao/internal/advertisement_oceanegine.go

@ -30,6 +30,8 @@ type AdvertisementOceanegineColumns struct {
Idfa string // Idfa string //
Os string // 安卓:0 IOS:1 其他:3 Os string // 安卓:0 IOS:1 其他:3
UnitId string // UnitId string //
Caid string //
Ip string //
} }
// advertisementOceanegineColumns holds the columns for table advertisement_oceanegine. // advertisementOceanegineColumns holds the columns for table advertisement_oceanegine.
@ -44,6 +46,8 @@ var advertisementOceanegineColumns = AdvertisementOceanegineColumns{
Idfa: "idfa", Idfa: "idfa",
Os: "os", Os: "os",
UnitId: "unitId", UnitId: "unitId",
Caid: "caid",
Ip: "ip",
} }
// NewAdvertisementOceanegineDao creates and returns a new DAO object for table data access. // NewAdvertisementOceanegineDao creates and returns a new DAO object for table data access.

4
internal/dao/internal/server_battle_pass.go

@ -21,8 +21,8 @@ type ServerBattlePassDao struct {
// ServerBattlePassColumns defines and stores column names for table server_battle_pass. // ServerBattlePassColumns defines and stores column names for table server_battle_pass.
type ServerBattlePassColumns struct { type ServerBattlePassColumns struct {
Id string // Id string //
Server string // 区服
Uid string // 账号id Uid string // 账号id
Server string // 区服
PeriodId string // 战令期数 PeriodId string // 战令期数
CDate string // 创建时间 CDate string // 创建时间
} }
@ -30,8 +30,8 @@ type ServerBattlePassColumns struct {
// serverBattlePassColumns holds the columns for table server_battle_pass. // serverBattlePassColumns holds the columns for table server_battle_pass.
var serverBattlePassColumns = ServerBattlePassColumns{ var serverBattlePassColumns = ServerBattlePassColumns{
Id: "id", Id: "id",
Server: "server",
Uid: "uid", Uid: "uid",
Server: "server",
PeriodId: "period_id", PeriodId: "period_id",
CDate: "c_date", CDate: "c_date",
} }

2
internal/model/do/advertisement_oceanegine.go

@ -22,4 +22,6 @@ type AdvertisementOceanegine struct {
Idfa interface{} // Idfa interface{} //
Os interface{} // 安卓:0 IOS:1 其他:3 Os interface{} // 安卓:0 IOS:1 其他:3
UnitId interface{} // UnitId interface{} //
Caid interface{} //
Ip interface{} //
} }

2
internal/model/do/server_battle_pass.go

@ -13,8 +13,8 @@ import (
type ServerBattlePass struct { type ServerBattlePass struct {
g.Meta `orm:"table:server_battle_pass, do:true"` g.Meta `orm:"table:server_battle_pass, do:true"`
Id interface{} // Id interface{} //
Server interface{} // 区服
Uid interface{} // 账号id Uid interface{} // 账号id
Server interface{} // 区服
PeriodId interface{} // 战令期数 PeriodId interface{} // 战令期数
CDate *gtime.Time // 创建时间 CDate *gtime.Time // 创建时间
} }

2
internal/model/entity/advertisement_oceanegine.go

@ -20,4 +20,6 @@ type AdvertisementOceanegine struct {
Idfa string `json:"idfa" description:""` Idfa string `json:"idfa" description:""`
Os int `json:"os" description:"安卓:0 IOS:1 其他:3"` Os int `json:"os" description:"安卓:0 IOS:1 其他:3"`
UnitId int64 `json:"unitId" description:""` UnitId int64 `json:"unitId" description:""`
Caid string `json:"caid" description:""`
Ip string `json:"ip" description:""`
} }

2
internal/model/entity/server_battle_pass.go

@ -11,8 +11,8 @@ import (
// ServerBattlePass is the golang structure for table server_battle_pass. // ServerBattlePass is the golang structure for table server_battle_pass.
type ServerBattlePass struct { type ServerBattlePass struct {
Id int64 `json:"id" description:""` Id int64 `json:"id" description:""`
Server int `json:"server" description:"区服"`
Uid int64 `json:"uid" description:"账号id"` Uid int64 `json:"uid" description:"账号id"`
Server int `json:"server" description:"区服"`
PeriodId int `json:"periodId" description:"战令期数"` PeriodId int `json:"periodId" description:"战令期数"`
CDate *gtime.Time `json:"cDate" description:"创建时间"` CDate *gtime.Time `json:"cDate" description:"创建时间"`
} }

20
internal/serviceGame/advertisement.go

@ -2,6 +2,7 @@ package serviceGame
import ( import (
"context" "context"
"encoding/json"
"errors" "errors"
"strconv" "strconv"
"tyj_admin/api/v1/game" "tyj_admin/api/v1/game"
@ -16,7 +17,7 @@ type IAdvertisement interface {
AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.ATHARes, err error) AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.ATHARes, err error)
ConversionHugeAmount(ctx context.Context, req *game.CSHAReq) (res *game.CSHARes, err error) ConversionHugeAmount(ctx context.Context, req *game.CSHAReq) (res *game.CSHARes, err error)
AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, err error) AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, err error)
AdvertiseHugeAmount1(ctx context.Context, androidId, idfa, os, callBack, timestamp string) (err error) AdvertiseHugeAmount1(ctx context.Context, androidId, idfa, os, callBack, timestamp, caid, ip string) (err error)
GetAccessToken(ctx context.Context, req *game.GetAccessTokenReq) (res *game.GetAccessTokenRes, err error) GetAccessToken(ctx context.Context, req *game.GetAccessTokenReq) (res *game.GetAccessTokenRes, err error)
RefreshAccessToken(ctx context.Context, req *game.RefreshAccessTokenReq) (res *game.RefreshAccessTokenRes, err error) RefreshAccessToken(ctx context.Context, req *game.RefreshAccessTokenReq) (res *game.RefreshAccessTokenRes, err error)
} }
@ -60,7 +61,7 @@ func (g *advertisementImpl) AdvertiseHugeAmount(ctx context.Context, req *game.A
return return
} }
func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId, idfa, os, callBack, timestamp string) (err error) { func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId, idfa, os, callBack, timestamp, caidlist, ip string) (err error) {
osInt, err := strconv.Atoi(os) osInt, err := strconv.Atoi(os)
if err != nil { if err != nil {
return return
@ -74,12 +75,27 @@ func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId,
if osInt == 0 && androidId == "__ANDROIDID__" { if osInt == 0 && androidId == "__ANDROIDID__" {
return return
} }
caid := ""
if caidlist != "" {
var list []map[string]string
_ = json.Unmarshal([]byte(caidlist), &list)
versionNow := int64(0)
for _, v := range list {
version, _ := strconv.ParseInt(v["version"], 10, 64)
if versionNow < version {
caid = v["caid"]
versionNow = version
}
}
}
_, err = dao.AdvertisementOceanegine.Ctx(ctx).Insert(do.AdvertisementOceanegine{ _, err = dao.AdvertisementOceanegine.Ctx(ctx).Insert(do.AdvertisementOceanegine{
AdvAndroidId: androidId, AdvAndroidId: androidId,
Idfa: idfa, Idfa: idfa,
Os: os, Os: os,
CallbackParam: callBack, CallbackParam: callBack,
Caid: caid,
LastTouchTime: timestamp, LastTouchTime: timestamp,
Ip: ip,
}) })
return return
} }

37
internal/serviceGame/internal/advertisement.go

@ -130,16 +130,23 @@ func AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.AT
//if req.Idfa != "" { //if req.Idfa != "" {
_ = model.Where("idfa=?", req.Idfa).Page(1, 1).Scan(&adData) _ = model.Where("idfa=?", req.Idfa).Page(1, 1).Scan(&adData)
//} //}
//if len(adData) == 0 { if len(adData) == 0 {
// if req.Idfv != "" { if req.Caid != "" {
// _ = model.Where("adv_idfv=?", req.Idfv).Scan(&adData) var list []map[string]string
// } _ = json.Unmarshal([]byte(req.Caid), &list)
for _, v := range list {
_ = model.Where("caid=?", v["caid"]).Page(1, 1).Scan(&adData)
if len(adData) > 0 {
break
}
}
}
if len(adData) == 0 { if len(adData) == 0 {
log.Printf("AttributionHugeAmount: adData is nil %s", gjson.MustEncodeString(req)) log.Printf("AttributionHugeAmount: adData is nil %s", gjson.MustEncodeString(req))
err = errors.New("account is nil") err = errors.New("account is nil")
return return
} }
//} }
data["idfv"] = req.Idfv data["idfv"] = req.Idfv
} else { } else {
err = errors.New("platform is error " + req.Platform) err = errors.New("platform is error " + req.Platform)
@ -234,16 +241,24 @@ func ConversionHugeAmount(ctx context.Context, req *game.CSHAReq) (res *game.CSH
//if req.Idfa != "" && req.Idfa != "00000000-0000-0000-0000-000000000000" { //if req.Idfa != "" && req.Idfa != "00000000-0000-0000-0000-000000000000" {
_ = model.Where("idfa=?", req.Idfa).Page(1, 1).Scan(&adData) _ = model.Where("idfa=?", req.Idfa).Page(1, 1).Scan(&adData)
//} //}
//if len(adData) == 0 { if len(adData) == 0 {
// if req.Id != "" { if req.Caid != "" {
// _ = model.Where("adv_idfv=?", req.Id).Scan(&adData) var list []map[string]string
// } _ = json.Unmarshal([]byte(req.Caid), &list)
for _, v := range list {
_ = model.Where("caid=?", v["caid"]).Page(1, 1).Scan(&adData)
if len(adData) > 0 {
break
}
}
}
if len(adData) == 0 { if len(adData) == 0 {
log.Printf("ConversionHugeAmount: adData is nil %s", gjson.MustEncodeString(req)) log.Printf("ConversionHugeAmount: adData is nil %s", gjson.MustEncodeString(req))
err = errors.New("account is nil") err = errors.New("account is nil")
return return
} }
//} }
device["idfv"] = req.Id device["idfv"] = req.Id
} else { } else {
err = errors.New("platform is error " + req.Platform) err = errors.New("platform is error " + req.Platform)
@ -312,6 +327,7 @@ func HugeAmount(ctx context.Context, req *game.AdvertiseHAReq) {
EventType: req.EventType, EventType: req.EventType,
Properties: req.Properties, Properties: req.Properties,
UnitId: req.UnitId, UnitId: req.UnitId,
Caid: req.Caid,
} }
req2.Id = req.Id req2.Id = req.Id
_, err := ConversionHugeAmount(ctx, &req2) _, err := ConversionHugeAmount(ctx, &req2)
@ -324,6 +340,7 @@ func HugeAmount(ctx context.Context, req *game.AdvertiseHAReq) {
PackageName: req.PackageName, PackageName: req.PackageName,
Idfa: req.Idfa, Idfa: req.Idfa,
UnitId: req.UnitId, UnitId: req.UnitId,
Caid: req.Caid,
} }
if req.Platform == "android" { if req.Platform == "android" {
req1.AndroidId = req.Id req1.AndroidId = req.Id

10
internal/serviceGame/internal/server_battle_pass.go

@ -124,13 +124,13 @@ func InsertBattlePass(ctx context.Context, req *game.InsertBattlePassReq) (err e
func CheckBattlePass(ctx context.Context, req *game.CheckBattlePassReq) (total int64, err error) { func CheckBattlePass(ctx context.Context, req *game.CheckBattlePassReq) (total int64, err error) {
log.Print("CheckBattlePass", gjson.MustEncodeString(req)) log.Print("CheckBattlePass", gjson.MustEncodeString(req))
filter1 := bson.M{"$and": bson.A{bson.M{"PeriodId": req.PeriodId}, bson.M{"Server": req.Server}}} filter1 := bson.M{"PeriodId": req.PeriodId, "Server": req.Server}
log.Printf("CheckBattlePass filter %v", gjson.MustEncodeString(filter1)) log.Printf("CheckBattlePass filter %v", gjson.MustEncodeString(filter1))
total, err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter1).Count() total, err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter1).Count()
if total > 0 { //if total > 0 {
err = errors.New(fmt.Sprint(req.Server) + "区期数重复配置") // err = errors.New(fmt.Sprint(req.Server) + "区期数重复配置")
return // return
} //}
//beginTime, _ := strconv.ParseInt(req.BeginTime, 10, 64) //beginTime, _ := strconv.ParseInt(req.BeginTime, 10, 64)
//log.Print("CheckBattlePass", gjson.MustEncodeString(req)) //log.Print("CheckBattlePass", gjson.MustEncodeString(req))
//filter := bson.M{"$and": bson.A{bson.M{"BeginTime": bson.M{"$gte": beginTime}}, bson.M{"Server": req.Server}}} //filter := bson.M{"$and": bson.A{bson.M{"BeginTime": bson.M{"$gte": beginTime}}, bson.M{"Server": req.Server}}}

Loading…
Cancel
Save