Esempio n. 1
0
File: zj.go Progetto: qgweb/new
// 保存投放轨迹到投放系统
func (this *ZjPut) saveTraceToPutSys() {
	rdb, err := lib.GetRedisObj()
	if err != nil {
		log.Error("redis连接失败", err)
		return
	}
	rdb.SelectDb("1")
	adcount := 0
	this.kf.AdUaIdsSet(func(ad string, ua string, aids map[string]int8) {
		key := ad
		if ua != "ua" {
			key = encrypt.DefaultMd5.Encode(ad + "_" + ua)
		}
		for aid, _ := range aids {
			rdb.HSet(key, "advert:"+aid, aid)
		}
		rdb.Expire(key, 5400)
		adcount++
	})
	rdb.Flush()
	rdb.Close()
	// 广告数量统计数据 put_stats , Zj_1461016800, 11111
	lib.StatisticsData("put_stats", fmt.Sprintf("zj_%s", this.Timestamp),
		convert.ToString(adcount), "incr")
}
Esempio n. 2
0
File: zj.go Progetto: qgweb/new
// 初始化投放标签
func (this *ZjPut) initPutTags(tagkey string, prefix1 string, prefix2 string) {
	rdb, err := lib.GetRedisObj()
	if err != nil {
		log.Fatal(err)
	}
	rdb.SelectDb("0")
	for _, key := range rdb.Keys(tagkey) {
		rkey := strings.TrimPrefix(key, strings.TrimSuffix(tagkey, "*")+"_")
		if lib.IsMongo(rkey) {
			rkey = prefix2 + rkey
		} else {
			rkey = prefix1 + rkey
		}
		if _, ok := this.putTags[rkey]; !ok {
			this.putTags[rkey] = make(map[string]int)
		}
		for _, aid := range rdb.SMembers(key) {
			if _, ok := this.putAdverts[aid]; ok {
				this.putTags[rkey][aid] = 1
			}
		}
	}
	//特殊标签
	this.putTags["url_FFF"] = map[string]int{"99999": 1}
}
Esempio n. 3
0
File: js.go Progetto: qgweb/new
// 初始化需要投放的广告
func (this *JsPut) initPutAdverts() {
	rdb, err := lib.GetRedisObj()
	if err != nil {
		log.Fatal(err)
	}
	rdb.SelectDb("0")
	this.putAdverts = make(map[string]int)
	alist := rdb.SMembers(lib.GetConfVal("jiangsu::province_prefix"))
	for _, v := range alist {
		this.putAdverts[v] = 1
	}
	rdb.Close()
}
Esempio n. 4
0
File: sh.go Progetto: qgweb/new
// 初始化需要投放的广告
func (this *ShPut) initPutAdverts() {
	rdb, err := lib.GetRedisObj()
	if err != nil {
		log.Fatal(err)
	}
	rdb.SelectDb("0")
	this.putAdverts = make(map[string]int)
	alist := rdb.SMembers(lib.GetConfVal("shanghai::province_prefix"))
	log.Info(alist)
	for _, v := range alist {
		if this.filterPriceAdvert(v) {
			this.putAdverts[v] = 1
		}
	}
	rdb.Close()
}
Esempio n. 5
0
File: ck.go Progetto: qgweb/new
// 初始化需要投放的广告
func (this *CookiePut) initPutAdverts() {
	rdb, err := lib.GetRedisObj()
	if err != nil {
		log.Fatal(err)
	}
	rdb.SelectDb("0")
	this.putAdverts = make(map[string]int)
	for _, v := range strings.Split(lib.GetConfVal("cookie::province_prefix"), ",") {
		alist := rdb.SMembers(v)
		for _, v := range alist {
			this.putAdverts[v] = 1
		}
	}

	rdb.Close()
}
Esempio n. 6
0
File: sh.go Progetto: qgweb/new
// 判断是否满足出价的广告
func (this *ShPut) filterPriceAdvert(aid string) bool {
	rdb, err := lib.GetRedisObj()
	if err != nil {
		log.Error(err)
		return false
	}
	defer rdb.Close()
	rdb.SelectDb("0")
	js, err := simplejson.NewJson([]byte(rdb.Get("advert_info:" + aid)))
	if err != nil {
		return false
	}
	log.Info(js.Get("price").String())
	if v, ok := js.Get("price").String(); ok == nil && (convert.ToFloat64(v) >= 0.8) {
		log.Info(1)
		return true
	}
	return false
}
Esempio n. 7
0
File: zj.go Progetto: qgweb/new
// 获取投放店铺信息
func (this *ZjPut) GetPutShopInfo() (list map[string]ShopInfo) {
	rdb, err := lib.GetRedisObj()
	if err != nil {
		log.Error(err)
		return nil
	}
	defer rdb.Close()

	shopkeys := rdb.Keys("SHOP_*")
	list = make(map[string]ShopInfo)
	for _, key := range shopkeys {
		var sinfo ShopInfo
		shopkeys := strings.Split(key, "_")
		sk := ""
		if len(shopkeys) < 3 {
			continue
		}
		sk = shopkeys[2]
		sinfo.ShopId = sk
		oaids := rdb.SMembers(key)
		aids := make([]string, 0, len(oaids))
		for _, v := range oaids {
			if _, ok := this.putAdverts[v]; ok {
				aids = append(aids, v)
			}
		}
		sinfo.ShopAdverts = make([]ShopAdvert, 0, len(aids))
		for _, aid := range aids {
			aaids := strings.Split(aid, "_")
			if len(aaids) == 2 {
				sinfo.ShopAdverts = append(sinfo.ShopAdverts, ShopAdvert{
					AdvertId: aaids[0],
					Date:     convert.ToInt(aaids[1]),
				})
			}
		}
		list[sk] = sinfo
	}
	return

}