|
@@ -183,8 +183,14 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
|
|
|
global.GVA_LOG.Error("获取机房数据失败RequestXjfTaskData", zap.Error(err))
|
|
global.GVA_LOG.Error("获取机房数据失败RequestXjfTaskData", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- xjfJson, _ := simplejson.NewJson(dataXjf)
|
|
|
|
|
- xjfArr, _ := xjfJson.Array()
|
|
|
|
|
|
|
+ xjfJson, err := simplejson.NewJson(dataXjf)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ xjfArr, err := xjfJson.Array()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
//查询微信扫码订单数
|
|
//查询微信扫码订单数
|
|
|
|
|
|
|
|
//var num map[string]map[int]int /*创建集合,存储机房查询日志接口返回值 */
|
|
//var num map[string]map[int]int /*创建集合,存储机房查询日志接口返回值 */
|
|
@@ -198,10 +204,19 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
|
|
|
if k == "登陆_成功" {
|
|
if k == "登陆_成功" {
|
|
|
arrNum6 := make(map[int]int)
|
|
arrNum6 := make(map[int]int)
|
|
|
for _, ss := range action6 {
|
|
for _, ss := range action6 {
|
|
|
- result = s.QueryXjfLogByBatch(ss, actionResult)
|
|
|
|
|
|
|
+ result, err = s.QueryXjfLogByBatch(ss, actionResult)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if string(result) != "null" {
|
|
if string(result) != "null" {
|
|
|
- dataJson, _ := simplejson.NewJson(result)
|
|
|
|
|
- dataArr, _ := dataJson.Array()
|
|
|
|
|
|
|
+ dataJson, err := simplejson.NewJson(result)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ dataArr, err := dataJson.Array()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
for iii, _ := range dataArr {
|
|
for iii, _ := range dataArr {
|
|
|
info := dataJson.GetIndex(iii)
|
|
info := dataJson.GetIndex(iii)
|
|
|
gameId, _ := info.Get("game_id").Int()
|
|
gameId, _ := info.Get("game_id").Int()
|
|
@@ -220,17 +235,32 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
|
|
|
}
|
|
}
|
|
|
num[k] = arrNum6
|
|
num[k] = arrNum6
|
|
|
} else {
|
|
} else {
|
|
|
- result = s.QueryXjfLogByBatch(action, actionResult)
|
|
|
|
|
|
|
+ result, err = s.QueryXjfLogByBatch(action, actionResult)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if string(result) == "null" {
|
|
if string(result) == "null" {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
- dataJson, _ := simplejson.NewJson(result)
|
|
|
|
|
- dataArr, _ := dataJson.Array()
|
|
|
|
|
|
|
+ dataJson, err := simplejson.NewJson(result)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ dataArr, err := dataJson.Array()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
arrTemp := make(map[int]int)
|
|
arrTemp := make(map[int]int)
|
|
|
for iii, _ := range dataArr {
|
|
for iii, _ := range dataArr {
|
|
|
info := dataJson.GetIndex(iii)
|
|
info := dataJson.GetIndex(iii)
|
|
|
- gameId, _ := info.Get("game_id").Int()
|
|
|
|
|
- total, _ := info.Get("total").Int()
|
|
|
|
|
|
|
+ gameId, err := info.Get("game_id").Int()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ total, err := info.Get("total").Int()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
//global.GVA_LOG.Info(strconv.Itoa(gameId))
|
|
//global.GVA_LOG.Info(strconv.Itoa(gameId))
|
|
|
//global.GVA_LOG.Info(strconv.Itoa(total))
|
|
//global.GVA_LOG.Info(strconv.Itoa(total))
|
|
|
//var arr = XjfTotal{GameId: gameId, Total: total}
|
|
//var arr = XjfTotal{GameId: gameId, Total: total}
|
|
@@ -314,16 +344,27 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
|
|
|
|
|
|
|
|
for iii, _ := range xjfArr {
|
|
for iii, _ := range xjfArr {
|
|
|
info := xjfJson.GetIndex(iii)
|
|
info := xjfJson.GetIndex(iii)
|
|
|
- gameId, _ := info.Get("game_id").Int()
|
|
|
|
|
|
|
+ gameId, err := info.Get("game_id").Int()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if gameId == task.TaskId {
|
|
if gameId == task.TaskId {
|
|
|
- orderSuccessRate, _ = info.Get("order_success_rate").String()
|
|
|
|
|
|
|
+ orderSuccessRate, err = info.Get("order_success_rate").String()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
orderSuccessRateArr := strings.Split(orderSuccessRate, "/")
|
|
orderSuccessRateArr := strings.Split(orderSuccessRate, "/")
|
|
|
- numOrderPay, _ = strconv.Atoi(orderSuccessRateArr[0]) // 付费订单数
|
|
|
|
|
- numPay, _ = strconv.Atoi(orderSuccessRateArr[1]) // 付费成功数
|
|
|
|
|
- ratePaySuccess = orderSuccessRateArr[2] //付费成功率
|
|
|
|
|
|
|
+ if len(orderSuccessRateArr) == 3 {
|
|
|
|
|
+ numOrderPay, err = strconv.Atoi(orderSuccessRateArr[0]) // 付费订单数
|
|
|
|
|
+ numPay, err = strconv.Atoi(orderSuccessRateArr[1]) // 付费成功数
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ ratePaySuccess = orderSuccessRateArr[2] //付费成功率
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
var data dataStatistics.DataAbnormalRate
|
|
var data dataStatistics.DataAbnormalRate
|
|
|
data.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
data.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
@@ -352,16 +393,22 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
|
|
|
data.NumPay = numPay
|
|
data.NumPay = numPay
|
|
|
data.RatePaySuccess = ratePaySuccess
|
|
data.RatePaySuccess = ratePaySuccess
|
|
|
|
|
|
|
|
- global.GVA_LOG.Info(data.TaskName)
|
|
|
|
|
|
|
+ //global.GVA_LOG.Info(data.TaskName)
|
|
|
|
|
|
|
|
if !errors.Is(global.GVA_DB.Model(&dataStatistics.DataAbnormalRate{}).Where("new_date = ? and task_id = ? and hour = ?", newDate, taskId, hour).First(&dataStatistics.DataAbnormalRate{}).Error, gorm.ErrRecordNotFound) {
|
|
if !errors.Is(global.GVA_DB.Model(&dataStatistics.DataAbnormalRate{}).Where("new_date = ? and task_id = ? and hour = ?", newDate, taskId, hour).First(&dataStatistics.DataAbnormalRate{}).Error, gorm.ErrRecordNotFound) {
|
|
|
//已存在,更新
|
|
//已存在,更新
|
|
|
//global.GVA_LOG.Info("已存在,更新")
|
|
//global.GVA_LOG.Info("已存在,更新")
|
|
|
- _ = global.GVA_DB.Model(&dataStatistics.DataAbnormalRate{}).Where("new_date = ? and task_id = ? and hour = ?", newDate, taskId, hour).Updates(data).Error
|
|
|
|
|
|
|
+ err = global.GVA_DB.Model(&dataStatistics.DataAbnormalRate{}).Where("new_date = ? and task_id = ? and hour = ?", newDate, taskId, hour).Updates(data).Error
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
//不存在,新建
|
|
//不存在,新建
|
|
|
//global.GVA_LOG.Info("不存在,新建")
|
|
//global.GVA_LOG.Info("不存在,新建")
|
|
|
- _ = global.GVA_DB.Create(&data).Error
|
|
|
|
|
|
|
+ err = global.GVA_DB.Create(&data).Error
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -369,7 +416,7 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// QueryXjfLogByBatch 请求机房任务数据
|
|
// QueryXjfLogByBatch 请求机房任务数据
|
|
|
-func (s *ServiceDataAbnormalRate) QueryXjfLogByBatch(action string, actionResult string) (result []byte) {
|
|
|
|
|
|
|
+func (s *ServiceDataAbnormalRate) QueryXjfLogByBatch(action string, actionResult string) (result []byte, err error) {
|
|
|
today := time.Now().Format("2006-01-02")
|
|
today := time.Now().Format("2006-01-02")
|
|
|
jfUrl := "http://xjf.lianyou.fun:8099/v1/device/get_log_by_game"
|
|
jfUrl := "http://xjf.lianyou.fun:8099/v1/device/get_log_by_game"
|
|
|
jfParams := map[string]string{
|
|
jfParams := map[string]string{
|
|
@@ -377,7 +424,7 @@ func (s *ServiceDataAbnormalRate) QueryXjfLogByBatch(action string, actionResult
|
|
|
"action": action,
|
|
"action": action,
|
|
|
"action_result": actionResult,
|
|
"action_result": actionResult,
|
|
|
}
|
|
}
|
|
|
- result, _ = utils.HttpGet(jfUrl, jfParams)
|
|
|
|
|
|
|
+ result, err = utils.HttpGet(jfUrl, jfParams)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|