|
|
|
@ -7,6 +7,7 @@ import ( |
|
|
|
"log" |
|
|
|
"log" |
|
|
|
"math" |
|
|
|
"math" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"sync" |
|
|
|
"tyj_admin/api/v1/game" |
|
|
|
"tyj_admin/api/v1/game" |
|
|
|
"tyj_admin/internal/dao" |
|
|
|
"tyj_admin/internal/dao" |
|
|
|
"tyj_admin/internal/model/do" |
|
|
|
"tyj_admin/internal/model/do" |
|
|
|
@ -21,12 +22,14 @@ type IAdvertisement interface { |
|
|
|
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, caid, ip string) (err error) |
|
|
|
AdvertiseHugeAmount1(ctx context.Context, androidId, idfa, os, callBack, timestamp, caid, ip string) (err error) |
|
|
|
|
|
|
|
AdvertiseHugeAmountReadOnly(ctx context.Context, osInt int, list []map[string]string, caid, androidId, idfa, os, callBack, timestamp, 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) |
|
|
|
RefreshAdvertisementOceanegine(ctx context.Context, req *game.RefreshAdvertisementOceanegineReq) (res *game.RefreshAdvertisementOceanegineRes, err error) |
|
|
|
RefreshAdvertisementOceanegine(ctx context.Context, req *game.RefreshAdvertisementOceanegineReq) (res *game.RefreshAdvertisementOceanegineRes, err error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type advertisementImpl struct { |
|
|
|
type advertisementImpl struct { |
|
|
|
|
|
|
|
sync.RWMutex |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var advertisementService = advertisementImpl{} |
|
|
|
var advertisementService = advertisementImpl{} |
|
|
|
@ -83,8 +86,9 @@ func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId, |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
caid := "" |
|
|
|
caid := "" |
|
|
|
if caidList != "" { |
|
|
|
|
|
|
|
var list []map[string]string |
|
|
|
var list []map[string]string |
|
|
|
|
|
|
|
if caidList != "" { |
|
|
|
|
|
|
|
//var list []map[string]string
|
|
|
|
_ = json.Unmarshal([]byte(caidList), &list) |
|
|
|
_ = json.Unmarshal([]byte(caidList), &list) |
|
|
|
versionNow := int64(0) |
|
|
|
versionNow := int64(0) |
|
|
|
for _, v := range list { |
|
|
|
for _, v := range list { |
|
|
|
@ -95,29 +99,27 @@ func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = g.AdvertiseHugeAmountReadOnly(ctx, osInt, list, caid, androidId, idfa, os, callBack, timestamp, ip) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (g *advertisementImpl) AdvertiseHugeAmountReadOnly(ctx context.Context, osInt int, list []map[string]string, caid, androidId, idfa, os, callBack, timestamp, ip string) (err error) { |
|
|
|
|
|
|
|
//g.Lock()
|
|
|
|
model := dao.AdvertisementOceanegine1.Ctx(ctx) |
|
|
|
model := dao.AdvertisementOceanegine1.Ctx(ctx) |
|
|
|
lastTouchTime, _ := strconv.ParseInt(timestamp, 10, 64) |
|
|
|
lastTouchTime, _ := strconv.ParseInt(timestamp, 10, 64) |
|
|
|
adDatas := []entity.AdvertisementOceanegine1{} |
|
|
|
adDatas := []entity.AdvertisementOceanegine1{} |
|
|
|
if osInt == 0 { |
|
|
|
if osInt == 0 { |
|
|
|
_ = model.Where("adv_android_id=?", androidId).Where("os=?", os).Scan(&adDatas) |
|
|
|
_ = model.Where("adv_android_id=?", androidId).Where("os=?", os).Scan(&adDatas) |
|
|
|
} else if osInt == 1 { |
|
|
|
} else if osInt == 1 { |
|
|
|
if caidList != "" { |
|
|
|
|
|
|
|
var list []map[string]string |
|
|
|
|
|
|
|
_ = json.Unmarshal([]byte(caidList), &list) |
|
|
|
|
|
|
|
for _, v := range list { |
|
|
|
for _, v := range list { |
|
|
|
adDatas1 := []entity.AdvertisementOceanegine1{} |
|
|
|
_ = model.Where("caid=?", v["caid"]).Where("os=?", os).Scan(&adDatas) |
|
|
|
_ = model.Where("caid=?", v["caid"]).Where("os=?", os).Scan(&adDatas1) |
|
|
|
|
|
|
|
if len(adDatas) > 0 { |
|
|
|
if len(adDatas) > 0 { |
|
|
|
adDatas = append(adDatas, adDatas1...) |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if idfa != "" { |
|
|
|
|
|
|
|
adDatas1 := []entity.AdvertisementOceanegine1{} |
|
|
|
|
|
|
|
_ = model.Where("idfa=?", idfa).Where("os=?", os).Scan(&adDatas1) |
|
|
|
|
|
|
|
if len(adDatas1) > 0 { |
|
|
|
|
|
|
|
adDatas = append(adDatas, adDatas1...) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if idfa != "" && len(adDatas) == 0 { |
|
|
|
|
|
|
|
_ = model.Where("idfa=?", idfa).Where("os=?", os).Scan(&adDatas) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if len(adDatas) > 0 { |
|
|
|
if len(adDatas) > 0 { |
|
|
|
@ -129,14 +131,16 @@ func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId, |
|
|
|
} |
|
|
|
} |
|
|
|
if adData.LastTouchTime > lastTouchTime { |
|
|
|
if adData.LastTouchTime > lastTouchTime { |
|
|
|
err = errors.New("不是最后一次!") |
|
|
|
err = errors.New("不是最后一次!") |
|
|
|
|
|
|
|
//g.Unlock()
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_, err = model.WherePri(adData.Id).Update(do.AdvertisementOceanegine1{CallbackParam: callBack, LastTouchTime: timestamp, Caid: caid}) |
|
|
|
_, err = model.WherePri(adData.Id).Update(do.AdvertisementOceanegine1{CallbackParam: callBack, LastTouchTime: timestamp, Caid: caid}) |
|
|
|
|
|
|
|
//g.Unlock()
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_, err = dao.AdvertisementOceanegine1.Ctx(ctx).Insert(do.AdvertisementOceanegine1{ |
|
|
|
_, err = model.Insert(do.AdvertisementOceanegine1{ |
|
|
|
AdvAndroidId: androidId, |
|
|
|
AdvAndroidId: androidId, |
|
|
|
Idfa: idfa, |
|
|
|
Idfa: idfa, |
|
|
|
Os: os, |
|
|
|
Os: os, |
|
|
|
@ -145,6 +149,7 @@ func (g *advertisementImpl) AdvertiseHugeAmount1(ctx context.Context, androidId, |
|
|
|
LastTouchTime: timestamp, |
|
|
|
LastTouchTime: timestamp, |
|
|
|
Ip: ip, |
|
|
|
Ip: ip, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
//g.Unlock()
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|