浏览代码

更新接口

www 2 年之前
父节点
当前提交
9cb2e60d5c

+ 1 - 1
api/v1/log/loging.go

@@ -746,7 +746,7 @@ func (e *ApiLoging) GetWuYToken(c *gin.Context) {
 	token := reqs.Cookies()[1].Value
 	if token != "" {
 		token = "token=" + token
-		global.GVA_REDIS.Set(c, key, token, time.Hour*15)
+		global.GVA_REDIS.Set(c, key, token, time.Minute*30)
 	}
 	data.Token = token
 	response.OkWithDetailed(data, "获取成功", c)

+ 22 - 1
api/v1/task/game_task.go

@@ -537,7 +537,6 @@ func (e *GameTaskApi) TaskTargetExport(c *gin.Context) {
 func (e *GameTaskApi) TemporaryTask(c *gin.Context) {
 	var params request.GetTemporaryTaskRequest
 	_ = c.ShouldBindJSON(&params)
-	global.GVA_LOG.Warn(params.PcCode)
 	if params.PcCode == "" {
 		response.FailWithMessage("参数错误", c)
 		return
@@ -564,3 +563,25 @@ func (e *GameTaskApi) GetSheepPay(c *gin.Context) {
 	taskService.GetSheepPay(c, moneyInt, gameid, payTime)
 	response.OkWithDetailed("", "收到数据", c)
 }
+
+func (e *GameTaskApi) UpdateRetentionRatio(c *gin.Context) {
+	var params request.RetentionRatioRequest
+	_ = c.ShouldBindJSON(&params)
+	if err := taskService.UpdateRetentionRatio(c, params); err != nil {
+		global.GVA_LOG.Error("设置失败!", zap.Error(err))
+		response.FailWithMessage("设置失败 "+err.Error(), c)
+	} else {
+		response.OkWithMessage("设置成功", c)
+	}
+}
+
+func (e *GameTaskApi) GetRetentionRatio(c *gin.Context) {
+	var params request.GetRetentionRatioRequest
+	_ = c.ShouldBindJSON(&params)
+	if api, err := taskService.GetRetentionRatio(c, params); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败 "+err.Error(), c)
+	} else {
+		response.OkWithDetailed(api, "获取成功", c)
+	}
+}

+ 1 - 0
compile.bat

@@ -1,3 +1,4 @@
+SET CGO_ENABLED=0
 set GOOS=linux
 set GOARCH=amd64
 go build -ldflags "-s -w"

+ 2 - 2
config.yaml

@@ -167,8 +167,8 @@ send-url:
   tx-send-mobile: "1111111111"
 extranet-domain:
   #control: "http://bpm.kfzs.com:7089"
-  control: "http://192.168.50.35:8099"
+  control: "http://xjf.lianyou.fun:8099"
 #extranet-domain:
-#  control: "http://192.168.50.35:8099"
+#  control: "http://xjf.lianyou.fun:8099"
 prefix-url:
   prefix-local: "http://192.168.50.17:8080/api/"

+ 14 - 0
model/task/control/request.go

@@ -16,3 +16,17 @@ type CreateGameTaskRequest struct {
 	NewRetained       string `json:"new_retained"`
 	GamePort          string `json:"game_port"`
 }
+
+type GameRetentionRatio struct {
+	GameId    int `json:"game_id"`   //游戏Id
+	Second    int `json:"second"`    //次日留
+	Third     int `json:"third"`     //3日留存
+	Forth     int `json:"forth"`     //4日留存
+	Fifth     int `json:"fifth"`     //5日留存
+	Sixth     int `json:"sixth"`     //6日留存
+	Seventh   int `json:"seventh"`   //7日留存
+	Tenth     int `json:"tenth"`     //10日留存
+	Fifteenth int `json:"fifteenth"` //15日留存
+	Twentieth int `json:"twentieth"` //20日留存
+	Thirtieth int `json:"thirtieth"` //30日留存
+}

+ 19 - 0
model/task/game_retention_ratio.go

@@ -0,0 +1,19 @@
+package task
+
+type GameRetentionRatio struct {
+	GameId    int `json:"game_id"`   //游戏Id
+	Second    int `json:"second"`    //次日留
+	Third     int `json:"third"`     //3日留存
+	Forth     int `json:"forth"`     //4日留存
+	Fifth     int `json:"fifth"`     //5日留存
+	Sixth     int `json:"sixth"`     //6日留存
+	Seventh   int `json:"seventh"`   //7日留存
+	Tenth     int `json:"tenth"`     //10日留存
+	Fifteenth int `json:"fifteenth"` //15日留存
+	Twentieth int `json:"twentieth"` //20日留存
+	Thirtieth int `json:"thirtieth"` //30日留存
+}
+
+func (GameRetentionRatio) TableName() string {
+	return "game_retention_ratio"
+}

+ 18 - 0
model/task/request/game_task.go

@@ -131,3 +131,21 @@ type GameListRequest struct {
 type GetTemporaryTaskRequest struct {
 	PcCode string `json:"pc_code"`
 }
+
+type RetentionRatioRequest struct {
+	GameId    int `json:"game_id"`   //游戏Id
+	Second    int `json:"second"`    //次日留
+	Third     int `json:"third"`     //3日留存
+	Forth     int `json:"forth"`     //4日留存
+	Fifth     int `json:"fifth"`     //5日留存
+	Sixth     int `json:"sixth"`     //6日留存
+	Seventh   int `json:"seventh"`   //7日留存
+	Tenth     int `json:"tenth"`     //10日留存
+	Fifteenth int `json:"fifteenth"` //15日留存
+	Twentieth int `json:"twentieth"` //20日留存
+	Thirtieth int `json:"thirtieth"` //30日留存
+}
+
+type GetRetentionRatioRequest struct {
+	GameID int `json:"game_id"` //游戏Id
+}

+ 2 - 0
router/task/game_task.go

@@ -29,6 +29,8 @@ func (e *GameTaskRouter) InitGameTaskRouter(Router *gin.RouterGroup) {
 		GameTaskRouter.POST("getXmyTaskList", GameTaskApi.GetXmyTaskList) //获取小绵羊任务列表
 		GameTaskRouter.POST("temporaryTask", GameTaskApi.TemporaryTask)
 		GameTaskRouter.GET("sheepPay", GameTaskApi.GetSheepPay)
+		GameTaskRouter.POST("getRatio", GameTaskApi.GetRetentionRatio)
+		GameTaskRouter.POST("updateRatio", GameTaskApi.UpdateRetentionRatio)
 	}
 	GameTaskRouter1 := Router.Group("gameTask").Use(middleware.OperationRecord())
 	{

+ 3 - 0
service/log/loging/logical_log.go

@@ -339,18 +339,21 @@ func (s *LogicalLog) SetCacheNum(ctx context.Context, key string) (err error) {
 	}
 }
 
+// 节点缓存
 func (s *LogicalLog) NodeLogGetNum(ctx context.Context, date string, gameId int, code string, status string, taskType int) (num int, err error) {
 	node := code[:3]
 	num, err = s.LogGetNum(ctx, date, gameId, node, status, taskType)
 	return
 }
 
+// 类型缓存
 func (s *LogicalLog) TypeLogGetNum(ctx context.Context, date string, gameId int, code string, status string, taskType int) (num int, err error) {
 	node := code[:5]
 	num, err = s.LogGetNum(ctx, date, gameId, node, status, taskType)
 	return
 }
 
+// 编号缓存
 func (s *LogicalLog) CodeLogGetNum(ctx context.Context, date string, gameId int, code string, status string, taskType int) (num int, err error) {
 	num, err = s.LogGetNum(ctx, date, gameId, code, status, taskType)
 	return

+ 37 - 0
service/task/game_task.go

@@ -1277,3 +1277,40 @@ func (apiService *GameTask) GetSheepPay(ctx context.Context, money int, gameId s
 		global.GVA_LOG.Error("保存SheepPay错误", zap.Error(err))
 	}
 }
+
+func (apiService *GameTask) UpdateRetentionRatio(ctx context.Context, ratioRequest request.RetentionRatioRequest) (err error) {
+	if ratioRequest.GameId == 0 {
+		return errors.New("参数错误")
+	}
+	var entity task.GameTask
+	err = global.GVA_DB.Where("task_id = ?", ratioRequest.GameId).First(&entity).Error
+	if errors.Is(err, gorm.ErrRecordNotFound) {
+		return
+	}
+	url := global.GVA_CONFIG.ExtranetDomain.Control + "/v1/task_statistics/retained/" + strconv.Itoa(ratioRequest.GameId)
+	data, code, err := utils.HttpPutReplyCode(url, ratioRequest)
+	fmt.Println(code)
+	if code != 200 {
+		return err
+	}
+	fmt.Println(string(data))
+	if string(data) != "\"OK\"" {
+		return errors.New("更新失败")
+	}
+	return
+}
+
+func (apiService *GameTask) GetRetentionRatio(ctx context.Context, ratioRequest request.GetRetentionRatioRequest) (gameRatio task.GameRetentionRatio, err error) {
+	//http://xjf.lianyou.fun:8099/v1/task_statistics/retained/1000961
+	if ratioRequest.GameID == 0 {
+		err = errors.New("参数错误")
+	}
+	url := global.GVA_CONFIG.ExtranetDomain.Control + "/v1/task_statistics/retained/" + strconv.Itoa(ratioRequest.GameID)
+	data, code, err := utils.HttpGetReplyCode(url, nil)
+	fmt.Println(code)
+	if code != 200 {
+		return gameRatio, errors.New(string(data))
+	}
+	err = json.Unmarshal(data, &gameRatio)
+	return
+}