本文整理汇总了Python中models.order.Order.put方法的典型用法代码示例。如果您正苦于以下问题:Python Order.put方法的具体用法?Python Order.put怎么用?Python Order.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.order.Order
的用法示例。
在下文中一共展示了Order.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import put [as 别名]
def get(self):
tCode = re.sub(r"\W", "", self.request.get("code")).lower()
tOrderId = self.request.get("id")
logging.debug(tCode)
tOrder = Order()
# tOrder.orderVerificationCode
tOrderQuery = Order().all()
tOrderQuery.filter("orderVerificationCode", tCode)
if tOrderId:
tOrderQuery.filter("orderTransactionId", tOrderId)
tOrderList = tOrderQuery.fetch(limit=1)
logging.debug(str(tOrderList))
tSave = False
if tOrderList is not None:
try:
tOrder = tOrderList[0]
tOrder.orderIsVerified = True
tSave = True
except:
if len(tOrderList) > 0:
tOrder = tOrderList
tOrder.orderIsVerified = True
tSave = True
if tSave:
try:
tOrder.put()
except:
pass
示例2: post
# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import put [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")
示例3: post
# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import put [as 别名]
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'
#.........这里部分代码省略.........
示例4: ProcessOrder
# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import put [as 别名]
#.........这里部分代码省略.........
tOrder.orderPaypalFirstName = tCustomerFirstName
tOrder.orderPaypalLastName = tCustomerLastName
tOrder.orderCost = float(tArgumentDic["payment_gross"])
tOrder.orderCustomerPaypalId = tArgumentDic["payer_id"]
tOrder.orderPaypalEmail = str(tPaypalEmail).lower()
tAssignedAgentNick = tPaypalOrder.GetAssignedAgent(tOrder)
tOrder.orderAssignedAgent = tAssignedAgentNick
# logging.debug("Order assigned to agent: " + str(tAssignedAgentNick))
tOrder.orderReferralCode = tReferCode
tOrder.orderDeliver = "False"
if tOrder.orderVerificationCode == None or tOrder.orderVerificationCode == "":
tOrder.orderVerificationCode = re.sub(r"\W", "", str(uuid.uuid4())).lower()
tCurrentEocPrices = PriceContainer.GetCurrentPriceDic()
tCurrent07Prices = PriceContainer.GetCurrentPriceDic07()
tSkip07 = False
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"
tOrderKey = str(tOrder.put())
# logging.debug("Order Saved: " + str(tOrderKey))
taskqueue.add(url="/iplookup", countdown=1, params={"ip": tOrderIp, "transid": tTransactionId})
tUsedBonus = []
tCustomerList = tCustomerHandler.GetCustomerByPpid(tOrder.orderCustomerPaypalId)
if len(tCustomerList) == 1:
tCustomer = tCustomerList[0]
tIpList = tCustomer.customerIpAddresses
tIpList.append(tOrderIp)
tCustomer.customerIpAddresses = tIpList
tOrderList = tCustomer.customerOrders
tOrderList.append(tOrderKey)
tCustomer.customerOrders = tOrderList
tCustomer.customerOrderCount = int(tCustomer.customerOrderCount) + 1
# tUsedBonus = tCustomer.customerUsedBonus
tUsedBonus = Order.GetCustomerPromoCodes(tCustomer.customerPaypalId)
# tOrder.orderCustomer = str(tCustomer.key())
elif len(tCustomerList) == 0:
tCustomer.customerEmail = str(tOrder.orderPaypalEmail).lower()
tCustomer.customerName = tCustomerName
tCustomer.customerFirstName = tOrder.orderPaypalFirstName
tCustomer.customerLastName = tOrder.orderPaypalLastName
tCustomer.customerIpAddresses = [tOrderIp]
tCustomer.customerOrders = [tOrderKey]
tCustomer.customerOrderCount = 1
tCustomer.customerPhone = tMobilePhone
tCustomer.customerEmailVerified = False
示例5: cart_finalize
# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import put [as 别名]
def cart_finalize(seller):
T = {'sellername':seller}
helpers.template.get_user(T=T, path=request.path)
if not "user" in T:
flash(u'ログインしてから再度カートに追加してください', category='warning')
return redirect(url_for('cart_index', seller=seller))
# FIXME: ブラウザ2重起動によるセッション情報の変更検知
cart_cache_key = 'C-%s' % (T["user"].user_id())
cart = memcache.get(cart_cache_key)
if not cart or not seller in cart:
flash(u'カートが空です', category='warning')
return redirect(url_for('cart_index', seller=seller))
has_error = None
reserved = {}
for code, item in cart[seller].items():
stock = ProductStock.get_by_key_name("%s-%s" % (seller, code))
stock.quantity -= item['quantity']
if stock.quantity < 0:
has_error = code
break
stock.put()
reserved[code] = item['quantity']
if has_error:
for code, quatity in reserved.items():
stock = ProductStock.get_by_key_name("%s-%s" % (seller, code))
stock.quantity += quantity
stock.put()
flash(u'商品コード %s の在庫がなくなりました' % has_error,
category='warning')
return redirect(url_for('cart_index', seller=seller))
content = {"cart" : helpers.template.calc_cart(cart[seller]),
"buyer": cart["BUYER"]}
key_name = "-".join([seller,
T["user"].user_id(),
datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S'),
str(random.randint(0,256))])
order = Order(key_name = key_name,
cart = unicode(json.dumps(helpers.template.calc_cart(cart[seller]))),
seller = seller,
status = 0)
order.buyer_mail = cart["BUYER"]["mail"]
order.buyer_note = cart["BUYER"]["note"]
order.buyer_ship_country = cart["BUYER"]["ship"]['country']
order.buyer_ship_postalcode = cart["BUYER"]["ship"]['postalcode']
order.buyer_ship_pref = cart["BUYER"]["ship"]['pref']
order.buyer_ship_city = cart["BUYER"]["ship"]['city']
order.buyer_ship_addr1 = cart["BUYER"]["ship"]['addr1']
order.buyer_ship_addr2 = cart["BUYER"]["ship"]['addr2']
order.put()
del(cart[seller])
memcache.set(cart_cache_key, cart, 86400)
return redirect(url_for('cart_finished', seller=seller))