| Line 3501... |
Line 3501... |
| 3501 |
return ServiceProvider.query.filter_by(id = providerId).one()
|
3501 |
return ServiceProvider.query.filter_by(id = providerId).one()
|
| 3502 |
|
3502 |
|
| 3503 |
def get_provider_code(providerId):
|
3503 |
def get_provider_code(providerId):
|
| 3504 |
return ServiceProvider.query.filter_by(id = providerId).one().code
|
3504 |
return ServiceProvider.query.filter_by(id = providerId).one().code
|
| 3505 |
|
3505 |
|
| 3506 |
def get_provider_id(providerCode):
|
3506 |
def get_provider_by_code(providerCode):
|
| 3507 |
return ServiceProvider.query.filter_by(code = providerCode).one().id
|
3507 |
return ServiceProvider.query.filter_by(code = providerCode).one()
|
| 3508 |
|
3508 |
|
| 3509 |
def get_service_providers(recharge_type, only_active):
|
3509 |
def get_service_providers(recharge_type, only_active):
|
| 3510 |
query = ServiceProvider.query.filter_by(type = recharge_type)
|
3510 |
query = ServiceProvider.query.filter_by(type = recharge_type)
|
| 3511 |
if only_active:
|
3511 |
if only_active:
|
| 3512 |
query = query.filter_by(status = only_active)
|
3512 |
query = query.filter_by(status = only_active)
|
| Line 3525... |
Line 3525... |
| 3525 |
try:
|
3525 |
try:
|
| 3526 |
providerCode, operatorCircle = RechargeService.checkServiceProviderApi(serviceType, deviceNumber)
|
3526 |
providerCode, operatorCircle = RechargeService.checkServiceProviderApi(serviceType, deviceNumber)
|
| 3527 |
if providerCode == 'SNS' or providerCode == '':
|
3527 |
if providerCode == 'SNS' or providerCode == '':
|
| 3528 |
providerId = 0
|
3528 |
providerId = 0
|
| 3529 |
else:
|
3529 |
else:
|
| 3530 |
providerId = get_provider_id(providerCode)
|
3530 |
provider = get_provider_by_code(providerCode)
|
| - |
|
3531 |
providerId = provider.id
|
| 3531 |
except:
|
3532 |
except:
|
| 3532 |
providerId = -1
|
3533 |
providerId = -1
|
| 3533 |
|
3534 |
|
| 3534 |
deviceNumberInfo = DeviceNumberInfo()
|
3535 |
deviceNumberInfo = DeviceNumberInfo()
|
| 3535 |
deviceNumberInfo.circleName = operatorCircle
|
3536 |
deviceNumberInfo.circleName = operatorCircle
|
| 3536 |
deviceNumberInfo.operatorId = providerId
|
3537 |
deviceNumberInfo.operatorId = providerId
|
| - |
|
3538 |
deviceNumberInfo.operatorName = provider.name
|
| 3537 |
return deviceNumberInfo
|
3539 |
return deviceNumberInfo
|
| 3538 |
|
3540 |
|
| 3539 |
def validate_recharge(rechargeType, deviceNumber, circleCode, userSelectedProviderId):
|
3541 |
def validate_recharge(rechargeType, deviceNumber, circleCode, userSelectedProviderId):
|
| 3540 |
deviceNumberInfo = get_service_provider_for_device(rechargeType, deviceNumber)
|
3542 |
deviceNumberInfo = get_service_provider_for_device(rechargeType, deviceNumber)
|
| 3541 |
if deviceNumberInfo.operatorId == -1:
|
3543 |
if deviceNumberInfo.operatorId == -1:
|
| 3542 |
return "Oops! There seems to be a problem. Please try after some time."
|
3544 |
return "Oops! There seems to be a problem. Please try after some time."
|
| 3543 |
circle_id = TelecomCircle.query.filter_by(code = circleCode).first().id
|
3545 |
circle = TelecomCircle.query.filter_by(code = circleCode).first()
|
| 3544 |
if not ServiceAvailability.query.filter_by(circleId = circle_id).filter_by(operatorId = userSelectedProviderId).first().isServiceAvailable :
|
3546 |
if not ServiceAvailability.query.filter_by(circleId = circle.id).filter_by(operatorId = userSelectedProviderId).first().isServiceAvailable :
|
| 3545 |
return "This operator is not available at this time. Please try later."
|
3547 |
return deviceNumberInfo.operatorName + " is down in " + circle.name + " currently. Please try later."
|
| 3546 |
allcounts, successcounts = get_previous_transactions(rechargeType, deviceNumber)
|
3548 |
allcounts, successcounts = get_previous_transactions(rechargeType, deviceNumber)
|
| 3547 |
if allcounts >= 15 or successcounts >= 5:
|
3549 |
if allcounts >= 15 or successcounts >= 5:
|
| 3548 |
return "You have exceeded daily limit for this mobile number."
|
3550 |
return "You have exceeded daily limit for this mobile number."
|
| 3549 |
return "SUCCESS"
|
3551 |
return "SUCCESS"
|
| 3550 |
|
3552 |
|