| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- package task
- import (
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- "log-server/global"
- "log-server/model/common/response"
- "log-server/model/task/request"
- taskResponse "log-server/model/task/response"
- "log-server/utils"
- "net/http"
- "strconv"
- "time"
- )
- type GameTaskApi struct {
- }
- // @Tags gameTask
- // @Summary 创建游戏任务
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GameTaskRequest true
- // @Success 200 {object} response.Response{msg=string} "创建游戏任务"
- // @Router /gameTask/create [post]
- func (s *GameTaskApi) CreateGameTask(c *gin.Context) {
- var api request.GameTaskRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.GameTaskVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.CreateGameTask(api); err != nil {
- global.GVA_LOG.Error("创建失败!", zap.Error(err))
- response.FailWithMessage("创建失败 "+err.Error(), c)
- } else {
- response.OkWithMessage("创建成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 游戏任务列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GetCardListRequest true "游戏任务列表"
- // @Success 200 {object} response.Response{data=response.GetGameTaskListReply,msg=string} "分页游戏任务列表,返回包括列表,总数,页码,每页数量"
- // @Router /gameTask/getGameTaskList [post]
- func (s *GameTaskApi) GetGameTaskList(c *gin.Context) {
- var paramsInfo request.GetGameTaskListRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if list, option, total, err := taskService.GetGameTaskInfoList(paramsInfo.GameTask, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败"+err.Error(), c)
- } else {
- response.OkWithDetailed(taskResponse.GameTaskPageResult{
- List: list,
- OptionList: option,
- Total: total,
- Page: paramsInfo.Page,
- PageSize: paramsInfo.PageSize,
- }, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 小绵羊任务列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GetXmyTaskListRequest true "小绵羊任务列表"
- // @Success 200 {object} response.Response{data=response.GetXmyTaskListReply,msg=string} "分页小绵羊任务列表,返回包括列表,总数,页码,每页数量"
- // @Router /gameTask/getXmyTaskList [post]
- func (s *GameTaskApi) GetXmyTaskList(c *gin.Context) {
- var paramsInfo request.GetXmyGameListRequest
- _ = c.ShouldBindJSON(¶msInfo)
- startDay := time.Now().Format("2006-01-02")
- endDay := time.Now().Format("2006-01-02")
- if len(paramsInfo.Date) != 0 {
- startDay = paramsInfo.Date[0]
- endDay = paramsInfo.Date[1]
- }
- if list, err := taskService.GetXmyTaskList(startDay, endDay); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败"+err.Error(), c)
- } else {
- response.OkWithDetailed(list, "获取成功", c)
- }
- }
- //获取启用状态的任务
- func (s *GameTaskApi) GetUsedGameTaskList(c *gin.Context) {
- var paramsInfo request.GetGameTaskListRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if list, option, total, err := taskService.GetUsedGameTaskInfoList(paramsInfo.GameTask, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败"+err.Error(), c)
- } else {
- response.OkWithDetailed(taskResponse.GameTaskPageResult{
- List: list,
- OptionList: option,
- Total: total,
- Page: paramsInfo.Page,
- PageSize: paramsInfo.PageSize,
- }, "获取成功", 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=systemRes.GameTaskRequest} "根据id获取游戏任务信息,返回包括游戏任务信息详情"
- // @Router /gameTask/getGameTaskById [post]
- func (s *GameTaskApi) GetGameTaskById(c *gin.Context) {
- var idInfo request.GetById
- _ = c.ShouldBindJSON(&idInfo)
- if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- api, err := taskService.GetGameTaskById(idInfo.ID)
- if err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(api, "获取成功", c)
- }
- }
- // @Tags GameTask
- // @Summary 游戏任务信息状态
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.UpdateGameTaskStatusRequest true "id, 状态"
- // @Success 200 {object} response.Response{msg=string} "修改游戏任务信息状态"
- // @Router /gameTask/statusOperation [post]
- func (s *GameTaskApi) StatusOperation(c *gin.Context) {
- var paramsInfo request.UpdateGameTaskStatusRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if paramsInfo.TaskId == 0 {
- response.FailWithMessage("Id不能为空", c)
- return
- }
- if paramsInfo.Status == 0 {
- response.FailWithMessage("状态值不能为空", c)
- return
- }
- if err := taskService.UpdateGameTaskStatus(paramsInfo); err != nil {
- global.GVA_LOG.Error("修改失败!", zap.Error(err))
- response.FailWithMessage(err.Error(), c)
- } else {
- response.OkWithMessage("修改成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 更新游戏任务
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GameTaskRequest true
- // @Success 200 {object} response.Response{msg=string} "更新游戏任务"
- // @Router /gameTask/update [post]
- func (s *GameTaskApi) UpdateGameTask(c *gin.Context) {
- var api request.GameTaskRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.GameTaskVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.UpdateGameTask(api); err != nil {
- global.GVA_LOG.Error("更新失败!", zap.Error(err))
- response.FailWithMessage("更新失败 "+err.Error(), c)
- } else {
- response.OkWithMessage("更新成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 删除gameTask
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body task.GameTask true "ID"
- // @Success 200 {object} response.Response{msg=string} "删除gameTask"
- // @Router /gameTask/delete [post]
- func (s *GameTaskApi) DeleteGameTask(c *gin.Context) {
- var api request.GameTaskRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.TaskIdVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.DeleteGameTask(api); err != nil {
- global.GVA_LOG.Error("删除失败!", zap.Error(err))
- response.FailWithMessage("删除失败 "+err.Error(), c)
- } else {
- response.OkWithMessage("删除成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 游戏任务列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GetCardListRequest true "游戏任务列表"
- // @Success 200 {object} response.Response{data=response.GetGameTaskListReply,msg=string} "分页游戏任务列表,返回包括列表,总数,页码,每页数量"
- // @Router /gameTask/getGameTaskTargetList [post]
- func (s *GameTaskApi) GetGameTaskTargetList(c *gin.Context) {
- var paramsInfo request.GetGameTaskListTargetRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if list, total, err := taskService.GetGameTaskTargetInfoList(paramsInfo.GameTargetCompleteRequest, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc, false); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: list,
- Total: total,
- Page: paramsInfo.Page,
- PageSize: paramsInfo.PageSize,
- }, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 腾讯游戏任务列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GetCardListRequest true "腾讯游戏任务列表"
- // @Success 200 {object} response.Response{data=response.GetGameTaskListReply,msg=string} "分页游戏任务列表,返回包括列表,总数,页码,每页数量"
- // @Router /gameTask/getGameTxTaskList [post]
- func (s *GameTaskApi) GetGameTxTaskList(c *gin.Context) {
- var paramsInfo request.GetGameTaskListTargetRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if list, total, err := taskService.GetGameTaskTargetInfoList(paramsInfo.GameTargetCompleteRequest, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc, true); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: list,
- Total: total,
- Page: paramsInfo.Page,
- PageSize: paramsInfo.PageSize,
- }, "获取成功", 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/getGameTaskTargetById [post]
- func (s *GameTaskApi) GetGameTaskTargetById(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.GetGameTaskTargetById(idInfo.ID, date)
- if err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(api, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 更新游戏任务目标
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GameTaskRequest true
- // @Success 200 {object} response.Response{msg=string} "更新游戏任务目标"
- // @Router /gameTask/updateTarget [post]
- func (s *GameTaskApi) UpdateGameTaskTarget(c *gin.Context) {
- var api request.UpdateGameTaskTargetRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.UpdateTargetVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.UpdateGameTaskTarget(api); err != nil {
- global.GVA_LOG.Error("更新失败!", zap.Error(err))
- response.FailWithMessage("更新失败 "+err.Error(), c)
- } else {
- response.OkWithMessage("更新成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 群控任务目标
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data Query new_date true
- // @Success 200 {object} []control.TargetStatisticsReply "更新游戏任务目标"
- // @Router /gameTask/targetStatistics [get]
- func (s *GameTaskApi) TargetStatistics(c *gin.Context) {
- date := c.Query("new_date")
- if date == "" {
- response.FailWithMessage("获取失败!参数错误!", c)
- return
- }
- if list, err := taskService.TargetStatistics(date); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- c.JSON(http.StatusOK, response.ControlResult{
- Data: list,
- Message: "获取成功",
- Code: 1000,
- Date: date,
- })
- return
- }
- }
- // @Tags gameTask
- // @Summary 数优每日统计
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data Query create_date true
- // @Success 200 {object} []response.GameTargetStatistics "数优每日统计数据"
- // @Router /gameTask/everyDayStatistics [post]
- func (s *GameTaskApi) EveryDayStatistics(c *gin.Context) {
- var paramsInfo request.GameTaskStatisticsRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if data, err := taskService.DayStatisticsData(paramsInfo); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: data,
- Total: 0,
- Page: 1,
- PageSize: 10,
- }, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 数优每月统计
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data Query create_date true
- // @Success 200 {object} []response.GameTargetStatistics "数优每月统计数据"
- // @Router /gameTask/monthStatistics [post]
- func (s *GameTaskApi) MonthStatistics(c *gin.Context) {
- if data, err := taskService.MonthStatisticsData(); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: data,
- Total: 0,
- Page: 1,
- PageSize: 10,
- }, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 数优游戏统计
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data Query create_date true
- // @Success 200 {object} []response.GameTargetStatistics "数优游戏统计数据"
- // @Router /gameTask/gameStatistics [post]
- func (s *GameTaskApi) GameStatistics(c *gin.Context) {
- var paramsInfo request.CreateDateReply
- _ = c.ShouldBindJSON(¶msInfo)
- if data, err := taskService.GameStatisticsData(paramsInfo.CreateDate); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: data,
- Total: 10,
- Page: 1,
- PageSize: 10,
- }, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 负责人端口游戏列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data Query create_date true
- // @Success 200 {object} []response.GameTargetStatistics "负责人端口游戏列表"
- // @Router /gameTask/gameList [post]
- func (s *GameTaskApi) GameList(c *gin.Context) {
- var paramsInfo request.GameListRequest
- _ = c.ShouldBindJSON(¶msInfo)
- if data, err := taskService.GameStatisticsList(paramsInfo); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: data,
- Total: 10,
- Page: 1,
- PageSize: 10,
- }, "获取成功", c)
- }
- }
- // @Tags gameTask
- // @Summary 重置付费
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GameTaskRequest true
- // @Success 200 {object} response.Response{msg=string} "更新游戏任务目标"
- // @Router /gameTask/taskResetFee [post]
- func (s *GameTaskApi) TaskResetFee(c *gin.Context) {
- var api request.GameTaskRequest
- _ = c.ShouldBindJSON(&api)
- if err := utils.Verify(api, utils.TaskIdVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- if err := taskService.TaskResetFee(api); err != nil {
- global.GVA_LOG.Error("重置付费失败!", zap.Error(err))
- response.FailWithMessage("重置付费失败 "+err.Error(), c)
- } else {
- 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)
- }
- }
- // @Tags gameTask
- // @Summary 导出任务目标Excel
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/octet-stream
- // @Param data body request.GameTargetCompleteRequest true "导出Excel文件信息"
- // @Success 200
- // @Router /gameTask/taskTargetExport [post]
- func (e *GameTaskApi) TaskTargetExport(c *gin.Context) {
- var excelInfo request.ExcelInfo
- _ = c.ShouldBindJSON(&excelInfo)
- paramsInfo := excelInfo.InfoList
- paramsInfo.PageSize = 300
- paramsInfo.Page = 1
- if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- list, _, err := taskService.GetGameTaskTargetInfoList(paramsInfo.GameTargetCompleteRequest, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc, false)
- if err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Error(err))
- response.FailWithMessage("获取失败 "+err.Error(), c)
- }
- filePath := global.GVA_CONFIG.Excel.Dir + excelInfo.FileName
- err = taskService.TaskStatisticsList2Excel(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)
- }
- func (e *GameTaskApi) TemporaryTask(c *gin.Context) {
- var params request.GetTemporaryTaskRequest
- _ = c.ShouldBindJSON(¶ms)
- global.GVA_LOG.Warn(params.PcCode)
- if params.PcCode == "" {
- response.FailWithMessage("参数错误", c)
- return
- }
- if data, err := taskService.TemporaryTask(c, params.PcCode); err != nil {
- response.FailWithMessage("获取失败 "+err.Error(), c)
- } else {
- response.OkWithDetailed(data, "获取成功", c)
- }
- }
- func (e *GameTaskApi) GetSheepPay(c *gin.Context) {
- money := c.Query("money")
- gameid := c.Query("gameid")
- payTime := c.Query("pay_time")
- global.GVA_LOG.Info(money)
- global.GVA_LOG.Info(gameid)
- global.GVA_LOG.Info(payTime)
- if money == "" || gameid == "" || payTime == "" {
- response.FailWithMessage("参数错误", c)
- return
- }
- moneyInt, _ := strconv.Atoi(money)
- taskService.GetSheepPay(c, moneyInt, gameid, payTime)
- response.OkWithDetailed("", "收到数据", c)
- }
|