|
@@ -253,7 +253,7 @@ func SetReqSourceView(adv string, reqSource string, source string) {
|
253
|
253
|
}
|
254
|
254
|
|
255
|
255
|
// 获取剩余总投放量
|
256
|
|
-func GetRemainDispatchCount(key string) (int, error) {
|
|
256
|
+func GetRemainDispatchCount(key string) (int, error) {
|
257
|
257
|
conn := ads_redis.RedisConn.Get()
|
258
|
258
|
defer conn.Close()
|
259
|
259
|
|
|
@@ -270,10 +270,9 @@ func GetRemainDispatchCount(key string) (int, error) {
|
270
|
270
|
return count, nil
|
271
|
271
|
}
|
272
|
272
|
|
273
|
|
-
|
274
|
273
|
// 获取已经投放的量
|
275
|
274
|
// dispatchType: "click", "show"
|
276
|
|
-func GetFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, error) {
|
|
275
|
+func GetFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, error) {
|
277
|
276
|
conn := ads_redis.RedisConn.Get()
|
278
|
277
|
defer conn.Close()
|
279
|
278
|
|
|
@@ -293,7 +292,7 @@ func GetFinishedDispatchCount(orderId int64, dispatchType string, curTime time.T
|
293
|
292
|
|
294
|
293
|
// 增加已经投放的量
|
295
|
294
|
// dispatchType: "click", "show"
|
296
|
|
-func IncrFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
|
|
295
|
+func IncrFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
|
297
|
296
|
conn := ads_redis.RedisConn.Get()
|
298
|
297
|
defer conn.Close()
|
299
|
298
|
|
|
@@ -309,11 +308,11 @@ func IncrFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int,
|
309
|
308
|
|
310
|
309
|
// 获取当前分钟已经投放的量
|
311
|
310
|
// dispatchType: "click", "show"
|
312
|
|
-func GetPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, error) {
|
|
311
|
+func GetPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, error) {
|
313
|
312
|
conn := ads_redis.RedisConn.Get()
|
314
|
313
|
defer conn.Close()
|
315
|
314
|
|
316
|
|
- curMinutes := curTime.Hour() * 60 + curTime.Minute()
|
|
315
|
+ curMinutes := curTime.Hour()*60 + curTime.Minute()
|
317
|
316
|
key := fmt.Sprintf("order_kpi_%d_%d%d%d_%d_%s_kpi", orderId, curTime.Year(), curTime.Month(), curTime.Day(), curMinutes, dispatchType)
|
318
|
317
|
rsp, err := conn.Do("GET", key)
|
319
|
318
|
if err != nil {
|
|
@@ -330,11 +329,11 @@ func GetPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTi
|
330
|
329
|
|
331
|
330
|
// 增加当前分钟已经投放的量
|
332
|
331
|
// dispatchType: "click", "show"
|
333
|
|
-func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
|
|
332
|
+func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
|
334
|
333
|
conn := ads_redis.RedisConn.Get()
|
335
|
334
|
defer conn.Close()
|
336
|
335
|
|
337
|
|
- curMinutes := curTime.Hour() * 60 + curTime.Minute()
|
|
336
|
+ curMinutes := curTime.Hour()*60 + curTime.Minute()
|
338
|
337
|
key := fmt.Sprintf("order_kpi_%d_%d%d%d_%d_%s_kpi", orderId, curTime.Year(), curTime.Month(), curTime.Day(), curMinutes, dispatchType)
|
339
|
338
|
rsp, err := conn.Do("INCR", key, incrCnt)
|
340
|
339
|
if err != nil {
|
|
@@ -360,13 +359,13 @@ func SetOrderPlanDispatchCount(orderId int64, dispatchType string, cnt int, curT
|
360
|
359
|
conn := ads_redis.RedisConn.Get()
|
361
|
360
|
defer conn.Close()
|
362
|
361
|
|
363
|
|
- curMinutes := curTime.Hour() * 60 + curTime.Minute()
|
|
362
|
+ curMinutes := curTime.Hour()*60 + curTime.Minute()
|
364
|
363
|
key := fmt.Sprintf("plan_kpi_%d_%d%d%d_%d_%s_kpi", orderId, curTime.Year(), curTime.Month(), curTime.Day(), curMinutes, dispatchType)
|
365
|
364
|
conn.Do("SET", key, cnt, 3600*24)
|
366
|
365
|
}
|
367
|
366
|
|
368
|
367
|
// 获取每分钟要投放的量
|
369
|
|
-func GetPerMinuteNeedDispatchCnt(orderId int64, curTime time.Time) (int, error){
|
|
368
|
+func GetPerMinuteNeedDispatchCnt(orderId int64, curTime time.Time) (int, error) {
|
370
|
369
|
conn := ads_redis.RedisConn.Get()
|
371
|
370
|
defer conn.Close()
|
372
|
371
|
|
|
@@ -387,21 +386,21 @@ func GetPerMinuteNeedDispatchCnt(orderId int64, curTime time.Time) (int, error){
|
387
|
386
|
}
|
388
|
387
|
|
389
|
388
|
// 获取ios的ua和imei
|
390
|
|
-func GetIosUaImei(ip string) (string, string, error){
|
|
389
|
+func GetIosUaImei(ip string) (string, string, error) {
|
391
|
390
|
conn := ads_redis.RedisConn.Get()
|
392
|
391
|
defer conn.Close()
|
393
|
392
|
|
394
|
393
|
dateInt, _ := strconv.Atoi(time.Now().Format("20060102"))
|
395
|
|
- redisKey := fmt.Sprintf("ads_ios_%d_%s", dateInt, ip)
|
|
394
|
+ iosUaImeiRedisKey := fmt.Sprintf("ads_ios_%d_%s", dateInt, ip)
|
396
|
395
|
|
397
|
396
|
// "{'imei': 'F389E3E1-5459-4B30-83A9-1AD504F6293F', 'ua': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML like Gecko) Mobile/15E148'}"
|
398
|
|
- rsp, err := conn.Do("GET", redisKey)
|
|
397
|
+ rsp, err := conn.Do("GET", iosUaImeiRedisKey)
|
399
|
398
|
if err != nil {
|
400
|
399
|
return "", "", err
|
401
|
400
|
}
|
402
|
401
|
|
403
|
402
|
if rsp == nil {
|
404
|
|
- redisKey = fmt.Sprintf("new_ios_ua_v2_%d", dateInt)
|
|
403
|
+ redisKey := fmt.Sprintf("new_ios_ua_v2_%d", dateInt)
|
405
|
404
|
rsp, err = conn.Do("SRANDMEMBER", redisKey)
|
406
|
405
|
if err != nil {
|
407
|
406
|
return "", "", err
|
|
@@ -412,17 +411,22 @@ func GetIosUaImei(ip string) (string, string, error){
|
412
|
411
|
|
413
|
412
|
conn.Do("SREM", redisKey, rsp)
|
414
|
413
|
|
415
|
|
- tomorrowDateInt := time.Unix(time.Now().Unix()+86400, 0).Format("20060102")
|
416
|
|
- set_new_ios_ua(redis_value,tomorrow_day_id)
|
417
|
|
- return eval(redis_value)
|
|
414
|
+ tomorrowDateInt, _ := strconv.Atoi(time.Unix(time.Now().Unix()+86400, 0).Format("20060102"))
|
|
415
|
+ redisKey = fmt.Sprintf("new_ios_ua_v2_%d", tomorrowDateInt)
|
|
416
|
+ conn.Do("SADD", redisKey, rsp)
|
|
417
|
+ }
|
|
418
|
+
|
|
419
|
+ if rsp == nil {
|
|
420
|
+ return "", "", nil
|
418
|
421
|
}
|
419
|
422
|
|
420
|
|
- redis_ua_value = redis_ua.get_ip_ios_ua(ip)
|
421
|
|
- if not redis_ua_value:
|
422
|
|
- redis_ua_value = redis_ua.get_new_ios_ua()
|
423
|
|
- if redis_ua_value:
|
424
|
|
- redis_ua.set_ip_ios_ua(ip,redis_ua_value)
|
425
|
|
- imei = redis_ua_value.get('imei','')
|
426
|
|
- ua = redis_ua_value.get('ua','')
|
427
|
|
- return imei,ua
|
|
423
|
+ conn.Do("SET", iosUaImeiRedisKey, rsp, 86520)
|
|
424
|
+
|
|
425
|
+ var uaImeiInfo struct {
|
|
426
|
+ Imei string
|
|
427
|
+ Ua string
|
|
428
|
+ }
|
|
429
|
+ rspBytes, _ := redis.Bytes(rsp, err)
|
|
430
|
+ json.Unmarshal(rspBytes, &uaImeiInfo)
|
|
431
|
+ return uaImeiInfo.Imei, uaImeiInfo.Ua, nil
|
428
|
432
|
}
|