|
@@ -312,12 +312,12 @@ func GetFinishedDispatchCount(orderId int64, dispatchType string, curTime time.T
|
312
|
312
|
|
313
|
313
|
// 增加已经投放的量
|
314
|
314
|
// dispatchType: "click", "show"
|
315
|
|
-func IncrFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
|
|
315
|
+func IncrFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, error) {
|
316
|
316
|
conn := ads_redis.RedisConn.Get()
|
317
|
317
|
defer conn.Close()
|
318
|
318
|
|
319
|
319
|
key := fmt.Sprintf("order_kpi_%d_%d%d%d_%s_kpi", orderId, curTime.Year(), curTime.Month(), curTime.Day(), dispatchType)
|
320
|
|
- rsp, err := conn.Do("INCR", key, incrCnt)
|
|
320
|
+ rsp, err := conn.Do("INCR", key)
|
321
|
321
|
if err != nil {
|
322
|
322
|
return 0, err
|
323
|
323
|
}
|
|
@@ -328,35 +328,34 @@ func IncrFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int,
|
328
|
328
|
|
329
|
329
|
// 获取当前分钟已经投放的量
|
330
|
330
|
// dispatchType: "click", "show"
|
331
|
|
-func GetPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, error) {
|
|
331
|
+func GetPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, string, error) {
|
332
|
332
|
conn := ads_redis.RedisConn.Get()
|
333
|
333
|
defer conn.Close()
|
334
|
334
|
|
335
|
335
|
curMinutes := curTime.Hour()*60 + curTime.Minute()
|
336
|
336
|
key := fmt.Sprintf("order_kpi_%d_%d%d%d_%d_%s_kpi", orderId, curTime.Year(), curTime.Month(), curTime.Day(), curMinutes, dispatchType)
|
337
|
337
|
rsp, err := conn.Do("GET", key)
|
338
|
|
- log.Infof("%s %s", key, rsp)
|
339
|
338
|
if err != nil {
|
340
|
|
- return 0, err
|
|
339
|
+ return 0, key, err
|
341
|
340
|
}
|
342
|
341
|
|
343
|
342
|
if rsp == nil {
|
344
|
|
- return 0, nil
|
|
343
|
+ return 0, key, nil
|
345
|
344
|
}
|
346
|
345
|
|
347
|
346
|
count, _ := redis.Int(rsp, err)
|
348
|
|
- return count, nil
|
|
347
|
+ return count, key, nil
|
349
|
348
|
}
|
350
|
349
|
|
351
|
350
|
// 增加当前分钟已经投放的量
|
352
|
351
|
// dispatchType: "click", "show"
|
353
|
|
-func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, incrCnt int, curTime time.Time) (int, error) {
|
|
352
|
+func IncrPreMinuteFinishedDispatchCount(orderId int64, dispatchType string, curTime time.Time) (int, error) {
|
354
|
353
|
conn := ads_redis.RedisConn.Get()
|
355
|
354
|
defer conn.Close()
|
356
|
355
|
|
357
|
356
|
curMinutes := curTime.Hour()*60 + curTime.Minute()
|
358
|
357
|
key := fmt.Sprintf("order_kpi_%d_%d%d%d_%d_%s_kpi", orderId, curTime.Year(), curTime.Month(), curTime.Day(), curMinutes, dispatchType)
|
359
|
|
- rsp, err := conn.Do("INCR", key, incrCnt)
|
|
358
|
+ rsp, err := conn.Do("INCR", key)
|
360
|
359
|
if err != nil {
|
361
|
360
|
return 0, err
|
362
|
361
|
}
|
|
@@ -386,7 +385,7 @@ func SetOrderPlanDispatchCount(orderId int64, dispatchType string, cnt int, curT
|
386
|
385
|
}
|
387
|
386
|
|
388
|
387
|
// 获取总量每分钟要投放的量
|
389
|
|
-func GetPerMinuteNeedDispatchCnt(curTime time.Time) (int, error) {
|
|
388
|
+func GetPerMinuteNeedDispatchCnt(curTime time.Time) (int, string, error) {
|
390
|
389
|
conn := ads_redis.RedisConn.Get()
|
391
|
390
|
defer conn.Close()
|
392
|
391
|
|
|
@@ -395,19 +394,19 @@ func GetPerMinuteNeedDispatchCnt(curTime time.Time) (int, error) {
|
395
|
394
|
rsp, err := conn.Do("GET", key)
|
396
|
395
|
|
397
|
396
|
if err != nil {
|
398
|
|
- return 0, err
|
|
397
|
+ return 0, key, err
|
399
|
398
|
}
|
400
|
399
|
|
401
|
400
|
if rsp == nil {
|
402
|
|
- return 0, nil
|
|
401
|
+ return 0, key, nil
|
403
|
402
|
}
|
404
|
403
|
|
405
|
404
|
count, _ := redis.Int(rsp, err)
|
406
|
|
- return count, nil
|
|
405
|
+ return count, key, nil
|
407
|
406
|
}
|
408
|
407
|
|
409
|
408
|
// 获取订单每分钟要投放的量
|
410
|
|
-func GetOrderPerMinuteNeedDispatchCnt(orderId int64, curTime time.Time) (int, error) {
|
|
409
|
+func GetOrderPerMinuteNeedDispatchCnt(orderId int64, curTime time.Time) (int, string, error) {
|
411
|
410
|
conn := ads_redis.RedisConn.Get()
|
412
|
411
|
defer conn.Close()
|
413
|
412
|
|
|
@@ -416,15 +415,15 @@ func GetOrderPerMinuteNeedDispatchCnt(orderId int64, curTime time.Time) (int, er
|
416
|
415
|
rsp, err := conn.Do("GET", key)
|
417
|
416
|
|
418
|
417
|
if err != nil {
|
419
|
|
- return 0, err
|
|
418
|
+ return 0, key, err
|
420
|
419
|
}
|
421
|
420
|
|
422
|
421
|
if rsp == nil {
|
423
|
|
- return 0, nil
|
|
422
|
+ return 0, key, nil
|
424
|
423
|
}
|
425
|
424
|
|
426
|
425
|
count, _ := redis.Int(rsp, err)
|
427
|
|
- return count, nil
|
|
426
|
+ return count, key, nil
|
428
|
427
|
}
|
429
|
428
|
|
430
|
429
|
// 获取ios的ua和imei
|
|
@@ -464,8 +463,11 @@ func GetIosUaImei(ip string) (string, string, error) {
|
464
|
463
|
Imei string
|
465
|
464
|
Ua string
|
466
|
465
|
}
|
|
466
|
+
|
467
|
467
|
rspBytes, _ := redis.Bytes(rsp, err)
|
468
|
|
- err = json.Unmarshal(rspBytes, &uaImeiInfo)
|
|
468
|
+ rspStr := strings.ReplaceAll(string(rspBytes), "'", "\"")
|
|
469
|
+
|
|
470
|
+ err = json.Unmarshal([]byte(rspStr), &uaImeiInfo)
|
469
|
471
|
if err != nil {
|
470
|
472
|
return "", "", err
|
471
|
473
|
}
|