| Line 487... |
Line 487... |
| 487 |
return False
|
487 |
return False
|
| 488 |
|
488 |
|
| 489 |
def mark_orders_as_picked_up(provider_id, pickup_details):
|
489 |
def mark_orders_as_picked_up(provider_id, pickup_details):
|
| 490 |
for awb, pickup_timestamp in pickup_details.iteritems():
|
490 |
for awb, pickup_timestamp in pickup_details.iteritems():
|
| 491 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
491 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| 492 |
if order == None:
|
492 |
if order == None or order.status != OrderStatus.SHIPPED_FROM_WH:
|
| 493 |
#raise TransactionServiceException(102, "No order found for the awb: " + awb)
|
493 |
#raise TransactionServiceException(102, "No order found for the awb: " + awb)
|
| 494 |
continue
|
494 |
continue
|
| 495 |
order.status = OrderStatus.SHIPPED_TO_LOGST
|
495 |
order.status = OrderStatus.SHIPPED_TO_LOGST
|
| 496 |
order.statusDescription = "Order picked up by Courier Company"
|
496 |
order.statusDescription = "Order picked up by Courier Company"
|
| 497 |
order.pickup_timestamp = pickup_timestamp
|
497 |
order.pickup_timestamp = pickup_timestamp
|
| Line 504... |
Line 504... |
| 504 |
return orders_not_picked_up
|
504 |
return orders_not_picked_up
|
| 505 |
|
505 |
|
| 506 |
def mark_orders_as_delivered(provider_id, delivered_orders):
|
506 |
def mark_orders_as_delivered(provider_id, delivered_orders):
|
| 507 |
for awb, detail in delivered_orders.iteritems():
|
507 |
for awb, detail in delivered_orders.iteritems():
|
| 508 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
508 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| 509 |
if order == None:
|
509 |
if order == None or order.status not in [OrderStatus.SHIPPED_FROM_WH, OrderStatus.SHIPPED_TO_LOGST]:
|
| 510 |
continue
|
510 |
continue
|
| 511 |
#raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
511 |
#raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
| 512 |
order.status = OrderStatus.DELIVERY_SUCCESS
|
512 |
order.status = OrderStatus.DELIVERY_SUCCESS
|
| 513 |
order.statusDescription = "Order delivered"
|
513 |
order.statusDescription = "Order delivered"
|
| 514 |
order.delivery_timestamp, order.receiver = detail.split('|')
|
514 |
order.delivery_timestamp, order.receiver = detail.split('|')
|
| 515 |
session.commit()
|
515 |
session.commit()
|
| 516 |
|
516 |
|
| 517 |
def mark_orders_as_failed(provider_id, returned_orders):
|
517 |
def mark_orders_as_failed(provider_id, returned_orders):
|
| 518 |
for awb, detail in returned_orders.iteritems():
|
518 |
for awb, detail in returned_orders.iteritems():
|
| 519 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
519 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| - |
|
520 |
if order == None or order.status not in [OrderStatus.SHIPPED_FROM_WH, OrderStatus.SHIPPED_TO_LOGST]:
|
| 520 |
if order == None:
|
521 |
continue
|
| 521 |
raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
522 |
#raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
| 522 |
order.status = OrderStatus.FAILED
|
523 |
order.status = OrderStatus.SALES_RETURN_IN_TRANSIT
|
| 523 |
order.delivery_timestamp, reason = detail.split('|')
|
524 |
order.delivery_timestamp, reason = detail.split('|')
|
| 524 |
order.statusDescription = "Order Returned to Origin:" + reason
|
525 |
order.statusDescription = "Order Returned to Origin:" + reason
|
| 525 |
session.commit()
|
526 |
session.commit()
|
| 526 |
|
527 |
|
| 527 |
def update_non_delivery_reason(provider_id, undelivered_orders):
|
528 |
def update_non_delivery_reason(provider_id, undelivered_orders):
|
| 528 |
for awb, reason in undelivered_orders.iteritems():
|
529 |
for awb, reason in undelivered_orders.iteritems():
|
| 529 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
530 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| 530 |
if order == None:
|
531 |
if order == None:
|
| - |
|
532 |
continue
|
| 531 |
raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
533 |
#raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
| 532 |
order.statusDescription = reason
|
534 |
order.statusDescription = reason
|
| 533 |
session.commit()
|
535 |
session.commit()
|
| 534 |
|
536 |
|
| 535 |
def get_alerts(order_id, all):
|
537 |
def get_alerts(order_id, all):
|
| 536 |
query = Alerts.query.filter_by(order_id=order_id)
|
538 |
query = Alerts.query.filter_by(order_id=order_id)
|