| Line 7... |
Line 7... |
| 7 |
from collections import namedtuple
|
7 |
from collections import namedtuple
|
| 8 |
from elixir import session
|
8 |
from elixir import session
|
| 9 |
from shop2020.clients.CatalogClient import CatalogClient
|
9 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 10 |
from shop2020.clients.InventoryClient import InventoryClient
|
10 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 11 |
from shop2020.clients.TransactionClient import TransactionClient
|
11 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 12 |
from shop2020.logistics.service.impl import BluedartService, DataService,\
|
12 |
from shop2020.logistics.service.impl import BluedartService, DataService, \
|
| 13 |
EcomExpressService
|
13 |
EcomExpressService
|
| 14 |
from shop2020.logistics.service.impl.DataService import Awb, AwbUpdate, Provider, \
|
14 |
from shop2020.logistics.service.impl.DataService import Awb, AwbUpdate, Provider, \
|
| 15 |
DeliveryEstimate, WarehouseAllocation, PublicHolidays, \
|
15 |
DeliveryEstimate, WarehouseAllocation, PublicHolidays, \
|
| 16 |
ServiceableLocationDetails, PickupStore, Locations, ProviderCosting, \
|
16 |
ServiceableLocationDetails, PickupStore, Locations, ProviderCosting, \
|
| 17 |
BluedartAttribute, PincodeStates
|
17 |
BluedartAttribute, PincodeStates
|
| Line 19... |
Line 19... |
| 19 |
DeliveryType, LogisticsLocationInfo, LocationInfo, ProviderInfo, \
|
19 |
DeliveryType, LogisticsLocationInfo, LocationInfo, ProviderInfo, \
|
| 20 |
DeliveryEstimateAndCosting
|
20 |
DeliveryEstimateAndCosting
|
| 21 |
from shop2020.thriftpy.model.v1.inventory.ttypes import Warehouse, BillingType, \
|
21 |
from shop2020.thriftpy.model.v1.inventory.ttypes import Warehouse, BillingType, \
|
| 22 |
WarehouseType
|
22 |
WarehouseType
|
| 23 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
23 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
| - |
|
24 |
from shop2020.utils.caching.SimpleCaching import memoized
|
| 24 |
from sqlalchemy.sql import or_
|
25 |
from sqlalchemy.sql import or_
|
| 25 |
import datetime
|
26 |
import datetime
|
| 26 |
import logging
|
27 |
import logging
|
| 27 |
import math
|
28 |
import math
|
| 28 |
import os
|
29 |
import os
|
| Line 83... |
Line 84... |
| 83 |
__cache_locations()
|
84 |
__cache_locations()
|
| 84 |
__cache_pincode_estimates()
|
85 |
__cache_pincode_estimates()
|
| 85 |
__cache_courier_costing_table()
|
86 |
__cache_courier_costing_table()
|
| 86 |
close_session()
|
87 |
close_session()
|
| 87 |
print "Done cache population at: " + str(datetime.datetime.now())
|
88 |
print "Done cache population at: " + str(datetime.datetime.now())
|
| - |
|
89 |
|
| - |
|
90 |
@memoized(3600)
|
| - |
|
91 |
def fetchStateMaster():
|
| - |
|
92 |
inventory_client = InventoryClient().get_client()
|
| - |
|
93 |
return inventory_client.getStateMaster()
|
| - |
|
94 |
|
| 88 |
|
95 |
|
| 89 |
def __cache_locations():
|
96 |
def __cache_locations():
|
| 90 |
locations = Locations.query.all()
|
97 |
locations = Locations.query.all()
|
| 91 |
for location in locations:
|
98 |
for location in locations:
|
| 92 |
location_state[location.id] = location.state_id
|
99 |
location_state[location.id] = location.state_id
|
| Line 410... |
Line 417... |
| 410 |
if awb is None:
|
417 |
if awb is None:
|
| 411 |
additionalQuery = additionalQuery.filter_by(awbUsedFor=2)
|
418 |
additionalQuery = additionalQuery.filter_by(awbUsedFor=2)
|
| 412 |
awb = additionalQuery.first()
|
419 |
awb = additionalQuery.first()
|
| 413 |
print "-------", awb.awb_number, awb.is_available
|
420 |
print "-------", awb.awb_number, awb.is_available
|
| 414 |
awb.is_available = False
|
421 |
awb.is_available = False
|
| - |
|
422 |
if provider_id==49:
|
| - |
|
423 |
success = EcomExpressService.forward_request(awb.awb_number, logisticsTransactionId)
|
| - |
|
424 |
if not success:
|
| - |
|
425 |
raise LogisticsServiceException(103, "Unable to forward shipment for the given Provider: " + str(provider_id))
|
| - |
|
426 |
#Commit only if everything works fine
|
| 415 |
session.commit()
|
427 |
session.commit()
|
| 416 |
return awb.awb_number
|
428 |
return awb.awb_number
|
| 417 |
except:
|
429 |
except:
|
| 418 |
session.close()
|
430 |
session.close()
|
| 419 |
print "oops"
|
431 |
print "oops"
|
| Line 598... |
Line 610... |
| 598 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
610 |
return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
|
| 599 |
else:
|
611 |
else:
|
| 600 |
return sp.recommendedPrice, False
|
612 |
return sp.recommendedPrice, False
|
| 601 |
#Start:- Added by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
|
613 |
#Start:- Added by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
|
| 602 |
|
614 |
|
| 603 |
def run_Logistics_Location_Info_Update(logisticsLocationInfoList, runCompleteUpdate):
|
615 |
def run_Logistics_Location_Info_Update(logisticsLocationInfoList, runCompleteUpdate, providerId):
|
| 604 |
if runCompleteUpdate == True :
|
616 |
if runCompleteUpdate == True :
|
| 605 |
serviceableLocationDetails = ServiceableLocationDetails.query.all()
|
617 |
serviceableLocationDetails = ServiceableLocationDetails.get_by(provider_id=providerId).all()
|
| 606 |
for serviceableLocationDetail in serviceableLocationDetails:
|
618 |
for serviceableLocationDetail in serviceableLocationDetails:
|
| 607 |
serviceableLocationDetail.exp = False
|
619 |
serviceableLocationDetail.exp = False
|
| 608 |
serviceableLocationDetail.cod = False
|
620 |
serviceableLocationDetail.cod = False
|
| 609 |
for logisticsLocationInfo in logisticsLocationInfoList:
|
621 |
for logisticsLocationInfo in logisticsLocationInfoList:
|
| 610 |
serviceableLocationDetail = ServiceableLocationDetails.get_by(provider_id = logisticsLocationInfo.providerId, dest_pincode = logisticsLocationInfo.pinCode)
|
622 |
serviceableLocationDetail = ServiceableLocationDetails.get_by(provider_id = logisticsLocationInfo.providerId, dest_pincode = logisticsLocationInfo.pinCode)
|