示例#1
0
    def ProcessPlayerAuctions(self, pArgumentDic):
        tPaOrder = PaOrder()

        if ('mc_gross' in pArgumentDic.keys()):
            tPaOrder.paAmount = pArgumentDic['mc_gross']

        if ('payer_id' in pArgumentDic.keys()):
            tPaOrder.paTransactionId = pArgumentDic['payer_id']

        tPaOrder.put()
示例#2
0
    def ProcessPlayerAuctions(self, pArgumentDic):
        tPaOrder = PaOrder()

        if "mc_gross" in pArgumentDic.keys():
            tPaOrder.paAmount = pArgumentDic["mc_gross"]

        if "payer_id" in pArgumentDic.keys():
            tPaOrder.paTransactionId = pArgumentDic["payer_id"]

        tPaOrder.put()
示例#3
0
    def receive(self, mail_message):
        #logging.debug("Received a message from: " + PaOrderHandler.unwraptext(mail_message.sender))
        #logging.debug("Subject: " + PaOrderHandler.unwraptext(mail_message.subject))

        for bodies in mail_message.bodies('text/plain'):
            emailtext = ""
            for body in bodies:
                try:
                    encodedtext = body[1]
                    emailtext = PaOrderHandler.unwraptext(encodedtext)
                except:
                    emailtext = body.payload.decode(body.encoding)

                if (isinstance(emailtext, unicode)):
                    emailtext = emailtext.encode('utf-8')

            #logging.debug("Body PlainText: " + emailtext)

        OrderAmountText = self.reOrder.search(
            emailtext).groupdict()['order'].strip()
        OrderAmountInt = NumberToGp.ConvertBetToInt(OrderAmountText)
        OrderId = self.reOrderId.search(
            emailtext).groupdict()['orderid'].strip()

        tMatchingOrderQuery = PaOrder.all()
        tMatchingOrderQuery.filter("paTransactionId", OrderId)

        tMatches = tMatchingOrderQuery.fetch(10)

        if (len(tMatches) > 0):
            return

        tPaOrder = PaOrder()
        tPaOrder.paAmount = OrderAmountText
        tPaOrder.paAmountInt = OrderAmountInt
        tPaOrder.paTransactionId = OrderId

        tAssignedAgentClass = DeliveryAssignment()
        tAssignedAgent = tAssignedAgentClass.GetAssignedAgent()

        if (tAssignedAgent != 'No Agent Online'):
            tPaOrder.paAssignedAgent = tAssignedAgent.agentId
            tPaOrder.paAssignedAgentNick = tAssignedAgent.agentNickName
        else:
            tPaOrder.paAssignedAgent = "No Agent Online"
            tPaOrder.paAssignedAgentNick = "No Agent Online"

        tPaOrder.put()
    def receive(self, mail_message):
        #logging.debug("Received a message from: " + PaOrderHandler.unwraptext(mail_message.sender))
        #logging.debug("Subject: " + PaOrderHandler.unwraptext(mail_message.subject))

        for bodies in mail_message.bodies('text/plain'):
            emailtext = ""
            for body in bodies:
                try:
                    encodedtext = body[1]
                    emailtext = PaOrderHandler.unwraptext(encodedtext)
                except:
                    emailtext = body.payload.decode(body.encoding)
                    
                if(isinstance(emailtext, unicode)):
                    emailtext = emailtext.encode('utf-8')
                
            #logging.debug("Body PlainText: " + emailtext)
            
        OrderAmountText = self.reOrder.search(emailtext).groupdict()['order'].strip()
        OrderAmountInt = NumberToGp.ConvertBetToInt(OrderAmountText)
        OrderId = self.reOrderId.search(emailtext).groupdict()['orderid'].strip()
        
        tMatchingOrderQuery = PaOrder.all()
        tMatchingOrderQuery.filter("paTransactionId", OrderId)
        
        tMatches = tMatchingOrderQuery.fetch(10)
        
        if(len(tMatches) > 0):
            return
        
        tPaOrder = PaOrder()
        tPaOrder.paAmount = OrderAmountText
        tPaOrder.paAmountInt = OrderAmountInt
        tPaOrder.paTransactionId = OrderId

        tAssignedAgentClass = DeliveryAssignment() 
        tAssignedAgent = tAssignedAgentClass.GetAssignedAgent()
        
        if(tAssignedAgent != 'No Agent Online'):
            tPaOrder.paAssignedAgent = tAssignedAgent.agentId
            tPaOrder.paAssignedAgentNick = tAssignedAgent.agentNickName
        else:
            tPaOrder.paAssignedAgent = "No Agent Online"
            tPaOrder.paAssignedAgentNick = "No Agent Online"
            
        tPaOrder.put()
    def post(self):
        tOrderKey = self.request.get('orderid')

        #logging.debug("tOrderKey: " + tOrderKey)

        tPaOrder = PaOrder()
        tPaOrder = PaOrder.get(tOrderKey)

        tUser = users.get_current_user()
        tAgent = Agent().GetAgentByEmail(str(tUser.email()))

        if (tPaOrder.paOrderDeliver == False and tPaOrder.paOrderLock == False
                and tAgent.agentIsEnabled == True):
            tGoldAmount = tPaOrder.paAmountInt

            tGoldAmountLong = tGoldAmount
            tGoldAmount = tGoldAmount / 1000000

            if (tAgent.agentGoldSupply == None):
                tAgent.agentGoldSupply = 0

            tCommission = tGoldAmount * 0.05 + 0.50

            tAgent.agentGoldSupply = int(
                tAgent.agentGoldSupply) - int(tGoldAmountLong)
            tAgent.agentCurrentCommission = tAgent.agentCurrentCommission + tCommission
            tAgent.agentTotalCommission = tAgent.agentTotalCommission + tCommission

            tAgentOrders = tAgent.agentOrders  #Add order to agent pa orders
            tAgentOrders.append(tOrderKey)
            tAgent.agentOrders = tAgentOrders

            tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + 1

            tAgentKey = tAgent.put()

            tPaOrder.paDeliveryAgent = str(tAgent.agentId)
            tPaOrder.paDeliveryAgentNick = tAgent.agentNickName
            tPaOrder.paOrderDeliver = True
            tPaOrder.paOrderLock = True
            tKey = tPaOrder.put()

            #logging.debug("Delivery by Agent: " + str(tAgentKey))
            #logging.debug("Delivery of Order: " + str(tKey))

            self.response.headers[
                'Cache-Control'] = 'Cache-Control: no-cache, must-revalidate'
            self.response.headers['Content-Type'] = 'Content-Type: plain/text'
            self.response.out.write("Order Delivered")
        else:
            #logging.debug('Attempted to Deliver ' + tOrderKey + " by Agent " + tAgent.agentId)
            self.response.headers[
                'Cache-Control'] = 'Cache-Control: no-cache, must-revalidate'
            self.response.headers['Content-Type'] = 'Content-Type: plain/text'
            self.response.out.write("Order Not Deliverable")
 def post(self):
     tOrderKey = self.request.get('orderid')
     
     #logging.debug("tOrderKey: " + tOrderKey)
     
     tPaOrder = PaOrder()
     tPaOrder = PaOrder.get(tOrderKey)
     
     tUser = users.get_current_user()
     tAgent = Agent().GetAgentByEmail(str(tUser.email()))
     
     if (tPaOrder.paOrderDeliver == False and tPaOrder.paOrderLock == False and tAgent.agentIsEnabled == True):
         tGoldAmount = tPaOrder.paAmountInt
         
         tGoldAmountLong = tGoldAmount
         tGoldAmount = tGoldAmount / 1000000
         
         if (tAgent.agentGoldSupply == None):
             tAgent.agentGoldSupply = 0
         
         tCommission = tGoldAmount * 0.05 + 0.50
         
         tAgent.agentGoldSupply = int(tAgent.agentGoldSupply) - int(tGoldAmountLong)
         tAgent.agentCurrentCommission = tAgent.agentCurrentCommission + tCommission
         tAgent.agentTotalCommission = tAgent.agentTotalCommission + tCommission
         
         tAgentOrders = tAgent.agentOrders #Add order to agent pa orders
         tAgentOrders.append(tOrderKey)
         tAgent.agentOrders = tAgentOrders           
         
         tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + 1
         
         tAgentKey = tAgent.put()
         
         tPaOrder.paDeliveryAgent = str(tAgent.agentId)
         tPaOrder.paDeliveryAgentNick = tAgent.agentNickName
         tPaOrder.paOrderDeliver = True
         tPaOrder.paOrderLock = True
         tKey = tPaOrder.put()
         
         #logging.debug("Delivery by Agent: " + str(tAgentKey))
         #logging.debug("Delivery of Order: " + str(tKey))
         
         self.response.headers['Cache-Control'] = 'Cache-Control: no-cache, must-revalidate'
         self.response.headers['Content-Type'] = 'Content-Type: plain/text'
         self.response.out.write("Order Delivered")
     else:
         #logging.debug('Attempted to Deliver ' + tOrderKey + " by Agent " + tAgent.agentId)
         self.response.headers['Cache-Control'] = 'Cache-Control: no-cache, must-revalidate'
         self.response.headers['Content-Type'] = 'Content-Type: plain/text'
         self.response.out.write("Order Not Deliverable")