| Line 9... |
Line 9... |
| 9 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem,\
|
9 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem,\
|
| 10 |
Alerts, Order, BatchNoGenerator
|
10 |
Alerts, Order, BatchNoGenerator
|
| 11 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
11 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
| 12 |
TransactionServiceException, TransactionStatus, OrderStatus
|
12 |
TransactionServiceException, TransactionStatus, OrderStatus
|
| 13 |
import datetime
|
13 |
import datetime
|
| - |
|
14 |
import time
|
| 14 |
from elixir import *
|
15 |
from elixir import *
|
| 15 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
16 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
| 16 |
from sqlalchemy.sql.expression import and_, or_
|
17 |
from sqlalchemy.sql.expression import and_, or_
|
| 17 |
from shop2020.model.v1 import order
|
18 |
from shop2020.model.v1 import order
|
| 18 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
19 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| Line 318... |
Line 319... |
| 318 |
query = query.filter_by(Order.logistics_provider_id == provider_id)
|
319 |
query = query.filter_by(Order.logistics_provider_id == provider_id)
|
| 319 |
if warehouse_id != -1:
|
320 |
if warehouse_id != -1:
|
| 320 |
query = query.filter(Order.warehouse_id == warehouse_id)
|
321 |
query = query.filter(Order.warehouse_id == warehouse_id)
|
| 321 |
query = query.filter(and_(Order.status != OrderStatus.DELIVERY_SUCCESS, Order.status != OrderStatus.FAILED, \
|
322 |
query = query.filter(and_(Order.status != OrderStatus.DELIVERY_SUCCESS, Order.status != OrderStatus.FAILED, \
|
| 322 |
Order.status > OrderStatus.SHIPPED_FROM_WH))
|
323 |
Order.status > OrderStatus.SHIPPED_FROM_WH))
|
| - |
|
324 |
#Get last midnight time instead of current time as courier company would have sent the
|
| - |
|
325 |
#delivery records updated at least till midnight and not by the current time.
|
| - |
|
326 |
time_format = "%Y-%m-%d %H:%M:%S.%f"
|
| - |
|
327 |
t = time.strptime(str(datetime.datetime.now()), time_format)
|
| - |
|
328 |
midnightTime = datetime.datetime(*t[:3])
|
| 323 |
query = query.filter(Order.expected_delivery_time < datetime.datetime.now())
|
329 |
query = query.filter(Order.expected_delivery_time < midnightTime)
|
| 324 |
orders = query.all()
|
330 |
orders = query.all()
|
| 325 |
return orders
|
331 |
return orders
|
| 326 |
|
332 |
|
| 327 |
def get_line_items_for_order(order_id):
|
333 |
def get_line_items_for_order(order_id):
|
| 328 |
query = LineItem.query.filter(LineItem.order_id == order_id)
|
334 |
query = LineItem.query.filter(LineItem.order_id == order_id)
|