当前位置: 首页>>代码示例>>Python>>正文


Python Order.all方法代码示例

本文整理汇总了Python中models.order.Order.all方法的典型用法代码示例。如果您正苦于以下问题:Python Order.all方法的具体用法?Python Order.all怎么用?Python Order.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.order.Order的用法示例。


在下文中一共展示了Order.all方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetContext

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
 def GetContext(self):
         
     tAgent = Agent()
     tAgentList = []
     tAgentOrders = []
     tAgentDonations = []
     tAgentRequest = self.request.get('agent')
     context = {}
     
     tAgentList = Agent.all()
     context['agents'] = tAgentList
     if (tAgentRequest != ""):
         tAgent = Agent.get(tAgentRequest)
         
         tAgentOrdersQuery = Order.all()
         tAgentOrdersQuery.filter('orderAgent', str(tAgentRequest))
         tAgentOrdersQuery.order('-orderCompleted')
         tAgentOrders = tAgentOrdersQuery.fetch(100)
         
         tAgentDonorsQuery = DonorRecord.all()
         tAgentDonorsQuery.filter('donorAgent', tAgent.agentId)
         tAgentDonorsQuery.order('-donorDate')
         tAgentDonations = tAgentDonorsQuery.fetch(100)
         
         #logging.debug("Agent Order Count: " + str(len(tAgentOrders)))
         #logging.debug("Agent Donation Count: " + str(len(tAgentDonations)))
         
         context['agent'] = tAgent
         context['orders'] = tAgentOrders
         context['donations'] = tAgentDonations
         context['extended'] = 'True'
         
     return context
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:35,代码来源:agentmaster.py

示例2: GetContext

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
 def GetContext(self):
     tContext = {}
     tOrderQuery = Order.all()
     tOrderQuery.filter("orderDeliver", "False")
     tOrderQuery.order("orderCreated")
     tOrderList = tOrderQuery.fetch(500)
     tContext['orders'] = tOrderList
     
     return tContext
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:11,代码来源:refundrollup.py

示例3: get

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
  def get(self):	
	path = os.path.join(os.path.dirname(__file__),
	                    '../views/orders/index.html')
	
	template_values = {
		'name': self.__class__.__name__,
		'orders': Order.all().order('-createdOn'),		
	}
	
	self.response.out.write(template.render(path, template_values))
开发者ID:ciriarte,项目名称:laundry,代码行数:12,代码来源:order.py

示例4: post

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
    def post(self):
        tUrl = "https://api-3t.paypal.com/nvp"
        tPaypalPayload = {}
        tPaypal = PaypalRefund()
        tAgent = Agent()
        tOrder = Order()
        tUser = users.get_current_user()

        tTransId = str(self.request.get("orderid"))

        tAgentEmail = str(tUser.email())
        tAgent = Agent().GetAgentByEmail(tAgentEmail)
        tRefundAgent = tAgentEmail

        tOrderQuery = Order.all()
        tOrderQuery.filter("orderTransactionId", tTransId)
        # logging.debug("Transaction id: " + tTransId)
        tOrder = tOrderQuery.get()

        if tOrder.orderDeliver != "True":

            tPaypalPayload["METHOD"] = "RefundTransaction"
            tPaypalPayload["TRANSACTIONID"] = tTransId

            tPayloadEncoded = tPaypal.GeneratePayload(tPaypalPayload)

            request_cookies = mechanize.CookieJar()
            request_opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(request_cookies))
            request_opener.addheaders = [("Content-Type", "application/x-www-form-urlencoded")]
            mechanize.install_opener(request_opener)

            tResponse = mechanize.urlopen(url=tUrl, timeout=25.0, data=tPayloadEncoded)
            # logging.debug("Mechanize Package")
            # logging.debug("Url: " + tUrl)
            # logging.debug("Data: " + str(tPaypalPayload))

            tResult = tResponse.read()
            # logging.debug(tResult)

            tOrder.orderIsRefunded = "True"
            tOrder.orderRefundAgent = tRefundAgent
            tOrder.orderLocked = "True"
            tOrder.orderRefundId = ""
            tOrder.put()

            self.response.out.write("Order Locked and Refunded")
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:48,代码来源:paypal.py

示例5: index

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
def index():
    if not (g.user.is_super_leader() or g.user.is_aduit() or g.user.is_finance() or g.user.is_contract()):
        abort(403)
    shenji = int(request.values.get('shenji', 0))
    now_date = datetime.datetime.now()
    year = int(request.values.get('year', now_date.year))
    # 获取整年月份
    pre_year_month = get_monthes_pre_days(datetime.datetime.strptime(str(year) + '-01', '%Y-%m'),
                                          datetime.datetime.strptime(str(year) + '-12', '%Y-%m'))
    # 获取所有回款包含返点发票
    back_money_data = _all_douban_order_back_moneys()
    client_back_money_data = _all_client_order_back_moneys()
    # 获取代理返点系数
    all_agent_rebate = _all_agent_rebate()
    # 获取所有外包
    all_outsource_data = _all_douban_order_outsource()

    # 获取当年豆瓣合同
    orders = DoubanOrder.query.filter(DoubanOrder.status == 1,
                                      DoubanOrder.contract != '')
    # 去重合同
    orders = [k for k in orders if k.client_start.year ==
              year or k.client_end.year == year]
    # 格式化合同
    orders = [_douban_order_to_dict(k, back_money_data, all_agent_rebate, pre_year_month,
                                    all_outsource_data, shenji) for k in orders]
    # 获取豆瓣合同结束
    orders = [k for k in orders if k['contract_status'] in [2, 4, 5, 10, 19, 20]]
    # 获取关联豆瓣合同
    medium_orders = [_medium_order_to_dict(k, client_back_money_data, all_agent_rebate,
                                           pre_year_month, all_outsource_data, shenji)
                     for k in Order.all() if (k.medium_start.year == year or k.medium_end.year == year)
                     and k.associated_douban_order]
    orders += [k for k in medium_orders if k['contract_status']
               in [2, 4, 5, 10, 19, 20] and k['status'] == 1]
    # 获取关联豆瓣合同结束
    orders = sorted(
        orders, key=operator.itemgetter('start_date_cn'), reverse=False)
    total_outsource_data = [0 for k in range(12)]
    total_money_data = [0 for k in range(12)]
    total_money_rebate_data = [0 for k in range(12)]
    total_profit_data = [0 for k in range(12)]
    for k in orders:
        total_money_data = numpy.array(
            total_money_data) + numpy.array(k['money_data'])
        total_outsource_data = numpy.array(
            total_outsource_data) + numpy.array(k['outsource_data'])
        total_money_rebate_data = numpy.array(
            total_money_rebate_data) + numpy.array(k['money_rebate_data'])
        total_profit_data = numpy.array(
            total_profit_data) + numpy.array(k['profit_data'])
    if request.values.get('action') == 'excel':
        return write_douban_order_excel(orders=orders, year=year, total_money_data=total_money_data,
                                        total_money_rebate_data=total_money_rebate_data,
                                        total_profit_data=total_profit_data, total_outsource_data=total_outsource_data,
                                        shenji=shenji)
    if shenji:
        tpl_html = '/shenji/cost_income_douban_order_s.html'
    else:
        tpl_html = '/shenji/cost_income_douban_order.html'
    return tpl(tpl_html, orders=orders, year=year,
               total_money_data=total_money_data,
               total_money_rebate_data=total_money_rebate_data,
               total_outsource_data=total_outsource_data,
               total_profit_data=total_profit_data)
开发者ID:giveme168,项目名称:braavos,代码行数:67,代码来源:cost_income_douban_order.py

示例6: GetContext

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
 def GetContext(self):
     
     tUser = self.GetUser()        
     tCustomerList = []
     tCustomerOrders = []
     tCustomerOrderKeys = []
     tOrderData = {}
     tOrder = Order()
     tShowSearch = False
     tCustomerLookup = CustomerHandler()
     tCustomerKey = urllib.unquote(self.request.get('key'))
     
     if(tCustomerKey):
         tCustomerList.append(tCustomerLookup.GetCustomerByKey(tCustomerKey))
     #logging.debug(str(len(tCustomerList)))
     
     if (tCustomerList == None or len(tCustomerList) == 0):
         tShowSearch = True
     else:
         tShowSearch = False
         tCustomer = Customer()
         tCustomer = tCustomerList[0]
         
         #Get date 30 days ago
         tStartDate = datetime.datetime.now()
         tIncrement = datetime.timedelta(days = -30)
         tEndDate = tStartDate + tIncrement
         tCustomerOrderQuery = Order.all()
         tCustomerOrderQuery.filter("orderCreated >", tEndDate)
         tCustomerOrderQuery.filter("orderCustomer", tCustomerKey)
         tCustomerOrderQuery.filter("orderDeliver", 'True')
         tCustomerOrders = tCustomerOrderQuery.fetch(1000)
         #logging.debug("30 day date: " + str(tEndDate))
         #logging.debug("30 day orders: " + str(len(tCustomerOrders)))
         tCustomerOrderTotal = 0.0
         for tCustomerOrder in tCustomerOrders:
             tCustomerOrderTotal += float(tCustomerOrder.orderCost)
         if (tOrder.orderDeliver == 'False'):
             tCustomerOrderTotal += tCurrentCost
         tOrderData['orderTotal'] = str("%.2f"% tCustomerOrderTotal)
         
         #Get date 24 hours ago
         tStartDate = datetime.datetime.now()
         tIncrement = datetime.timedelta(days = -1)
         tEndDate = tStartDate + tIncrement
         tCustomerOrderQuery = Order.all().filter("orderCreated >", tEndDate)
         tCustomerOrderQuery.filter("orderCustomer", tCustomerKey)
         tCustomerOrderQuery.filter("orderDeliver", 'True')
         tCustomerOrders = tCustomerOrderQuery.fetch(1000)
         #logging.debug("24 hour date: " + str(tEndDate))
         #logging.debug("24 hour orders: " + str(len(tCustomerOrders)))
         tCustomerOrderTotal24 = 0.0
         for tCustomerOrder in tCustomerOrders:
             tCustomerOrderTotal24 += float(tCustomerOrder.orderCost)
             
         if (tOrder.orderDeliver == 'False'):
             tCustomerOrderTotal24 += tCurrentCost
         tOrderData['orderTotal24'] = str("%.2f" % tCustomerOrderTotal24)
         
         #Get date 15 days ago
         #tStartDate = datetime.datetime.now()
         #tIncrement = datetime.timedelta(days = -15)
         #tEndDate = tStartDate + tIncrement
         #tCustomerOrderQuery = Order.all().filter("orderCreated >", tEndDate)
         #tCustomerOrderQuery.filter("orderCustomer", tCustomerKey)
         #tCustomerOrderQuery.filter("orderDeliver", 'True')
         #tCustomerOrders = tCustomerOrderQuery.fetch(1000)
         #logging.debug("15 day date: " + str(tEndDate))
         #logging.debug("15 day orders: " + str(len(tCustomerOrders)))
         #tCustomerOrderTotal15 = 0.0
         #for tCustomerOrder in tCustomerOrders:
             #tCustomerOrderTotal15 += float(tCustomerOrder.orderCost)
             
         #if (tOrder.orderDeliver == 'False'):
             #tCustomerOrderTotal15 += tCurrentCost
         #tOrderData['orderTotal15'] = str("%.2f" % tCustomerOrderTotal15)
         
         #logging.debug(str(tCustomerKey))
         tOrderQuery = Order.all()
         tOrderQuery.filter("orderCustomer", tCustomerKey)
         tOrderQuery.order("-orderCreated")
         tCustomerOrders = tOrderQuery.fetch(20)
         #logging.debug(str(tCustomerOrders))
         
             
     tShowSearch = str(tShowSearch)
     
     return {
         'result':    tCustomerList,
         'customerorders': tCustomerOrders,
         'tOrderData':tOrderData,
         'search':    tShowSearch,
     }   
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:95,代码来源:customerhandler.py

示例7: get

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
    def get(self):
        tOrder = Order()
        tUnattachedCustomer = Customer()
        tMasterCustomer = CustomerMaster()
        tMasterCustomer.masterIsPaBlacklisted = False
        tMasterCustomer.masterIsGlobalBlacklisted = False
        
        #Lists of customer masters
        tMasterCustomerEmailList = []
        tMasterCustomerIpList = []
        tMasterCustomerPhoneList = []
        tMasterCustomerRsnList = []
        tMasterCustomerPaypalList = []
        
        tMasterCustomerEmailQuery = CustomerMaster.all()          
        tMasterCustomerIpQuery = CustomerMaster.all()    
        tMasterCustomerPhoneQuery = CustomerMaster.all()      
        tMasterCustomerRsnQuery = CustomerMaster.all()   
        tMasterCustomerPaypalQuery = CustomerMaster.all()
        
        #Final lists for deletion
        tDeletionList = []
        
        #First get an unmastered customer
        tUnattachedCustomerQuery = Customer.all()
        tUnattachedCustomerQuery.filter("customerMaster", "")
        #tUnattachedCustomerQuery.filter("customerEmail", "[email protected]")
        tUnattachedCustomerList = tUnattachedCustomerQuery.fetch(1)
        if(len(tUnattachedCustomerList) > 0):
            tUnattachedCustomer = tUnattachedCustomerList[0]
        else:
            return
        
        #logging.debug("Testing with customer: " + str(tUnattachedCustomer.customerEmail))
        
        #Defaults
        tEmail = ""     
        tPhone = ""
        tIpList = []
        
        #Assign from unmastered customer
        tEmail = str(tUnattachedCustomer.customerEmail).strip().lower()
        tPhone = str(tUnattachedCustomer.customerPhone).strip().lower()
        tPhone = re.sub(r'\D', '', tPhone)
        
        for tIp in tUnattachedCustomer.customerIpAddresses:
            tIp = str(tIp).strip()
            if (tIp != '' and tIp != None):
                tIpList.append(tIp)
        
        #Get Customer's Orders
        tOrderQuery = Order.all()
        tOrderQuery.filter("orderPaypalEmail", tEmail)
        tOrderList = tOrderQuery.fetch(200)
        
        #Merge together a list of the RSNs and Order Paypal IDs
        tRsnList = []
        tPaypalList = []
        for tOrder in tOrderList:
            if(tOrder.orderAccountName != None and tOrder.orderAccountName != ""):
                tTempRsn = str(tOrder.orderAccountName).lower().strip()
                tTempRsn = tTempRsn.replace(' ', '_')
                tTempRsn = tTempRsn.replace('-', '_')
                tRsnList.append(tTempRsn)
            if(tOrder.orderCustomerPaypalId != None and tOrder.orderCustomerPaypalId != ""):
                tPaypalList.append(str(tOrder.orderCustomerPaypalId))

        #Dedupification
        tIpList = list(set(tIpList))
        tRsnList = list(set(tRsnList))
        tPaypalList = list(set(tPaypalList))
        
        #Now that the data to search is filled we can start searching for masters

        if(tEmail != None and tEmail != ""):
            #logging.debug("Searching for masters with customer email: " + str(tEmail))
            tMasterCustomerEmailQuery.filter("masterEmailList", tEmail)
            tMasterCustomerEmailList = tMasterCustomerEmailQuery.fetch(200)
            
        if(tPhone != None and tPhone != ""):
            #logging.debug("Searching for masters with customer phone: " + str(tPhone))
            tMasterCustomerPhoneQuery.filter("masterPhoneList", tPhone)
            tMasterCustomerPhoneList = tMasterCustomerPhoneQuery.fetch(200)
            
        if(len(tIpList) > 0):
            for tIp in tIpList:
                if(tIp != None and tIp != ""):
                    #logging.debug("Searching for masters with customer ip: " + str(tIp))        
                    tMasterCustomerIpQuery = CustomerMaster.all()    
                    tMasterCustomerIpQuery.filter("masterIpList", tIp)
                    tMasterCustomerIpList += tMasterCustomerIpQuery.fetch(200)
                
        if(len(tRsnList) > 0):
            for tRsn in tRsnList:
                if(tRsn != None and tRsn != ""):
                    #logging.debug("Searching for masters with customer rsn: " + str(tRsn))
                    tMasterCustomerRsnQuery = CustomerMaster.all()    
                    tMasterCustomerRsnQuery.filter("masterRsnList", tRsn)
                    tMasterCustomerRsnList += tMasterCustomerRsnQuery.fetch(200)
            
#.........这里部分代码省略.........
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:103,代码来源:customermasterhandler.py

示例8: get_Orders

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
 def get_Orders(self):
   # This is not at the top to prevent circular imports.
   from models.order import Order
   return Order.all().ancestor(self)
开发者ID:nardorb,项目名称:OneStop,代码行数:6,代码来源:account.py

示例9: index

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
def index():
    if not (g.user.is_super_leader() or g.user.is_media_leader()):
        return abort(403)
    now_date = datetime.datetime.now()
    year = int(request.values.get('year', now_date.year))
    start_date_month = datetime.datetime.strptime(
        str(year) + '-01' + '-01', '%Y-%m-%d')
    end_date_month = datetime.datetime.strptime(
        str(year) + '-12' + '-31', '%Y-%m-%d')
    pre_monthes = get_monthes_pre_days(start_date_month, end_date_month)
    medium_id = int(request.values.get('medium_id', 0))

    ex_medium_orders = [o for o in Order.all(
    ) if o.medium_start.year == year or o.medium_end.year == year]
    obj_data = []
    for order in ex_medium_orders:
        pre_month_sale_money = pre_month_money(order.sale_money, order.medium_start, order.medium_end)
        pre_month_medium_money2 = pre_month_money(order.medium_money2, order.medium_start, order.medium_end)
        # 单笔返点
        agent_rebate = order.client_order.agent_rebate
        try:
            self_agent_rebate = order.client_order.self_agent_rebate
            self_agent_rebate = float(self_agent_rebate.split('-')[0])
            self_agent_rebate_value = float(self_agent_rebate.split('-')[1])
        except:
            self_agent_rebate = 0
            self_agent_rebate_value = 0
        for p in range(len(pre_month_sale_money)):
            d_order = {}
            d_order['medium_id'] = order.medium.id
            d_order['money'] = order.client_order.money
            d_order['contract_status'] = order.client_order.contract_status
            d_order['status'] = order.client_order.status
            d_order['sale_money'] = pre_month_sale_money[p]['money']
            d_order['medium_money2'] = pre_month_medium_money2[p]['money']
            d_order['month_day'] = pre_month_sale_money[p]['month_day']
            medium_rebate = order.medium_rebate_by_year(d_order['month_day'])
            # 媒体单笔返点
            try:
                self_medium_rebate_data = order.self_medium_rebate
                self_medium_rebate = self_medium_rebate_data.split('-')[0]
                self_medium_rebate_value = float(self_medium_rebate_data.split('-')[1])
            except:
                self_medium_rebate = 0
                self_medium_rebate_value = 0
            if int(self_medium_rebate):
                if d_order['sale_money']:
                    d_order['medium_rebate_value'] = d_order['sale_money'] / d_order['money'] * self_medium_rebate_value
                else:
                    d_order['medium_rebate_value'] == 0
            else:
                d_order['medium_rebate_value'] = d_order['medium_money2'] * medium_rebate / 100

            if self_agent_rebate:
                if d_order['money']:
                    d_order['agent_rebate_value'] = self_agent_rebate_value * d_order['sale_money'] / d_order['money']
                else:
                    d_order['agent_rebate_value'] = 0
            else:
                d_order['agent_rebate_value'] = d_order['sale_money'] * agent_rebate / 100
            obj_data.append(d_order)
    ex_medium_orders = [k for k in obj_data if k[
        'contract_status'] not in [0, 1, 3, 6, 7, 8, 81, 9] and k['status'] == 1]

    medium_data = []
    if medium_id:
        mediums = Medium.query.filter_by(id=medium_id)
    else:
        mediums = Medium.all()
    sum_sale_money = 0
    for k in mediums:
        sale_money_data = []
        medium_money2_data = []
        medium_rebate_data = []
        agent_rebate_data = []
        for i in pre_monthes:
            sale_money_data.append(sum([ex['sale_money'] for ex in ex_medium_orders if ex[
                                   'medium_id'] == k.id and ex['month_day'].date() == i['month'].date()]))
            medium_money2_data.append(sum([ex['medium_money2'] for ex in ex_medium_orders if ex[
                                      'medium_id'] == k.id and ex['month_day'].date() == i['month'].date()]))
            medium_rebate_data.append(sum([ex['medium_rebate_value'] for ex in ex_medium_orders if ex[
                                      'medium_id'] == k.id and ex['month_day'].date() == i['month'].date()]))
            agent_rebate_data.append(sum([ex['agent_rebate_value'] for ex in ex_medium_orders if ex[
                                     'medium_id'] == k.id and ex['month_day'].date() == i['month'].date()]))
        sum_sale_money += sum(sale_money_data)
        medium_data.append({'id': k.id, 'name': k.name,
                            'level': k.level or 100,
                            'sale_money_data': sale_money_data,
                            'medium_money2_data': medium_money2_data,
                            'medium_rebate_data': medium_rebate_data,
                            'agent_rebate_data': agent_rebate_data})
    print sum_sale_money
    medium_data = sorted(
        medium_data, key=operator.itemgetter('level'), reverse=False)
    if request.values.get('action', '') == 'download':
        return write_client_excel(medium_data, year)
    return tpl('/data_query/medium/index.html', medium_data=medium_data, medium_id=medium_id,
               year=year, params="?medium_id=%s&year=%s" % (
                   medium_id, str(year)),
               s_mediums=Medium.all())
开发者ID:giveme168,项目名称:braavos,代码行数:102,代码来源:medium.py

示例10: GetContext

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
 def GetContext(self):
     tUser = self.GetUser()
     
     tCustomerOrders = []
     tOrderData = {}
     tContext = {}
     
     tOrder = Order()
     tCustomer = Customer()
     tIpHandler = IpLookup()
     tIpInfo = IpInfo()
     
     tDeliveryAgent = Agent()
     tRefundAgent = Agent()
     tAssignedAgent = Agent()
     
     tPriceDic = PriceContainer.GetCurrentPriceDic()
     tCountryDic = CountryContainer.GetCurrentCountryCodes()
     tOrderKey = str(urllib.unquote(self.request.get('key')))
     
     if(tOrderKey != None and len(tOrderKey) > 0):
         tOrder = Order.get(tOrderKey)
     if(tOrder):
         tOrderHandler = OrderHandler()
         
         tResultDictionary = {}
         tPaypalPayload = {}        
         tPayload = {}
         
         tUrl = "https://api-3t.paypal.com/nvp"
         tOperation = "GetTransactionDetails"            
         tCustomer = Customer.get(tOrder.orderCustomer)
                     
         # disabled to try to trace the "empty order" bug
         #if tOrder.orderVerificationCode is None:
             #tOrder.orderVerificationCode = str(uuid.uuid4())
             #tOrder.put()                    
         
         try:
             tIpInfo = tIpHandler.GetIp(tOrder.orderIp)[0]
         except:
             tIpInfo.ipCountry = "Loading"
             tIpInfo.ipState = "Loading"
             tIpInfo.ipHost = "Loading"
             tIpInfo.ipProxy = "Loading"
             tIpInfo.ipIsp = "Loading"
             tIpInfo.ipType = "Loading"
         
         if (tIpInfo.ipProxy == ""):
             tIpInfo.ipProxy = 'No Proxy'
         tContext['tDisplayDeliver'] = 'True'
                     
         #Get Paypal Information
         tPaypalPayload['METHOD'] = tOperation
         tPaypalPayload['TRANSACTIONID'] = tOrder.orderTransactionId
         
         #logging.debug("Order Paypal Email: " + tOrder.orderPaypalEmail)
         
         try:
             tPayloadEncoded = tOrderHandler.GeneratePayload(tPaypalPayload)
             request_cookies = mechanize.CookieJar()
             request_opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(request_cookies))
             request_opener.addheaders = [('Content-Type', 'application/x-www-form-urlencoded')]
             mechanize.install_opener(request_opener)
             tResponse = mechanize.urlopen(url = tUrl, timeout = 25.0, data = tPayloadEncoded)
         except: 
             tContext['error'] = 'Unable to Connect to Paypal, Try Refreshing'
             tContext['showerror'] = 'True'
             #tmpl = os.path.join(os.path.dirname(__file__), '../views/order.html')
             #self.response.out.write(render(tmpl, tContext))
             return tContext
             
         tResult = str(urllib.unquote(tResponse.read()))
         tResultSplit = tResult.split('&')
         
         for tPair in tResultSplit:
             tSplitPair = tPair.split("=")
             try:
                 tResultDictionary[tSplitPair[0]] = tSplitPair[1]
                 #logging.debug(tSplitPair[0] + "    " + tSplitPair[1])
             except:
                 logging.error("Error splitting item: " + str(tPair))
         
         if('COUNTRYCODE' in tResultDictionary.keys()):
             tCountryCode = tResultDictionary['COUNTRYCODE']
             tPaypalCountry = tCountryDic[tCountryCode]
         else:
             tPaypalCountry = 'UNKNOWN'
             
         tOrderData['paypalcountry'] = tPaypalCountry                    
         
         if 'PROTECTIONELIGIBILITYTYPE' in tResultDictionary.keys():
             tProtectionEligibility = tResultDictionary['PROTECTIONELIGIBILITYTYPE']
             
             if tProtectionEligibility == 'ItemNotReceivedEligible,UnauthorizedPaymentEligible':
                 tProtectionEligibility = 'Eligible'
                 
             if tProtectionEligibility != 'Eligible':
                 tProtectionEligibility = 'Not Eligible'
                 
#.........这里部分代码省略.........
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:103,代码来源:orderhandler.py

示例11: GetContext

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
    def GetContext(self):
        tOrder = Order()
        tOrderList = []
        tOrderAgentPairs = {}
        tOrderDataDict = {}
        tPaypalOrder = PaypalOrder()
        tStringOffset = self.request.get("offset")
        if len(tStringOffset) > 0:
            tOffset = int(tStringOffset)
        else:
            tOffset = 0

        tOrderQuery = Order.all()
        tOrderQuery.filter("orderIsGenerated", False)
        tOrderQuery.order("-orderCreated")
        tOrderList = tOrderQuery.fetch(10, offset=tOffset)

        tCurrentEocPrices = PriceContainer.GetCurrentPriceDic()
        tCurrent07Prices = PriceContainer.GetCurrentPriceDic07()

        tSkip07 = False

        if tOrder.orderGoldType != None:
            if tOrder.orderGoldType in ("eoc", "07") is not True:
                tOrder.orderGoldType = "UNKNOWN"
        else:
            tOrder.orderGoldType = "UNKNOWN"

        for tOrder in tOrderList:

            if tOrder.orderSimpleGoldAmount in tCurrentEocPrices.keys():
                if str(tOrder.orderCost) == str(tCurrentEocPrices[tOrder.orderSimpleGoldAmount]):
                    tOrder.orderGoldType = "eoc"
                    tSkip07 = True

            if not tSkip07:
                if tOrder.orderSimpleGoldAmount in tCurrent07Prices.keys():
                    if str(tOrder.orderCost) == str(tCurrent07Prices[tOrder.orderSimpleGoldAmount]):
                        tOrder.orderGoldType = "07"
            # tOrder.orderSimpleGoldAmount = tOrder.orderSimpleGoldAmount + ' ' + str(tOrder.orderGoldType)

            tOrderAgentPairs[str(tOrder.orderAssignedAgent)] = Agent.GetAgentByEmail(
                tOrder.orderAssignedAgent
            ).agentNickName

        if tOffset == 0:
            tPrev = tOffset
        else:
            tPrev = tOffset - 10
        tOffset = tOffset + 10
        tNext = tOffset

        tOffset = str(tOffset)
        tNext = str(tNext)
        tPrev = str(tPrev)

        tAgent = tPaypalOrder.GetAssignedAgent()

        if tAgent != "No Agent Online":
            tAgent = Agent.GetAgentByEmail(tAgent).agentNickName

        tContext = {
            "orders": tOrderList,
            "agents": tOrderAgentPairs,
            "next": tNext,
            "prev": tPrev,
            "offset": tOffset,
            "agent": tAgent,
        }
        return tContext
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:72,代码来源:paypal.py

示例12: ProcessOrder

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
    def ProcessOrder(self, pArgumentDic):
        tOrderHandler = OrderHandler()
        tCustomerHandler = CustomerHandler()
        tCustomer = Customer()
        tPaypalOrder = PaypalOrder()
        tArgumentDic = pArgumentDic

        # Assign Values from POST from Paypal IPN
        tTransactionId = tArgumentDic["txn_id"]
        tAlphaMatch = re.compile("[^A-Za-z0-9]+")
        tAlphaSpaceMatch = re.compile("[^A-Za-z0-9 ]+")

        # Short circuits the order process for special PA page
        if "payer_email" in tArgumentDic.keys():
            if tArgumentDic["payer_email"] == "[email protected]":
                tPaypalOrder.ProcessPlayerAuctions(tArgumentDic)
                return

        try:
            tGoldAmount = tArgumentDic["option_name7"]
        except:
            tGoldAmount = ""

        try:
            tCustomerFirstName = tAlphaSpaceMatch.sub("", tArgumentDic["first_name"])
        except:
            tCustomerFirstName = ""

        try:
            tCustomerLastName = tAlphaSpaceMatch.sub("", tArgumentDic["last_name"])
        except:
            tCustomerLastName = ""

        try:
            tCustomerName = tAlphaSpaceMatch.sub("", tArgumentDic["option_name1"])
        except:
            tCustomerName = ""

        try:
            tEmail = tArgumentDic["option_name2"]
        except:
            tEmail = ""
        tPaypalEmail = str(tArgumentDic["payer_email"]).lower()
        try:
            tMobilePhone = tArgumentDic["option_name3"]
            tMobilePhone = re.sub(r"\D", "", tMobilePhone)
        except:
            tMobilePhone = ""
        try:
            tRsName = tArgumentDic["option_name4"].strip().lower()
            tRsName = tRsName.replace(" ", "_")
            tRsName = tRsName.replace("-", "_")
        except:
            tRsName = ""
        try:
            tCombatLevel = ""
        except:
            tCombatLevel = ""

        # try:
        # tReferCode = str(tArgumentDic['option_name5']).strip()
        # except:
        tReferCode = ""

        try:
            tPromotionCode = str(tArgumentDic["option_name5"]).strip()
        except:
            tPromotionCode = ""

        tOrderIp = tArgumentDic["custom"]
        tMembers = ""

        try:
            tOrderQuery = Order.all().filter("orderTransactionId", tTransactionId)
            tOrder = tOrderQuery.fetch(1)[0]
        except:
            tOrder = Order()

        if "fake" in tArgumentDic.keys():
            # logging.debug('Fake key hit')
            # logging.debug(str(tArgumentDic['fake']))
            if tArgumentDic["fake"] == "True":
                tOrder.orderIsGenerated = True

        tOrder.orderFormName = tCustomerName
        tOrder.orderCombatLevel = tCombatLevel

        if len(tGoldAmount) == 0:
            tUrl = "https://api-3t.paypal.com/nvp"
            # tOperation = "AddressVerify"
            tOperation = "GetTransactionDetails"
            # Get Paypal Information
            # tPaypal = PaypalTrigger()
            tResultDictionary = {}
            tPaypalPayload = {}
            tPayload = {}
            tPaypalPayload["METHOD"] = tOperation
            tPaypalPayload["TRANSACTIONID"] = tTransactionId

            tPayloadEncoded = tOrderHandler.GeneratePayload(tPaypalPayload)
#.........这里部分代码省略.........
开发者ID:Kenneth-Posey,项目名称:kens-old-projects,代码行数:103,代码来源:paypal.py

示例13: index

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import all [as 别名]
def index():
    query_type = int(request.args.get('query_type', 4))
    query_month = request.args.get('query_month', '')
    page = int(request.args.get('page', 1))
    if query_month:
        query_month = datetime.datetime.strptime(query_month, '%Y-%m')
    else:
        query_month = datetime.datetime.strptime(
            datetime.datetime.now().strftime('%Y-%m'), '%Y-%m')
    # 全部客户订单
    if query_type == 1:
        query_orders = [o for o in ClientOrder.all() if o.client_end.strftime('%Y-%m') >=
                        query_month.strftime('%Y-%m') and o.contract_status in ECPM_CONTRACT_STATUS_LIST]
        orders = [{'agent_name': o.agent.name, 'client_name': o.client.name, 'campaign': o.campaign,
                   'start': o.client_start, 'end': o.client_end, 'money': o.money} for o in query_orders]
    # 全部媒体订单
    elif query_type == 2:
        query_orders = [o for o in Order.all() if o.medium_end.strftime('%Y-%m') >=
                        query_month.strftime('%Y-%m') and o.contract_status in ECPM_CONTRACT_STATUS_LIST]
        orders = [{'medium_name': o.medium.name, 'campaign': o.campaign, 'start': o.medium_start,
                   'end': o.medium_end, 'money': o.medium_money} for o in query_orders]
    # 全部关联豆瓣订单
    elif query_type == 3:
        query_orders = [o for o in AssociatedDoubanOrder.all() if o.end_date.strftime('%Y-%m') >=
                        query_month.strftime('%Y-%m') and o.contract_status in ECPM_CONTRACT_STATUS_LIST]
        orders = [{'jiafang_name': o.jiafang_name, 'client_name': o.client.name, 'campaign': o.campaign,
                   'start': o.start_date, 'end': o.end_date, 'money': o.money} for o in query_orders]
    # 全部直签豆瓣订单
    else:
        query_orders = [o for o in DoubanOrder.all() if o.client_end.strftime('%Y-%m') >=
                        query_month.strftime('%Y-%m') and o.contract_status in ECPM_CONTRACT_STATUS_LIST]
        orders = [{'agent_name': o.agent.name, 'client_name': o.client.name, 'campaign': o.campaign,
                   'start': o.client_start, 'end': o.client_end, 'money': o.money} for o in query_orders]
    th_count = 0
    th_obj = []
    for order in orders:
        if order['money']:
            pre_money = float(order['money']) / \
                ((order['end'] - order['start']).days + 1)
        else:
            pre_money = 0
        monthes_pre_days = get_monthes_pre_days(query_month, datetime.datetime.fromordinal(order['start'].toordinal()),
                                                datetime.datetime.fromordinal(order['end'].toordinal()))
        order['order_pre_money'] = [{'month': k['month'].strftime('%Y-%m'),
                                     'money': '%.2f' % (pre_money * k['days'])}
                                    for k in monthes_pre_days]
        if len(monthes_pre_days) > th_count:
            th_obj = [
                {'month': k['month'].strftime('%Y-%m')}for k in monthes_pre_days]
            th_count = len(monthes_pre_days)
    if 'excel' == request.args.get('extype', ''):
        if query_type == 1:
            filename = (
                "%s-%s.xls" % (u"月度客户订单金额", datetime.datetime.now().strftime('%Y%m%d%H%M%S'))).encode('utf-8')
        elif query_type == 2:
            filename = (
                "%s-%s.xls" % (u"月度媒体订单金额", datetime.datetime.now().strftime('%Y%m%d%H%M%S'))).encode('utf-8')
        elif query_type == 3:
            filename = ("%s-%s.xls" % (u"月度关联豆瓣订单金额",
                                       datetime.datetime.now().strftime('%Y%m%d%H%M%S'))).encode('utf-8')
        else:
            filename = ("%s-%s.xls" % (u"月度直签豆瓣订单金额",
                                       datetime.datetime.now().strftime('%Y%m%d%H%M%S'))).encode('utf-8')
        xls = write_excel(orders, query_type, th_obj)
        response = get_download_response(xls, filename)
        return response
    return tpl('/data_query/order/index.html',
               orders=orders,
               page=page,
               query_type=query_type,
               query_month=query_month.strftime('%Y-%m'),
               th_obj=th_obj)
开发者ID:giveme168,项目名称:braavos,代码行数:74,代码来源:order.py


注:本文中的models.order.Order.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。