Subversion Repositories SmartDukaan

Rev

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

Rev 23128 Rev 23132
Line 249... Line 249...
249
        delivery_estimate = _DeliveryEstimateObject(delivery_time, delivery_delay, provider_id, codAllowed, otgAvailable)
249
        delivery_estimate = _DeliveryEstimateObject(delivery_time, delivery_delay, provider_id, codAllowed, otgAvailable)
250
        return delivery_estimate
250
        return delivery_estimate
251
    except Exception as ex:
251
    except Exception as ex:
252
        print ex
252
        print ex
253
        raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
253
        raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
-
 
254
    
-
 
255
def __get_provider(providerList, destination_pin, item_selling_price, weight, type, billingWarehouseId):
-
 
256
        provider_id = providerList[0]
-
 
257
        provider_serviable = serviceable_location_cache.has_key(provider_id) and serviceable_location_cache.get(provider_id).has_key(destination_pin)
-
 
258
        if provider_serviable:
-
 
259
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(provider_id).get(destination_pin)
-
 
260
            if item_selling_price <= providerPrepaidLimit:
-
 
261
                iscod = iscod and item_selling_price <= websiteCodLimit
-
 
262
                if iscod:
-
 
263
                    return provider_id, True
-
 
264
                elif len(providerList) > 1:
-
 
265
                    providerList = providerList[1:]
-
 
266
                    next_provider_id, next_cod = __get_provider(providerList, destination_pin, item_selling_price, weight, type, billingWarehouseId)
-
 
267
                    if next_cod:
-
 
268
                        return  next_provider_id, next_cod
-
 
269
                    else:
-
 
270
                        return provider_id, False
-
 
271
                else:
-
 
272
                    return provider_id, False
-
 
273
        elif len(providerList) > 1:
-
 
274
                providerList = providerList[1:]
-
 
275
                return __get_provider(providerList, destination_pin, item_selling_price, weight, type, billingWarehouseId)
-
 
276
        else:
-
 
277
            return None, False
-
 
278
            
-
 
279
        
254
 
280
 
255
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId):
281
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId):
256
    #As of now we are dealing with Aramex and RQucikExpress. i.e. 2 and 47 and we have just one location i.e. gurgaon will generailise this 
282
    #As of now we are dealing with Aramex and RQucikExpress. i.e. 2 and 47 and we have just one location i.e. gurgaon will generailise this 
257
    #Once bandwidth is available these things will be derived through improved logic.
283
    #Once bandwidth is available these things will be derived through improved logic.
258
    #As of now otg is set to False, Use rquick if it is serviceable else use aramex
284
    #As of now otg is set to False, Use rquick if it is serviceable else use aramex
259
    otg=False
285
    otg=False
260
    PRIMARY_PROVIDER = 47
286
    PRIMARY_PROVIDER = 47
261
    SECONDARY_PROVIDER = 2
287
    SECONDARY_PROVIDER = 2
262
    aramexServiceable = serviceable_location_cache.has_key(SECONDARY_PROVIDER) and serviceable_location_cache.get(SECONDARY_PROVIDER).has_key(destination_pin)
-
 
263
    rquickServiceable =  serviceable_location_cache.has_key(PRIMARY_PROVIDER) and serviceable_location_cache.get(PRIMARY_PROVIDER).has_key(destination_pin)
-
 
264
    
-
 
265
    #blueDartServiceable =  False
-
 
266
    if rquickServiceable and aramexServiceable:
-
 
267
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(PRIMARY_PROVIDER).get(destination_pin)
-
 
268
        if item_selling_price <= providerPrepaidLimit:
-
 
269
            iscod = iscod and item_selling_price <= websiteCodLimit
-
 
270
            if iscod:
-
 
271
                return PRIMARY_PROVIDER, True, otg
288
    TERTIARY_PROVIDER = 49
272
            else:
-
 
273
                dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(SECONDARY_PROVIDER).get(destination_pin)
-
 
274
                if item_selling_price <= providerPrepaidLimit:
-
 
275
                    iscod = iscod and item_selling_price <= websiteCodLimit
-
 
276
                    if iscod:
-
 
277
                        return SECONDARY_PROVIDER, True, otg
289
    providerList = [PRIMARY_PROVIDER, SECONDARY_PROVIDER, TERTIARY_PROVIDER]
278
                    else:
-
 
279
                        return PRIMARY_PROVIDER, False, otg
-
 
280
        else:
-
 
281
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(SECONDARY_PROVIDER).get(destination_pin)
-
 
282
            if item_selling_price <= providerPrepaidLimit:
-
 
283
                iscod = iscod and item_selling_price <= websiteCodLimit
290
    a, b = __get_provider(providerList,destination_pin, item_selling_price, weight, type, billingWarehouseId)
284
                return SECONDARY_PROVIDER, iscod, otg
-
 
285
            
291
    print "a", a 
286
    else:
-
 
287
        if rquickServiceable:
-
 
288
            provider=PRIMARY_PROVIDER
-
 
289
        elif aramexServiceable:
-
 
290
            provider=SECONDARY_PROVIDER
-
 
291
        else:
-
 
292
            provider = None
-
 
293
        
-
 
294
        if provider:
292
    return a, b, otg
295
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(provider).get(destination_pin)
-
 
296
            if item_selling_price <= providerPrepaidLimit:
-
 
297
                iscod = iscod and item_selling_price <= websiteCodLimit
-
 
298
                return provider, iscod, otg
-
 
299
            
-
 
300
    
293
    
301
    return None, False, False
-
 
302
 
294
 
303
def __getStateByPin(destination_pin):
295
def __getStateByPin(destination_pin):
304
    pinCodeState = PincodeStates.get_by(pin=destination_pin)
296
    pinCodeState = PincodeStates.get_by(pin=destination_pin)
305
    if pinCodeState is not None:
297
    if pinCodeState is not None:
306
        return pinCodeState.statename
298
        return pinCodeState.statename
Line 613... Line 605...
613
#Start:- Added by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
605
#Start:- Added by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
614
    
606
    
615
def run_Logistics_Location_Info_Update(logisticsLocationInfoList, runCompleteUpdate, providerId):
607
def run_Logistics_Location_Info_Update(logisticsLocationInfoList, runCompleteUpdate, providerId):
616
    if runCompleteUpdate == True :
608
    if runCompleteUpdate == True :
617
        serviceableLocationDetails = ServiceableLocationDetails.query.filter_by(provider_id=providerId).all()
609
        serviceableLocationDetails = ServiceableLocationDetails.query.filter_by(provider_id=providerId).all()
-
 
610
        provider = Provider.query.filter_by(id = providerId).one()
618
        for serviceableLocationDetail in serviceableLocationDetails:
611
        for serviceableLocationDetail in serviceableLocationDetails:
619
            serviceableLocationDetail.exp = False
612
            serviceableLocationDetail.exp = False
620
            serviceableLocationDetail.cod = False
613
            serviceableLocationDetail.cod = False
621
    for logisticsLocationInfo in logisticsLocationInfoList:
614
    for logisticsLocationInfo in logisticsLocationInfoList:
622
        serviceableLocationDetail = ServiceableLocationDetails.get_by(provider_id = logisticsLocationInfo.providerId, dest_pincode = logisticsLocationInfo.pinCode)
615
        serviceableLocationDetail = ServiceableLocationDetails.get_by(provider_id = logisticsLocationInfo.providerId, dest_pincode = logisticsLocationInfo.pinCode)
-
 
616
        if provider is None:
623
        provider = Provider.query.filter_by(id = logisticsLocationInfo.providerId).one()
617
            provider = Provider.query.filter_by(id = logisticsLocationInfo.providerId).one()
624
        if serviceableLocationDetail:
618
        if serviceableLocationDetail:
625
            serviceableLocationDetail.exp = logisticsLocationInfo.expAvailable
619
            serviceableLocationDetail.exp = logisticsLocationInfo.expAvailable
626
            serviceableLocationDetail.cod = logisticsLocationInfo.codAvailable
620
            serviceableLocationDetail.cod = logisticsLocationInfo.codAvailable
627
            serviceableLocationDetail.otgAvailable = logisticsLocationInfo.otgAvailable
621
            serviceableLocationDetail.otgAvailable = logisticsLocationInfo.otgAvailable
628
            serviceableLocationDetail.providerCodLimit = logisticsLocationInfo.codLimit
622
            serviceableLocationDetail.providerCodLimit = logisticsLocationInfo.codLimit