コード例 #1
0
    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")
コード例 #2
0
 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")    
コード例 #3
0
 def post(self):
     tOrderKey = self.request.get('orderid')
     tAgentGold = self.request.get('agentgold')
     
     #logging.debug("tOrderKey: " + tOrderKey)
     #logging.debug("tAgentGold: " + tAgentGold)
     tOrder = Order()
     tOrder = Order.get(tOrderKey)
     tUser = users.get_current_user()
     tAgent = Agent().GetAgentByEmail(str(tUser.email()))
     
     if (tOrder.orderDeliver == "" or tOrder.orderDeliver == 'False' and tOrder.orderLocked != 'True' and tAgent.agentIsEnabled == True):
             
         tGoldAmount = tOrder.orderQuantity
         tPromoCode = ""
         tPromoCode = tOrder.orderPromotionalCode
         tPromo = Promo()
         tPromoCode = tPromoCode.lower()
         tReferCode = tOrder.orderReferralCode
         tCustomerLookup = CustomerHandler()
         tCustomer = Customer()
         
         tCustomer = Customer().get(str(tOrder.orderCustomer))
         # Promo codes get unlimited uses per customer
         # tUsedBonus = Order.GetCustomerPromoCodes(tCustomer.customerPaypalId)
         # tUsedBonus = tCustomer.customerUsedBonus
         # logging.debug("Customer used bonuses: " + str(tUsedBonus))
         # logging.debug("Order Promo Code: " + str(tPromoCode))
         tUsedBonus = [] 
         
         try:
             tPromo = Promo.GetPromoByCode(tPromoCode)
             # logging.debug(str(tPromo.promoGoldAmount))
             # logging.debug(str(tPromo.promoPercentage))
             # logging.debug(str(tPromo.promoIsActive))
             
             if ((tPromo.promoIsActive) and (tPromo.promoUses <= tPromo.promoLimit)):
                 if (tPromo.promoLimit != 0):
                     tPromo.promoUses = tPromo.promoUses + 1
                 
                 if((tPromoCode in tUsedBonus) == True):
                     tPercentBonus = 0.0
                 else:
                     tPercentBonus = float(tGoldAmount) * tPromo.promoPercentage
                     #tUsedBonus.append(tPromoCode)
                     
                 tGoldAmount = tGoldAmount + tPercentBonus
                 tGoldAmount = tGoldAmount + tPromo.promoGoldAmount
                 tTotalBonusFloat = tPercentBonus + tPromo.promoGoldAmount
                 tOrder.orderBonusQuantity = int(tTotalBonusFloat)     
         except:
             tOrder.orderBonusQuantity = 0
             
         tGoldAmountLong = tGoldAmount
         tGoldAmount = tGoldAmount / 1000000
         
         tOrderValue = float(tOrder.orderCost)
         
         #if(tOrder.orderIsGenerated == True):
             #tGoldAmountLong = 0
             #tGoldAmount = 0
         
             
         tStockManager = StockManager()
         tStockManager.LoadAccounts()            
         tStockManager.PlaceOrder(tGoldAmountLong * -1, tOrder.orderGoldType)            
                         
         #if tOrder.orderGoldType == '07':
             #tStockAccountManager.Set07Stock(int(tGoldAmountLong * -1))
         #else:
             #tStockAccountManager.SetEOCStock(int(tGoldAmountLong * -1))
                         
         tCommission = float(tOrderValue) * 0.05 + 0.50
         
         if tCommission >= 10.0:
             tCommission = 10.0                           
             
         tAgent.agentCurrentCommission = float(tAgent.agentCurrentCommission + tCommission)
         tAgent.agentTotalCommission = float(tAgent.agentTotalCommission + tCommission)                
         
         tAgentOrders = tAgent.agentOrders
         tAgentOrders.append(tOrderKey)
         tAgent.agentOrders = tAgentOrders
         tAgentKey = tAgent.put()
         tOrder.orderDeliveryAgent = str(tAgent.agentId)
         tOrder.orderAgent = str(tAgentKey)
         tOrder.orderDeliver = 'True'
         tKey = tOrder.put()
         
         #logging.debug("Delivery by Agent: " + str(tAgentKey))
         #logging.debug("Delivery of Order: " + str(tKey))
         
         #taskqueue.add(url='/calcreferral', countdown = 1, params={'key' : 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")
コード例 #4
0
 def PostContext(self):
             
     tNewOrder = ManualPaOrder()
     tAgent = Agent()
     tPromo = Promo()
     
     tUserEmail = self.GetUser().email()
     
     tStockAccount = StockAccount()
     tStockManager = StockManager()
     tStockManager.LoadAccounts()
     
     tAgent = Agent().GetAgentByEmail(tUserEmail)
     logging.debug('Agent ' + str(tAgent.agentNickName))
             
     tPromoCode = self.request.get('promocode').lower().lstrip().rstrip()
     tPromoCode = tPromoCode.lower().lstrip().rstrip()
     
     tGoldType = str(self.request.get('type')).lower().lstrip().rstrip()
     tGoldAmountWeb = str(self.request.get('amount')).lower()
     tGoldAmountPretty = re.sub(r'[^0-9kmb]*','', tGoldAmountWeb)
     tGoldMatches = re.match(r'^[0-9]*(k|m|b{1})$', tGoldAmountPretty)
     if tGoldMatches is None:
         return {'error' : str(tGoldAmountWeb) + ' is an invalid gold amount'}
     
     tGoldValue = str(self.request.get('value')).lower()
     tGoldValue = float(re.sub(r'[^0-9\.*]*', '', tGoldValue))
     
     tPaId = self.request.get('paid').lower().lstrip().rstrip()
     
     if (tGoldType in ('eoc', '07')) is not True:
         return {'error' : str(tGoldType) + ' is an invalid gold type' }
             
     if not tGoldValue >= 0.0:
         return {'error' : str(tGoldValue) + ' is an invalid gold value'}
     
     tStringOffset = self.request.get('offset')
     if (len(tStringOffset) > 0):
         tOffset = int(tStringOffset)
     else:
         tOffset = 0        
             
     tNewOrder.orderOwner = tUserEmail
     
     tGoldAmount = NumberToGp.ConvertBetToInt(tGoldAmountPretty)
     
     tUsedBonus = []
     try:
         #logging.debug("Promo Code: " + str(tPromoCode))
         tPromo = Promo.GetPromoByCode(tPromoCode)
         #logging.debug("Promo: " + str(tPromo))
         #logging.debug("Gold Amount: " + str(tGoldAmount))
         #logging.debug("Promo is active: " + str(tPromo.promoIsActive))
         
         if ((tPromo.promoIsActive) and (tPromo.promoUses <= tPromo.promoLimit)):
             if (tPromo.promoLimit != 0):
                 tPromo.promoUses = tPromo.promoUses + 1
             
             if((tPromoCode in tUsedBonus) == True):
                 tPercentBonus = 0.0
             else:
                 tPercentBonus = tGoldAmount * tPromo.promoPercentage
                 #tUsedBonus.append(tPromoCode)
 
             tGoldAmount = tGoldAmount + tPercentBonus
             tGoldAmount = tGoldAmount + tPromo.promoGoldAmount
             tTotalBonusFloat = tPercentBonus + tPromo.promoGoldAmount
             #logging.debug("Bonus float: " + str(tTotalBonusFloat))
             tPromoGoldAmount = int(tTotalBonusFloat)
                 
             #logging.debug("Total Bonus Float " + str(tTotalBonusFloat))
             #logging.debug("Promo Gold Amount " + str(tPromo.promoGoldAmount))
             #logging.debug("Promo Percentage " + str(tPercentBonus))
     except:
         tPromoGoldAmount = 0        
     
     tOrderTotalAmount = int(tGoldAmount) + int(tPromoGoldAmount)
     #logging.debug('Order gold ' + str(tOrderTotalAmount))
     
     logging.debug("{}".format(tOrderTotalAmount))
     logging.debug("{}".format(tGoldType))
     tStockManager.PlaceOrder(tOrderTotalAmount * -1, tGoldType)
     
     #if tGoldType == '07':
         ##logging.debug('07 detected')
         #tStockManager.PlaceOrder(aGoldQua
         #tStockAccountManager.Set07Stock(int(tOrderTotalAmount * -1))
         ##tAgent.agentGoldSupply07 = int(tAgent.agentGoldSupply07) - tOrderTotalAmount
     #elif tGoldType == 'eoc':
         ##logging.debug('eoc detected')
         ##tStockAccountManager.SetEOCStock(int(tOrderTotalAmount * -1))
         ##tAgent.agentGoldSupplyEoc = int(tAgent.agentGoldSupplyEoc) - tOrderTotalAmount
         
     #logging.debug('Agent 07 ' + str(tAgent.agentGoldSupply07))
     #logging.debug('Agent eoc ' + str(tAgent.agentGoldSupplyEoc))        
         
     tCommission = float(tGoldValue) * 0.05 + 0.50
     
     if tCommission >= 10.0:
         tCommission = 10.0
     
     tNewOrder.orderCashValue = float(tGoldValue)
     tNewOrder.orderOwner = tUserEmail
     tNewOrder.orderGoldAmount = int(tGoldAmount)
     tNewOrder.orderGoldAmountPretty = tGoldAmountPretty
     tNewOrder.orderGoldType = tGoldType
     tNewOrder.orderPaId = tPaId
     tNewOrder.orderPromoCode = tPromoCode
     tNewOrder.orderPromoGoldAmount = tPromoGoldAmount
     tNewOrderGuid = tNewOrder.put()
     
     tAgent.agentCurrentCommission = float(tAgent.agentCurrentCommission + tCommission)
     tAgent.agentTotalCommission = float(tAgent.agentTotalCommission + tCommission)
     tAgent.agentManualPaOrders = tAgent.agentManualPaOrders + [str(tNewOrderGuid)]
     tAgent.put()
     
     if int(tOffset) > 0:
         self.LOCATION = '/palist?offset=' + str(tOffset)
     else:
         self.LOCATION = '/palist'
         
     self.REDIRECT = True
     return {} 
     
     
     
     
     
     
     
     
     
     
     
コード例 #5
0
    def GetContext(self):
        tContext = {}
        tAgent = Agent()
        tAgentHandler = AgentHandler()
        tOrders = []
        tOrder = Order()
        tUser = self.USER

        tAgentQuery = Agent().all()
        tAgentQuery.filter('agentOnline', True)
        tAgents = tAgentQuery.fetch(100)
        if (len(tAgents) > 0):
            tContext['agentnum'] = len(tAgents)
            tContext['agents'] = tAgents
        try:
            tAgent = Agent().GetAgentByEmail(str(tUser.email()))
        except:
            pass
        if (tAgent.agentId == 'No Agent'):
            tAgent.agentCurrentCommission = 0.0
            tAgent.agentTotalCommission = 0.0
            tAgent.agentOrders = []
            tAgent.agentId = str(tUser.email())
            tAgent.agentGoldSupply = 0
            tAgent.agentOnline = False
            tAgent.put()

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

        tOrderQuery = PaOrder.all()
        tOrderQuery.filter("paDeliveryAgent", tAgent.agentId)
        tOrderQuery.order("-paDateDelivered")
        tOrdersRaw = tOrderQuery.fetch(50)

        tAgentDonorsQuery = DonorRecord.all()
        tAgentDonorsQuery.filter('donorAgent', tAgent.agentId)
        tAgentDonorsQuery.order('-donorDate')
        tAgentDonations = tAgentDonorsQuery.fetch(20)

        for o in tOrdersRaw:
            tOrder = o
            if (tOrder != None):
                tOrders.append(tOrder)

        #tGoldSupply = tAgent.agentGoldSupply

        logging.debug('Original eoc ' + str(tAgent.agentGoldSupplyEoc))
        logging.debug('Original 07 ' + str(tAgent.agentGoldSupply07))

        tEocString = NumberToGp.ConvertIntToBet(tAgent.agentGoldSupplyEoc)
        t07String = NumberToGp.ConvertIntToBet(tAgent.agentGoldSupply07)

        logging.debug('Stringed version eoc ' + tEocString)
        logging.debug('Stringed version 07 ' + t07String)

        #tAgent.__setattr__('agentGoldSupplyEocString', tEocString)
        #tAgent.__setattr__('agentGoldSupply07String', t07String)

        tContext['agent'] = tAgent
        tContext['gpeocstring'] = str(tEocString)
        tContext['gp07string'] = str(t07String)
        #tContext['agentgold'] = locale.format("%d", int(tGoldSupply), grouping = True)
        tContext['orders'] = tOrders
        tContext['agentcomm'] = locale.format("%0.2f",
                                              tAgent.agentCurrentCommission,
                                              grouping=True)
        tContext['agenttotal'] = locale.format("%0.2f",
                                               tAgent.agentTotalCommission,
                                               grouping=True)
        tContext['donations'] = tAgentDonations
        return tContext
コード例 #6
0
    def post(self):
        tOrderKey = self.request.get('orderid')
        tAgentGold = self.request.get('agentgold')

        #logging.debug("tOrderKey: " + tOrderKey)
        #logging.debug("tAgentGold: " + tAgentGold)
        tOrder = Order()
        tOrder = Order.get(tOrderKey)
        tUser = users.get_current_user()
        tAgent = Agent().GetAgentByEmail(str(tUser.email()))

        if (tOrder.orderDeliver == "" or tOrder.orderDeliver == 'False'
                and tOrder.orderLocked != 'True'
                and tAgent.agentIsEnabled == True):

            tGoldAmount = tOrder.orderQuantity
            tPromoCode = ""
            tPromoCode = tOrder.orderPromotionalCode
            tPromo = Promo()
            tPromoCode = tPromoCode.lower()
            tReferCode = tOrder.orderReferralCode
            tCustomerLookup = CustomerHandler()
            tCustomer = Customer()

            tCustomer = Customer().get(str(tOrder.orderCustomer))
            # Promo codes get unlimited uses per customer
            # tUsedBonus = Order.GetCustomerPromoCodes(tCustomer.customerPaypalId)
            # tUsedBonus = tCustomer.customerUsedBonus
            # logging.debug("Customer used bonuses: " + str(tUsedBonus))
            # logging.debug("Order Promo Code: " + str(tPromoCode))
            tUsedBonus = []

            try:
                tPromo = Promo.GetPromoByCode(tPromoCode)
                # logging.debug(str(tPromo.promoGoldAmount))
                # logging.debug(str(tPromo.promoPercentage))
                # logging.debug(str(tPromo.promoIsActive))

                if ((tPromo.promoIsActive)
                        and (tPromo.promoUses <= tPromo.promoLimit)):
                    if (tPromo.promoLimit != 0):
                        tPromo.promoUses = tPromo.promoUses + 1

                    if ((tPromoCode in tUsedBonus) == True):
                        tPercentBonus = 0.0
                    else:
                        tPercentBonus = float(
                            tGoldAmount) * tPromo.promoPercentage
                        #tUsedBonus.append(tPromoCode)

                    tGoldAmount = tGoldAmount + tPercentBonus
                    tGoldAmount = tGoldAmount + tPromo.promoGoldAmount
                    tTotalBonusFloat = tPercentBonus + tPromo.promoGoldAmount
                    tOrder.orderBonusQuantity = int(tTotalBonusFloat)
            except:
                tOrder.orderBonusQuantity = 0

            tGoldAmountLong = tGoldAmount
            tGoldAmount = tGoldAmount / 1000000

            tOrderValue = float(tOrder.orderCost)

            #if(tOrder.orderIsGenerated == True):
            #tGoldAmountLong = 0
            #tGoldAmount = 0

            tStockManager = StockManager()
            tStockManager.LoadAccounts()
            tStockManager.PlaceOrder(tGoldAmountLong * -1,
                                     tOrder.orderGoldType)

            #if tOrder.orderGoldType == '07':
            #tStockAccountManager.Set07Stock(int(tGoldAmountLong * -1))
            #else:
            #tStockAccountManager.SetEOCStock(int(tGoldAmountLong * -1))

            tCommission = float(tOrderValue) * 0.05 + 0.50

            if tCommission >= 10.0:
                tCommission = 10.0

            tAgent.agentCurrentCommission = float(
                tAgent.agentCurrentCommission + tCommission)
            tAgent.agentTotalCommission = float(tAgent.agentTotalCommission +
                                                tCommission)

            tAgentOrders = tAgent.agentOrders
            tAgentOrders.append(tOrderKey)
            tAgent.agentOrders = tAgentOrders
            tAgentKey = tAgent.put()
            tOrder.orderDeliveryAgent = str(tAgent.agentId)
            tOrder.orderAgent = str(tAgentKey)
            tOrder.orderDeliver = 'True'
            tKey = tOrder.put()

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

            #taskqueue.add(url='/calcreferral', countdown = 1, params={'key' : 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")