Beispiel #1
0
    def select_order(self):
        inputs = self.getInput()
        if inputs.has_key('query'):
            return self.orders_list()

        try:
            price, product_id = inputs['product'].split(' ')
            product = Products.get(Products.id == int(product_id))
            order = int(inputs['order'])

            if order > 0:
                details = OrderDetails.create(
                    name = product.category.name +"   "+product.diameter,
                    product = product,
                    count = 1,
                    price = price,
                    ratio = 0.0,
                    order = order,
                )
                return web.seeother(self.makeUrl('/wap/edit_price_sheet', {'id': order}))
            else:
                ordersList = Orders.select().order_by(Orders.id.desc())
                self.privData['ORDERS_LIST'] = ordersList
                self.privData['PRICE'] = price
                self.privData['PRODUCT'] = product
                return self.display('select-order')
        except Exception, e:
            print e
            return self.error(msg='加入订单失败!')
Beispiel #2
0
 def confirm_select_order(self):
     inputs = self.getInput()
     try:
         product = Products.get(Products.id == int(inputs['product']))
         user =Users.get(Users.name == self.isLogin())
         price = inputs['price']
         if inputs.has_key('add'):
             order = Orders.create(
                 owner = user,
                 price = price,
                 description = product.category.name,
             )
         else:
             if not inputs.has_key('selected'):
                 return self.orders_list()
             order = Orders.get(Orders.id == int(inputs['selected']))
         
         details = OrderDetails.create(
             name = product.category.name + "   "+product.diameter,
             product = product,
             count = user,
             price = price,
             ratio = 0.0,
             order = order,
         )
         return web.seeother(self.makeUrl('/wap/edit_price_sheet', {'id': order.id}))
     except Exception, e:
         print 'exc',e
         return self.error(msg='保存订单失败!')
Beispiel #3
0
    def delete(self):
        inputParams = self.getInput()

        try:
            product = Products.get(Products.id == int(inputParams['id']))
            product.delete_instance()
        except Exception, e:
            return self.success(msg='删除失败: %s' % e, url=self.makeUrl('/admin/products/list'))
Beispiel #4
0
 def _get_trade_info(self, inputs, from_mobile):
     try:
         product = Products.get(Products.id == inputs.get("id",0))   
         total_fee = product.discount     
         count = int(inputs.get("count", 0))
         total_fee = total_fee*count 
     except Exception, e:
         raise e
Beispiel #5
0
    def update(self):
        inputParams= self.getInput() 
        product = Products.get(Products.id == int(inputParams['id']))

        try:
            product.name = inputParams['name']
            product.description = self.htmlunquote(inputParams['desc'])
            product.category = int(inputParams['category'])
            product.diameter = inputParams['diameter']
            product.price1 = inputParams['price1']
            product.price2 = inputParams['price2']
            product.type = int(inputParams['type'])
            product.save()
        except Exception, e:
            return self.error(msg = '修改失败: %s' % e, url=self.makeUrl('/admin/products/list'))