| Line 56... |
Line 56... |
| 56 |
try:
|
56 |
try:
|
| 57 |
provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
|
57 |
provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
|
| 58 |
except:
|
58 |
except:
|
| 59 |
provider_pincodes = {}
|
59 |
provider_pincodes = {}
|
| 60 |
serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes
|
60 |
serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes
|
| 61 |
provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.otgAvailable
|
61 |
provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.otgAvailable, serviceable_location.websiteCodLimit, serviceable_location.storeCodLimit
|
| 62 |
|
62 |
|
| 63 |
def __cache_warehouse_allocation_table():
|
63 |
def __cache_warehouse_allocation_table():
|
| 64 |
warehouse_allocations = WarehouseAllocation.query.all()
|
64 |
warehouse_allocations = WarehouseAllocation.query.all()
|
| 65 |
for warehouse_allocation in warehouse_allocations:
|
65 |
for warehouse_allocation in warehouse_allocations:
|
| 66 |
warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
|
66 |
warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
|
| Line 89... |
Line 89... |
| 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):
|
| 93 |
if item_selling_price >= 5000 and item_selling_price <= 10000 and serviceable_location_cache.get(6).has_key(destination_pin):
|
93 |
if item_selling_price >= 5000 and item_selling_price <= 10000 and serviceable_location_cache.get(6).has_key(destination_pin):
|
| 94 |
dest_code, exp, iscod, otgAvailable = 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 <= 25000
|
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 |
return 6, iscod, otgAvailable
|
97 |
return 6, iscod, otgAvailable
|
| 98 |
|
98 |
|
| 99 |
if serviceable_location_cache.get(3).has_key(destination_pin):
|
99 |
if serviceable_location_cache.get(3).has_key(destination_pin):
|
| 100 |
dest_code, exp, iscod, otgAvailable = serviceable_location_cache.get(3).get(destination_pin)
|
100 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
|
| 101 |
iscod = iscod and item_selling_price <= 25000
|
101 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 102 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
102 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| 103 |
return 3, iscod, otgAvailable
|
103 |
return 3, iscod, otgAvailable
|
| 104 |
|
104 |
|
| 105 |
if serviceable_location_cache.get(1).has_key(destination_pin):
|
105 |
if serviceable_location_cache.get(1).has_key(destination_pin):
|
| 106 |
dest_code, exp, iscod, otgAvailable = serviceable_location_cache.get(1).get(destination_pin)
|
106 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
| 107 |
iscod = iscod and item_selling_price <= 9600
|
107 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 108 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
108 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| 109 |
return 1, iscod, otgAvailable
|
109 |
return 1, iscod, otgAvailable
|
| 110 |
else:
|
110 |
else:
|
| 111 |
return None, False, False
|
111 |
return None, False, False
|
| 112 |
|
112 |
|
| Line 215... |
Line 215... |
| 215 |
serviceableLocationDetails.dest_code = destCode
|
215 |
serviceableLocationDetails.dest_code = destCode
|
| 216 |
serviceableLocationDetails.exp = exp
|
216 |
serviceableLocationDetails.exp = exp
|
| 217 |
serviceableLocationDetails.cod = cod
|
217 |
serviceableLocationDetails.cod = cod
|
| 218 |
serviceableLocationDetails.station_type = stationType
|
218 |
serviceableLocationDetails.station_type = stationType
|
| 219 |
serviceableLocationDetails.otgAvailable = otgAvailable
|
219 |
serviceableLocationDetails.otgAvailable = otgAvailable
|
| - |
|
220 |
if provider == 1:
|
| - |
|
221 |
limit = 10000
|
| - |
|
222 |
elif provider == 3:
|
| - |
|
223 |
limit = 25000
|
| - |
|
224 |
elif provider == 6:
|
| - |
|
225 |
limit = 25000
|
| - |
|
226 |
serviceableLocationDetails.providerCodLimit = limit
|
| - |
|
227 |
serviceableLocationDetails.websiteCodLimit = limit
|
| - |
|
228 |
serviceableLocationDetails.websiteCodLimit = limit
|
| 220 |
session.commit()
|
229 |
session.commit()
|
| 221 |
|
230 |
|
| 222 |
def update_pincode(providerId, pincode, exp, cod, otgAvailable):
|
231 |
def update_pincode(providerId, pincode, exp, cod, otgAvailable):
|
| 223 |
serviceableLocationDetails = ServiceableLocationDetails.get_by(provider_id = providerId, dest_pincode = pincode)
|
232 |
serviceableLocationDetails = ServiceableLocationDetails.get_by(provider_id = providerId, dest_pincode = pincode)
|
| 224 |
serviceableLocationDetails.exp = exp
|
233 |
serviceableLocationDetails.exp = exp
|
| Line 249... |
Line 258... |
| 249 |
sp = client.getStorePricing(itemId)
|
258 |
sp = client.getStorePricing(itemId)
|
| 250 |
|
259 |
|
| 251 |
if codAllowed:
|
260 |
if codAllowed:
|
| 252 |
return sp.minAdvancePrice, True
|
261 |
return sp.minAdvancePrice, True
|
| 253 |
else:
|
262 |
else:
|
| 254 |
dest_code, exp, iscod, otgAvailable = serviceable_location_cache.get(providerId).get(destination_pin)
|
263 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(providerId).get(destination_pin)
|
| 255 |
if iscod:
|
264 |
if iscod:
|
| 256 |
if providerId == 6:
|
265 |
if providerId == 6:
|
| 257 |
return max(sp.minAdvancePrice, sp.recommendedPrice - 10000), True
|
266 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
| 258 |
if providerId == 3:
|
267 |
if providerId == 3:
|
| 259 |
return max(sp.minAdvancePrice, sp.recommendedPrice - 25000), True
|
268 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
| 260 |
if providerId == 1:
|
269 |
if providerId == 1:
|
| 261 |
return max(sp.minAdvancePrice, sp.recommendedPrice - 10000), True
|
270 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
| 262 |
else:
|
271 |
else:
|
| 263 |
return sp.recommendedPrice, False
|
272 |
return sp.recommendedPrice, False
|
| 264 |
|
273 |
|
| 265 |
|
274 |
|
| 266 |
|
275 |
|