コード例 #1
0
def save_order_db():
    order = request.get_json()['order']

    date = int(datetime.datetime.now().timestamp() * 1000)
    items = order['items']
    total = order['total']

    OrderManager.save_order(int(current_user.get_id()), date, items, total, 0)

    return "1"
コード例 #2
0
def get_orders_by_date(time_from, time_to):

    orders = OrderManager.get_orders_by_date(user_id=int(
        current_user.get_id()),
                                             time_from=time_from,
                                             time_to=time_to)
    orders_dicts = [order.to_dict() for order in orders]

    return json.dumps(orders_dicts, ensure_ascii=False).encode('utf8')
コード例 #3
0
def get_orders_today():
    today = datetime.date.today()
    midnight = datetime.datetime.combine(today, datetime.datetime.min.time())
    time_from = int(midnight.timestamp()) * 1000
    day_in_millis = 86400000
    time_to = time_from + day_in_millis

    orders = OrderManager.get_orders(time_from=time_from, time_to=time_to)
    orders_dicts = [order.to_dict() for order in orders]

    return json.dumps(orders_dicts, ensure_ascii=False).encode('utf8')
コード例 #4
0
def get_orders_filter_admin():
    time_from = request.args.get("time_from")
    time_to = request.args.get("time_to")
    name = request.args.get("name")
    order_id = request.args.get("num")

    orders = OrderManager.get_orders(user_name=name,
                                     order_id=order_id,
                                     time_from=time_from,
                                     time_to=time_to)
    orders_dicts = [order.to_dict() for order in orders]

    return json.dumps(orders_dicts, ensure_ascii=False).encode('utf8')
コード例 #5
0
def get_orders_admin(time_from, time_to):
    orders = OrderManager.get_orders(time_from=time_from, time_to=time_to)
    orders_dicts = [order.to_dict() for order in orders]

    return json.dumps(orders_dicts, ensure_ascii=False).encode('utf8')
コード例 #6
0
def get_orders_filter(order_id):
    order = OrderManager.get_order_by_id(int(current_user.get_id()), order_id)
    order_dict = order.to_dict()

    return json.dumps(order_dict, ensure_ascii=False).encode('utf8')
コード例 #7
0
def get_all_orders():
    orders = OrderManager.get_orders(user_id=int(current_user.get_id()))
    orders_dicts = [order.to_dict() for order in orders]

    return json.dumps(orders_dicts, ensure_ascii=False).encode('utf8')