|
|
@@ -13,6 +13,7 @@ import (
|
|
|
"log-server/model/task/control"
|
|
|
"log-server/model/task/request"
|
|
|
"log-server/model/task/response"
|
|
|
+ "log-server/model/typeManage"
|
|
|
"log-server/service/cache"
|
|
|
"log-server/utils"
|
|
|
"math"
|
|
|
@@ -55,8 +56,10 @@ var (
|
|
|
)
|
|
|
|
|
|
type GameTask struct {
|
|
|
- cache cache.Cache
|
|
|
- common Common
|
|
|
+ cache cache.Cache
|
|
|
+ common Common
|
|
|
+ gameChannel typeManage.GameChannel
|
|
|
+ loginType typeManage.LoginType
|
|
|
}
|
|
|
|
|
|
// 创建游戏任务
|
|
|
@@ -84,12 +87,16 @@ func (s *GameTask) CreateGameTask(requestData request.GameTaskRequest) (err erro
|
|
|
gameTask.PayTarget = requestData.PayTarget
|
|
|
gameTask.RetainedTarget = requestData.RetainedTarget
|
|
|
gameTask.PayPrice = requestData.PayPrice
|
|
|
+ gameTask.NewTargetH = requestData.NewTargetH
|
|
|
+ gameTask.RetainedTargetH = requestData.RetainedTargetH
|
|
|
//gameTask.CreateTime = requestData.CreateTime
|
|
|
//gameTask.UpdateTime = requestData.UpdateTime
|
|
|
//gameTask.Status = requestData.Status
|
|
|
//gameTask.IsDel = requestData.IsDel
|
|
|
//gameTask.DeleteTime = requestData.DeleteTime
|
|
|
taskRequestData := s.CreateGameTaskRequestData(requestData)
|
|
|
+ body, _ := json.Marshal(taskRequestData)
|
|
|
+ global.GVA_LOG.Info(string(body))
|
|
|
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
|
|
err = tx.Omit("create_time", "update_time", "status", "is_del", "delete_time", "control_task_id").Create(&gameTask).Error
|
|
|
if err != nil {
|
|
|
@@ -158,12 +165,13 @@ func (s *GameTask) CreateGameTargetCompleteModel(oldA task.GameTask, date time.T
|
|
|
// 创建任务群控请求数据
|
|
|
func (s *GameTask) CreateGameTaskRequestData(requestData request.GameTaskRequest) control.CreateGameTaskRequest {
|
|
|
gameTask := control.CreateGameTaskRequest{}
|
|
|
+ gchannel, _ := s.gameChannel.GetGameChannelById(requestData.GamePortId)
|
|
|
gameTask.GameId = requestData.TaskId
|
|
|
gameTask.GameName = requestData.TaskName
|
|
|
gameTask.Remark = requestData.User
|
|
|
gameTask.NewRetained = requestData.NewRetained
|
|
|
gameTask.Date = time.Now().Format("2006-01-02")
|
|
|
- gameTask.GamePort = GamePort[requestData.GamePortId]
|
|
|
+ gameTask.GamePort = gchannel.ChannelName
|
|
|
gameTask.GameIdXmy = requestData.GameIdXmy
|
|
|
gameTask.NewTarget = requestData.NewTarget
|
|
|
gameTask.PayTarget = requestData.PayTarget
|
|
|
@@ -257,7 +265,7 @@ func (apiService *GameTask) GetGameTaskInfoList(api task.GameTask, info request.
|
|
|
global.GVA_DB.Table("account_type").Select("id", "type_name").Find(&option.AccountTypeOptions)
|
|
|
global.GVA_DB.Table("game_list").Select("id", "game_name").Find(&option.GameListOptions)
|
|
|
//fmt.Println(option)
|
|
|
-
|
|
|
+ accountMp, gamePortMp, loginTypeMp := apiService.TypeManageToMps(option)
|
|
|
if err != nil {
|
|
|
return apiList, option, total, err
|
|
|
} else {
|
|
|
@@ -293,9 +301,9 @@ func (apiService *GameTask) GetGameTaskInfoList(api task.GameTask, info request.
|
|
|
apiReply.Status = apiInfo.Status
|
|
|
apiReply.TaskId = apiInfo.TaskId
|
|
|
apiReply.TaskName = apiInfo.TaskName
|
|
|
- apiReply.GamePort = GamePort[apiInfo.GamePortId]
|
|
|
- apiReply.AccountType = AccountType[apiInfo.AccountType]
|
|
|
- apiReply.LoginMethod = LoginMethod[apiInfo.LoginMethod]
|
|
|
+ apiReply.GamePort = gamePortMp[apiInfo.GamePortId].ChannelName
|
|
|
+ apiReply.AccountType = accountMp[apiInfo.AccountType].TypeName
|
|
|
+ apiReply.LoginMethod = loginTypeMp[apiInfo.LoginMethod].LoginName
|
|
|
apiReply.CreateTime = apiInfo.CreateTime.Format("2006-01-02 15:04:05")
|
|
|
apiReply.User = apiInfo.User
|
|
|
apiReply.Date = apiInfo.Date.Format("2006-01-02")
|
|
|
@@ -318,6 +326,22 @@ func (apiService *GameTask) GetGameTaskInfoList(api task.GameTask, info request.
|
|
|
return apisReply, option, total, err
|
|
|
}
|
|
|
|
|
|
+func (apiService *GameTask) TypeManageToMps(Option task.Option) (map[int]task.AccountTypeOption, map[int]task.GamePortOption, map[int]task.LoginTypeOption) {
|
|
|
+ var accountMp = make(map[int]task.AccountTypeOption, len(Option.AccountTypeOptions))
|
|
|
+ for _, pc := range Option.AccountTypeOptions {
|
|
|
+ accountMp[pc.Id] = pc
|
|
|
+ }
|
|
|
+ var gamePortMp = make(map[int]task.GamePortOption, len(Option.GamePortOptions))
|
|
|
+ for _, gamePort := range Option.GamePortOptions {
|
|
|
+ gamePortMp[gamePort.Id] = gamePort
|
|
|
+ }
|
|
|
+ var loginTypeMp = make(map[int]task.LoginTypeOption, len(Option.LoginTypeOptions))
|
|
|
+ for _, loginType := range Option.LoginTypeOptions {
|
|
|
+ loginTypeMp[loginType.Id] = loginType
|
|
|
+ }
|
|
|
+ return accountMp, gamePortMp, loginTypeMp
|
|
|
+}
|
|
|
+
|
|
|
//获取启用状态的任务
|
|
|
func (apiService *GameTask) GetUsedGameTaskInfoList(api task.GameTask, info request.PageInfo, order string, desc bool) (list interface{}, options interface{}, total int64, err error) {
|
|
|
limit := info.PageSize
|
|
|
@@ -354,7 +378,7 @@ func (apiService *GameTask) GetUsedGameTaskInfoList(api task.GameTask, info requ
|
|
|
global.GVA_DB.Table("account_type").Select("id", "type_name").Find(&option.AccountTypeOptions)
|
|
|
global.GVA_DB.Table("game_list").Select("id", "game_name").Find(&option.GameListOptions)
|
|
|
//fmt.Println(option)
|
|
|
-
|
|
|
+ accountMp, gamePortMp, loginTypeMp := apiService.TypeManageToMps(option)
|
|
|
if err != nil {
|
|
|
return apiList, option, total, err
|
|
|
} else {
|
|
|
@@ -391,9 +415,9 @@ func (apiService *GameTask) GetUsedGameTaskInfoList(api task.GameTask, info requ
|
|
|
apiReply.TaskId = apiInfo.TaskId
|
|
|
apiReply.TaskName = apiInfo.TaskName
|
|
|
apiReply.AddFeeNotice = apiInfo.AddFeeNotice
|
|
|
- apiReply.GamePort = GamePort[apiInfo.GamePortId]
|
|
|
- apiReply.AccountType = AccountType[apiInfo.AccountType]
|
|
|
- apiReply.LoginMethod = LoginMethod[apiInfo.LoginMethod]
|
|
|
+ apiReply.GamePort = gamePortMp[apiInfo.GamePortId].ChannelName
|
|
|
+ apiReply.AccountType = accountMp[apiInfo.AccountType].TypeName
|
|
|
+ apiReply.LoginMethod = loginTypeMp[apiInfo.LoginMethod].LoginName
|
|
|
apiReply.CreateTime = apiInfo.CreateTime.Format("2006-01-02 15:04:05")
|
|
|
apiReply.User = apiInfo.User
|
|
|
apiReply.Date = apiInfo.Date.Format("2006-01-02")
|
|
|
@@ -546,7 +570,7 @@ func (s *GameTask) UpdateGameTask(requestData request.GameTaskRequest) (err erro
|
|
|
gameTask.RetainedTargetH = requestData.RetainedTargetH
|
|
|
taskRequestData := s.CreateGameTaskRequestData(requestData)
|
|
|
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
|
|
- err = tx.Where("task_id = ?", requestData.TaskId).Omit("create_time", "update_time", "status", "is_del", "delete_time", "control_task_id", "date", "task_id").Updates(&gameTask).Error
|
|
|
+ err = tx.Where("task_id = ?", requestData.TaskId).Omit("create_time", "update_time", "status", "is_del", "delete_time", "control_task_id", "date", "task_id").Save(&gameTask).Error
|
|
|
if err != nil {
|
|
|
global.GVA_LOG.Error("更新任务数据失败: ", zap.Error(err))
|
|
|
return err
|
|
|
@@ -674,10 +698,11 @@ func (apiService *GameTask) GetGameTaskTargetInfoList(api request.GameTargetComp
|
|
|
}
|
|
|
}
|
|
|
if len(apiList) != 0 {
|
|
|
+ loginType, _ := apiService.loginType.GetLoginTypeData()
|
|
|
for i, api := range apiList {
|
|
|
date := strings.Split(api.CreateDate, "T")
|
|
|
loginMethod, _ := strconv.Atoi(api.LoginMethod)
|
|
|
- apiList[i].LoginMethod = LoginMethod[loginMethod]
|
|
|
+ apiList[i].LoginMethod = loginType[int64(loginMethod)].LoginName
|
|
|
apiList[i].CreateDate = date[0]
|
|
|
apiList[i].NewComplete = api.NewComplete + api.HandNewComplete
|
|
|
apiList[i].RetainedComplete = api.RetainedComplete + api.HandRetainedComplete
|