| Line 32... |
Line 32... |
| 32 |
warehouse_allocation_cache = {}
|
32 |
warehouse_allocation_cache = {}
|
| 33 |
serviceable_location_cache = {}
|
33 |
serviceable_location_cache = {}
|
| 34 |
delivery_estimate_cache = {}
|
34 |
delivery_estimate_cache = {}
|
| 35 |
warehouse_location_cache = {}
|
35 |
warehouse_location_cache = {}
|
| 36 |
location_state={}
|
36 |
location_state={}
|
| - |
|
37 |
|
| - |
|
38 |
'Delhivery Bluedart, Fedex Surface, Fedex Air'
|
| 37 |
state_locations = {}
|
39 |
state_locations = {}
|
| 38 |
provider_costing_sheet = {}
|
40 |
provider_costing_sheet = {}
|
| 39 |
DELHIVERY = 3
|
41 |
DELHIVERY = 3
|
| 40 |
|
42 |
|
| 41 |
#pincode location map is ab
|
43 |
#pincode location map is ab
|
| Line 70... |
Line 72... |
| 70 |
print "Starting cache population at: " + str(datetime.datetime.now())
|
72 |
print "Starting cache population at: " + str(datetime.datetime.now())
|
| 71 |
#__cache_warehouse_allocation_table()
|
73 |
#__cache_warehouse_allocation_table()
|
| 72 |
__cache_warehouse_locations()
|
74 |
__cache_warehouse_locations()
|
| 73 |
__cache_serviceable_location_details_table()
|
75 |
__cache_serviceable_location_details_table()
|
| 74 |
__cache_delivery_estimate_table()
|
76 |
__cache_delivery_estimate_table()
|
| - |
|
77 |
__cache_pincode_provider_serviceability()
|
| 75 |
__cache_locations()
|
78 |
__cache_locations()
|
| 76 |
__cache_pincode_estimates()
|
79 |
__cache_pincode_estimates()
|
| 77 |
__cache_courier_costing_table()
|
80 |
__cache_courier_costing_table()
|
| 78 |
close_session()
|
81 |
close_session()
|
| 79 |
print "Done cache population at: " + str(datetime.datetime.now())
|
82 |
print "Done cache population at: " + str(datetime.datetime.now())
|
| Line 173... |
Line 176... |
| 173 |
if pincode_locations.has_key(destination_pin):
|
176 |
if pincode_locations.has_key(destination_pin):
|
| 174 |
locations = pincode_locations[destination_pin]
|
177 |
locations = pincode_locations[destination_pin]
|
| 175 |
for item_selling_price in selling_price_list:
|
178 |
for item_selling_price in selling_price_list:
|
| 176 |
returnMap[item_selling_price] = {}
|
179 |
returnMap[item_selling_price] = {}
|
| 177 |
for location_id, value in locations.iteritems():
|
180 |
for location_id, value in locations.iteritems():
|
| 178 |
returnMap[item_selling_price][location_id] = LocationInfo(locationId = location_id, sameState=value['sameState'])
|
- |
|
| 179 |
#put weight logic here
|
181 |
#put weight logic here
|
| 180 |
otgAvailable = False
|
182 |
otgAvailable = False
|
| 181 |
codAvailable = False
|
183 |
codAvailable = False
|
| 182 |
minDelay = -1
|
184 |
minDelay = -1
|
| 183 |
maxDelay = -1
|
185 |
maxDelay = -1
|
| Line 187... |
Line 189... |
| 187 |
if not serviceable_map.has_key(pp):
|
189 |
if not serviceable_map.has_key(pp):
|
| 188 |
continue
|
190 |
continue
|
| 189 |
iscod, isotg, providerCodLimit, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_map[pp]
|
191 |
iscod, isotg, providerCodLimit, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_map[pp]
|
| 190 |
if item_selling_price <= providerPrepaidLimit:
|
192 |
if item_selling_price <= providerPrepaidLimit:
|
| 191 |
if not serviceable:
|
193 |
if not serviceable:
|
| - |
|
194 |
returnMap[item_selling_price][location_id] = LocationInfo(locationId = location_id, sameState=value['sameState'])
|
| 192 |
serviceable = True
|
195 |
serviceable = True
|
| 193 |
minDelay = delay_days
|
196 |
minDelay = delay_days
|
| 194 |
maxDelay = delay_days
|
197 |
maxDelay = delay_days
|
| 195 |
else:
|
198 |
else:
|
| 196 |
minDelay = min(delay_days,minDelay)
|
199 |
minDelay = min(delay_days,minDelay)
|
| Line 198... |
Line 201... |
| 198 |
iscod = iscod and item_selling_price <= min(providerCodLimit, websiteCodLimit)
|
201 |
iscod = iscod and item_selling_price <= min(providerCodLimit, websiteCodLimit)
|
| 199 |
isotg = (isotg and item_selling_price >= 2000)
|
202 |
isotg = (isotg and item_selling_price >= 2000)
|
| 200 |
otgAvailable = otgAvailable or isotg
|
203 |
otgAvailable = otgAvailable or isotg
|
| 201 |
codAvailable = codAvailable or iscod
|
204 |
codAvailable = codAvailable or iscod
|
| 202 |
if serviceable:
|
205 |
if serviceable:
|
| 203 |
returnMap[item_selling_price][location_id].otgAvailable = otgAvailable
|
206 |
returnMap[item_selling_price][location_id].isOtg = otgAvailable
|
| 204 |
returnMap[item_selling_price][location_id].codAvailable = codAvailable
|
207 |
returnMap[item_selling_price][location_id].isCod = codAvailable
|
| 205 |
returnMap[item_selling_price][location_id].minDelay = minDelay
|
208 |
returnMap[item_selling_price][location_id].minDelay = minDelay
|
| 206 |
returnMap[item_selling_price][location_id].maxDelay = maxDelay
|
209 |
returnMap[item_selling_price][location_id].maxDelay = maxDelay
|
| 207 |
return returnMap
|
210 |
return returnMap
|
| 208 |
|
211 |
|
| 209 |
def get_logistics_estimation(destination_pin, item_selling_price, weight, type, billingWarehouseId):
|
212 |
def get_logistics_estimation(destination_pin, item_selling_price, weight, type, billingWarehouseId):
|
| Line 246... |
Line 249... |
| 246 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(6).get(destination_pin)
|
249 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(6).get(destination_pin)
|
| 247 |
if item_selling_price <= providerPrepaidLimit:
|
250 |
if item_selling_price <= providerPrepaidLimit:
|
| 248 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
251 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 249 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
252 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| 250 |
return 6, iscod, otgAvailable
|
253 |
return 6, iscod, otgAvailable
|
| 251 |
'''
|
254 |
'''
|
| 252 |
if serviceable_location_cache.has_key(3) and serviceable_location_cache.get(3).has_key(destination_pin):
|
- |
|
| 253 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(3).get(destination_pin)
|
- |
|
| 254 |
if item_selling_price <= providerPrepaidLimit:
|
255 |
''' lets give opportunity to provider who is cod serviceable
|
| 255 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
- |
|
| 256 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
- |
|
| 257 |
return 3, iscod, otgAvailable
|
256 |
'''
|
| 258 |
|
257 |
|
| 259 |
if billingWarehouseId not in [12,13] and serviceable_location_cache.has_key(7) and serviceable_location_cache.get(7).has_key(destination_pin):
|
258 |
if billingWarehouseId not in [12,13] and serviceable_location_cache.has_key(7) and serviceable_location_cache.get(7).has_key(destination_pin):
|
| 260 |
if item_selling_price < 3000 and serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin):
|
259 |
if item_selling_price < 3000 and serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin):
|
| 261 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
260 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
| 262 |
if item_selling_price <= providerPrepaidLimit:
|
261 |
if item_selling_price <= providerPrepaidLimit:
|
| 263 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
262 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 264 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
263 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| - |
|
264 |
if iscod:
|
| 265 |
return 1, iscod, otgAvailable
|
265 |
return 1, iscod, otgAvailable
|
| 266 |
else:
|
266 |
else:
|
| 267 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(7).get(destination_pin)
|
267 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(7).get(destination_pin)
|
| 268 |
if item_selling_price <= providerPrepaidLimit:
|
268 |
if item_selling_price <= providerPrepaidLimit:
|
| 269 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
269 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 270 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
270 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| - |
|
271 |
if iscod:
|
| 271 |
return 7, iscod, otgAvailable
|
272 |
return 7, iscod, otgAvailable
|
| 272 |
|
273 |
|
| 273 |
if billingWarehouseId not in [12,13] and serviceable_location_cache.has_key(46) and serviceable_location_cache.get(46).has_key(destination_pin):
|
274 |
if billingWarehouseId not in [12,13] and serviceable_location_cache.has_key(46) and serviceable_location_cache.get(46).has_key(destination_pin):
|
| 274 |
if item_selling_price < 3000 and serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin):
|
275 |
if item_selling_price < 3000 and serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin):
|
| 275 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
276 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
| 276 |
if item_selling_price <= providerPrepaidLimit:
|
277 |
if item_selling_price <= providerPrepaidLimit:
|
| 277 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
278 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 278 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
279 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| - |
|
280 |
if iscod:
|
| 279 |
return 1, iscod, otgAvailable
|
281 |
return 1, iscod, otgAvailable
|
| 280 |
else:
|
282 |
else:
|
| 281 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(46).get(destination_pin)
|
283 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(46).get(destination_pin)
|
| 282 |
if item_selling_price <= providerPrepaidLimit:
|
284 |
if item_selling_price <= providerPrepaidLimit:
|
| 283 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
285 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 284 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
286 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| - |
|
287 |
if iscod:
|
| 285 |
return 46, iscod, otgAvailable
|
288 |
return 46, iscod, otgAvailable
|
| 286 |
|
289 |
|
| 287 |
if serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin):
|
290 |
if serviceable_location_cache.has_key(1) and serviceable_location_cache.get(1).has_key(destination_pin):
|
| 288 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
291 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(1).get(destination_pin)
|
| 289 |
if item_selling_price <= providerPrepaidLimit:
|
292 |
if item_selling_price <= providerPrepaidLimit:
|
| 290 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
293 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| 291 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
294 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| - |
|
295 |
if iscod:
|
| 292 |
return 1, iscod, otgAvailable
|
296 |
return 1, iscod, otgAvailable
|
| 293 |
|
297 |
|
| - |
|
298 |
if serviceable_location_cache.has_key(3) and serviceable_location_cache.get(3).has_key(destination_pin):
|
| - |
|
299 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(3).get(destination_pin)
|
| - |
|
300 |
if item_selling_price <= providerPrepaidLimit:
|
| - |
|
301 |
iscod = iscod and item_selling_price <= websiteCodLimit
|
| - |
|
302 |
otgAvailable = otgAvailable and item_selling_price >= 2000
|
| - |
|
303 |
return 3, iscod, otgAvailable
|
| 294 |
return None, False, False
|
304 |
return None, False, False
|
| 295 |
|
305 |
|
| 296 |
def get_destination_code(providerId, pinCode):
|
306 |
def get_destination_code(providerId, pinCode):
|
| 297 |
serviceableLocationDetail = ServiceableLocationDetails.query.filter_by(provider_id = providerId, dest_pincode = pinCode).one()
|
307 |
serviceableLocationDetail = ServiceableLocationDetails.query.filter_by(provider_id = providerId, dest_pincode = pinCode).one()
|
| 298 |
return serviceableLocationDetail.dest_code
|
308 |
return serviceableLocationDetail.dest_code
|
| Line 307... |
Line 317... |
| 307 |
awb.awb_number = number
|
317 |
awb.awb_number = number
|
| 308 |
awb.provider_id = provider_id
|
318 |
awb.provider_id = provider_id
|
| 309 |
awb.is_available = True
|
319 |
awb.is_available = True
|
| 310 |
awb.type = type
|
320 |
awb.type = type
|
| 311 |
session.commit()
|
321 |
session.commit()
|
| 312 |
|
- |
|
| 313 |
def get_pincode_item_serviceability():
|
- |
|
| 314 |
pass
|
- |
|
| 315 |
|
322 |
|
| 316 |
def set_AWB_as_used(awb_number):
|
323 |
def set_AWB_as_used(awb_number):
|
| 317 |
query = Awb.query.filter_by(awb_number = awb_number)
|
324 |
query = Awb.query.filter_by(awb_number = awb_number)
|
| 318 |
awb = query.one()
|
325 |
awb = query.one()
|
| 319 |
awb.is_available=False
|
326 |
awb.is_available=False
|
| Line 470... |
Line 477... |
| 470 |
sp = client.getStorePricing(itemId)
|
477 |
sp = client.getStorePricing(itemId)
|
| 471 |
|
478 |
|
| 472 |
if codAllowed:
|
479 |
if codAllowed:
|
| 473 |
return sp.minAdvancePrice, True
|
480 |
return sp.minAdvancePrice, True
|
| 474 |
else:
|
481 |
else:
|
| 475 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(providerId).get(destination_pin)
|
482 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(providerId).get(destination_pin)
|
| 476 |
if iscod:
|
483 |
if iscod:
|
| 477 |
if providerId == 6:
|
484 |
if providerId == 6:
|
| 478 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
485 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
| 479 |
if providerId == 3:
|
486 |
if providerId == 3:
|
| 480 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
487 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|