Subversion Repositories SmartDukaan

Rev

Rev 20745 | Rev 22637 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20745 Rev 22634
Line 17... Line 17...
17
    add_pincode, store_shipment_info, adjust_delivery_time, get_min_advance_amount, \
17
    add_pincode, store_shipment_info, adjust_delivery_time, get_min_advance_amount, \
18
    add_new_awbs, run_Logistics_Location_Info_Update, \
18
    add_new_awbs, run_Logistics_Location_Info_Update, \
19
    get_first_delivery_estimate_for_wh_location, \
19
    get_first_delivery_estimate_for_wh_location, \
20
    get_provider_limit_details_for_pincode, get_new_empty_awb, \
20
    get_provider_limit_details_for_pincode, get_new_empty_awb, \
21
    get_logistics_locations, get_costing_and_delivery_estimate_for_pincode, \
21
    get_logistics_locations, get_costing_and_delivery_estimate_for_pincode, \
22
    get_bluedart_attributes_for_logistics_txn_id
22
    get_bluedart_attributes_for_logistics_txn_id, _DeliveryEstimateObject
23
from shop2020.logistics.service.impl.DataService import \
23
from shop2020.logistics.service.impl.DataService import \
24
    ServiceableLocationDetails
24
    ServiceableLocationDetails
25
from shop2020.thriftpy.logistics.ttypes import ItemText, LogisticsInfo, \
25
from shop2020.thriftpy.logistics.ttypes import ItemText, LogisticsInfo, \
26
    LogisticsServiceException, DeliveryType, PickUpType
26
    LogisticsServiceException, DeliveryType, PickUpType
27
from shop2020.thriftpy.model.v1.catalog.ttypes import status
27
from shop2020.thriftpy.model.v1.catalog.ttypes import status
Line 82... Line 82...
82
         - destination_pincode
82
         - destination_pincode
83
         - item_id
83
         - item_id
84
         - type
84
         - type
85
        """
85
        """
86
        try:
86
        try:
87
            logistics_info = self.get_logistics_estimation_with_type(itemId, destination_pincode, type)
87
            logistics_info = self.get_logistics_estimation_with_type(itemId, destination_pincode, type, pickUp)
88
            if pickUp == PickUpType.RUNNER or pickUp == PickUpType.SELF:
-
 
89
                logistics_info.providerId = get_provider_for_pickup_type(pickUp)
-
 
90
            #logistics_info.airway_billno = get_empty_AWB(logistics_info.providerId, type)
88
            #logistics_info.airway_billno = get_empty_AWB(logistics_info.providerId, type)
91
            return logistics_info
89
            return logistics_info
92
        finally:
90
        finally:
93
            close_session()
91
            close_session()
94
            
92
            
Line 159... Line 157...
159
            logistics_info.providerId = int(minAdvanceAmount)
157
            logistics_info.providerId = int(minAdvanceAmount)
160
            return logistics_info
158
            return logistics_info
161
        finally:
159
        finally:
162
            close_session()
160
            close_session()
163
            
161
            
164
    def get_logistics_estimation_with_type(self, itemId, destination_pin, type):
162
    def get_logistics_estimation_with_type(self, itemId, destination_pin, type, pickUp=PickUpType.COURIER):
165
        try:
163
        try:
166
            #Get the id and location of actual warehouse that'll be used to fulfil this order.
164
            #Get the id and location of actual warehouse that'll be used to fulfil this order.
167
            client = InventoryClient().get_client()
165
            client = InventoryClient().get_client()
168
            fulfilmentWarehouseId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = client.getItemAvailabilityAtLocation(itemId, self.sourceId)
166
            fulfilmentWarehouseId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = client.getItemAvailabilityAtLocation(itemId, self.sourceId)
169
        except Exception as ex:
167
        except Exception as ex:
170
            raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
168
            raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
171
        
169
        
-
 
170
        if pickUp == PickUpType.COURIER:
172
        delivery_estimate = get_logistics_estimation(destination_pin, sellingPrice, weight, type, billingWarehouseId)
171
            delivery_estimate = get_logistics_estimation(destination_pin, sellingPrice, weight, type, billingWarehouseId)
-
 
172
        else:
-
 
173
            #if pickUp == PickUpType.RUNNER or pickUp == PickUpType.SELF:
-
 
174
            delivery_estimate = _DeliveryEstimateObject(get_provider_for_pickup_type(pickUp), 0, 0, False, False)
173
        if delivery_estimate is None:
175
        if delivery_estimate is None:
174
            raise LogisticsServiceException(104, "Unable to fetch delivery estimate for this pincode.")
176
            raise LogisticsServiceException(104, "Unable to fetch delivery estimate for this pincode.")
175
                
177
                
176
        
178
        
177
        ## Commented below part as we have only Delhi as warehouse city. If we will add some more warehouses in different cities, this could be  useful. 
179
        ## Commented below part as we have only Delhi as warehouse city. If we will add some more warehouses in different cities, this could be  useful. 
Line 186... Line 188...
186
        '''
188
        '''
187
        We're now calculating the expected shipping delay which is independent of
189
        We're now calculating the expected shipping delay which is independent of
188
        the courier agency and is completely within our control (well, almost).
190
        the courier agency and is completely within our control (well, almost).
189
        '''
191
        '''
190
        #Always add the expected delay
192
        #Always add the expected delay
-
 
193
        #As per Deenanath This should be removed
191
        shipping_delay = 24 * expected_delay
194
        shipping_delay = 24 * expected_delay
192
        
195
        
193
        # Sometimes we set negative shipping delay just in case we know time to procure will be less than the default.
196
        # Sometimes we set negative shipping delay just in case we know time to procure will be less than the default.
194
        # If we have received inventory and forgot to remove expected delay from item, it could lead to display negative shipping days. 
197
        # If we have received inventory and forgot to remove expected delay from item, it could lead to display negative shipping days. 
195
        if shipping_delay < 0:
198
        if shipping_delay < 0:
Line 199... Line 202...
199
        current_hour = datetime.datetime.now().hour
202
        current_hour = datetime.datetime.now().hour
200
        if type == DeliveryType.PREPAID and self.cutoff_time <= current_hour:
203
        if type == DeliveryType.PREPAID and self.cutoff_time <= current_hour:
201
            shipping_delay = shipping_delay + 24
204
            shipping_delay = shipping_delay + 24
202
        
205
        
203
        #In case of COD,increase delay by one more day
206
        #In case of COD,increase delay by one more day
-
 
207
        #As per deenanath why are doing this?
204
        if type == DeliveryType.COD:
208
        if type == DeliveryType.COD:
205
            shipping_delay = shipping_delay + 24
209
            shipping_delay = shipping_delay + 24
206
            delivery_estimate.otgAvailable = False
210
            delivery_estimate.otgAvailable = False
207
            
211
            
208
        delivery_time = delivery_time + shipping_delay
212
        delivery_time = delivery_time + shipping_delay