jiantaoli 4 年 前
コミット
4422559068
共有1 個のファイルを変更した45 個の追加43 個の削除を含む
  1. 45 43
      adslib/addata/custom.go

+ 45 - 43
adslib/addata/custom.go

@@ -13,7 +13,7 @@ import (
13 13
 type CustomAdData struct {
14 14
 	Duration       int64         `json:"duration"`
15 15
 	ImageURL       string        `json:"image_url"`
16
-	JsOrderID      string        `json:"js_order_id"`
16
+	JsOrderID      int64        `json:"js_order_id"`
17 17
 	Msg            int64         `json:"msg"`
18 18
 	OrderName      string        `json:"order_name"`
19 19
 	Result         int64         `json:"result"`
@@ -217,67 +217,69 @@ func GetAdsInfos(dsp *utils.DspParam, advertiser string, orderType int, fixFlag
217 217
 
218 218
 	if curMinutefinishedDispatchCnt < curMinuteNeedDispatchCnt {
219 219
 
220
-		data =
221
-		{
222
-			"js_order_id":js_order_id,
223
-			"target":"",
224
-			"video_url":"",
225
-			"duration":5,
226
-			"target_addition":[],
227
-			"image_url":"",
228
-			"result":0,
229
-			"msg":0,
230
-			"user_agent":ua,
231
-			"order_name":order_name
220
+		data := CustomAdData{
221
+			Duration:       5,
222
+			JsOrderID:      order.JsOrderID,
223
+			OrderName:      order.Title,
224
+			UserAgent:      dsp.UaOrigin,
232 225
 		}
233 226
 
234 227
 		//放量
235
-		newFinishCnt, err := redis_data.IncrFinishedDispatchCount(order.OrderID, "show", 1, curTime)
228
+		_, err := redis_data.IncrFinishedDispatchCount(order.OrderID, "show", 1, curTime)
236 229
 		if err != nil {
237 230
 			return err
238 231
 		}
239
-		newCurMinutefinishedCnt, err := redis_data.IncrPreMinuteFinishedDispatchCount(order.OrderID, "show", 1, curTime)
232
+		_, err := redis_data.IncrPreMinuteFinishedDispatchCount(order.OrderID, "show", 1, curTime)
240 233
 		if err != nil {
241 234
 			return err
242 235
 		}
243 236
 
244
-		show_url = ads_item['show_url']
245
-		click_url = ads_item['click_url']
246
-
247
-		target = ads_item['target_url']
237
+		showUrl := order.ShowURL
238
+		clickUrl := order.ClickURL
239
+		targetUrl := order.TargetURL
248 240
 
249 241
 		if strings.Index(order.Title, "_ios") != -1 {
250 242
 			iosImei, iosUa, err := redis_data.GetIosUaImei(dsp.Ip)
251 243
 			if err != nil {
252 244
 				return err
253 245
 			}
254
-			if iosUa {
255
-
246
+			if iosUa != "" {
247
+				data.UserAgent = iosUa
248
+			}
249
+			if order.ImeiReplaceFlag == 1 && iosImei != "" {
250
+				showUrl = strings.ReplaceAll(showUrl, "__IDFA__", iosImei)
251
+				clickUrl = strings.ReplaceAll(clickUrl, "__IDFA__", iosImei)
252
+				targetUrl = strings.ReplaceAll(targetUrl, "__IDFA__", iosImei)
256 253
 			}
257
-		data['user_agent'] = ios_ua
258
-		if ads_item.get('imei_replace_flag', 0) == 1 and
259
-	ios_imei:
260
-		show_url = show_url.replace('__IDFA__', ios_imei)
261
-		click_url = click_url.replace('__IDFA__', ios_imei)
262
-		target = target.replace('__IDFA__', ios_imei)
263
-		if order_name.find("__OS__") > 0:
264
-		show_url = show_url.replace('__OS__', '1')
265
-		click_url = click_url.replace('__OS__', '1')
266
-		target = target.replace('__OS__', '1')
267
-		}
268 254
 
269
-		elif
270
-		order_name.find("_android") > 0 :
271
-		### 判断是否需要替换imei
272
-		if ads_item.get('imei_replace_flag', 0) == 1:
273
-		show_url = show_url.replace('__IMEI__', dsp.real_md5_imei)
274
-		click_url = click_url.replace('__IMEI__', dsp.real_md5_imei)
275
-		target = target.replace('__IMEI__', dsp.real_md5_imei)
255
+			if strings.Index(order.Title, "__OS__") != -1 {
256
+				showUrl = strings.ReplaceAll(showUrl, "__OS__", "1")
257
+				clickUrl = strings.ReplaceAll(clickUrl, "__OS__", "1")
258
+				targetUrl = strings.ReplaceAll(targetUrl, "__OS__", "1")
259
+			}
260
+		} else if strings.Index(order.Title, "_android") != -1 {
261
+			// 判断是否需要替换imei
262
+			if order.ImeiReplaceFlag == 1 {
263
+				showUrl = strings.ReplaceAll(showUrl, "__IMEI__", dsp.RealMd5Imei)
264
+				clickUrl = strings.ReplaceAll(clickUrl, "__IMEI__", dsp.RealMd5Imei)
265
+				targetUrl = strings.ReplaceAll(targetUrl, "__IMEI__", dsp.RealMd5Imei)
266
+			}
276 267
 
277
-		if order_name.find("__OS__") > 0:
278
-		show_url = show_url.replace('__OS__', '0')
279
-		click_url = click_url.replace('__OS__', '0')
280
-		target = target.replace('__OS__', '0')
268
+			if strings.Index(order.Title, "__OS__") != -1 {
269
+				showUrl = strings.ReplaceAll(showUrl, "__OS__", "0")
270
+				clickUrl = strings.ReplaceAll(clickUrl, "__OS__", "0")
271
+				targetUrl = strings.ReplaceAll(targetUrl, "__OS__", "0")
272
+			}
273
+			if ads_item.get('imei_replace_flag', 0) == 1:
274
+			show_url = show_url.replace('__IMEI__', dsp.real_md5_imei)
275
+			click_url = click_url.replace('__IMEI__', dsp.real_md5_imei)
276
+			target = target.replace('__IMEI__', dsp.real_md5_imei)
277
+
278
+			if order_name.find("__OS__") > 0:
279
+			show_url = show_url.replace('__OS__', '0')
280
+			click_url = click_url.replace('__OS__', '0')
281
+			target = target.replace('__OS__', '0')
282
+		}
281 283
 
282 284
 		else:
283 285
 		if r < 40: