Browse Source

广告投放,排行榜删除-黑名单

master
linquan 2 months ago
parent
commit
4e55803378
  1. 89
      api/v1/game/advertisement.go
  2. 6
      api/v1/game/basicinfo.go
  3. 2
      api/v1/game/pub.go
  4. 11
      api/v1/game/rank.go
  5. 31
      internal/controller/game_pub.go
  6. 5
      internal/controller/game_rank.go
  7. 27
      internal/dao/advertisement_oceanegine.go
  8. 85
      internal/dao/internal/advertisement_oceanegine.go
  9. 4
      internal/dao/internal/game_unit.go
  10. 22
      internal/model/do/advertisement_oceanegine.go
  11. 2
      internal/model/do/game_unit.go
  12. 20
      internal/model/entity/advertisement_oceanegine.go
  13. 2
      internal/model/entity/game_unit.go
  14. 16
      internal/service/internal/dao/internal/game_white_list.go
  15. 7
      internal/serviceGame/advertisement.go
  16. 54
      internal/serviceGame/game_role.go
  17. 141
      internal/serviceGame/internal/advertisement.go
  18. 14
      internal/serviceGame/internal/basicinfo.go
  19. 1
      internal/serviceGame/internal/manage.go
  20. 2
      internal/serviceGame/notice.go
  21. 54
      internal/serviceGame/rank.go

89
api/v1/game/advertisement.go

@ -48,12 +48,11 @@ type DeepADRes struct {
}
type ATHAReq struct {
g.Meta `path:"/attributionHA" tags:"ad" method:"get" summary:"广告投放"`
Platform string `p:"platform"`
Idfv string `p:"idfv"`
AndroidId string `p:"android_id"`
PackageName string `p:"package_name"`
CustomerActiveTime string `p:"customer_active_time"`
g.Meta `path:"/attributionHA" tags:"ad" method:"get" summary:"广告投放"`
Platform string `p:"platform"`
Idfv string `p:"idfv"`
AndroidId string `p:"android_id"`
PackageName string `p:"package_name"`
}
type HugeAmount struct {
@ -95,3 +94,81 @@ type CSHARes struct {
g.Meta `mime:"application/json"`
Code int `json:"code"`
}
type AdvertiseHAReq struct {
g.Meta `path:"/advertiseHA" tags:"ad" method:"post" summary:"广告投放"`
EventType string `p:"event_type"`
Platform string `p:"platform"`
Id string `p:"id"`
PackageName string `p:"package_name"`
}
type AdvertiseHARes struct {
g.Meta `mime:"application/json"`
Code int `json:"code"`
}
type AdvertiseHA1Req struct {
g.Meta `path:"/advertiseHA1" tags:"ad" method:"get" summary:"广告投放"`
EventType string `p:"event_type"`
Platform string `p:"platform"`
Id string `p:"id"`
PackageName string `p:"package_name"`
}
type AdvertiseHA1Res struct {
g.Meta `mime:"application/json"`
Code int `json:"code"`
}
type AdvertiseHA2Req struct {
g.Meta `path:"/advertiseHA2" tags:"ad" method:"get" summary:"广告投放"`
EventType string `p:"event_type"`
Platform string `p:"platform"`
Id string `p:"id"`
PackageName string `p:"package_name"`
}
type AdvertiseHA2Res struct {
g.Meta `mime:"application/json"`
Code int `json:"code"`
}
type AdvertiseHA3Req struct {
g.Meta `path:"/advertiseHA3" tags:"ad" method:"get" summary:"广告投放"`
EventType string `p:"event_type"`
Platform string `p:"platform"`
Id string `p:"id"`
PackageName string `p:"package_name"`
}
type AdvertiseHA3Res struct {
g.Meta `mime:"application/json"`
Code int `json:"code"`
}
type AdvertiseHA4Req struct {
g.Meta `path:"/advertiseHA4" tags:"ad" method:"get" summary:"广告投放"`
EventType string `p:"event_type"`
Platform string `p:"platform"`
Id string `p:"id"`
PackageName string `p:"package_name"`
}
type AdvertiseHA4Res struct {
g.Meta `mime:"application/json"`
Code int `json:"code"`
}
type AdvertiseHA5Req struct {
g.Meta `path:"/advertiseHA5" tags:"ad" method:"get" summary:"广告投放"`
EventType string `p:"event_type"`
Platform string `p:"platform"`
Id string `p:"id"`
PackageName string `p:"package_name"`
}
type AdvertiseHA5Res struct {
g.Meta `mime:"application/json"`
Code int `json:"code"`
}

6
api/v1/game/basicinfo.go

@ -50,8 +50,10 @@ type RoleOnlineTopReq struct {
}
type RoleOnlineTop struct {
Num int `json:"num"`
Server int `json:"server"`
Num int `json:"num"`
Date string `json:"date"`
Channel string `json:"channel"`
Server int `json:"server"`
}
type RoleOnlineTopRes struct {

2
api/v1/game/pub.go

@ -125,6 +125,8 @@ type RegisterReq struct {
Channel string `p:"channel"`
Server int `p:"server"`
OAID string `p:"OAID"`
Idfv string `p:"idfv"`
AndroidId string `p:"androidId"`
}
type RegisterRes struct {

11
api/v1/game/rank.go

@ -111,3 +111,14 @@ type GetGameRankRes struct {
g.Meta `mime:"application/json"`
Groups []map[string]interface{} `json:"list"`
}
type DeleteGameRankReq struct {
g.Meta `path:"/rank/deleteGameRank" tags:"排行榜" method:"get" summary:"获取游戏排行榜"`
Uid int64 `p:"uid"`
ServerId int `p:"serverId" v:"required|min:1#服务器ID不能为空"`
}
type DeleteGameRankRes struct {
g.Meta `mime:"application/json"`
Mess string `json:"mess"`
}

31
internal/controller/game_pub.go

@ -235,3 +235,34 @@ func (c *pubController) ConversionHugeAmount(ctx context.Context, req *game.CSHA
res, err = serviceGame.Advertisement().ConversionHugeAmount(ctx, req)
return
}
func (c *pubController) AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, err error) {
log.Print("AdvertiseHugeAmount", gjson.MustEncodeString(req))
res, err = serviceGame.Advertisement().AdvertiseHugeAmount(ctx, req)
return
}
func (c *pubController) AdvertiseHugeAmount1(ctx context.Context, req *game.AdvertiseHA1Req) (res *game.AdvertiseHA1Res, err error) {
log.Print("AdvertiseHugeAmount1", gjson.MustEncodeString(req))
return
}
func (c *pubController) AdvertiseHugeAmount2(ctx context.Context, req *game.AdvertiseHA2Req) (res *game.AdvertiseHA2Res, err error) {
log.Print("AdvertiseHugeAmount2", gjson.MustEncodeString(req))
return
}
func (c *pubController) AdvertiseHugeAmount3(ctx context.Context, req *game.AdvertiseHA3Req) (res *game.AdvertiseHA3Res, err error) {
log.Print("AdvertiseHugeAmount3", gjson.MustEncodeString(req))
return
}
func (c *pubController) AdvertiseHugeAmount4(ctx context.Context, req *game.AdvertiseHA4Req) (res *game.AdvertiseHA4Res, err error) {
log.Print("AdvertiseHugeAmount4", gjson.MustEncodeString(req))
return
}
func (c *pubController) AdvertiseHugeAmount5(ctx context.Context, req *game.AdvertiseHA5Req) (res *game.AdvertiseHA5Res, err error) {
log.Print("AdvertiseHugeAmount5", gjson.MustEncodeString(req))
return
}

5
internal/controller/game_rank.go

@ -56,3 +56,8 @@ func (c *rankController) GetGameRank(ctx context.Context, req *game.GetGameRankR
res, err = serviceGame.GameRank().GetGameRank(ctx, req)
return
}
func (c *rankController) DeleteGameRank(ctx context.Context, req *game.DeleteGameRankReq) (res *game.DeleteGameRankRes, err error) {
res, err = serviceGame.GameRank().DeleteGameRank(ctx, req)
return
}

27
internal/dao/advertisement_oceanegine.go

@ -0,0 +1,27 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"tyj_admin/internal/dao/internal"
)
// internalAdvertisementOceanegineDao is internal type for wrapping internal DAO implements.
type internalAdvertisementOceanegineDao = *internal.AdvertisementOceanegineDao
// advertisementOceanegineDao is the data access object for table advertisement_oceanegine.
// You can define custom methods on it to extend its functionality as you wish.
type advertisementOceanegineDao struct {
internalAdvertisementOceanegineDao
}
var (
// AdvertisementOceanegine is globally public accessible object for table advertisement_oceanegine operations.
AdvertisementOceanegine = advertisementOceanegineDao{
internal.NewAdvertisementOceanegineDao(),
}
)
// Fill with you ideas below.

85
internal/dao/internal/advertisement_oceanegine.go

@ -0,0 +1,85 @@
// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// AdvertisementOceanegineDao is the data access object for table advertisement_oceanegine.
type AdvertisementOceanegineDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns AdvertisementOceanegineColumns // columns contains all the column names of Table for convenient usage.
}
// AdvertisementOceanegineColumns defines and stores column names for table advertisement_oceanegine.
type AdvertisementOceanegineColumns struct {
Id string //
AdvIdfv string //
AdvAndroidId string //
CallbackParam string //
CallbackUrl string //
LastTouchTime string //
CDate string //
}
// advertisementOceanegineColumns holds the columns for table advertisement_oceanegine.
var advertisementOceanegineColumns = AdvertisementOceanegineColumns{
Id: "id",
AdvIdfv: "adv_idfv",
AdvAndroidId: "adv_android_id",
CallbackParam: "callback_param",
CallbackUrl: "callback_url",
LastTouchTime: "last_touch_time",
CDate: "c_date",
}
// NewAdvertisementOceanegineDao creates and returns a new DAO object for table data access.
func NewAdvertisementOceanegineDao() *AdvertisementOceanegineDao {
return &AdvertisementOceanegineDao{
group: "default",
table: "advertisement_oceanegine",
columns: advertisementOceanegineColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *AdvertisementOceanegineDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *AdvertisementOceanegineDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *AdvertisementOceanegineDao) Columns() AdvertisementOceanegineColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *AdvertisementOceanegineDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *AdvertisementOceanegineDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *AdvertisementOceanegineDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

4
internal/dao/internal/game_unit.go

@ -36,6 +36,8 @@ type GameUnitColumns struct {
Day string // 游戏天数
Recharge string // 充值
OAID string //
Idfv string //
AndroidId string //
}
// gameUnitColumns holds the columns for table game_unit.
@ -56,6 +58,8 @@ var gameUnitColumns = GameUnitColumns{
Day: "day",
Recharge: "recharge",
OAID: "OAID",
Idfv: "idfv",
AndroidId: "android_id",
}
// NewGameUnitDao creates and returns a new DAO object for table data access.

22
internal/model/do/advertisement_oceanegine.go

@ -0,0 +1,22 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// AdvertisementOceanegine is the golang structure of table advertisement_oceanegine for DAO operations like Where/Data.
type AdvertisementOceanegine struct {
g.Meta `orm:"table:advertisement_oceanegine, do:true"`
Id interface{} //
AdvIdfv interface{} //
AdvAndroidId interface{} //
CallbackParam interface{} //
CallbackUrl interface{} //
LastTouchTime interface{} //
CDate *gtime.Time //
}

2
internal/model/do/game_unit.go

@ -28,4 +28,6 @@ type GameUnit struct {
Day interface{} // 游戏天数
Recharge interface{} // 充值
OAID interface{} //
Idfv interface{} //
AndroidId interface{} //
}

20
internal/model/entity/advertisement_oceanegine.go

@ -0,0 +1,20 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// AdvertisementOceanegine is the golang structure for table advertisement_oceanegine.
type AdvertisementOceanegine struct {
Id int64 `json:"id" description:""`
AdvIdfv string `json:"advIdfv" description:""`
AdvAndroidId string `json:"advAndroidId" description:""`
CallbackParam string `json:"callbackParam" description:""`
CallbackUrl string `json:"callbackUrl" description:""`
LastTouchTime int64 `json:"lastTouchTime" description:""`
CDate *gtime.Time `json:"cDate" description:""`
}

2
internal/model/entity/game_unit.go

@ -26,4 +26,6 @@ type GameUnit struct {
Day int `json:"day" description:"游戏天数"`
Recharge int64 `json:"recharge" description:"充值"`
OAID string `json:"oAID" description:""`
Idfv string `json:"idfv" description:""`
AndroidId string `json:"androidId" description:""`
}

16
internal/service/internal/dao/internal/game_white_list.go

@ -12,21 +12,21 @@ import (
// GameWhiteListDao is the data access object for table game_white_list.
type GameWhiteListDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns GameWhiteListColumns // columns contains all the column names of Table for convenient usage.
}
// GameWhiteListColumns defines and stores column names for table game_white_list.
type GameWhiteListColumns struct {
Id string //
Ip string //
Id string //
Ip string //
}
// gameWhiteListColumns holds the columns for table game_white_list.
// gameWhiteListColumns holds the columns for table game_white_list.
var gameWhiteListColumns = GameWhiteListColumns{
Id: "id",
Ip: "ip",
Id: "id",
Ip: "ip",
}
// NewGameWhiteListDao creates and returns a new DAO object for table data access.
@ -71,4 +71,4 @@ func (dao *GameWhiteListDao) Ctx(ctx context.Context) *gdb.Model {
// as it is automatically handled by this function.
func (dao *GameWhiteListDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}
}

7
internal/serviceGame/advertisement.go

@ -11,6 +11,7 @@ type IAdvertisement interface {
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)
}
type advertisementImpl struct {
@ -40,6 +41,12 @@ func (g *advertisementImpl) AttributionHugeAmount(ctx context.Context, req *game
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) ConversionHugeAmount(ctx context.Context, req *game.CSHAReq) (res *game.CSHARes, err error) {
res = new(game.CSHARes)
res, err = internal.ConversionHugeAmount(ctx, req)

54
internal/serviceGame/game_role.go

@ -53,7 +53,7 @@ func (s *gameRoleImpl) GetOnlineList(ctx context.Context, req *game.RoleOnlineRe
//fmt.Println("GetOnlineList: ", url, bytes)
src := string(bytes)
if g.IsEmpty(src) {
g.Log().Printf(ctx, "GetOnlineList: gerror.New(\"空回调,发送失败\")")
g.Log().Printf(ctx, "%d GetOnlineList: gerror.New(\"空回调,发送失败\")", req.ServerId)
return res, nil
}
@ -86,18 +86,58 @@ var DateFormat = "2006-01-02"
func (s *gameRoleImpl) GetOnlineTopList(ctx context.Context, req *game.RoleOnlineTopReq) (res *game.RoleOnlineTopRes, err error) {
res = new(game.RoleOnlineTopRes)
fsql := fmt.Sprintf(`select max(num) as num, max(server) AS server,channel, date from game_online where STR_TO_DATE(date, "%%Y-%%m-%%d")="%s" `, time.Now().Format(DateFormat))
fsql := fmt.Sprintf(`select num,server,channel,date from game_online where STR_TO_DATE(date, "%%Y-%%m-%%d")="%s" `, time.Now().Format(DateFormat))
if req.ServerId != 0 {
fsql += fmt.Sprintf(" and server=%d ", req.ServerId)
}
fsql += " group by date,server,channel"
sSql := fmt.Sprintf(`select sum(b.num) as num, max(b.server) AS server, b.date from (%s) as b group by b.date,b.server`, fsql)
tsql := fmt.Sprintf(`select max(a.num) as num, max(a.server) AS server from (%s) as a group by a.server asc`, sSql)
err = g.Model().Raw(tsql).Scan(&res.Onlines)
g.Log().Printf(ctx, "res.Onlines: %v", res.Onlines)
data := []game.RoleOnlineTop{}
err = g.Model().Raw(fsql).Scan(&data)
//g.Log().Printf(ctx, "res1: %v", gjson.MustEncodeString(data))
res1 := []game.RoleOnlineTop{}
for _, v := range data {
index := isContain(res1, v.Date, v.Server)
if index == -1 {
v1 := game.RoleOnlineTop{
Server: v.Server,
Date: v.Date,
Num: v.Num,
}
res1 = append(res1, v1)
} else {
res1[index].Num += v.Num
}
}
//g.Log().Printf(ctx, "res1: %v", gjson.MustEncodeString(res1))
for _, v := range res1 {
index := isContain(res.Onlines, "", v.Server)
if index == -1 {
v1 := game.RoleOnlineTop{
Server: v.Server,
Date: "",
Num: v.Num,
}
res.Onlines = append(res.Onlines, v1)
} else {
if res.Onlines[index].Num < v.Num {
res.Onlines[index].Num = v.Num
}
//g.Log().Printf(ctx, "v1: %v, v: %v", gjson.MustEncodeString(res.Onlines[index]), gjson.MustEncodeString(v))
}
}
g.Log().Printf(ctx, "res.Onlines: %v", gjson.MustEncodeString(res.Onlines))
return
}
func isContain(data []game.RoleOnlineTop, date string, server int) int {
for k, v := range data {
if date == v.Date && server == v.Server {
return k
}
}
return -1
}
func (s *gameRoleImpl) GetAccount(ctx context.Context, req *game.AccountReq) (res *game.AccountRes, err error) {
res, err = internal.GetAccount(ctx, req)
return

141
internal/serviceGame/internal/advertisement.go

@ -2,10 +2,14 @@ package internal
import (
"context"
"encoding/json"
"fmt"
"github.com/gogf/gf/v2/encoding/gcharset"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"log"
"strings"
"time"
"tyj_admin/api/v1/game"
"tyj_admin/internal/consts"
@ -85,44 +89,119 @@ func sendMsg(ctx context.Context, url string, eventType, amount int32) {
return
}
func sendMsgHugeAmount(ctx context.Context, url, platform, idfv, androidId, packageName string) {
//url := "https://analytics.oceanengine.com/sdk/app/attribution"
func sendMsgHugeAmount(ctx context.Context, url string, data map[string]interface{}) (string, error) {
g.Client().SetHeader("Content-Type", "application/json;charset=UTF-8")
data := map[string]string{
"platform": platform, // ios或android
"idfv": idfv, // 仅ios需要
"android_id": androidId, // 仅android需要
"package_name": packageName,
"customer_active_time": fmt.Sprint(time.Now().UnixMicro()), // 毫秒时间戳,客户激活归因时间点
}
bytes, _ := g.Client().Post(ctx, url, data)
g.Log().Info(ctx, "sendMsg - res: ", bytes)
return
log.Printf("sendMsgHugeAmount - url: %s, data: %s", url, gjson.MustEncodeString(data))
marshal, _ := json.Marshal(data)
bytes, err := g.Client().Post(ctx, url, string(marshal))
if err != nil {
return "", err
}
g.Log().Info(ctx, "sendMsgHugeAmount - res: ", bytes)
src := string(bytes.ReadAll())
tmp, err := gcharset.ToUTF8("UTF-8", src)
if err != nil {
return "", err
}
fmt.Println("Deposit - json: ", tmp)
return tmp, err
}
func AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.ATHARes, err error) {
log.Printf("Advertise: %s", gjson.MustEncodeString(req))
//g.Try(ctx, func(ctx context.Context) {
// model := dao.Advertisement.Ctx(ctx)
// _, err = model.Insert(do.Advertisement{Idfa: req.Idfa, Time: req.Time, Ip: req.Ip, OrgId: req.OrgId, OrgName: req.OrgName,
// GameId: req.GameId, GameName: req.GameName, AdsetId: req.AdsetId, AdsetNet: req.AdsetNet, DeviceBrand: req.DeviceBrand,
// DeviceModel: req.DeviceModel, CreativeId: req.CreativeId, ConversionType: req.ConversionType, Device: req.Device,
// OAID: req.OAID, Callback: req.Callback, TapProjectId: req.TapProjectId, TapTrackId: req.TapTrackId, IMEI: req.IMEI,
// ANID: req.ANID})
//})
log.Printf("AttributionHugeAmount: %s", gjson.MustEncodeString(req))
data := map[string]interface{}{
"platform": req.Platform, // ios或android
"package_name": req.PackageName,
"customer_active_time": fmt.Sprint(time.Now().UnixMilli()), // 毫秒时间戳,客户激活归因时间点
}
if req.Platform == "android" {
data["android_id"] = req.AndroidId
} else if req.Platform == "ios" {
data["idfv"] = req.Idfv
}
url := "https://analytics.oceanengine.com/sdk/app/attribution"
tmp, err := sendMsgHugeAmount(ctx, url, data)
if err != nil {
return
}
json, err := gjson.DecodeToJson(tmp)
if err != nil {
return
}
if json.Get("code").Int() == 0 {
callbackUrl := json.Get("callback_url").String()
callbackParam := json.Get("callback_param").String()
lastTouchTime := json.Get("last_touch_time").Int64()
model := dao.AdvertisementOceanegine.Ctx(ctx)
_, _ = model.Insert(do.AdvertisementOceanegine{AdvAndroidId: req.AndroidId, AdvIdfv: req.Idfv, CallbackUrl: callbackUrl, CallbackParam: callbackParam, LastTouchTime: lastTouchTime})
} else {
return nil, gerror.New("获取失败")
}
return
}
func ConversionHugeAmount(ctx context.Context, req *game.CSHAReq) (res *game.CSHARes, err error) {
log.Printf("Advertise: %s", gjson.MustEncodeString(req))
//g.Try(ctx, func(ctx context.Context) {
// model := dao.Advertisement.Ctx(ctx)
// _, err = model.Insert(do.Advertisement{Idfa: req.Idfa, Time: req.Time, Ip: req.Ip, OrgId: req.OrgId, OrgName: req.OrgName,
// GameId: req.GameId, GameName: req.GameName, AdsetId: req.AdsetId, AdsetNet: req.AdsetNet, DeviceBrand: req.DeviceBrand,
// DeviceModel: req.DeviceModel, CreativeId: req.CreativeId, ConversionType: req.ConversionType, Device: req.Device,
// OAID: req.OAID, Callback: req.Callback, TapProjectId: req.TapProjectId, TapTrackId: req.TapTrackId, IMEI: req.IMEI,
// ANID: req.ANID})
//})
log.Printf("ConversionHugeAmount: %s", gjson.MustEncodeString(req))
adData := []entity.AdvertisementOceanegine{}
device := map[string]interface{}{
"platform": req.Platform,
}
model := dao.AdvertisementOceanegine.Ctx(ctx).Order("last_touch_time desc")
if req.Platform == "android" {
_ = model.Where("adv_android_id=?", req.Id).Scan(&adData)
device["android_id"] = req.Id
} else if req.Platform == "ios" {
_ = model.Where("adv_idfv=?", req.Id).Scan(&adData)
device["idfv"] = req.Id
}
ad := map[string]interface{}{
"callback": adData[0].CallbackParam,
}
ct := map[string]interface{}{
"ad": ad,
"device": device,
}
data := map[string]interface{}{
"event_type": req.EventType,
"context": ct,
"timestamp": time.Now().UnixMilli(),
}
url := "https://analytics.oceanengine.com/api/v2/conversion"
_, _ = sendMsgHugeAmount(ctx, url, data)
return
}
func AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, err error) {
req.Platform = strings.ToLower(req.Platform)
log.Printf("AdvertiseHugeAmount: %s", gjson.MustEncodeString(req))
if req.EventType == "active" {
req1 := game.ATHAReq{
Platform: req.Platform,
PackageName: req.PackageName,
}
if req.Platform == "android" {
req1.AndroidId = req.Id
} else if req.Platform == "ios" {
req1.Idfv = req.Id
} else {
return
}
_, err = AttributionHugeAmount(ctx, &req1)
if err != nil {
return
}
}
req2 := game.CSHAReq{
Platform: req.Platform,
Id: req.Id,
EventType: req.EventType,
}
req2.Id = req.Id
_, err = ConversionHugeAmount(ctx, &req2)
return
}

14
internal/serviceGame/internal/basicinfo.go

@ -785,11 +785,13 @@ func GameRegister(ctx context.Context, req *game.RegisterReq) (res *game.Registe
})
}
_, err = dao.GameUnit.Ctx(ctx).Insert(&do.GameUnit{
Account: req.Account,
Channel: req.Channel,
Uid: req.Uid,
Server: req.Server,
OAID: req.OAID,
Account: req.Account,
Channel: req.Channel,
Uid: req.Uid,
Server: req.Server,
OAID: req.OAID,
Idfv: req.Idfv,
AndroidId: req.AndroidId,
})
if req.Channel == consts.Channel_TAPTAP {
@ -935,7 +937,7 @@ func sendAdvertisement(ctx context.Context, uid int64) {
log.Printf("sendAdvertisement===DeepAdvertise: err: %s", err.Error())
return
}
log.Printf("sendAdvertisement: OAID: %d, req1: %s", uid, gjson.MustEncodeString(req1))
log.Printf("sendAdvertisement: uid: %d, req1: %s", uid, gjson.MustEncodeString(req1))
}
func GameUnitChangeName(ctx context.Context, req *game.UnitChangeNameReq) (res *game.UnitChangeNameRes, err error) {

1
internal/serviceGame/internal/manage.go

@ -244,7 +244,6 @@ func GetLive(ctx context.Context, req *game.GetLiveReq) (res *game.GetLiveRes, e
}
HighSql += ` GROUP BY cd`
g.Model().Raw(HighSql).Scan(&res.HighLogs)
//g.Log().Info(ctx, "a== ", res)
return
}

2
internal/serviceGame/notice.go

@ -92,7 +92,7 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot
model := dao.GameNotice.Ctx(ctx)
model = model.Where("notice_type = ?", req.NoticeType)
ip := libUtils.GetClientIp(ctx)
fmt.Println("ip: ", ip)
//fmt.Println("ip: ", ip)
var ipList []*entity.GameNotice
err = model.Where("channel=?", ip).Scan(&ipList)

54
internal/serviceGame/rank.go

@ -2,6 +2,11 @@ package serviceGame
import (
"context"
"fmt"
"github.com/gogf/gf/v2/encoding/gcharset"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"log"
"tyj_admin/api/v1/game"
"tyj_admin/internal/serviceGame/internal"
@ -18,6 +23,7 @@ type IGameRank interface {
InsertAward(ctx context.Context, req *game.InsertRankAwardReq) (res *game.InsertRankAwardRes, err error)
AddRankGroup(ctx context.Context, req *game.AddRankGroupReq) (res *game.AddRankGroupRes, err error)
GetGameRank(ctx context.Context, req *game.GetGameRankReq) (res *game.GetGameRankRes, err error)
DeleteGameRank(ctx context.Context, req *game.DeleteGameRankReq) (res *game.DeleteGameRankRes, err error)
}
type gameRankImpl struct {
@ -29,66 +35,94 @@ func GameRank() IGameRank {
return &gameRankService
}
func (g *gameRankImpl) GetAward(ctx context.Context, req *game.GetRankAwardReq) (res *game.GetRankAwardRes, err error) {
func (r *gameRankImpl) GetAward(ctx context.Context, req *game.GetRankAwardReq) (res *game.GetRankAwardRes, err error) {
res = new(game.GetRankAwardRes)
res.RankAward, err = internal.GetRankAward(ctx, req.Id, req.Type)
log.Print("GetRankAward ", res)
return
}
func (g *gameRankImpl) UpdateAward(ctx context.Context, req *game.UpdateRankAwardReq) (res *game.UpdateRankAwardRes, err error) {
func (r *gameRankImpl) UpdateAward(ctx context.Context, req *game.UpdateRankAwardReq) (res *game.UpdateRankAwardRes, err error) {
err = internal.UpdateRankAward(ctx, req.RankAward)
log.Print("UpdateRankAward", err)
return
}
func (g *gameRankImpl) InsertAward(ctx context.Context, req *game.InsertRankAwardReq) (res *game.InsertRankAwardRes, err error) {
func (r *gameRankImpl) InsertAward(ctx context.Context, req *game.InsertRankAwardReq) (res *game.InsertRankAwardRes, err error) {
err = internal.InsertRankAward(ctx, req.RankAward)
log.Print("InsertRankAward", err)
return
}
func (g *gameRankImpl) Get(ctx context.Context, req *game.GetRankReq) (res *game.GetRankRes, err error) {
func (r *gameRankImpl) Get(ctx context.Context, req *game.GetRankReq) (res *game.GetRankRes, err error) {
res, err = internal.GetRank(ctx, req)
log.Print("GetRankAward ", res)
return
}
func (g *gameRankImpl) Update(ctx context.Context, req *game.UpdateRankReq) (res *game.UpdateRankRes, err error) {
func (r *gameRankImpl) Update(ctx context.Context, req *game.UpdateRankReq) (res *game.UpdateRankRes, err error) {
err = internal.UpdateRank(ctx, req.Rank)
log.Print("UpdateRankAward", err)
return
}
func (g *gameRankImpl) Insert(ctx context.Context, req *game.InsertRankReq) (res *game.InsertRankRes, err error) {
func (r *gameRankImpl) Insert(ctx context.Context, req *game.InsertRankReq) (res *game.InsertRankRes, err error) {
err = internal.InsertRank(ctx, req.Rank)
log.Print("InsertRank", err)
return
}
func (g *gameRankImpl) Del(ctx context.Context, req *game.DelRankReq) (res *game.DelRankRes, err error) {
func (r *gameRankImpl) Del(ctx context.Context, req *game.DelRankReq) (res *game.DelRankRes, err error) {
err = internal.DelRank(ctx, req.Rank)
log.Print("InsertRank", err)
return
}
func (g *gameRankImpl) Check(ctx context.Context, req *game.CheckRankReq) (res *game.CheckRankRes, err error) {
func (r *gameRankImpl) Check(ctx context.Context, req *game.CheckRankReq) (res *game.CheckRankRes, err error) {
res = new(game.CheckRankRes)
res.Rank, res.StringId, err = internal.CheckRank(ctx, req.Rank)
log.Print("InsertRank", err)
return
}
func (g *gameRankImpl) AddRankGroup(ctx context.Context, req *game.AddRankGroupReq) (res *game.AddRankGroupRes, err error) {
func (r *gameRankImpl) AddRankGroup(ctx context.Context, req *game.AddRankGroupReq) (res *game.AddRankGroupRes, err error) {
res = new(game.AddRankGroupRes)
res, err = internal.AddRankGroup(ctx, req)
log.Print("InsertRank", err)
return
}
func (g *gameRankImpl) GetGameRank(ctx context.Context, req *game.GetGameRankReq) (res *game.GetGameRankRes, err error) {
func (r *gameRankImpl) GetGameRank(ctx context.Context, req *game.GetGameRankReq) (res *game.GetGameRankRes, err error) {
res = new(game.GetGameRankRes)
res, err = internal.GetGameRank(ctx, req)
log.Print("GetGameRank", err)
return
}
func (r *gameRankImpl) DeleteGameRank(ctx context.Context, req *game.DeleteGameRankReq) (res *game.DeleteGameRankRes, err error) {
res = new(game.DeleteGameRankRes)
ip := internal.ServerConfig[fmt.Sprint(req.ServerId)]
url := "http://" + ip + "/deleteRank?unitId="
uid, _ := internal.GetIdToUid(ctx, req.Uid)
url += fmt.Sprint(uid)
bytes := g.Client().GetBytes(ctx, url)
fmt.Println("DeleteGameRank: ", url)
src := string(bytes)
if g.IsEmpty(src) {
g.Log().Printf(ctx, "%d DeleteGameRank: gerror.New(\"空回调,发送失败\")", req.ServerId)
return res, nil
}
srcCharset := "UTF-8"
tmp, _ := gcharset.ToUTF8(srcCharset, src)
fmt.Println("DeleteGameRank: ", tmp)
json, err := gjson.DecodeToJson(tmp)
if err != nil {
return
}
fmt.Println("DeleteGameRank: ", gjson.MustEncodeString(json))
if json.Get("Error").Int() == 200 {
return nil, gerror.New(json.Get("Message").String())
}
return
}

Loading…
Cancel
Save