def post(self, *args, **kwargs): product_id = self.get_argument(u"product_id") buy_count = self.get_argument(u"buyCount") user_id = self.get_secure_cookie(u"user_id") product_id = int(product_id) buy_count = int(buy_count) user_id = int(user_id) #首先获得商品的单价,再获得用户所有的支付宝账户 #print u'用户购买' accounts = get_user_accounts(user_id) #用户当前剩余金额 rem =0 product = get_product(product_id) for account in accounts: if account.balance < product.price*buy_count: pass else: by_transaction( user_id,product_id,buy_count ) user_pay(user_id,account.id,product.price*buy_count) self.redirect('/buy_history') break self.render('addAccount.html')
def post(self, *args, **kwargs): product_id = self.get_argument(u"product_id") buy_count = self.get_argument(u"buyCount") user_id = self.get_secure_cookie(u"user_id") product_id = int(product_id) buy_count = int(buy_count) user_id = int(user_id) #首先获得商品的单价,再获得用户所有的支付宝账户 #print u'用户购买' accounts = get_user_accounts(user_id) #用户当前剩余金额 rem = 0 product = get_product(product_id) for account in accounts: if account.balance < product.price * buy_count: pass else: by_transaction(user_id, product_id, buy_count) user_pay(user_id, account.id, product.price * buy_count) self.redirect('/buy_history') break self.render('addAccount.html')
def get(self,*args, **kwargs): user_id = self.get_secure_cookie("user_id") user_id = int(user_id) user_accounts = get_user_accounts(user_id) print user_accounts self.render('user_accounts.html',accounts=user_accounts)
def get(self, *args, **kwargs): user_id = self.get_secure_cookie("user_id") user_id = int(user_id) user_accounts = get_user_accounts(user_id) print user_accounts self.render('user_accounts.html', accounts=user_accounts)