|
@@ -33,11 +33,8 @@ func adsHandler(c *gin.Context) {
|
33
|
33
|
|
34
|
34
|
request := adslib.Request{}
|
35
|
35
|
request.Parse(c)
|
36
|
|
- //uaClientOrigin := utils.GetArgument(c, "ua","")
|
37
|
|
- //originMac := utils.GetArgument(c, "mac","")
|
38
|
|
- //clientImei := request.Imei
|
39
|
36
|
|
40
|
|
- fmt.Printf("%+v", request)
|
|
37
|
+ fmt.Printf("%+v\n", request)
|
41
|
38
|
advertiser := "xiaomi"
|
42
|
39
|
uaClient := request.UaClient
|
43
|
40
|
// 获取ua
|
|
@@ -51,7 +48,7 @@ func adsHandler(c *gin.Context) {
|
51
|
48
|
// 获取ip
|
52
|
49
|
checkReqSourceFlag, err := ads_checker.CheckReqSource(request.ReqSource)
|
53
|
50
|
if err != nil {
|
54
|
|
- c.String(404, "check req source failed")
|
|
51
|
+ c.String(404, "check req source failed: %s", err)
|
55
|
52
|
return
|
56
|
53
|
}
|
57
|
54
|
|
|
@@ -76,9 +73,10 @@ func adsHandler(c *gin.Context) {
|
76
|
73
|
|
77
|
74
|
ipInfo, err := ip2region.Ip2Region(ip)
|
78
|
75
|
if err != nil {
|
79
|
|
- c.String(404, "ip 2 region failed")
|
|
76
|
+ c.String(404, "ip 2 region failed: %s", err)
|
80
|
77
|
return
|
81
|
78
|
}
|
|
79
|
+ fmt.Printf("ip 2 region: %s, %+v\n", ip, ipInfo)
|
82
|
80
|
|
83
|
81
|
// 上報
|
84
|
82
|
if request.NewAdsFlag == 1 {
|
|
@@ -115,7 +113,7 @@ func adsHandler(c *gin.Context) {
|
115
|
113
|
|
116
|
114
|
cityCode, err := city.GetCityCode(ipInfo.City)
|
117
|
115
|
if err != nil {
|
118
|
|
- c.String(404, "get city code failed")
|
|
116
|
+ c.String(404, "get city code failed: %s", err)
|
119
|
117
|
return
|
120
|
118
|
}
|
121
|
119
|
|
|
@@ -422,7 +420,7 @@ func adsHandler(c *gin.Context) {
|
422
|
420
|
if len(adData.TargetAddition) == 2 && serverActionResponse["server_video_finish"] == 1 && (dspInfo.ReqSource == "kuxin" || dspInfo.ReqSource == "zhiku") {
|
423
|
421
|
adData, err = addata.CombineOrderBy(adData, advertiser, &dspInfo)
|
424
|
422
|
if err != nil {
|
425
|
|
- c.String(404, err.Error())
|
|
423
|
+ c.String(404, "combine order failed: %s", err.Error())
|
426
|
424
|
return
|
427
|
425
|
}
|
428
|
426
|
}
|
|
@@ -441,7 +439,7 @@ func adsHandler(c *gin.Context) {
|
441
|
439
|
} else {
|
442
|
440
|
jsonBytes, err := json.Marshal(*adData)
|
443
|
441
|
if err != nil {
|
444
|
|
- c.String(404, err.Error())
|
|
442
|
+ c.String(404, "marshal AdData failed: %s", err.Error())
|
445
|
443
|
return
|
446
|
444
|
}
|
447
|
445
|
encryptData, _ := encrypt.Encrypt(jsonBytes, []byte(adslib.GetConf().SecretKey))
|
|
@@ -458,14 +456,9 @@ func adsHandler(c *gin.Context) {
|
458
|
456
|
// 增加打底广告
|
459
|
457
|
if (dspInfo.ReqSource == "kuxin" || dspInfo.ReqSource == "zhiku") && !needControl && !isBlackImei {
|
460
|
458
|
shortMessage := "kong"
|
461
|
|
- if err != nil {
|
462
|
|
- c.String(404, err.Error())
|
463
|
|
- return
|
464
|
|
- }
|
465
|
|
-
|
466
|
459
|
customAdData, err := addata.GetCustomAdsInfos(&dspInfo, advertiser, 0, 0, xiaomiResponseFlag)
|
467
|
460
|
if err != nil {
|
468
|
|
- c.String(404, err.Error())
|
|
461
|
+ c.String(404, "get custom ads info failed: %s", err.Error())
|
469
|
462
|
return
|
470
|
463
|
}
|
471
|
464
|
|
|
@@ -473,7 +466,7 @@ func adsHandler(c *gin.Context) {
|
473
|
466
|
if customAdData == nil {
|
474
|
467
|
customAdData, err = addata.GetCustomAdsInfos(&dspInfo, advertiser, 0, 1, xiaomiResponseFlag)
|
475
|
468
|
if err != nil {
|
476
|
|
- c.String(404, err.Error())
|
|
469
|
+ c.String(404, "get fix custom ads info failed: %s", err.Error())
|
477
|
470
|
return
|
478
|
471
|
}
|
479
|
472
|
}
|
|
@@ -559,7 +552,7 @@ func adsHandler(c *gin.Context) {
|
559
|
552
|
|
560
|
553
|
jsonBytes, err := json.Marshal(customAdData)
|
561
|
554
|
if err != nil {
|
562
|
|
- c.String(404, err.Error())
|
|
555
|
+ c.String(404, "marsha custom addata failed: %s", err.Error())
|
563
|
556
|
return
|
564
|
557
|
}
|
565
|
558
|
encryptData, _ := encrypt.Encrypt(jsonBytes, []byte(adslib.GetConf().SecretKey))
|
|
@@ -567,7 +560,7 @@ func adsHandler(c *gin.Context) {
|
567
|
560
|
graylog.ReportGrayLog(request, dspInfo, 0, 0)
|
568
|
561
|
rspBytes, err := json.Marshal(response)
|
569
|
562
|
if err != nil {
|
570
|
|
- c.String(404, err.Error())
|
|
563
|
+ c.String(404, "marshal Response failed: %s", err.Error())
|
571
|
564
|
return
|
572
|
565
|
}
|
573
|
566
|
c.String(200, string(rspBytes))
|