|
|
@@ -378,7 +378,7 @@ func (s *GameTask) UpdateGameTaskStatus(c request.UpdateGameTaskStatusRequest) (
|
|
|
global.GVA_LOG.Info("当天的任务目标已存在")
|
|
|
} else {
|
|
|
targetComplete := s.CreateGameTargetCompleteModel(oldA, date)
|
|
|
- err := tx.Omit("update_time").Create(&targetComplete).Error
|
|
|
+ err := tx.Omit("update_time,is_complete,hand_new_complete,hand_retained_complete,hand_pay_complete,hand_amount_total").Create(&targetComplete).Error
|
|
|
if err != nil {
|
|
|
global.GVA_LOG.Error("创建任务目标数据失败", zap.Error(err))
|
|
|
return err
|
|
|
@@ -463,14 +463,14 @@ func (s *GameTask) DeleteGameTask(api request.GameTaskRequest) (err error) {
|
|
|
gameTask := new(task.GameTask)
|
|
|
global.GVA_DB.Where("task_id = ?", api.TaskId).First(&gameTask)
|
|
|
controlTaskId := gameTask.ControlTaskId
|
|
|
- update := map[string]interface{}{
|
|
|
- "is_del": 1,
|
|
|
- "status": -1,
|
|
|
- "stop_time": time.Now(),
|
|
|
- "delete_time": time.Now(),
|
|
|
- }
|
|
|
+ //update := map[string]interface{}{
|
|
|
+ // "is_del": 1,
|
|
|
+ // "status": -1,
|
|
|
+ // "stop_time": time.Now(),
|
|
|
+ // "delete_time": time.Now(),
|
|
|
+ //}
|
|
|
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
|
|
- err := tx.Table("game_task").Where("task_id", api.TaskId).Updates(update).Error
|
|
|
+ err := tx.Where("task_id", api.TaskId).Delete(&task.GameTask{}).Error
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -492,7 +492,8 @@ func (apiService *GameTask) GetGameTaskTargetInfoList(api request.GameTargetComp
|
|
|
}
|
|
|
db := global.GVA_DB.Table("game_target_complete gtc")
|
|
|
db = db.Select("gtc.id,gtc.task_id,gt.task_name,gtc.new_target,gt.login_method,gt.user,gtc.pay_target,gtc.retained_target," +
|
|
|
- "gtc.new_complete,gtc.pay_complete,gtc.retained_complete,gtc.create_date,gtc.amount,gtc.game_rate,gtc.is_complete")
|
|
|
+ "gtc.new_complete,gtc.pay_complete,gtc.retained_complete,gtc.create_date,gtc.amount,gtc.game_rate,gtc.is_complete,gtc.hand_new_complete," +
|
|
|
+ "gtc.hand_retained_complete,gtc.hand_pay_complete,gtc.hand_amount_total")
|
|
|
db = db.Joins("left join game_task gt on gt.task_id = gtc.task_id")
|
|
|
db = db.Where("gtc.create_date = ?", api.CreateDate)
|
|
|
var apiList []response.GetGameTargetComplete
|
|
|
@@ -540,11 +541,72 @@ 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
|
|
|
}
|
|
|
}
|
|
|
return apiList, total, err
|
|
|
}
|
|
|
|
|
|
+func (s *GameTask) FreeUploadWt(gameId, channelId string, date string, money int, path string) (err error) {
|
|
|
+ url := "https://sy.nkfzs.com/v2/data_collect/" + path
|
|
|
+ requestData := map[string]string{
|
|
|
+ "channel_id": channelId,
|
|
|
+ "game_id": gameId,
|
|
|
+ "type": "3",
|
|
|
+ "account": "hand_" + date,
|
|
|
+ "money": strconv.Itoa(money),
|
|
|
+ }
|
|
|
+ data, code, err := utils.HttpGetReplyCode(url, requestData)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ fmt.Println(code)
|
|
|
+ if code != 200 {
|
|
|
+ return errors.New(string(data))
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (s *GameTask) FreeUploadXjf(gameId, action, account, actionResult, actionState string) (err error) {
|
|
|
+ url := global.GVA_CONFIG.ExtranetDomain.Control + "/v1/device/setAccountLog"
|
|
|
+ requestData := map[string]string{
|
|
|
+ "action": action,
|
|
|
+ "game_id": gameId,
|
|
|
+ "action_result": actionResult,
|
|
|
+ "account": account,
|
|
|
+ "actionState": actionState,
|
|
|
+ }
|
|
|
+ data, code, err := utils.HttpGetReplyCode(url, requestData)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ fmt.Println(code)
|
|
|
+ if code != 200 {
|
|
|
+ return errors.New(string(data))
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (s *GameTask) QQCardUsedLogUploadXjf(gameId int, account string, money int) (err error) {
|
|
|
+ url := global.GVA_CONFIG.ExtranetDomain.Control + "/v1/device/qq_card_hand"
|
|
|
+ requestData := map[string]string{
|
|
|
+ "game_id": strconv.Itoa(gameId),
|
|
|
+ "card_number": account,
|
|
|
+ "money": strconv.Itoa(money),
|
|
|
+ }
|
|
|
+ data, code, err := utils.HttpGetReplyCode(url, requestData)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if code != 200 {
|
|
|
+ return errors.New(string(data))
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
//@function: GetGameTaskTargetById
|
|
|
//@description: 根据id获取GameTargetComplete
|
|
|
//@param: id uint
|
|
|
@@ -567,19 +629,94 @@ func (s *GameTask) UpdateGameTaskTarget(requestData request.UpdateGameTaskTarget
|
|
|
}
|
|
|
gameTask := new(task.GameTargetComplete)
|
|
|
global.GVA_DB.Where("task_id = ?", requestData.TaskId).Where("create_date = ?", requestData.CreateDate).First(&gameTask)
|
|
|
+ var taskData task.GameTask
|
|
|
+ err = global.GVA_DB.Where("task_id = ?", requestData.TaskId).First(&taskData).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
//if gameTask.NewTarget > requestData.NewTarget && gameTask.RetainedTarget > requestData.RetainedTarget {
|
|
|
// return errors.New("任务目标不能小于当前目标")
|
|
|
//}
|
|
|
updateData := map[string]interface{}{
|
|
|
- "new_target": requestData.NewTarget,
|
|
|
- "retained_target": requestData.RetainedTarget,
|
|
|
+ "new_target": requestData.NewTarget,
|
|
|
+ "pay_complete": requestData.PayTarget,
|
|
|
+ "retained_target": requestData.RetainedTarget,
|
|
|
+ "hand_new_complete": requestData.HandNewComplete + gameTask.HandNewComplete,
|
|
|
+ "hand_retained_complete": requestData.HandRetainedComplete + gameTask.HandRetainedComplete,
|
|
|
+ "hand_pay_complete": requestData.HandPayComplete + gameTask.HandPayComplete,
|
|
|
+ "hand_amount_total": requestData.HandAmountTotal + gameTask.HandAmountTotal,
|
|
|
}
|
|
|
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
|
|
+ if requestData.IsFree == 1 {
|
|
|
+ handComplete := new(task.GameHandComplete)
|
|
|
+ handComplete.TaskId = requestData.TaskId
|
|
|
+ handComplete.IsFree = requestData.IsFree
|
|
|
+ handComplete.HandAmountTotal = requestData.HandAmountTotal
|
|
|
+ handComplete.HandPayComplete = requestData.HandPayComplete
|
|
|
+ handComplete.HandRetainedComplete = requestData.HandRetainedComplete
|
|
|
+ handComplete.HandNewComplete = requestData.HandNewComplete
|
|
|
+ handComplete.FreeMethod = requestData.FreeMethod
|
|
|
+ handComplete.CreateDate = gameTask.CreateDate
|
|
|
+ handComplete.IsUploadWt = requestData.IsUploadWt
|
|
|
+ handComplete.IsUploadXjf = requestData.IsUploadXjf
|
|
|
+ err := tx.Omit("create_time").Create(&handComplete).Error
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if len(requestData.CardList) > 0 {
|
|
|
+ var cards []task.GameHandCardLog
|
|
|
+ for _, card := range requestData.CardList {
|
|
|
+ var handCardLog task.GameHandCardLog
|
|
|
+ handCardLog.TaskId = requestData.TaskId
|
|
|
+ handCardLog.Card = card.Card
|
|
|
+ handCardLog.Amount = card.Amount
|
|
|
+ handCardLog.HandId = handComplete.Id
|
|
|
+ cards = append(cards, handCardLog)
|
|
|
+ }
|
|
|
+ err := tx.Omit("create_time").Create(&cards).Error
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
err = tx.Model(&task.GameTargetComplete{}).Where("task_id = ?", requestData.TaskId).Where("create_date = ?", requestData.CreateDate).Updates(updateData).Error
|
|
|
if err != nil {
|
|
|
global.GVA_LOG.Error("更新任务数据失败: ", zap.Error(err))
|
|
|
return err
|
|
|
}
|
|
|
+ if requestData.IsUploadXjf == 1 || requestData.IsUploadWt == 1 {
|
|
|
+ if requestData.HandAmountTotal <= 0 {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ createDate := gameTask.CreateDate.Format("2006-01-02")
|
|
|
+ if requestData.IsUploadWt == 1 {
|
|
|
+ if taskData.GamePortId == 5 {
|
|
|
+ err = s.FreeUploadWt(taskData.MzGameId, taskData.MzChannel, createDate, requestData.HandAmountTotal, "game_task_report_meizu")
|
|
|
+ } else if taskData.GamePortId == 1 {
|
|
|
+ err = s.FreeUploadWt(taskData.TxGameId, taskData.TxChannel, createDate, requestData.HandAmountTotal, "game_task_report")
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ global.GVA_LOG.Error("上传wt财务数据失败gameId = "+taskData.TxGameId+"date = "+createDate, zap.Error(err))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if requestData.IsUploadXjf == 1 {
|
|
|
+ for i := 0; i < requestData.HandPayComplete; i++ {
|
|
|
+ account := "hand_" + strconv.Itoa(i) + "_" + createDate
|
|
|
+ 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))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if requestData.FreeMethod == 1 && len(requestData.CardList) > 0 {
|
|
|
+ for _, card := range requestData.CardList {
|
|
|
+ err = s.QQCardUsedLogUploadXjf(taskData.TaskId, card.Card, card.Amount)
|
|
|
+ if err != nil {
|
|
|
+ global.GVA_LOG.Error("上传qq卡数据失败taskId = "+strconv.Itoa(taskData.TaskId)+"date = "+createDate, zap.Error(err))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return err
|
|
|
})
|
|
|
return
|
|
|
@@ -589,7 +726,8 @@ func (s *GameTask) TargetStatistics(date string) (apiList []control.TargetStatis
|
|
|
db := global.GVA_DB.Table("game_target_complete gtc")
|
|
|
db = db.Select("gtc.task_id,gt.task_name,gtc.new_target,gt.login_method,gt.user,gtc.pay_target,gtc.retained_target," +
|
|
|
"gtc.new_complete,gtc.pay_complete,gtc.retained_complete,gtc.create_date,gt.tx_channel,gt.tx_game_id,gt.mz_channel," +
|
|
|
- "gt.game_id_xmy,gt.mz_game_id,gt.game_port_id,gt.game_id,gt.game_name")
|
|
|
+ "gt.game_id_xmy,gt.mz_game_id,gt.game_port_id,gt.game_id,gt.game_name," +
|
|
|
+ "gtc.hand_new_complete,gtc.hand_retained_complete,gtc.hand_pay_complete,gtc.hand_amount_total")
|
|
|
db = db.Joins("left join game_task gt on gt.task_id = gtc.task_id")
|
|
|
db = db.Where("gt.is_del = ?", -1)
|
|
|
db = db.Where("gt.status = ?", 1)
|
|
|
@@ -605,9 +743,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
|
|
|
- targetStatistics.CompleteActive = target.RetainedComplete
|
|
|
- targetStatistics.CompletePay = target.PayComplete
|
|
|
+ targetStatistics.CompleteNew = target.NewComplete + target.HandNewComplete
|
|
|
+ targetStatistics.CompleteActive = target.RetainedComplete + target.HandRetainedComplete
|
|
|
+ targetStatistics.CompletePay = target.PayComplete + target.HandPayComplete
|
|
|
targetStatistics.XmyId = target.GameIdXmy
|
|
|
targetStatistics.QqId = target.TxGameId
|
|
|
targetStatistics.QqChannel = target.TxChannel
|