Forráskód Böngészése

增加可付费账号列表

wangbin 3 éve
szülő
commit
f23b4fd844

+ 31 - 0
api/v1/log/loging.go

@@ -429,3 +429,34 @@ func (s *ApiLoging) GetLogScanningList(c *gin.Context) {
 		}, "获取成功", c)
 	}
 }
+
+// @Tags loging
+// @Summary 导出Excel
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce  application/octet-stream
+// @Param data body request.GetStatisticsComputerRequest true "导出Excel文件信息"
+// @Success 200
+// @Router /loging/computerRateExport [post]
+func (e *ApiLoging) ComputerRateExport(c *gin.Context) {
+	var excelInfo request.ExcelInfo
+	_ = c.ShouldBindJSON(&excelInfo)
+	paramsInfo := excelInfo.InfoList
+	paramsInfo.PageSize = 300
+	paramsInfo.Page = 1
+	list, _, err := ServiceStatisticsLog.ComputerStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	if err != nil {
+		global.GVA_LOG.Error("获取电脑数据失败!", zap.Error(err))
+		response.FailWithMessage("获取电脑数据失败", c)
+		return
+	}
+	filePath := global.GVA_CONFIG.Excel.Dir + excelInfo.FileName
+	err = ServiceStatisticsLog.ComputeRateList2Excel(list, filePath)
+	if err != nil {
+		global.GVA_LOG.Error("转换Excel失败!", zap.Error(err))
+		response.FailWithMessage("转换Excel失败", c)
+		return
+	}
+	c.Writer.Header().Add("success", "true")
+	c.File(filePath)
+}

+ 29 - 0
api/v1/task/game_task.go

@@ -421,3 +421,32 @@ func (s *GameTaskApi) TaskResetFee(c *gin.Context) {
 		response.OkWithMessage("重置付费成功", c)
 	}
 }
+
+// @Tags gameTask
+// @Summary 根据id获取游戏可付费账号
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.GetById true "根据id获取可付费账号列表"
+// @Success 200 {object} response.Response{data=response.GetGameTargetComplete} "根据id获取可付费账号列表"
+// @Router /gameTask/getFeeAccountList [post]
+func (s *GameTaskApi) GetFeeAccountList(c *gin.Context) {
+	var idInfo request.GetGameTaskTargetByIdRequest
+	_ = c.ShouldBindJSON(&idInfo)
+	if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	date := time.Now().Format("2006-01-02")
+	if idInfo.CreateDate != date {
+		response.FailWithMessage("只能获取当天的任务", c)
+		return
+	}
+	api, err := taskService.GetFeeAccountList(idInfo.ID)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败 "+err.Error(), c)
+	} else {
+		response.OkWithDetailed(api, "获取成功", c)
+	}
+}

+ 1 - 0
router/log/loging.go

@@ -26,5 +26,6 @@ func (e *LogingRouter) InitLogingRouter(Router *gin.RouterGroup) {
 		excelRouter.POST("exportExcel", logApi.ExportExcel)
 		excelRouter.POST("updatePcRemarks", logApi.UpdatePcRemarks)
 		excelRouter.POST("getLogScanningList", logApi.GetLogScanningList)
+		excelRouter.POST("computerRateExport", logApi.ComputerRateExport)
 	}
 }

+ 1 - 0
router/task/game_task.go

@@ -23,6 +23,7 @@ func (e *GameTaskRouter) InitGameTaskRouter(Router *gin.RouterGroup) {
 		GameTaskRouter.POST("gameStatistics", GameTaskApi.GameStatistics)
 		GameTaskRouter.POST("gameList", GameTaskApi.GameList)
 		GameTaskRouter.POST("getGameTxTaskList", GameTaskApi.GetGameTxTaskList)
+		GameTaskRouter.POST("getFeeAccountList", GameTaskApi.GetFeeAccountList)
 	}
 	GameTaskRouter1 := Router.Group("gameTask").Use(middleware.OperationRecord())
 	{

+ 26 - 5
service/log/log_statistics.go

@@ -652,7 +652,7 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
 	return
 }
 
-func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
+func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo, order string, desc bool) (statisticsLogsComputer []*response.ComputerStatisticsReply1, total int64, err error) {
 	date := api.CreateDate
 	isCurrentDate := false
 	if date == "" {
@@ -660,7 +660,6 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
 		isCurrentDate = true
 	}
 	db := global.GVA_DB.Model(&log.LogComputer{})
-	var total int64
 	db = db.Where("create_date = ?", date)
 	if api.Operator != "" {
 		db = db.Where("operator = ?", api.Operator)
@@ -671,7 +670,7 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
 	if api.GameId != 0 {
 		db = db.Where("game_id = ?", api.GameId)
 	}
-	err := db.Count(&total).Error
+	err = db.Count(&total).Error
 	if err != nil {
 		return nil, 0, err
 	}
@@ -695,7 +694,7 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
 			}
 		} else { // didn't matched any order key in `orderMap`
 			global.GVA_LOG.Error("获取失败!", zap.Error(err))
-			return statisticsLogs, total, err
+			return statisticsLogsComputer, total, err
 		}
 		err = db.Order(OrderStr).Find(&statisticsLogs).Error
 	} else {
@@ -704,7 +703,6 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
 	if err != nil {
 		return nil, 0, err
 	}
-	var statisticsLogsComputer []*response.ComputerStatisticsReply1
 
 	for _, statisticsLog := range statisticsLogs {
 		/*var gameInfo []*response.GameInfo
@@ -1227,3 +1225,26 @@ func (apiService *ServiceStatisticsLog) GetScanningInfoList(api request.LogScann
 	}
 	return apisReply, total, err
 }
+
+func (exa *ServiceStatisticsLog) ComputeRateList2Excel(infoList []*response.ComputerStatisticsReply1, filePath string) error {
+	excel := excelize.NewFile()
+	excel.SetSheetRow("Sheet1", "A1", &[]string{"电脑编号", "使用者", "日期", "游戏id", "目标数量", "拉取账号", "进入主线", "主线成功", "半小时付费", "任务完成效率", "空闲时间"})
+	for i, statisticsLog := range infoList {
+		axis := fmt.Sprintf("A%d", i+2)
+		excel.SetSheetRow("Sheet1", axis, &[]interface{}{
+			statisticsLog.PcCode,
+			statisticsLog.Operator,
+			statisticsLog.CreateDate[:10],
+			statisticsLog.GameId,
+			statisticsLog.TargetNum,
+			statisticsLog.PullAccountNum,
+			statisticsLog.EnterMain,
+			statisticsLog.TaskSuccessNum,
+			statisticsLog.ComputerFeeRate,
+			statisticsLog.ComputerHourAverageRate,
+			statisticsLog.ComputerFreeTime,
+		})
+	}
+	err := excel.SaveAs(filePath)
+	return err
+}

+ 66 - 21
service/task/game_task.go

@@ -54,7 +54,8 @@ var (
 )
 
 type GameTask struct {
-	cache cache.Cache
+	cache  cache.Cache
+	common Common
 }
 
 // 创建游戏任务
@@ -572,10 +573,10 @@ func (apiService *GameTask) GetGameTaskTargetInfoList(api request.GameTargetComp
 			loginMethod, _ := strconv.Atoi(api.LoginMethod)
 			apiList[i].LoginMethod = LoginMethod[loginMethod]
 			apiList[i].CreateDate = date[0]
-			apiList[i].RetainedComplete = api.RetainedComplete + api.HandRetainedComplete + api.HandNewComplete
-			apiList[i].PayComplete = api.PayComplete + api.HandPayComplete
-			apiList[i].NewComplete = api.NewComplete + api.HandNewComplete
-			apiList[i].Amount = api.Amount + api.HandAmountTotal
+			apiList[i].RetainedComplete = api.RetainedComplete
+			apiList[i].PayComplete = api.PayComplete
+			apiList[i].NewComplete = api.NewComplete
+			apiList[i].Amount = api.Amount
 		}
 	}
 	return apiList, total, err
@@ -678,14 +679,6 @@ func (s *GameTask) UpdateGameTaskTarget(requestData request.UpdateGameTaskTarget
 		"hand_amount_total":      requestData.HandAmountTotal + gameTask.HandAmountTotal,
 	}
 	date := time.Now().Format("2006-01-02")
-	if gameTask.CreateDate.Format("2006-01-02") == date {
-		if gameTask.PayTarget < requestData.PayTarget {
-			global.GVA_LOG.Warn("进入修改add update")
-			lastPayAddUpdateTimeKey := fmt.Sprintf(LastPayAddUpdateTimeKey, date, gameTask.TaskId)
-			_ = s.cache.SetCacheStr(context.Background(), lastPayAddUpdateTimeKey, time.Now().Unix())
-		}
-	}
-
 	err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
 		if requestData.IsFree == 1 {
 			handComplete := new(task.GameHandComplete)
@@ -741,7 +734,7 @@ func (s *GameTask) UpdateGameTaskTarget(requestData request.UpdateGameTaskTarget
 			}
 			if requestData.IsUploadXjf == 1 {
 				for i := 0; i < requestData.HandPayComplete; i++ {
-					account := "hand_" + strconv.Itoa(i) + "_" + createDate
+					account := "hand_" + strconv.Itoa(i) + "_" + strconv.Itoa(int(time.Now().Unix()))
 					err = s.FreeUploadXjf(strconv.Itoa(taskData.TaskId), "付费充值", account, "付费成功", "")
 					if err != nil {
 						global.GVA_LOG.Error("上传xjf数据失败taskId = "+strconv.Itoa(taskData.TaskId)+"date = "+createDate, zap.Error(err))
@@ -759,6 +752,23 @@ func (s *GameTask) UpdateGameTaskTarget(requestData request.UpdateGameTaskTarget
 		}
 		return err
 	})
+	if gameTask.CreateDate.Format("2006-01-02") == date {
+		if gameTask.PayTarget < requestData.PayTarget {
+			global.GVA_LOG.Warn("进入修改add update")
+			lastPayAddUpdateTimeKey := fmt.Sprintf(LastPayAddUpdateTimeKey, date, gameTask.TaskId)
+			_ = s.cache.SetCacheStr(context.Background(), lastPayAddUpdateTimeKey, time.Now().Unix())
+			msg := "# 测试监控报警 " + time.Now().Format("2006-01-02 15:04:05")
+			msg += "\n"
+			msg += "**" + taskData.User + "**"
+			msg += "\n"
+			msg += taskData.TaskName + ", 付费目标改为" + strconv.Itoa(requestData.PayTarget)
+			url := "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5ccfb180-c062-48b5-ae18-0c96f7c19f0b"
+			var sendData SendMsg
+			sendData.MsgType = "markdown"
+			sendData.Markdown.Content = msg
+			s.common.SendMsgData(url, sendData)
+		}
+	}
 	return
 }
 
@@ -783,9 +793,9 @@ func (s *GameTask) TargetStatistics(date string) (apiList []control.TargetStatis
 			targetStatistics.TargetActive = target.RetainedTarget
 			targetStatistics.TargetPay = target.PayTarget
 			targetStatistics.TargetNew = target.NewTarget
-			targetStatistics.CompleteNew = target.NewComplete + target.HandNewComplete
-			targetStatistics.CompleteActive = target.RetainedComplete + target.HandRetainedComplete
-			targetStatistics.CompletePay = target.PayComplete + target.HandPayComplete
+			targetStatistics.CompleteNew = target.NewComplete
+			targetStatistics.CompleteActive = target.RetainedComplete
+			targetStatistics.CompletePay = target.PayComplete
 			targetStatistics.XmyId = target.GameIdXmy
 			targetStatistics.QqId = target.TxGameId
 			targetStatistics.QqChannel = target.TxChannel
@@ -815,10 +825,10 @@ func (s *GameTask) DayStatisticsData(request request.GameTaskStatisticsRequest)
 			gameTargetDate.PayTarget = gameTarget.PayTarget
 			gameTargetDate.NewTarget = gameTarget.NewTarget
 			gameTargetDate.RetainedTarget = gameTarget.RetainedTarget
-			gameTargetDate.PayComplete = gameTarget.PayComplete + gameTarget.HandPayComplete
-			gameTargetDate.NewComplete = gameTarget.NewComplete + gameTarget.HandNewComplete
-			gameTargetDate.RetainedComplete = gameTarget.RetainedComplete + gameTarget.HandRetainedComplete
-			gameTargetDate.Amount = gameTarget.Amount + gameTarget.HandAmountTotal
+			gameTargetDate.PayComplete = gameTarget.PayComplete
+			gameTargetDate.NewComplete = gameTarget.NewComplete
+			gameTargetDate.RetainedComplete = gameTarget.RetainedComplete
+			gameTargetDate.Amount = gameTarget.Amount
 			gameTargetDate.GamePort = GamePort[gameTarget.GamePortId]
 			gameTargetDate.User = gameTarget.User
 			gameTargetDate.TaskDate = gameTarget.CreateDate.Format("2006-01-02")
@@ -959,3 +969,38 @@ func (s *GameTask) TaskResetFee(api request.GameTaskRequest) (err error) {
 	}
 	return
 }
+
+// http请求群控付费账号
+func (s *GameTask) GetFeeAccountControl(taskId int) (d []byte, err error) {
+	url := global.GVA_CONFIG.ExtranetDomain.Control + "/v1/device/get_log_by_game"
+	//url := "http://xjf.lianyou.fun:8099/v1/device/get_log_by_game"
+	params := map[string]string{
+		"date":          time.Now().Format("2006-01-02"),
+		"action":        "付费账号",
+		"action_result": "占位",
+		"game_id":       strconv.Itoa(taskId),
+	}
+	d, code, err := utils.HttpGetReplyCode(url, params)
+	fmt.Println(code)
+	if code != 200 {
+		return nil, errors.New(string(d))
+	}
+	return
+}
+
+type FeeAccount struct {
+	Account  string `json:"account"`
+	Password string `json:"password"`
+}
+
+func (s *GameTask) GetFeeAccountList(taskId int) (fa []FeeAccount, err error) {
+	b, err := s.GetFeeAccountControl(taskId)
+	if err != nil {
+		return
+	}
+	err = json.Unmarshal(b, &fa)
+	if err != nil {
+		return
+	}
+	return
+}