github.com/jincm/wesharechain@v0.0.0-20210122032815-1537409ce26a/server/block/operation/order.py (about)

     1  #!/usr/bin/python
     2  # -*- coding: utf-8 -*-
     3  from operation import Base
     4  from db.example.order import OrderDB
     5  
     6  class OrderOp(Base):
     7      def __init__(self):
     8          super(OrderOp, self).__init__()
     9          self.exampledb = OrderDB()
    10  
    11      def create(self,  commodity_code='', order_type='', original_price='', real_price=''):
    12          kwargs = {
    13              'commodity_code': commodity_code,
    14              'order_type': order_type,
    15              'original_price':  float(original_price),
    16              'real_price': float(real_price)
    17          }
    18          return self.exampledb.create(**kwargs)
    19  
    20      def update(self, id='', status=''):
    21          kwargs = {'status': status}
    22          return self.exampledb.update(id, **kwargs)
    23  
    24      def lists(self, offset=0, limit=1000, id='', order_type='', status='', **kwargs):
    25          filters = {
    26              'offset': offset,
    27              'limit': limit
    28          }
    29          if id:
    30              filters.update({"id": id})
    31          if order_type:
    32              filters.update({"order_type": order_type})
    33          if status:
    34              filters.update({"status": status})
    35  
    36          order_list = self.exampledb.lists(offset, limit, **filters)
    37          return order_list