Exemplo n.º 1
0
 def priceImitation(self, msg):
     price = int(self.target_price) * random.uniform(0.9,1.1)
     imp_num = random.randint(2000,2500)
     cpm_price = int( float(price)/imp_num*1000 )
     remsg = promsg(self.uc, msg, cpm_price)
     #'''
     self.broker.database.incEidHourSp(str(msg['eid']), cpm_price * imp_num)
     self.broker.database.incEidHourPv(str(msg['eid']), imp_num)
     self.broker.database.incAdvBidSpend(str(msg['uid']), price)
     self.broker.database.decAdvBidSpend(str(msg['uid']), "-%.3f" % (float(price),))
     #'''
     self.sendImitationMsg(remsg,imp_num)
     loginfo("ImitationCPA:%s    price:%d  cpm_price:%d  imp_num:%d" % (remsg, price, cpm_price, imp_num))
Exemplo n.º 2
0
 def dealUserArriInfo(self):
     try:
         if self.bid_mode == "10000":
             return True
         if not self.uc:
             return True
         if self.broker.database.getUserArriInfo( USER_ARRI_RECORD % (self.uc, self.rid)):
             loginfo("User Have Arrive Info: %s" % ( USER_ARRI_RECORD % (self.uc, self.rid), ) )
             return False
         else:
             self.broker.database.setUserArriInfo( USER_ARRI_RECORD % (self.uc, self.rid), int(self.time))
             loginfo("Set User Arrive Info: %s" % ( USER_ARRI_RECORD % (self.uc, self.rid), ) )
             return True
     except Exception, e:
         logerr("dealUserArriInfo:%s" % e)
         return False
Exemplo n.º 3
0
 def getUserClickRecord(self):
     try:
         if self.gtmac and self.uc:
             dbg("user:%s adverid:%s" % (self.uc, self.gtmac))
             user_msg = self.broker.database.getUserClickInfo( USER_CLICK_RECORD % (self.uc, self.gtmac))
             if user_msg:
                 user_msg = sorted(user_msg.iteritems(), key = lambda pd:pd[0], reverse = True)
                 loginfo("user click record:%s" % user_msg)
                 if len(user_msg) > 0:
                     tm = user_msg[0][0]
                     val = user_msg[0][1]
                     val = json.loads(val)
                     dbg("Chose Click Time:%s" % (tm,))
                     self.ct = int(tm)*1000
                     if val.has_key('adver_id'):
                         pass
                     if val.has_key('adx_id'):
                         self.xid = val['adx_id']
                     if val.has_key('execute_id'):
                         self.eid = val['execute_id']
                     if val.has_key('creative_id'):
                         self.cid = val['creative_id']
                     if val.has_key('region'):
                         self.aid = val['region']
                     if val.has_key('pid'):
                         self.pid = val['pid']
                     if val.has_key('req_id'):
                         self.rid = val['req_id']
                     if val.has_key('bid_mode'):
                         self.bid_mode = val['bid_mode']
                     if val.has_key('target_price'):
                         self.target_price = val['target_price']
                             
                     return True
         return False
     except Exception, e:
         logerr(e)
         return False
Exemplo n.º 4
0
 def recordReg(self):
     try:
         loginfo("AdverReg Info advid %d od %s uc %s Referer %s" % (int(self.gtmac), self.od, self.uc, self.referer))
     except Exception:
         pass
Exemplo n.º 5
0
 def recordMoney(self):
     try:
         loginfo("AdverTransaction Info advid %d money %s uc %s" % (int(self.gtmac), self.mn, self.uc))
     except Exception:
         pass