| Line 2... |
Line 2... |
| 2 |
Created on 13-Sep-2010
|
2 |
Created on 13-Sep-2010
|
| 3 |
|
3 |
|
| 4 |
@author: rajveer
|
4 |
@author: rajveer
|
| 5 |
'''
|
5 |
'''
|
| 6 |
|
6 |
|
| - |
|
7 |
from collections import namedtuple
|
| 7 |
from elixir import session
|
8 |
from elixir import session
|
| 8 |
from shop2020.clients.CatalogClient import CatalogClient
|
9 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 9 |
from shop2020.clients.InventoryClient import InventoryClient
|
10 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 10 |
from shop2020.clients.TransactionClient import TransactionClient
|
11 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 11 |
from shop2020.logistics.service.impl import DataService
|
- |
|
| 12 |
from shop2020.logistics.service.impl import BluedartService
|
12 |
from shop2020.logistics.service.impl import BluedartService, DataService
|
| 13 |
from shop2020.logistics.service.impl.DataService import Awb, AwbUpdate, Provider, \
|
13 |
from shop2020.logistics.service.impl.DataService import Awb, AwbUpdate, Provider, \
|
| 14 |
DeliveryEstimate, WarehouseAllocation, PublicHolidays, \
|
14 |
DeliveryEstimate, WarehouseAllocation, PublicHolidays, \
|
| 15 |
ServiceableLocationDetails, PickupStore, Locations, ProviderCosting, BluedartAttribute
|
15 |
ServiceableLocationDetails, PickupStore, Locations, ProviderCosting, \
|
| - |
|
16 |
BluedartAttribute, PincodeStates
|
| 16 |
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException, \
|
17 |
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException, \
|
| 17 |
DeliveryType, LogisticsLocationInfo, LocationInfo, ProviderInfo, DeliveryEstimateAndCosting
|
18 |
DeliveryType, LogisticsLocationInfo, LocationInfo, ProviderInfo, \
|
| - |
|
19 |
DeliveryEstimateAndCosting
|
| 18 |
from shop2020.thriftpy.model.v1.inventory.ttypes import Warehouse, BillingType, \
|
20 |
from shop2020.thriftpy.model.v1.inventory.ttypes import Warehouse, BillingType, \
|
| 19 |
WarehouseType
|
21 |
WarehouseType
|
| 20 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
22 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
| 21 |
from sqlalchemy.sql import or_
|
23 |
from sqlalchemy.sql import or_
|
| 22 |
import datetime
|
24 |
import datetime
|
| 23 |
import logging
|
25 |
import logging
|
| - |
|
26 |
import math
|
| 24 |
import os
|
27 |
import os
|
| 25 |
import sys
|
28 |
import sys
|
| 26 |
import time
|
29 |
import time
|
| 27 |
from collections import namedtuple
|
- |
|
| 28 |
import math
|
- |
|
| 29 |
import traceback
|
30 |
import traceback
|
| 30 |
|
31 |
|
| 31 |
logging.basicConfig(level=logging.DEBUG)
|
32 |
logging.basicConfig(level=logging.DEBUG)
|
| 32 |
|
33 |
|
| 33 |
PincodeProvider = namedtuple("PincodeProvider", ["dest_pin", "provider"])
|
34 |
PincodeProvider = namedtuple("PincodeProvider", ["dest_pin", "provider"])
|
| Line 242... |
Line 243... |
| 242 |
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId):
|
243 |
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId):
|
| 243 |
#As of now we are dealing with Aramex and Bluedart. i.e. 1 and 2 and we have just one location i.e. gurgaon will generailise this
|
244 |
#As of now we are dealing with Aramex and Bluedart. i.e. 1 and 2 and we have just one location i.e. gurgaon will generailise this
|
| 244 |
#Once bandwidth is available these things will be derived through improved logic.
|
245 |
#Once bandwidth is available these things will be derived through improved logic.
|
| 245 |
#As of now otg is set to False
|
246 |
#As of now otg is set to False
|
| 246 |
otg=False
|
247 |
otg=False
|
| - |
|
248 |
aramexServiceable = serviceable_location_cache.has_key(2) and serviceable_location_cache.get(2).has_key(destination_pin)
|
| - |
|
249 |
blueDartServiceable = serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin)
|
| - |
|
250 |
if blueDartServiceable and aramexServiceable:
|
| - |
|
251 |
state = __getStateByPin(destination_pin)
|
| 247 |
prepaidProvider=None
|
252 |
if state is None:
|
| - |
|
253 |
state = 'DELHI'
|
| - |
|
254 |
#Prioritise Bluedart in Gujarat and Rajasthan
|
| - |
|
255 |
if state in ['GUJARAT', 'RAJASTHAN']:
|
| 248 |
if serviceable_location_cache.has_key(2) and serviceable_location_cache.get(2).has_key(destination_pin):
|
256 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
| - |
|
257 |
if item_selling_price <= providerPrepaidLimit:
|
| - |
|
258 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| - |
|
259 |
if iscod:
|
| - |
|
260 |
return 1, True, otg
|
| - |
|
261 |
else:
|
| - |
|
262 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(2).get(destination_pin)
|
| - |
|
263 |
if item_selling_price <= providerPrepaidLimit:
|
| - |
|
264 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| - |
|
265 |
if iscod:
|
| - |
|
266 |
return 2, True, otg
|
| - |
|
267 |
else:
|
| - |
|
268 |
return 1, False, otg
|
| - |
|
269 |
else:
|
| 249 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(2).get(destination_pin)
|
270 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(2).get(destination_pin)
|
| 250 |
if item_selling_price <= providerPrepaidLimit:
|
271 |
if item_selling_price <= providerPrepaidLimit:
|
| 251 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
272 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 252 |
if iscod:
|
273 |
if iscod:
|
| 253 |
return 2, True, otg
|
274 |
return 2, True, otg
|
| 254 |
prepaidProvider=2
|
275 |
else:
|
| 255 |
if serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin):
|
276 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
| - |
|
277 |
if item_selling_price <= providerPrepaidLimit:
|
| - |
|
278 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| - |
|
279 |
if iscod:
|
| - |
|
280 |
return 1, True, otg
|
| - |
|
281 |
else:
|
| - |
|
282 |
return 2, False, otg
|
| - |
|
283 |
|
| - |
|
284 |
else:
|
| - |
|
285 |
provider = 1 if blueDartServiceable else 2
|
| 256 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
286 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(provider).get(destination_pin)
|
| 257 |
if item_selling_price <= providerPrepaidLimit:
|
287 |
if item_selling_price <= providerPrepaidLimit:
|
| 258 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
288 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 259 |
if iscod:
|
- |
|
| 260 |
return 1, True, otg
|
289 |
return provider, iscod, otg
|
| 261 |
if prepaidProvider is None:
|
- |
|
| 262 |
prepaidProvider=1
|
- |
|
| 263 |
|
290 |
|
| 264 |
if prepaidProvider:
|
- |
|
| 265 |
return prepaidProvider, False, otg
|
- |
|
| 266 |
|
291 |
|
| 267 |
return None, False, False
|
292 |
return None, False, False
|
| 268 |
|
293 |
|
| - |
|
294 |
def __getStateByPin(destination_pin):
|
| - |
|
295 |
pinCodeState = PincodeStates.get_by(pin=destination_pin)
|
| - |
|
296 |
if pinCodeState is not None:
|
| - |
|
297 |
return pinCodeState.statename
|
| - |
|
298 |
else:
|
| - |
|
299 |
return None
|
| - |
|
300 |
|
| 269 |
def __get_logistics_provider_for_destination_pincode_old(destination_pin, item_selling_price, weight, type, billingWarehouseId):
|
301 |
def __get_logistics_provider_for_destination_pincode_old(destination_pin, item_selling_price, weight, type, billingWarehouseId):
|
| 270 |
'''
|
302 |
'''
|
| 271 |
if serviceable_location_cache.get(6).has_key(destination_pin):
|
303 |
if serviceable_location_cache.get(6).has_key(destination_pin):
|
| 272 |
if weight < 480 and serviceable_location_cache.get(3).has_key(destination_pin) and type == DeliveryType.PREPAID:
|
304 |
if weight < 480 and serviceable_location_cache.get(3).has_key(destination_pin) and type == DeliveryType.PREPAID:
|
| 273 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(3).get(destination_pin)
|
305 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(3).get(destination_pin)
|