Prechádzať zdrojové kódy

基本弃用mongo 主要数据存入mysql中

wucan 5 mesiacov pred
rodič
commit
bd37e68429
10 zmenil súbory, kde vykonal 423 pridanie a 121 odobranie
  1. 3 1
      bootstrap/cron.go
  2. 93 51
      controller/v1/behavior.go
  3. 109 0
      controller/v1/online.go
  4. 111 61
      controller/v1/user.go
  5. 67 0
      crons/userAction.go
  6. 7 8
      main.go
  7. 1 0
      middleware/auth.go
  8. 17 0
      model/game.go
  9. 12 0
      model/user.go
  10. 3 0
      route/api.go

+ 3 - 1
bootstrap/cron.go

@@ -16,7 +16,9 @@ func InitializeCron() {
 			fmt.Println(time.Now())
 		})
 
-		global.App.Cron.AddFunc("0 0 * * * *", crons.SetEcpm)
+		global.App.Cron.AddFunc("0 1 * * * *", crons.SetEcpm)
+		//global.App.Cron.AddFunc("0 1 * * * *", crons.ActiveDelete)         //清理用户在线数据文件夹
+		//global.App.Cron.AddFunc("0 2 * * * *", crons.OnlineDatabaseDelete) //清理用户在线数据数据库
 		global.App.Cron.Start()
 		defer global.App.Cron.Stop()
 		select {}

+ 93 - 51
controller/v1/behavior.go

@@ -208,57 +208,57 @@ func FindUserBehavior(id string) *model.UserBehavior {
 
 // 新建UserBehavior
 func CreateUserBehavior(gid string, pf string, openId string, now time.Time) error {
-	id := gid + "|" + pf + "|" + openId
-
-	Behavior := FindUserBehavior(id)
-	if Behavior != nil {
-		//更新start_num参数
-		collection := global.App.MongoDB.Database("chunhao").Collection("userBehavior")
-		filter := bson.M{"_id": id}
-		update := bson.M{"$inc": bson.M{"startNum": 1}}
-
-		_, err := collection.UpdateOne(context.Background(), filter, update)
-		if err != nil {
-			return err
-		}
-
-		//更新关联的广告数据
-		filter = bson.M{"userId": id}
-		collection = global.App.MongoDB.Database("chunhao").Collection("adRelated")
-		update = bson.M{"$inc": bson.M{"startNum": 1}}
-		_, err = collection.UpdateMany(context.Background(), filter, update)
-		if err != nil {
-			return err
-		}
-
-		return nil
-	} else {
-		behavior := model.UserBehavior{
-			Id:                 id,
-			Gid:                gid,
-			Pf:                 pf,
-			OpenId:             openId,
-			TotalDuration:      0,
-			TotalAdReqCount:    0,
-			TotalAdEposedCount: 0,
-			RelatedAid:         0,
-			StartNum:           1,
-			CreateTime:         int(now.Unix()),
-			CreateDate:         now.Format("20060102"),
-			ActiveStatus:       false,
-			ConversionStatus:   false,
-			RemainData:         nil,
-		}
-		//新增
-		collection := global.App.MongoDB.Database("chunhao").Collection("userBehavior")
-		_, err := collection.InsertOne(context.Background(), behavior)
-		if err != nil {
-			return err
-		}
-	}
-
-	//存储在线数据到redis中
-	global.App.Redis.Set(context.Background(), id+"|online", now.Unix(), time.Second*300)
+	//id := gid + "|" + pf + "|" + openId
+	//
+	//Behavior := FindUserBehavior(id)
+	//if Behavior != nil {
+	//	//更新start_num参数
+	//	collection := global.App.MongoDB.Database("chunhao").Collection("userBehavior")
+	//	filter := bson.M{"_id": id}
+	//	update := bson.M{"$inc": bson.M{"startNum": 1}}
+	//
+	//	_, err := collection.UpdateOne(context.Background(), filter, update)
+	//	if err != nil {
+	//		return err
+	//	}
+	//
+	//	//更新关联的广告数据
+	//	filter = bson.M{"userId": id}
+	//	collection = global.App.MongoDB.Database("chunhao").Collection("adRelated")
+	//	update = bson.M{"$inc": bson.M{"startNum": 1}}
+	//	_, err = collection.UpdateMany(context.Background(), filter, update)
+	//	if err != nil {
+	//		return err
+	//	}
+	//
+	//	return nil
+	//} else {
+	//	behavior := model.UserBehavior{
+	//		Id:                 id,
+	//		Gid:                gid,
+	//		Pf:                 pf,
+	//		OpenId:             openId,
+	//		TotalDuration:      0,
+	//		TotalAdReqCount:    0,
+	//		TotalAdEposedCount: 0,
+	//		RelatedAid:         0,
+	//		StartNum:           1,
+	//		CreateTime:         int(now.Unix()),
+	//		CreateDate:         now.Format("20060102"),
+	//		ActiveStatus:       false,
+	//		ConversionStatus:   false,
+	//		RemainData:         nil,
+	//	}
+	//	//新增
+	//	collection := global.App.MongoDB.Database("chunhao").Collection("userBehavior")
+	//	_, err := collection.InsertOne(context.Background(), behavior)
+	//	if err != nil {
+	//		return err
+	//	}
+	//}
+
+	////存储在线数据到redis中
+	//global.App.Redis.Set(context.Background(), id+"|online", now.Unix(), time.Second*300)
 
 	return nil
 }
@@ -397,6 +397,48 @@ func CheckUserActive(gid string, pf string, openId string) {
 	fmt.Println(res)
 }
 
+type ReportReq struct {
+	EventType  string                 `json:"event_type"`
+	Context    *ReportContext         `json:"context"`
+	Properties map[string]interface{} `json:"properties,omitempty"`
+	Timestamp  int64                  `json:"timestamp"`
+}
+type ReportContext struct {
+	Ad     *ReportContextAdCfg    `json:"ad"`               //信息流相关的信息
+	Device map[string]interface{} `json:"device,omitempty"` //设备相关的信息
+}
+type ReportContextAdCfg struct {
+	Callback  string `json:"callback"`
+	MatchType string `json:"match_type,omitempty"`
+}
+type HttpResult struct {
+	Code int    `bson:"code"`
+	Msg  string `bson:"msg"`
+}
+
+func OceanReport(evt string, cid string) bool {
+
+	url := "https://analytics.oceanengine.com/api/v2/conversion"
+	dat := &ReportReq{
+		EventType: evt,
+		Context:   &ReportContext{Ad: &ReportContextAdCfg{Callback: cid}},
+		Timestamp: time.Now().UnixMilli(),
+	}
+	var resp HttpResult
+
+	data, err := service.CurlPost(url, dat, nil)
+	if err != nil {
+		return false
+	}
+
+	json.Unmarshal([]byte(data), &resp)
+	if resp.Code == 0 {
+		return true
+	} else {
+		return false
+	}
+}
+
 func CheckRetention(gid string, pf string, openId string) {
 	request := map[string]interface{}{
 		"gid":      gid,

+ 109 - 0
controller/v1/online.go

@@ -0,0 +1,109 @@
+package v1
+
+import (
+	"designs/app/common/response"
+	"designs/global"
+	"designs/model"
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"time"
+)
+
+func TestSetOnline(c *gin.Context) {
+	err := SetOnline("test222", "wx", 1, 1234, time.Now())
+	if err != nil {
+		response.Fail(c, 1001, err.Error())
+		return
+	}
+
+	response.Success(c, gin.H{})
+}
+
+func TestDelete(c *gin.Context) {
+
+	////读取前一日数据
+	//now := time.Now()
+	//
+	//for i := 30; i <= 40; i++ {
+	//	last := now.AddDate(0, 0, -i).Format("2006-01-02")
+	//
+	//	path := "storage" + "/" + last
+	//
+	//	//删除前一天的文件夹
+	//	err := os.RemoveAll(path)
+	//	if err != nil {
+	//		fmt.Println("删除文件夹失败:"+path, err)
+	//	} else {
+	//		fmt.Println("删除文件夹完成:" + path)
+	//	}
+	//}
+
+	//获取到表名
+	now := time.Now()
+
+	date := now.AddDate(0, 0, -29).Format("20060102")
+
+	tableName := "user_online_" + date
+
+	var tableList []string
+	sql := "SELECT table_name FROM information_schema.tables WHERE table_schema = 'chunhao' AND table_name LIKE '" + tableName + "%'"
+	err := global.App.DB.Raw(sql).Pluck("table_name", &tableList).Error
+
+	if err != nil {
+		global.App.Log.Error("查询", date, "user_online数据表失败", err.Error())
+		return
+	}
+
+	//批量删除数据表
+	for _, table := range tableList {
+		sql := "drop table IF EXISTS " + table
+		err := global.App.DB.Exec(sql).Error
+		if err != nil {
+			global.App.Log.Error("删除", table, "数据表失败", err.Error())
+			return
+		}
+	}
+
+	fmt.Println(tableList)
+
+}
+
+func SetOnline(gid string, pf string, types int, userId int, now time.Time) error {
+
+	//先根据date ,gid ,判定存哪个表
+	date := now.Format("20060102")
+	tableName := "user_online" + "_" + date + "_" + gid
+
+	//先尝试写入,如果写入失败证明表不存在,则创建表然后写入
+	userOnline := model.UserOnlineSplit{
+		Pf:      pf,
+		UserId:  userId,
+		LogTime: now,
+		Type:    types,
+	}
+
+	err := global.App.DB.Table(tableName).Create(&userOnline).Error
+	if err != nil {
+		err := global.App.DB.Exec(`
+    		CREATE TABLE IF NOT EXISTS ` + tableName + ` (
+			  id int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+			  pf varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '登录路径',
+			  userId int NOT NULL COMMENT '用户ID',
+			  type tinyint NOT NULL COMMENT '1:在线 2.下线',
+			  logTime timestamp NULL DEFAULT NULL COMMENT '时间',
+			  PRIMARY KEY (id) USING BTREE,
+				KEY pf (pf)
+			) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
+		`).Error
+		if err != nil {
+			return err
+		}
+
+		err = global.App.DB.Table(tableName).Create(&userOnline).Error
+		if err != nil {
+			return err
+		}
+	}
+
+	return nil
+}

+ 111 - 61
controller/v1/user.go

@@ -12,7 +12,6 @@ import (
 	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/pkg/errors"
-	"go.mongodb.org/mongo-driver/v2/bson"
 	"os"
 	"path/filepath"
 	"strconv"
@@ -22,9 +21,6 @@ import (
 
 func ReceiveGameMsg(c *gin.Context) {
 
-	//response.Success(c, gin.H{})
-	//return
-
 	form := request.Check(c, &struct {
 		//Gid       string `form:"gid" json:"gid" binding:"required"`
 		//Pf        string `form:"pf" json:"pf" binding:"required"`
@@ -80,16 +76,18 @@ func ReceiveGameMsg(c *gin.Context) {
 		err = login(gid, pf, openId, form.UserId, now)
 
 		//调用接口,上传留存
-		CheckRetention(gid, pf, openId)
+		//CheckRetention(gid, pf, openId)
 	} else if form.Action == "online" {
 		//活跃
 		err = online(gid, pf, openId, form.UserId, now)
 
+		err = SetOnline(gid, pf, 1, form.UserId, now)
 		err = SetLocalActiveLog(gid, pf, openId, form.UserId, 1, now)
+
 	} else if form.Action == "offline" {
 		//断开
 		err = offline(gid, pf, openId, form.UserId, now)
-
+		err = SetOnline(gid, pf, 2, form.UserId, now)
 		err = SetLocalActiveLog(gid, pf, openId, form.UserId, 2, now)
 	} else if form.Action == "seeAds" {
 
@@ -101,9 +99,6 @@ func ReceiveGameMsg(c *gin.Context) {
 		err = action(gid, pf, form.Action, form.UserId, now, form.Data)
 	}
 
-	//调用接口,检测需不需要上传到巨量
-	CheckUserActive(gid, pf, openId)
-
 	if err != nil {
 		response.Fail(c, 1003, err.Error())
 		return
@@ -149,6 +144,7 @@ func action(gid string, pf string, gameActionId string, userId int, now time.Tim
 		Gid:       gid,
 		Pf:        pf,
 		ActionId:  gameActionId,
+		Date:      now.Format("20060102"),
 		CreatedAt: model.XTime{Time: now},
 	}
 
@@ -242,10 +238,10 @@ func online(gid string, pf string, openId string, userId int, now time.Time) err
 		global.App.Log.Error("存储用户活跃信息失败", err.Error(), userOnline)
 		return err
 	}
-	err = UpdateUserBehaviorDuration(gid, pf, openId, now, 1)
-	if err != nil {
-		global.App.Log.Error("存储用户在线时长mongo失败", err.Error(), userOnline)
-	}
+	//err = UpdateUserBehaviorDuration(gid, pf, openId, now, 1)
+	//if err != nil {
+	//	global.App.Log.Error("存储用户在线时长mongo失败", err.Error(), userOnline)
+	//}
 
 	return nil
 }
@@ -266,10 +262,10 @@ func offline(gid string, pf string, openId string, userId int, now time.Time) er
 		return err
 	}
 
-	err = UpdateUserBehaviorDuration(gid, pf, openId, now, 2)
-	if err != nil {
-		global.App.Log.Error("存储用户在线时长mongo失败", err.Error(), userOnline)
-	}
+	//err = UpdateUserBehaviorDuration(gid, pf, openId, now, 2)
+	//if err != nil {
+	//	global.App.Log.Error("存储用户在线时长mongo失败", err.Error(), userOnline)
+	//}
 
 	return nil
 }
@@ -297,10 +293,10 @@ func seeAds(gid string, pf string, openId string, userId int, now time.Time, Ads
 		return err
 	}
 
-	err = UpdateUserBehaviorAdInfo(gid, pf, openId, AdsState)
-	if err != nil {
-		global.App.Log.Error("存储用户观看广告mongo失败", err.Error(), userOnline)
-	}
+	//err = UpdateUserBehaviorAdInfo(gid, pf, openId, AdsState)
+	//if err != nil {
+	//	global.App.Log.Error("存储用户观看广告mongo失败", err.Error(), userOnline)
+	//}
 
 	return nil
 }
@@ -373,59 +369,87 @@ func InitUser(c *gin.Context) {
 }
 
 func ReceiveAdsInfo(c *gin.Context) {
-
-	//response.Success(c, gin.H{"data": "success"})
-	//return
-
 	form := request.Check(c, &struct {
 		Aid string `form:"aid" json:"aid" binding:""`
 		Pid string `form:"pid" json:"pid" binding:""`
 		Cid string `form:"cid" json:"cid" binding:""`
 	}{})
 
-	//存储参数
-	global.App.Log.Info("ReceiveAdsInfo", form)
-
 	gid := c.GetString("gid")
 	pf := c.GetString("pf")
 	openId := c.GetString("openid")
 
-	userId := gid + "|" + pf + "|" + openId
-	global.App.Log.Info("userId", userId)
-
-	id := userId + "|" + form.Aid
-
-	aid, _ := strconv.Atoi(form.Aid)
-	pid, _ := strconv.Atoi(form.Pid)
-
-	collection := global.App.MongoDB.Database("chunhao").Collection("adRelated")
-
-	var adRelated model.AdRelated
-	filter := bson.M{"_id": id}
-	collection.FindOne(context.Background(), filter).Decode(&adRelated)
-	if adRelated.Id == "" {
-		//新增
-		adData := model.AdRelated{
-			UserId:     userId,
-			Id:         id,
-			Aid:        int64(aid),
-			Pid:        int64(pid),
-			Cid:        form.Cid,
-			Duration:   0,
-			StartNum:   1,
-			Revenue:    0,
-			ReqCount:   0,
-			ExpCount:   0,
-			CreateTime: time.Now().Unix(),
-		}
+	global.App.Log.Info(fmt.Sprintf("存入用户广告数据,用户信息:%s,%s,%s||广告信息:%s,%s,%s", gid, pf, openId, form.Aid, form.Pid, form.Cid))
 
-		//更新到MongoDB 中
-		_, err := collection.InsertOne(context.Background(), adData)
-		if err != nil {
-			response.Fail(c, 1003, "写入数据失败"+err.Error())
-			return
+	var user model.User
+	global.App.DB.Table("user").
+		Where("gid", gid).
+		Where("pf", pf).
+		Where("openId", openId).Find(&user)
+
+	if user.ID == 0 {
+		global.App.Log.Info("上报广告信息时用户不存在")
+		response.Fail(c, 1003, "上报广告信息时用户不存在")
+		return
+	}
+
+	//目前改为直接存储到mysql中
+	err := global.App.DB.Table("user").
+		Where("id", user.ID).
+		Updates(map[string]interface{}{
+			"aid": form.Aid,
+			"pid": form.Pid,
+			"cid": form.Cid,
+		}).Error
+	if err != nil {
+		global.App.Log.Error("存储用户的广告信息失败:", err.Error())
+		response.Fail(c, 501, err.Error())
+		return
+	}
+
+	//调用接口,将激活上传到巨量
+	if user.Pf == "tt" {
+		ok := OceanReport("active", form.Cid)
+		if !ok {
+			global.App.Log.Info("上报激活数据到抖音巨量失败")
 		}
 	}
+
+	//userId := gid + "|" + pf + "|" + openId
+	//
+	//id := userId + "|" + form.Aid
+	//
+	//aid, _ := strconv.Atoi(form.Aid)
+	//pid, _ := strconv.Atoi(form.Pid)
+	//
+	//collection := global.App.MongoDB.Database("chunhao").Collection("adRelated")
+	//
+	//var adRelated model.AdRelated
+	//filter := bson.M{"_id": id}
+	//collection.FindOne(context.Background(), filter).Decode(&adRelated)
+	//if adRelated.Id == "" {
+	//	//新增
+	//	adData := model.AdRelated{
+	//		UserId:     userId,
+	//		Id:         id,
+	//		Aid:        int64(aid),
+	//		Pid:        int64(pid),
+	//		Cid:        form.Cid,
+	//		Duration:   0,
+	//		StartNum:   1,
+	//		Revenue:    0,
+	//		ReqCount:   0,
+	//		ExpCount:   0,
+	//		CreateTime: time.Now().Unix(),
+	//	}
+	//
+	//	//更新到MongoDB 中
+	//	_, err := collection.InsertOne(context.Background(), adData)
+	//	if err != nil {
+	//		response.Fail(c, 1003, "写入数据失败"+err.Error())
+	//		return
+	//	}
+	//}
 	////关联到userInfo 上
 	//filter = bson.M{"_id": userId}
 	//update := bson.M{
@@ -445,6 +469,32 @@ func ReceiveAdsInfo(c *gin.Context) {
 	response.Success(c, gin.H{"data": "success"})
 }
 
+func ReceiveGameAdsCheck(c *gin.Context) {
+	form := request.Check(c, &struct {
+		UserId    int   `form:"userId" json:"userId" binding:"required"`
+		Timestamp int64 `form:"timestamp" json:"timestamp" binding:"required"`
+	}{})
+
+	now := time.UnixMilli(form.Timestamp)
+
+	gid := c.GetString("gid")
+	pf := c.GetString("pf")
+
+	err := global.App.DB.Table("user_ads_check").Create(map[string]interface{}{
+		"userId":    form.UserId,
+		"gid":       gid,
+		"pf":        pf,
+		"createdAt": now,
+		"date":      now.Format("20060102"),
+	}).Error
+	if err != nil {
+		response.Fail(c, 501, err.Error())
+		return
+	}
+
+	response.Success(c, gin.H{"data": "success"})
+}
+
 func SetLocalActiveLog(gid string, pf string, openId string, userId int, types int, now time.Time) error {
 	// 生成日期目录路径(示例:./data/2024-06-15)
 	dateDir := now.Format("2006-01-02")

+ 67 - 0
crons/userAction.go

@@ -0,0 +1,67 @@
+package crons
+
+import (
+	"designs/global"
+	"fmt"
+	"os"
+	"time"
+)
+
+func ActiveDelete() {
+	//读取前一日数据
+	now := time.Now()
+
+	for i := 30; i <= 40; i++ {
+		last := now.AddDate(0, 0, -i).Format("2006-01-02")
+
+		path := "storage" + "/" + last
+
+		//删除前一天的文件夹
+		err := os.RemoveAll(path)
+		if err != nil {
+			fmt.Println("删除文件夹失败:"+path, err)
+		} else {
+			fmt.Println("删除文件夹完成:" + path)
+		}
+	}
+}
+
+func OnlineDatabaseDelete() {
+	//获取到表名
+	now := time.Now()
+
+	date := now.AddDate(0, 0, -29).Format("20060102")
+
+	tableName := "user_online_" + date
+
+	var tableList []string
+	sql := "SELECT table_name FROM information_schema.tables WHERE table_schema = 'chunhao' AND table_name LIKE '" + tableName + "%'"
+	err := global.App.DB.Raw(sql).Pluck("table_name", &tableList).Error
+
+	if err != nil {
+		global.App.Log.Error("查询", date, "user_online数据表失败", err.Error())
+		return
+	}
+
+	//批量删除数据表
+	for _, table := range tableList {
+		sql := "drop table IF EXISTS " + table
+		err := global.App.DB.Exec(sql).Error
+		if err != nil {
+			global.App.Log.Error("删除", table, "数据表失败", err.Error())
+			return
+		}
+	}
+
+	global.App.Log.Info(date, "数据表清理完成", tableList)
+}
+
+// 对日活数据进行汇算
+func RemainDataSummary() {
+	//计算每日的留存
+
+}
+
+//对广告数据进行汇算
+
+//对打点数据进行汇算

+ 7 - 8
main.go

@@ -1,7 +1,6 @@
 package main
 
 import (
-	"context"
 	"designs/bootstrap"
 	"designs/global"
 	"designs/utils"
@@ -51,13 +50,13 @@ func main() {
 		}
 	}()
 
-	//初始化mongodb
-	global.App.MongoDB = bootstrap.InitializeMongo()
-	defer func() {
-		if global.App.MongoDB != nil {
-			global.App.MongoDB.Disconnect(context.Background())
-		}
-	}()
+	////初始化mongodb
+	//global.App.MongoDB = bootstrap.InitializeMongo()
+	//defer func() {
+	//	if global.App.MongoDB != nil {
+	//		global.App.MongoDB.Disconnect(context.Background())
+	//	}
+	//}()
 
 	bootstrap.InitializeCron()
 

+ 1 - 0
middleware/auth.go

@@ -38,6 +38,7 @@ func TokenAuthMiddleware() gin.HandlerFunc {
 		//	return
 		//}
 		token := c.GetHeader("Authorization")
+		//fmt.Println("token:", token)
 		//校验token
 		if token == "" {
 			common.RetJson(-2, "Unauthorized", "", c)

+ 17 - 0
model/game.go

@@ -0,0 +1,17 @@
+package model
+
+type Game struct {
+	Id         int    `json:"id" gorm:"primary_key"`
+	Pid        string `json:"pid" gorm:"column:pid; "`
+	Gid        string `json:"gid" gorm:"column:gid; "`
+	GameName   string `json:"gameName" gorm:"column:gameName; "`
+	WxAppid    string `json:"wxAppid" gorm:"column:wxAppid; "`
+	WxSecret   string `json:"wxSecret" gorm:"column:wxSecret; "`
+	TtAppid    string `json:"ttAppid" gorm:"column:ttAppid; "`
+	TtSecret   string `json:"ttSecret" gorm:"column:ttSecret; "`
+	TtTplId    string `json:"ttTplId" gorm:"column:ttTplId; "`
+	WxTplId    string `json:"wxTplId" gorm:"column:wxTplId; "`
+	ConfigPath string `json:"configPath" gorm:"column:configPath; "`
+	CreatedAt  XTime  `json:"createdAt" gorm:"column:createdAt; "`
+	UpdatedAt  XTime  `json:"updatedAt" gorm:"column:updatedAt; "`
+}

+ 12 - 0
model/user.go

@@ -28,6 +28,9 @@ type User struct {
 	ID        int       `json:"id" gorm:"not null;"`
 	Pf        string    `json:"pf" gorm:"not null;"`
 	Gid       string    `json:"gid" gorm:"not null;"`
+	Aid       string    `json:"aid" gorm:"not null;" column:"aid;"`
+	Pid       string    `json:"pid" gorm:"not null;" column:"pid;"`
+	Cid       string    `json:"cid" gorm:"not null;" column:"cid;"`
 	UserId    int       `json:"userId" gorm:"not null;column:userId;"`
 	OpenId    string    `json:"openId" gorm:"not null;column:openId;"`
 	CreatedAt time.Time `json:"createdAt" gorm:"column:createdAt;"`
@@ -51,6 +54,14 @@ type UserOnline struct {
 	LogTime time.Time `json:"logTime" gorm:"column:logTime;"`
 }
 
+type UserOnlineSplit struct {
+	ID      int       `json:"id" gorm:"not null;"`
+	Pf      string    `json:"pf" gorm:"not null;"`
+	UserId  int       `json:"userId" gorm:"not null;column:userId;"`
+	Type    int       `json:"type" gorm:"not null;"`
+	LogTime time.Time `json:"logTime" gorm:"column:logTime;"`
+}
+
 type UserSeeAds struct {
 	ID        int       `json:"id" gorm:"not null;"`
 	Pf        string    `json:"pf" gorm:"not null;"`
@@ -123,6 +134,7 @@ type UserAction struct {
 	Gid       string `json:"gid" gorm:"not null;"`
 	ActionId  string `json:"actionId" gorm:"not null;column:actionId;"`
 	UserId    int    `json:"userId" gorm:"not null;column:userId;"`
+	Date      string `json:"date" gorm:"not null;column:date;"`
 	CreatedAt XTime  `json:"createdAt" gorm:"column:createdAt;type:date;"`
 }
 

+ 3 - 0
route/api.go

@@ -13,6 +13,8 @@ func SetApiGroupRoutes(router *gin.RouterGroup) {
 	router.POST("/admin/ss/initUser", v1.InitUser)
 
 	router.POST("/TestEcpm", v1.TestEcpm)
+	router.POST("/TestSetOnline", v1.TestSetOnline)
+	router.POST("/TestDelete", v1.TestDelete)
 
 	router.POST("/user/updateUserBehavior", v1.UpdateUserBehavior)
 
@@ -20,6 +22,7 @@ func SetApiGroupRoutes(router *gin.RouterGroup) {
 	GroupV1.Use(middleware.TokenAuthMiddleware()).Use()
 	{
 		GroupV1.POST("/user/receiveGameMsg", v1.ReceiveGameMsg)
+		GroupV1.POST("/user/receiveGameAdsCheck", v1.ReceiveGameAdsCheck)
 
 		GroupV1.POST("/user/receiveAdsInfo", v1.ReceiveAdsInfo)