コード例 #1
0
 def PostContext(self):
     
     tStockAccount = StockAccount()
     tStockAccountManager = StockAccountManager()
     tStockAccountManager.LoadAccount('primary')
     tStockAccount = tStockAccountManager.CURRENT_STOCK
     
     t07Price = self.request.get('07price')
     tEocPrice = self.request.get('eocprice')
     
     if self.USER.email().lower() == '*****@*****.**':        
         if t07Price is not None:
             if len(t07Price) > 0:
                 tStockAccount.stockPrice07 = float(t07Price)
                                 
         if tEocPrice is not None:
             if len(tEocPrice) > 0:
                 tStockAccount.stockPriceEoc = float(tEocPrice)        
     else:
         return {'error' : 'You bad bad boy. FBI Notified.'}
     
     tStockAccount.put()
     
     self.LOCATION = "/manage-commission"
     self.REDIRECT = True
     return {} #need to return something for processing
     #self.redirect(tLocation)
     
     
     
コード例 #2
0
    def LoadAccount(self, aAccountName):
        tStockAccount = StockAccount()

        tStockQuery = StockAccount.all()
        tStockQuery.filter('stockName', aAccountName)
        tStockAccount = tStockQuery.fetch(limit=1)
        tStockAccount = tStockAccount[0]

        self.CURRENT_STOCK = tStockAccount
        self.CURRENT_07 = tStockAccount.stockPrice07
        self.CURRENT_EOC = tStockAccount.stockPriceEoc

        return self.CURRENT_STOCK.key()
コード例 #3
0
 def SetStock(self, aNewStockAmount, aGoldType):
     tStockAccount = StockAccount()        
     tStockAccount = self.CURRENT_STOCK       
     #logging.debug("{}".format(aNewStockAmount))
     #logging.debug("{}".format(aGoldType))
     if aGoldType == "07":
         tStockAccount.stockQuantity07 = tStockAccount.stockQuantity07 + aNewStockAmount
     elif aGoldType == "eoc":
         tStockAccount.stockQuantityEoc = tStockAccount.stockQuantityEoc + aNewStockAmount
         
     tKey = tStockAccount.put()        
     self.CURRENT_STOCK = tStockAccount
     
     return tKey
コード例 #4
0
    def SetStock(self, aNewStockAmount, aGoldType):
        tStockAccount = StockAccount()
        tStockAccount = self.CURRENT_STOCK
        #logging.debug("{}".format(aNewStockAmount))
        #logging.debug("{}".format(aGoldType))
        if aGoldType == "07":
            tStockAccount.stockQuantity07 = tStockAccount.stockQuantity07 + aNewStockAmount
        elif aGoldType == "eoc":
            tStockAccount.stockQuantityEoc = tStockAccount.stockQuantityEoc + aNewStockAmount

        tKey = tStockAccount.put()
        self.CURRENT_STOCK = tStockAccount

        return tKey
コード例 #5
0
    def GetContext(self):

        tStockAccount = StockAccount()
        tStockAccountManager = StockAccountManager()
        tStockAccountManager.LoadAccount('primary')
        tStockAccount = tStockAccountManager.CURRENT_STOCK

        return {'stock': tStockAccount}
コード例 #6
0
 def AddCommission(self, aGoldAmount, aGoldType):
     tStockAccount = StockAccount()
     
     tStockAccount = self.CURRENT_STOCK       
     
     if aGoldType == "07":
         tCommission = aGoldAmount * self.CURRENT_07 / 1000000
         
     elif aGoldType == "eoc":
         tCommission = aGoldAmount * self.CURRENT_EOC / 1000000
         
     tStockAccount.stockCommission = tStockAccount.stockCommission + tCommission
         
     tKey = tStockAccount.put()        
     self.CURRENT_STOCK = tStockAccount
     
     return tKey        
コード例 #7
0
    def AddCommission(self, aGoldAmount, aGoldType):
        tStockAccount = StockAccount()

        tStockAccount = self.CURRENT_STOCK

        if aGoldType == "07":
            tCommission = aGoldAmount * self.CURRENT_07 / 1000000

        elif aGoldType == "eoc":
            tCommission = aGoldAmount * self.CURRENT_EOC / 1000000

        tStockAccount.stockCommission = tStockAccount.stockCommission + tCommission

        tKey = tStockAccount.put()
        self.CURRENT_STOCK = tStockAccount

        return tKey
コード例 #8
0
    def PostContext(self):

        tStockAccount = StockAccount()
        tStockAccountManager = StockAccountManager()
        tStockAccountManager.LoadAccount('primary')
        tStockAccount = tStockAccountManager.CURRENT_STOCK

        t07Price = self.request.get('07price')
        tEocPrice = self.request.get('eocprice')

        if self.USER.email().lower() == '*****@*****.**':
            if t07Price is not None:
                if len(t07Price) > 0:
                    tStockAccount.stockPrice07 = float(t07Price)

            if tEocPrice is not None:
                if len(tEocPrice) > 0:
                    tStockAccount.stockPriceEoc = float(tEocPrice)
        else:
            return {'error': 'You bad bad boy. FBI Notified.'}

        tStockAccount.put()

        self.LOCATION = "/manage-commission"
        self.REDIRECT = True
        return {}  #need to return something for processing
コード例 #9
0
 def LoadAccount(self, aAccountName):
     tStockAccount = StockAccount()
     
     tStockQuery = StockAccount.all()
     tStockQuery.filter('stockName', aAccountName)
     tStockAccount = tStockQuery.fetch(limit = 1)
     tStockAccount = tStockAccount[0]
     
     self.CURRENT_STOCK = tStockAccount
     self.CURRENT_07 = tStockAccount.stockPrice07
     self.CURRENT_EOC = tStockAccount.stockPriceEoc
     
     return self.CURRENT_STOCK.key()
コード例 #10
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 {} 
     
     
     
     
     
     
     
     
     
     
     
コード例 #11
0
class StockAccountManager(object):
    CURRENT_STOCK = StockAccount()
    CURRENT_EOC = float()
    CURRENT_07 = float()

    def LoadAccount(self, aAccountName):
        tStockAccount = StockAccount()

        tStockQuery = StockAccount.all()
        tStockQuery.filter('stockName', aAccountName)
        tStockAccount = tStockQuery.fetch(limit=1)
        tStockAccount = tStockAccount[0]

        self.CURRENT_STOCK = tStockAccount
        self.CURRENT_07 = tStockAccount.stockPrice07
        self.CURRENT_EOC = tStockAccount.stockPriceEoc

        return self.CURRENT_STOCK.key()

    def GetCurrentEOCStock(self):
        return self.CURRENT_STOCK.stockQuantityEoc

    def GetCurrent07Stock(self):
        return self.CURRENT_STOCK.stockQuantity07

    def SetEOCStock(self, aNewStockAmount):
        return self.SetStock(
            aNewStockAmount,
            'eoc',
        )

    def Set07Stock(self, aNewStockAmount):
        return self.SetStock(
            aNewStockAmount,
            '07',
        )

    def SetStock(self, aNewStockAmount, aGoldType):
        tStockAccount = StockAccount()
        tStockAccount = self.CURRENT_STOCK
        #logging.debug("{}".format(aNewStockAmount))
        #logging.debug("{}".format(aGoldType))
        if aGoldType == "07":
            tStockAccount.stockQuantity07 = tStockAccount.stockQuantity07 + aNewStockAmount
        elif aGoldType == "eoc":
            tStockAccount.stockQuantityEoc = tStockAccount.stockQuantityEoc + aNewStockAmount

        tKey = tStockAccount.put()
        self.CURRENT_STOCK = tStockAccount

        return tKey

    def AddCommission(self, aGoldAmount, aGoldType):
        tStockAccount = StockAccount()

        tStockAccount = self.CURRENT_STOCK

        if aGoldType == "07":
            tCommission = aGoldAmount * self.CURRENT_07 / 1000000

        elif aGoldType == "eoc":
            tCommission = aGoldAmount * self.CURRENT_EOC / 1000000

        tStockAccount.stockCommission = tStockAccount.stockCommission + tCommission

        tKey = tStockAccount.put()
        self.CURRENT_STOCK = tStockAccount

        return tKey