diff --git a/api/v1/game/advertisement.go b/api/v1/game/advertisement.go index d368c75..c36402c 100644 --- a/api/v1/game/advertisement.go +++ b/api/v1/game/advertisement.go @@ -55,6 +55,7 @@ type ATHAReq struct { AndroidId string `p:"android_id"` PackageName string `p:"package_name"` UnitId string `p:"unitId"` + Caid string `p:"caid"` } type HugeAmount struct { @@ -93,6 +94,7 @@ type CSHAReq struct { Idfa string `p:"idfa"` Properties string `p:"properties"` UnitId string `p:"unitId"` + Caid string `p:"caid"` } type CSHARes struct { @@ -109,6 +111,7 @@ type AdvertiseHAReq struct { PackageName string `p:"package_name"` Properties string `p:"properties"` UnitId string `p:"unitId"` + Caid string `p:"caid"` } type AdvertiseHARes struct { @@ -123,6 +126,8 @@ type AdvertiseHA1Req struct { TIMESTAMP string `p:"TIMESTAMP"` Callback string `p:"callback"` Androidid string `p:"androidid"` + Caid string `p:"caid"` + Ip string `p:"ip"` } type AdvertiseHA1Res struct { @@ -137,6 +142,8 @@ type AdvertiseHA2Req struct { TIMESTAMP string `p:"TIMESTAMP"` Callback string `p:"callback"` Androidid string `p:"androidid"` + Caid string `p:"caid"` + Ip string `p:"ip"` } type AdvertiseHA2Res struct { @@ -151,6 +158,8 @@ type AdvertiseHA3Req struct { TIMESTAMP string `p:"TIMESTAMP"` Callback string `p:"callback"` Androidid string `p:"androidid"` + Caid string `p:"caid"` + Ip string `p:"ip"` } type AdvertiseHA3Res struct { @@ -165,6 +174,8 @@ type AdvertiseHA4Req struct { TIMESTAMP string `p:"TIMESTAMP"` Callback string `p:"callback"` Androidid string `p:"androidid"` + Caid string `p:"caid"` + Ip string `p:"ip"` } type AdvertiseHA4Res struct { @@ -179,6 +190,8 @@ type AdvertiseHA5Req struct { TIMESTAMP string `p:"TIMESTAMP"` Callback string `p:"callback"` Androidid string `p:"androidid"` + Caid string `p:"caid"` + Ip string `p:"ip"` } type AdvertiseHA5Res struct { diff --git a/internal/controller/game_pub.go b/internal/controller/game_pub.go index 7931ca6..81a25e2 100644 --- a/internal/controller/game_pub.go +++ b/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) { //log.Print("AdvertiseHugeAmount1", gjson.MustEncodeString(req)) 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 } func (c *pubController) AdvertiseHugeAmount2(ctx context.Context, req *game.AdvertiseHA2Req) (res *game.AdvertiseHA2Res, err error) { //log.Print("AdvertiseHugeAmount2", gjson.MustEncodeString(req)) 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 } func (c *pubController) AdvertiseHugeAmount3(ctx context.Context, req *game.AdvertiseHA3Req) (res *game.AdvertiseHA3Res, err error) { //log.Print("AdvertiseHugeAmount3", gjson.MustEncodeString(req)) 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 } func (c *pubController) AdvertiseHugeAmount4(ctx context.Context, req *game.AdvertiseHA4Req) (res *game.AdvertiseHA4Res, err error) { //log.Print("AdvertiseHugeAmount4", gjson.MustEncodeString(req)) 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 } func (c *pubController) AdvertiseHugeAmount5(ctx context.Context, req *game.AdvertiseHA5Req) (res *game.AdvertiseHA5Res, err error) { //log.Print("AdvertiseHugeAmount5", gjson.MustEncodeString(req)) 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 } diff --git a/internal/dao/internal/advertisement_oceanegine.go b/internal/dao/internal/advertisement_oceanegine.go index 9d0f433..117c8be 100644 --- a/internal/dao/internal/advertisement_oceanegine.go +++ b/internal/dao/internal/advertisement_oceanegine.go @@ -30,6 +30,8 @@ type AdvertisementOceanegineColumns struct { Idfa string // Os string // 安卓:0 IOS:1 其他:3 UnitId string // + Caid string // + Ip string // } // advertisementOceanegineColumns holds the columns for table advertisement_oceanegine. @@ -44,6 +46,8 @@ var advertisementOceanegineColumns = AdvertisementOceanegineColumns{ Idfa: "idfa", Os: "os", UnitId: "unitId", + Caid: "caid", + Ip: "ip", } // NewAdvertisementOceanegineDao creates and returns a new DAO object for table data access. diff --git a/internal/dao/internal/server_battle_pass.go b/internal/dao/internal/server_battle_pass.go index 9ba1624..ab2db36 100644 --- a/internal/dao/internal/server_battle_pass.go +++ b/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. type ServerBattlePassColumns struct { Id string // - Server string // 区服 Uid string // 账号id + Server string // 区服 PeriodId string // 战令期数 CDate string // 创建时间 } @@ -30,8 +30,8 @@ type ServerBattlePassColumns struct { // serverBattlePassColumns holds the columns for table server_battle_pass. var serverBattlePassColumns = ServerBattlePassColumns{ Id: "id", - Server: "server", Uid: "uid", + Server: "server", PeriodId: "period_id", CDate: "c_date", } diff --git a/internal/model/do/advertisement_oceanegine.go b/internal/model/do/advertisement_oceanegine.go index a212fc0..ef27f29 100644 --- a/internal/model/do/advertisement_oceanegine.go +++ b/internal/model/do/advertisement_oceanegine.go @@ -22,4 +22,6 @@ type AdvertisementOceanegine struct { Idfa interface{} // Os interface{} // 安卓:0 IOS:1 其他:3 UnitId interface{} // + Caid interface{} // + Ip interface{} // } diff --git a/internal/model/do/server_battle_pass.go b/internal/model/do/server_battle_pass.go index 23b2420..fdb1228 100644 --- a/internal/model/do/server_battle_pass.go +++ b/internal/model/do/server_battle_pass.go @@ -13,8 +13,8 @@ import ( type ServerBattlePass struct { g.Meta `orm:"table:server_battle_pass, do:true"` Id interface{} // - Server interface{} // 区服 Uid interface{} // 账号id + Server interface{} // 区服 PeriodId interface{} // 战令期数 CDate *gtime.Time // 创建时间 } diff --git a/internal/model/entity/advertisement_oceanegine.go b/internal/model/entity/advertisement_oceanegine.go index 07fc44d..8d3eaba 100644 --- a/internal/model/entity/advertisement_oceanegine.go +++ b/internal/model/entity/advertisement_oceanegine.go @@ -20,4 +20,6 @@ type AdvertisementOceanegine struct { Idfa string `json:"idfa" description:""` Os int `json:"os" description:"安卓:0 IOS:1 其他:3"` UnitId int64 `json:"unitId" description:""` + Caid string `json:"caid" description:""` + Ip string `json:"ip" description:""` } diff --git a/internal/model/entity/server_battle_pass.go b/internal/model/entity/server_battle_pass.go index 1076b1a..a27cf7f 100644 --- a/internal/model/entity/server_battle_pass.go +++ b/internal/model/entity/server_battle_pass.go @@ -11,8 +11,8 @@ import ( // ServerBattlePass is the golang structure for table server_battle_pass. type ServerBattlePass struct { Id int64 `json:"id" description:""` - Server int `json:"server" description:"区服"` Uid int64 `json:"uid" description:"账号id"` + Server int `json:"server" description:"区服"` PeriodId int `json:"periodId" description:"战令期数"` CDate *gtime.Time `json:"cDate" description:"创建时间"` } diff --git a/internal/serviceGame/advertisement.go b/internal/serviceGame/advertisement.go index acdc0fb..bed99d1 100644 --- a/internal/serviceGame/advertisement.go +++ b/internal/serviceGame/advertisement.go @@ -2,6 +2,7 @@ package serviceGame import ( "context" + "encoding/json" "errors" "strconv" "tyj_admin/api/v1/game" @@ -16,7 +17,7 @@ type IAdvertisement interface { AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.ATHARes, 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) - 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) 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 } -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) if err != nil { return @@ -74,12 +75,27 @@ func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId, if osInt == 0 && androidId == "__ANDROIDID__" { 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{ AdvAndroidId: androidId, Idfa: idfa, Os: os, CallbackParam: callBack, + Caid: caid, LastTouchTime: timestamp, + Ip: ip, }) return } diff --git a/internal/serviceGame/internal/advertisement.go b/internal/serviceGame/internal/advertisement.go index 7aef1b5..13a83cc 100644 --- a/internal/serviceGame/internal/advertisement.go +++ b/internal/serviceGame/internal/advertisement.go @@ -130,16 +130,23 @@ func AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.AT //if req.Idfa != "" { _ = model.Where("idfa=?", req.Idfa).Page(1, 1).Scan(&adData) //} - //if len(adData) == 0 { - // if req.Idfv != "" { - // _ = model.Where("adv_idfv=?", req.Idfv).Scan(&adData) - // } if len(adData) == 0 { - log.Printf("AttributionHugeAmount: adData is nil %s", gjson.MustEncodeString(req)) - err = errors.New("account is nil") - return + if req.Caid != "" { + 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 { + log.Printf("AttributionHugeAmount: adData is nil %s", gjson.MustEncodeString(req)) + err = errors.New("account is nil") + return + } } - //} data["idfv"] = req.Idfv } else { 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" { _ = model.Where("idfa=?", req.Idfa).Page(1, 1).Scan(&adData) //} - //if len(adData) == 0 { - // if req.Id != "" { - // _ = model.Where("adv_idfv=?", req.Id).Scan(&adData) - // } if len(adData) == 0 { - log.Printf("ConversionHugeAmount: adData is nil %s", gjson.MustEncodeString(req)) - err = errors.New("account is nil") - return + if req.Caid != "" { + 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 { + log.Printf("ConversionHugeAmount: adData is nil %s", gjson.MustEncodeString(req)) + err = errors.New("account is nil") + return + } } - //} device["idfv"] = req.Id } else { err = errors.New("platform is error " + req.Platform) @@ -312,6 +327,7 @@ func HugeAmount(ctx context.Context, req *game.AdvertiseHAReq) { EventType: req.EventType, Properties: req.Properties, UnitId: req.UnitId, + Caid: req.Caid, } req2.Id = req.Id _, err := ConversionHugeAmount(ctx, &req2) @@ -324,6 +340,7 @@ func HugeAmount(ctx context.Context, req *game.AdvertiseHAReq) { PackageName: req.PackageName, Idfa: req.Idfa, UnitId: req.UnitId, + Caid: req.Caid, } if req.Platform == "android" { req1.AndroidId = req.Id diff --git a/internal/serviceGame/internal/server_battle_pass.go b/internal/serviceGame/internal/server_battle_pass.go index bca9ead..38f1a24 100644 --- a/internal/serviceGame/internal/server_battle_pass.go +++ b/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) { 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)) total, err = MongoDatabaseList["0"].Collection(consts.PeachAdmin_Db_Battle_pass).Find(ctx, filter1).Count() - if total > 0 { - err = errors.New(fmt.Sprint(req.Server) + "区期数重复配置") - return - } + //if total > 0 { + // err = errors.New(fmt.Sprint(req.Server) + "区期数重复配置") + // return + //} //beginTime, _ := strconv.ParseInt(req.BeginTime, 10, 64) //log.Print("CheckBattlePass", gjson.MustEncodeString(req)) //filter := bson.M{"$and": bson.A{bson.M{"BeginTime": bson.M{"$gte": beginTime}}, bson.M{"Server": req.Server}}}