|
|
|
package serviceGame
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"strconv"
|
|
|
|
"tyj_admin/api/v1/game"
|
|
|
|
"tyj_admin/internal/dao"
|
|
|
|
"tyj_admin/internal/model/do"
|
|
|
|
"tyj_admin/internal/serviceGame/internal"
|
|
|
|
)
|
|
|
|
|
|
|
|
type IAdvertisement interface {
|
|
|
|
Advertise(ctx context.Context, req *game.ADReq) (res *game.ADRes, err error)
|
|
|
|
DeepAdvertise(ctx context.Context, req *game.DeepADReq) (res *game.DeepADRes, 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)
|
|
|
|
AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, 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)
|
|
|
|
}
|
|
|
|
|
|
|
|
type advertisementImpl struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
var advertisementService = advertisementImpl{}
|
|
|
|
|
|
|
|
func Advertisement() IAdvertisement {
|
|
|
|
return &advertisementService
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *advertisementImpl) Advertise(ctx context.Context, req *game.ADReq) (res *game.ADRes, err error) {
|
|
|
|
res = new(game.ADRes)
|
|
|
|
res, err = internal.Advertise(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *advertisementImpl) DeepAdvertise(ctx context.Context, req *game.DeepADReq) (res *game.DeepADRes, err error) {
|
|
|
|
res = new(game.DeepADRes)
|
|
|
|
res, err = internal.DeepAdvertise(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *advertisementImpl) AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.ATHARes, err error) {
|
|
|
|
res = new(game.ATHARes)
|
|
|
|
res, err = internal.AttributionHugeAmount(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *advertisementImpl) ConversionHugeAmount(ctx context.Context, req *game.CSHAReq) (res *game.CSHARes, err error) {
|
|
|
|
res = new(game.CSHARes)
|
|
|
|
res, err = internal.ConversionHugeAmount(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *advertisementImpl) AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, err error) {
|
|
|
|
res = new(game.AdvertiseHARes)
|
|
|
|
res, err = internal.AdvertiseHugeAmount(ctx, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
if osInt != 0 && osInt != 1 {
|
|
|
|
return errors.New("系统类型错误!")
|
|
|
|
}
|
|
|
|
if osInt == 1 && idfa == "__IDFA__" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *advertisementImpl) GetAccessToken(ctx context.Context, req *game.GetAccessTokenReq) (res *game.GetAccessTokenRes, err error) {
|
|
|
|
res = new(game.GetAccessTokenRes)
|
|
|
|
res.Msg = internal.GetAccessToken(ctx, req.AuthCode)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *advertisementImpl) RefreshAccessToken(ctx context.Context, req *game.RefreshAccessTokenReq) (res *game.RefreshAccessTokenRes, err error) {
|
|
|
|
internal.RefreshAccessToken(ctx)
|
|
|
|
return
|
|
|
|
}
|