| Line 71... |
Line 71... |
| 71 |
|
71 |
|
| 72 |
def get_providers():
|
72 |
def get_providers():
|
| 73 |
providers = Provider.query.filter_by(isActive = 1).all()
|
73 |
providers = Provider.query.filter_by(isActive = 1).all()
|
| 74 |
return providers
|
74 |
return providers
|
| 75 |
|
75 |
|
| 76 |
def get_logistics_estimation(destination_pin, item_selling_price):
|
76 |
def get_logistics_estimation(destination_pin, item_selling_price, weight, type):
|
| 77 |
logging.info("Getting logistics estimation for pincode:" + destination_pin )
|
77 |
logging.info("Getting logistics estimation for pincode:" + destination_pin )
|
| 78 |
|
78 |
|
| 79 |
provider_id, codAllowed, otgAvailable = __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price)
|
79 |
provider_id, codAllowed, otgAvailable = __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type)
|
| 80 |
|
80 |
|
| 81 |
if not provider_id:
|
81 |
if not provider_id:
|
| 82 |
raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(destination_pin))
|
82 |
raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(destination_pin))
|
| 83 |
try:
|
83 |
try:
|
| 84 |
delivery_time = delivery_estimate_cache[destination_pin, provider_id][0]
|
84 |
delivery_time = delivery_estimate_cache[destination_pin, provider_id][0]
|
| Line 87... |
Line 87... |
| 87 |
return delivery_estimate
|
87 |
return delivery_estimate
|
| 88 |
except Exception as ex:
|
88 |
except Exception as ex:
|
| 89 |
print ex
|
89 |
print ex
|
| 90 |
raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
|
90 |
raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
|
| 91 |
|
91 |
|
| 92 |
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price):
|
92 |
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type):
|
| 93 |
if item_selling_price >= 5000 and item_selling_price <= 10000 and serviceable_location_cache.get(6).has_key(destination_pin):
|
93 |
if serviceable_location_cache.get(6).has_key(destination_pin):
|
| 94 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(6).get(destination_pin)
|
94 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(6).get(destination_pin)
|
| 95 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
95 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 96 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
96 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| - |
|
97 |
if weight >= 480 or (type == DeliveryType.COD and item_selling_price >= 3000):
|
| 97 |
return 6, iscod, otgAvailable
|
98 |
return 6, iscod, otgAvailable
|
| 98 |
|
99 |
|
| 99 |
if serviceable_location_cache.get(3).has_key(destination_pin):
|
100 |
if serviceable_location_cache.get(3).has_key(destination_pin):
|
| 100 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
|
101 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
|
| 101 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
102 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 102 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
103 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| 103 |
return 3, iscod, otgAvailable
|
104 |
return 3, iscod, otgAvailable
|