| Line 1... |
Line 1... |
| 1 |
'''
|
1 |
'''
|
| 2 |
Created on 05-Aug-2010
|
2 |
Created on 05-Aug-2010
|
| 3 |
|
3 |
|
| 4 |
@author: ashish
|
4 |
@author: ashish
|
| 5 |
'''
|
5 |
'''
|
| 6 |
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo,\
|
- |
|
| 7 |
LogisticsServiceException, DeliveryType, PickUpType
|
- |
|
| 8 |
from shop2020.logistics.service.impl.DataAccessor import get_empty_AWB,\
|
- |
|
| 9 |
get_shipment_info, initialize, get_logistics_estimation, get_provider,\
|
- |
|
| 10 |
get_providers, close_session, get_free_awb_count, get_holidays,\
|
- |
|
| 11 |
is_alive, get_provider_for_pickup_type, get_pickup_store, get_all_pickup_stores,\
|
- |
|
| 12 |
get_pickup_store_by_hotspot_id
|
- |
|
| 13 |
from shop2020.logistics.service.impl.Converters import to_t_awbupdate,\
|
- |
|
| 14 |
to_t_provider, to_t_pickup_store
|
- |
|
| 15 |
from shop2020.clients.CatalogClient import CatalogClient
|
6 |
from shop2020.clients.CatalogClient import CatalogClient
|
| - |
|
7 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 16 |
from shop2020.config.client.ConfigClient import ConfigClient
|
8 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| - |
|
9 |
from shop2020.logistics.service.impl import DataAccessor
|
| - |
|
10 |
from shop2020.logistics.service.impl.Converters import to_t_awbupdate, \
|
| - |
|
11 |
to_t_provider, to_t_pickup_store
|
| - |
|
12 |
from shop2020.logistics.service.impl.DataAccessor import get_empty_AWB, \
|
| - |
|
13 |
get_shipment_info, initialize, get_logistics_estimation, get_provider, \
|
| - |
|
14 |
get_providers, close_session, get_free_awb_count, get_holidays, is_alive, \
|
| - |
|
15 |
get_provider_for_pickup_type, get_pickup_store, get_all_pickup_stores, \
|
| - |
|
16 |
get_pickup_store_by_hotspot_id
|
| - |
|
17 |
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo, \
|
| - |
|
18 |
LogisticsServiceException, DeliveryType, PickUpType
|
| - |
|
19 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status
|
| 17 |
import datetime
|
20 |
import datetime
|
| 18 |
import math
|
21 |
import math
|
| 19 |
import sys
|
22 |
import sys
|
| 20 |
from shop2020.logistics.service.impl import DataAccessor
|
- |
|
| 21 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status
|
- |
|
| 22 |
|
23 |
|
| 23 |
class LogisticsServiceHandler:
|
24 |
class LogisticsServiceHandler:
|
| 24 |
|
25 |
|
| 25 |
def __init__(self, dbname='logistics', db_hostname='localhost'):
|
26 |
def __init__(self, dbname='logistics', db_hostname='localhost'):
|
| 26 |
initialize(dbname, db_hostname)
|
27 |
initialize(dbname, db_hostname)
|
| Line 115... |
Line 116... |
| 115 |
close_session()
|
116 |
close_session()
|
| 116 |
|
117 |
|
| 117 |
def get_logistics_estimation_with_type(self, itemId, destination_pin, type):
|
118 |
def get_logistics_estimation_with_type(self, itemId, destination_pin, type):
|
| 118 |
try:
|
119 |
try:
|
| 119 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
120 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
| 120 |
client = CatalogClient().get_client()
|
121 |
client = InventoryClient().get_client()
|
| 121 |
fulfilmentWarehouseId, expected_delay, billingWarehouseId, sellingPrice = client.getItemAvailabilityAtLocation(itemId)
|
122 |
fulfilmentWarehouseId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability = client.getItemAvailabilityAtLocation(itemId)
|
| 122 |
except Exception as ex:
|
123 |
except Exception as ex:
|
| 123 |
raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
|
124 |
raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
|
| 124 |
|
125 |
|
| 125 |
delivery_estimate = get_logistics_estimation(destination_pin, sellingPrice, type)
|
126 |
delivery_estimate = get_logistics_estimation(destination_pin, sellingPrice, type)
|
| 126 |
if delivery_estimate is None:
|
127 |
if delivery_estimate is None:
|