Bladeren bron

设备异常逻辑更新

wangbin 2 jaren geleden
bovenliggende
commit
613af337c4
3 gewijzigde bestanden met toevoegingen van 10 en 6 verwijderingen
  1. 1 0
      model/log/device_log.go
  2. 1 0
      model/log/request/loging.go
  3. 8 6
      service/log/loging/logical_log.go

+ 1 - 0
model/log/device_log.go

@@ -24,6 +24,7 @@ type DeviceLog struct {
 	LogUuid            string `json:"log_uuid"` //日志UUID
 	ScriptDeviceId     string `json:"script_device_id"`
 	PcCode             string `json:"pc_code"`
+	SimulatorIpCity    string `json:"simulator_ip_city"`
 }
 
 func (DeviceLog) TableName() string {

+ 1 - 0
model/log/request/loging.go

@@ -33,6 +33,7 @@ type AddLogRequest struct {
 	DeviceIp           string `json:"device_ip"`
 	ScriptDeviceId     string `json:"script_device_id"`
 	Err                string `json:"err"` // 0或不传表示没有异常,其他表示异常,脚本端自定义
+	SimulatorIpCity    string `json:"simulator_ip_city"`
 }
 
 type ReportPointsData struct {

+ 8 - 6
service/log/loging/logical_log.go

@@ -902,7 +902,7 @@ func (s *LogicalLog) AddDeviceLog(request request.AddLogRequest) {
 	logSC.Account = request.Account
 	logSC.DeviceId = request.DeviceId
 	logSC.DeviceImei = request.DeviceImei
-	logSC.DeviceIp = request.DeviceIp
+	logSC.DeviceIp = request.SimulatorIp
 	logSC.DeviceMac = request.DeviceMac
 	logSC.DeviceManufacturer = request.DeviceManufacturer
 	logSC.DeviceModel = request.DeviceModel
@@ -915,6 +915,7 @@ func (s *LogicalLog) AddDeviceLog(request request.AddLogRequest) {
 	logSC.AccountHex = s.AccountHexLog(request)
 	logSC.CreateDate = time.Now().Format("2006-01-02")
 	logSC.PcCode = request.PcCode
+	logSC.SimulatorIpCity = request.SimulatorIpCity
 	ctx := context.Background()
 	if request.TaskType == 1 {
 		var deviceLog = log.DeviceLog{}
@@ -1034,8 +1035,8 @@ func (s *LogicalLog) CheckDeviceId(request request.AddLogRequest) {
 	if request.TaskType == 0 {
 		b, deviceLog := s.CheckDeviceIdErr(request.ScriptDeviceId, request.LogUuid, request.GameId)
 		// 有异常处理
-		if b {
-			s.AddScriptDeviceErr(request.GameId, request.Account, request.ScriptDeviceId, request.ScriptDeviceId, deviceLog.Account, deviceLog.GameId, 2, request.PcCode, request.Operator)
+		if b && len(deviceLog) >= 3 {
+			s.AddScriptDeviceErr(request.GameId, request.Account, request.ScriptDeviceId, request.ScriptDeviceId, deviceLog[0].Account, deviceLog[0].GameId, 2, request.PcCode, request.Operator)
 			//ct := fmt.Sprintf("<font color=\"warning\">%s:%d, 相同设备id</font>", request.PcCode, request.GameId)
 			//s.SendDeviceMsg(ct, request.Operator)
 		}
@@ -1108,9 +1109,10 @@ func (s *LogicalLog) SendMsgData(url string, params interface{}) (result []byte,
 	return
 }
 
-func (s *LogicalLog) CheckDeviceIdErr(scriptDeviceId string, uuid string, gameId int) (bool, log.DeviceLog) {
-	var deviceLog log.DeviceLog
-	result := global.GVA_DB.Where("create_date <= ?", time.Now().Format("2006-01-02")).Where("create_date >= ?", time.Now().Add(-time.Hour*24).Format("2006-01-02")).Where("game_id = ?", gameId).Where("script_device_id = ?", scriptDeviceId).Where("log_uuid != ?", uuid).First(&deviceLog)
+func (s *LogicalLog) CheckDeviceIdErr(scriptDeviceId string, uuid string, gameId int) (bool, []log.GameAccount) {
+	var deviceLog []log.GameAccount
+	// result := global.GVA_DB.Where("create_date <= ?", time.Now().Format("2006-01-02")).Where("create_date >= ?", time.Now().Add(-time.Hour*24).Format("2006-01-02")).Where("game_id = ?", gameId).Where("script_device_id = ?", scriptDeviceId).Find(&deviceLog)
+	result := global.GVA_DB.Where("game_id = ?", gameId).Where("script_device_id = ?", scriptDeviceId).Find(&deviceLog)
 	if result.Error != nil {
 		if result.Error == gorm.ErrRecordNotFound {
 			return false, deviceLog