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


Python Shop.get方法代码示例

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


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

示例1: post

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
    def post(self):
        
        result = {'status' : False, 'msg' : 0}
        user = self.get_current_user()
        
        if user:
            sid = int(self.get_argument("sid", 0))
            said = int(self.get_argument("said", 0))
            num = int(self.get_argument("num", 1))
            
            #判断商品是否下架
            if sid > 0 and said > 0 and num > 0:
                try:
                    Shop.get(id = sid)
                    ShopAttr.get(id = said)
                    
                    #判断是否有未使用的订单或生成新订单
                    try:
                        try:
                            order = Order.get(uid = user.id, status = 0)
                        except:
                            order = Order()
                            order.uid = user.id
                            order.mobile = user.mobile
                            order.ordered = int(time.time())
                            try:
                                order.save()
                            except Exception, ex:
                                logging.error(ex)
                        
                        try:
                            orderitem = OrderItem.get(oid = order.id, sid = sid, said = said)
                        except:
                            orderitem = OrderItem()

                        orderitem.oid = order.id
                        orderitem.sid = sid
                        orderitem.said = said
                        orderitem.num = orderitem.num + num
                        orderitem.save()
                        
                        result['status'] = True
                        result['msg'] = 200
                        
                    except Exception, ex:
                        logging.error(ex)
                        result['msg'] = 500
                    
                except:
开发者ID:yanjinjin,项目名称:wxshop,代码行数:51,代码来源:ajax.py

示例2: post

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
    def post(self, said):
        try:
            shopattr = ShopAttr.get(id = said)
            shop = Shop.get(id = shopattr.sid)
        except:
            self.flash("此商品不存在")
            self.redirect("/admin/shops")
            return
        
        name = self.get_argument("name", None)
        price = float(str(self.get_argument("price", 0.0)))
        order = int(self.get_argument("order", 1))

        shopattr.name = name
        shopattr.price = price
        shopattr.order = order

        try:
            shopattr.validate()
            shopattr.save()
            self.flash(u"规格%s修改成功" % name)
            self.redirect("/admin/shopattrs/%d" % int(shopattr.sid) )
            return
        except Exception, ex:
            self.flash(str(ex))
开发者ID:FashtimeDotCom,项目名称:cakeshop,代码行数:27,代码来源:admin.py

示例3: get

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
 def get(self, oid):
     orderitems = []
     price = 0.0
     credit = 0.0
     order = None
     try:
         order = Order.get(id = oid)
         print order.id
         for orderitem in OrderItem.select().where(OrderItem.oid == order.id).dicts():
             try:
                 orderitem['shop'] = Shop.get(id = orderitem['sid'])
                 _oiprice = orderitem['shop'].price
                 
                 if orderitem['said'] > 0:
                     orderitem['shopattr'] = ShopAttr.get(id = orderitem['said'])
                     if orderitem['shop'].cid == 1:
                         _oicredit = orderitem['shopattr'].price
                         credit = credit + _oicredit * orderitem['num']
                         _oiprice = orderitem['shopattr'].price
                     else:
                         _oiprice = orderitem['shopattr'].price
                 else:
                     _oiprice = float(_oiprice)
                     
                 orderitems.append(orderitem)
                 price = price + float(_oiprice) * orderitem['num']
             except:
                 pass
         print price
     except:
         pass
     
     self.render("/responsive/user_confirmorder.html", order = order, credit = credit, orderitems = orderitems)
开发者ID:yanjinjin,项目名称:wxshop,代码行数:35,代码来源:user.py

示例4: get

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
 def get(self, sid):
     try:
         shop = Shop.get(id = sid)
     except:
         self.flash("此商品不存在")
         self.redirect("/admin/shops")
         return
     
     self.render('admin/addshopattr.html', shop = shop, maxorder = ShopAttr.maxorder(sid))
开发者ID:FashtimeDotCom,项目名称:cakeshop,代码行数:11,代码来源:admin.py

示例5: get

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
 def get(self):
     user = self.get_current_user()
     status = self.get_argument("status", None)
     
     ft = (Order.uid == user.id)
     
     if status:
         ft = ft & (Order.status == status)
     
     page = int(self.get_argument("page", 1))
     pagesize = self.settings['admin_pagesize']
     
     oq = Order.select().where(ft)
     total = oq.count()
     
     orders = []
     for order in oq.paginate(page, pagesize).dicts():
         order['orderitems'] = []
         
         for orderitem in OrderItem.select().where(OrderItem.oid == order['id']).dicts():
             
             try:
                 orderitem['shop'] = Shop.get(id = orderitem['sid'])
                 if orderitem['said'] > 0:
                     orderitem['shopattr'] = ShopAttr.get(id = orderitem['said'])
             except:
                 break
             
             order['orderitems'].append(orderitem)
         
         if order['orderitems']:
             orders.append(order)
             
         else:
             Order.delete().where(Order.id == order['id']).execute()
             
             try:
                 user = User.get(id = user.id)
                 
                 if user.order > 0:
                     user.order = user.order - 1
                     user.save()
                     self.session['user'] = user
                     self.session.save()
             except:
                 pass
             
     
     self.render('user/order.html', orders = orders, total = total, page = page, pagesize = pagesize)
开发者ID:FashtimeDotCom,项目名称:cakeshop,代码行数:51,代码来源:user.py

示例6: get

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
 def get(self):
     orderitems = []
     user = self.current_user
     
     order = None
     
     distributions = self.get_distributions()
     price = 0.0
     credit = 0.0
     
     try:
         order = Order.get(uid = user.id, status = 0)
         
         try:
             mobile = '18014349809'
             sendmsg(self.settings, mobile, '新订单')
         except:
             pass
             
         for orderitem in OrderItem.select().where(OrderItem.oid == order.id).dicts():
             try:
                 orderitem['shop'] = Shop.get(id = orderitem['sid'])
                 _oiprice = orderitem['shop'].price
                 
                 if orderitem['said'] > 0:
                     orderitem['shopattr'] = ShopAttr.get(id = orderitem['said'])
                     if orderitem['shop'].cid == 1:
                         _oicredit = orderitem['shopattr'].price
                         credit = credit + _oicredit * orderitem['num']
                     else:
                         _oiprice = orderitem['shopattr'].price
                 else:
                     _oiprice = float(_oiprice)
                 
                 orderitems.append(orderitem)
                 
                 price = price + _oiprice * orderitem['num']
                 
             except:
                 pass
         order.price = price
         order.save()
         
     except:
         pass
     
     if orderitems:
         self.render("shop/settle.html", tmday = datetime.date.today() + datetime.timedelta(days=1), order  = order, orderitems = orderitems, distributions = distributions.values(), credit = credit)
开发者ID:finalbattle,项目名称:cakeshop,代码行数:50,代码来源:shop.py

示例7: get

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
    def get(self):
        user = self.get_current_user()

        page = int(self.get_argument("page", 1))
        pagesize = self.settings["admin_pagesize"]

        cq = Consult.select().where(Consult.uid == user.id)
        total = cq.count()
        consults = []
        for consult in cq.paginate(page, pagesize).order_by(Consult.replyed.desc(), Consult.posted.desc()).dicts():
            try:
                shop = Shop.get(id=consult["sid"])
            except:
                shop = Shop
            consult["shop"] = shop
            consults.append(consult)

        self.render("user/consult.html", consults=consults, total=total, page=page, pagesize=pagesize)
开发者ID:gislite,项目名称:cakeshop,代码行数:20,代码来源:user.py

示例8: post

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
 def post(self):
     order = None
     user = self.get_current_user()
     
     try:
         order = Order.get(uid = user.id, status = 0)
         
         mobile = self.get_argument("mobile", user.mobile)
         uaid = self.get_argument("uaid", None)
         distrid = self.get_argument("distrid", None)
         day = self.get_argument("day", datetime.date.today() + datetime.timedelta(days=1))
         hour = int(self.get_argument("hour", 10))
         payment = self.get_argument("payment", 0)
         message = self.get_argument("message", "")
         isinvoice = self.get_argument("isinvoice", 0)
         invoicesub = self.get_argument("invoicesub", 0)
         invoicename = self.get_argument("invoicename", "")
         invoicecontent = self.get_argument("payment", 1)
         shippingprice = self.get_argument("shippingprice", 0.0)
         
         if uaid and distrid:
             try:
                 distrib = Distribution.get(id = distrid)
                 shippingprice = distrib.price
             except:
                 pass
             
             order.mobile = mobile
             order.uaid = uaid
             order.distrid = distrid
             order.distribbed = "%s %d:00:00" % (str(day), hour)
             order.payment = payment
             order.message = message
             
             order.isinvoice = isinvoice
             
             if isinvoice:
                 order.invoicesub = invoicesub
                 order.invoicename = invoicename
                 order.invoicecontent = invoicecontent
             
             order.shippingprice = shippingprice
             
             order.save()
             
             
                 
             body = ""
             for orderitem in OrderItem.select().where(OrderItem.oid == order.id).dicts():
                     
                 try:
                     shop = Shop.get(id = orderitem['sid'])
                         
                     sname = ""
                     if orderitem['said'] > 0:
                         shopattr = ShopAttr.get(id = orderitem['said'])
                         
                         if shop.cid == 1:
                             credits = shopattr.price * orderitem['num']
                             
                             if credits > user.credit:
                                 OrderItem.delete().where(OrderItem.id == orderitem['id']).execute()
                             else:
                                 user = User.get(id = user.id)
                                 user.credit = user.credit - credits
                                 user.save()
                                 
                                 clog = CreditLog()
                                 clog.uid = user.id
                                 clog.mobile = user.mobile
                                 clog.ctype = 1
                                 clog.affect = int(credits)
                                 clog.log = u"购买" + shop.name
                                 clog.save()
                                 
                                 self.session['user'] = user
                                 self.session.save()
                                 
                         sname = shopattr.name
                         
                     #body = body + shop.name + " " + sname + " " + str(orderitem['num']) + "个\n"
                     body = body + shop.name + " " + sname + " " + str(orderitem['num'])
                 except Exception, ex:
                     logging.error(ex)
             
             tn = "U%d-S%d" % (user.id, order.id)
             
             if int(payment) == 1:
                 self.redirect("/alipay/topay?tn=%s&body=%s&price=%f" % (tn, body, order.price))
             else:
                 self.flash(u"请选择地址和收货方式")
                 self.redirect("/user/orders")
         else:
开发者ID:finalbattle,项目名称:cakeshop,代码行数:95,代码来源:shop.py

示例9: get

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import get [as 别名]
 def get(self):
     orderitems = []
     user = self.current_user
     
     order = None
     
     distributions = self.get_distributions()
     price = 0.0
     credit = 0.0
     
     try:
         order = Order.get(uid = user.id, status = 0)
         print order.id
         '''
         try:
             mobile = '18014349809'
             sendmsg(self.settings, mobile, '新订单')
         except:
             pass
         '''    
         for orderitem in OrderItem.select().where(OrderItem.oid == order.id).dicts():
             try:
                 orderitem['shop'] = Shop.get(id = orderitem['sid'])
                 _oiprice = orderitem['shop'].price
                 
                 if orderitem['said'] > 0:
                     orderitem['shopattr'] = ShopAttr.get(id = orderitem['said'])
                     if orderitem['shop'].cid == 1:
                         _oicredit = orderitem['shopattr'].price
                         credit = credit + _oicredit * orderitem['num']
                         _oiprice = orderitem['shopattr'].price
                     else:
                         _oiprice = orderitem['shopattr'].price
                 else:
                     _oiprice = float(_oiprice)
                     
                 orderitems.append(orderitem)
                 price = price + float(_oiprice) * orderitem['num']
             except:
                 pass
         print price
         price_pay = str(int(price*100))
         print 'price_pay:' + price_pay
         openid = user.openid
         print 'wx_pay:'+ openid
         jsApi = JsApi_pub()
         unifiedOrder = UnifiedOrder_pub()
         unifiedOrder.setParameter("openid",openid) #商品描述
         unifiedOrder.setParameter("body","菜市优品购物") #商品描述
         timeStamp = time.time()
         print timeStamp
         out_trade_no = "{0}{1}".format(WxPayConf_pub.APPID, int(timeStamp*100))
         unifiedOrder.setParameter("out_trade_no", out_trade_no) #商户订单号
         print 'out_trade_no:' + out_trade_no
         Order.update(wxid = out_trade_no).where(Order.id == order.id).execute()
         unifiedOrder.setParameter("total_fee", price_pay) #总金额
         print WxPayConf_pub.NOTIFY_URL
         unifiedOrder.setParameter("notify_url", WxPayConf_pub.NOTIFY_URL) #通知地址 
         unifiedOrder.setParameter("trade_type", "JSAPI") #交易类型
         
         prepay_id = unifiedOrder.getPrepayId()
         jsApi.setPrepayId(prepay_id)
         jsApiParameters = jsApi.getParameters()
         print jsApiParameters
         appid = json.loads(jsApiParameters).get("appId")
         timestamp = json.loads(jsApiParameters).get("timeStamp")
         noncestr = json.loads(jsApiParameters).get("nonceStr")
         package = json.loads(jsApiParameters).get("package")
         signtype = json.loads(jsApiParameters).get("signType")
         paysign = json.loads(jsApiParameters).get("paySign")
         print appid + timestamp + noncestr + package + signtype +paysign
         if orderitems:
             self.render("/responsive/wxpay.html", tmday = datetime.date.today() + datetime.timedelta(days=1), order  = order, orderitems = orderitems, distributions = distributions.values(), credit = credit, appid = appid, timestamp = timestamp, noncestr = noncestr, package = package, signtype = signtype, paysign = paysign)
     except:
         pass
开发者ID:yanjinjin,项目名称:wxshop,代码行数:77,代码来源:shop.py


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