Exemple #1
0
 def POST(self):
     data = web.input()
     item_id = data.get('item_id', '')
     add_price = int(data.get('add_price', 10))
     if not item_id:
         return error(QFRET.PARAMERR, '未传商品信息')
     ritem_price = RedisString(REDIS_AUCTION_PREFIX % item_id, redis_client)
     current_price = ritem_price.get_number()
     item_dict = mongo_auction.item.find_one({'_id': ObjectId(item_id)})
     if not current_price:
         current_price = int(item_dict.get('init_price', 10))
         ritem_price.set(current_price)
     final_price = current_price + add_price
     # Redis 计入当前累加价格
     ritem_price.incrby(add_price)
     # Mongo 记录拍卖记录
     timenow = datetime.datetime.now()
     mongo_auction.auction_record.insert(dict(
         item_id=item_dict.get('_id'),
         bidders=self.user_id,
         owner=item_dict.get('user_id'),
         price=final_price,
         created=timenow,
     ))
     ret = {'price': final_price}
     return success(ret)
Exemple #2
0
 def POST(self):
     data = web.input()
     pname = data.get('pname')
     pv_obj = RedisString(REDIS_PV_PREFIX % pname, redis_client)
     num = pv_obj.incrby()
     return success({'num': num})