| Line 1431... |
Line 1431... |
| 1431 |
print 'Got Response for Transaction Id:- '+ str(transaction_id)+ ' and Actual Payout:- '+str(payout)
|
1431 |
print 'Got Response for Transaction Id:- '+ str(transaction_id)+ ' and Actual Payout:- '+str(payout)
|
| 1432 |
transaction = list(get_mongo_connection().AppOrder.AppTransaction.find({'_id':ObjectId(transaction_id)}))
|
1432 |
transaction = list(get_mongo_connection().AppOrder.AppTransaction.find({'_id':ObjectId(transaction_id)}))
|
| 1433 |
if len(transaction) > 0:
|
1433 |
if len(transaction) > 0:
|
| 1434 |
if (transaction[0])['payout_status'] ==1:
|
1434 |
if (transaction[0])['payout_status'] ==1:
|
| 1435 |
get_mongo_connection().AppOrder.AppTransaction.update({'_id':ObjectId(transaction_id)},{"$set":{'payout_amount':float(payout), 'payout_description': CB_APPROVED,'payout_status':2, 'cashback_status': 2, 'cash_back_description': CB_APPROVED, 'payout_time':to_java_date(datetime.now())}})
|
1435 |
get_mongo_connection().AppOrder.AppTransaction.update({'_id':ObjectId(transaction_id)},{"$set":{'payout_amount':float(payout), 'payout_description': CB_APPROVED,'payout_status':2, 'cashback_status': 2, 'cash_back_description': CB_APPROVED, 'payout_time':to_java_date(datetime.now())}})
|
| 1436 |
|
- |
|
| 1437 |
approvedAppTransaction = approved_app_transactions()
|
- |
|
| 1438 |
approvedAppTransaction.app_id = transaction[0]['app_id']
|
- |
|
| 1439 |
approvedAppTransaction.cash_back_description = CB_APPROVED
|
- |
|
| 1440 |
approvedAppTransaction.retailer_id = transaction[0]['retailer_id']
|
- |
|
| 1441 |
approvedAppTransaction.transaction_id = transaction_id
|
- |
|
| 1442 |
approvedAppTransaction.transaction_time = to_py_date(long(transaction[0]['transaction_time']))
|
- |
|
| 1443 |
approvedAppTransaction.redirect_url = transaction[0]['redirect_url']
|
- |
|
| 1444 |
approvedAppTransaction.payout_status = 2
|
- |
|
| 1445 |
approvedAppTransaction.payout_description = CB_APPROVED
|
- |
|
| 1446 |
approvedAppTransaction.cashback_status = 2
|
- |
|
| 1447 |
approvedAppTransaction.payout_amount = long(payout)
|
- |
|
| 1448 |
approvedAppTransaction.payout_time = datetime.now()
|
- |
|
| 1449 |
approvedAppTransaction.offer_price = long(transaction[0]['offer_price'])
|
- |
|
| 1450 |
approvedAppTransaction.overridenCashBack = transaction[0]['overridenCashBack']
|
- |
|
| 1451 |
if str(transaction[0]['isCashBackOverriden']) == 'false' or str(transaction[0]['isCashBackOverriden']) == 'False':
|
- |
|
| 1452 |
approvedAppTransaction.isCashBackOverriden = False
|
- |
|
| 1453 |
else:
|
- |
|
| 1454 |
approvedAppTransaction.isCashBackOverriden = True
|
- |
|
| 1455 |
approvedAppTransaction.user_payout = transaction[0]['user_payout']
|
- |
|
| 1456 |
approvedAppTransaction.cashBackConsidered = False
|
- |
|
| 1457 |
session.commit()
|
- |
|
| 1458 |
|
1436 |
|
| - |
|
1437 |
approvedAppTransaction = approved_app_transactions.get_by(transaction_id=transaction_id)
|
| - |
|
1438 |
if approvedAppTransaction is None:
|
| - |
|
1439 |
approvedAppTransaction = approved_app_transactions()
|
| - |
|
1440 |
approvedAppTransaction.app_id = transaction[0]['app_id']
|
| - |
|
1441 |
approvedAppTransaction.cash_back_description = CB_APPROVED
|
| - |
|
1442 |
approvedAppTransaction.retailer_id = transaction[0]['retailer_id']
|
| - |
|
1443 |
approvedAppTransaction.transaction_id = transaction_id
|
| - |
|
1444 |
approvedAppTransaction.transaction_time = to_py_date(long(transaction[0]['transaction_time']))
|
| - |
|
1445 |
approvedAppTransaction.redirect_url = transaction[0]['redirect_url']
|
| - |
|
1446 |
approvedAppTransaction.payout_status = 2
|
| - |
|
1447 |
approvedAppTransaction.payout_description = CB_APPROVED
|
| - |
|
1448 |
approvedAppTransaction.cashback_status = 2
|
| - |
|
1449 |
approvedAppTransaction.payout_amount = long(payout)
|
| - |
|
1450 |
approvedAppTransaction.payout_time = datetime.now()
|
| - |
|
1451 |
approvedAppTransaction.offer_price = long(transaction[0]['offer_price'])
|
| - |
|
1452 |
approvedAppTransaction.overridenCashBack = transaction[0]['overridenCashBack']
|
| - |
|
1453 |
if str(transaction[0]['isCashBackOverriden']) == 'false' or str(transaction[0]['isCashBackOverriden']) == 'False':
|
| - |
|
1454 |
approvedAppTransaction.isCashBackOverriden = False
|
| - |
|
1455 |
else:
|
| - |
|
1456 |
approvedAppTransaction.isCashBackOverriden = True
|
| - |
|
1457 |
approvedAppTransaction.user_payout = transaction[0]['user_payout']
|
| - |
|
1458 |
approvedAppTransaction.cashBackConsidered = False
|
| - |
|
1459 |
session.commit()
|
| - |
|
1460 |
|
| 1459 |
updateResult = _updateApprovedCashbackToUser(approvedAppTransaction.id)
|
1461 |
updateResult = _updateApprovedCashbackToUser(approvedAppTransaction.id)
|
| - |
|
1462 |
else:
|
| - |
|
1463 |
session.close()
|
| - |
|
1464 |
|
| 1460 |
'''
|
1465 |
'''
|
| 1461 |
try:
|
1466 |
try:
|
| 1462 |
if int(transaction[0]['offer_price']) != payout or int(transaction[0]['user_payout']) < payout:
|
1467 |
if int(transaction[0]['offer_price']) != payout or int(transaction[0]['user_payout']) < payout:
|
| 1463 |
_sendAlertForAppPayouts(int(transaction[0]['app_id']), int(transaction[0]['offer_price']), int(transaction[0]['user_payout']), payout)
|
1468 |
_sendAlertForAppPayouts(int(transaction[0]['app_id']), int(transaction[0]['offer_price']), int(transaction[0]['user_payout']), payout)
|
| 1464 |
except:
|
1469 |
except:
|
| 1465 |
print traceback.print_exc()
|
1470 |
print traceback.print_exc()
|
| 1466 |
'''
|
1471 |
'''
|
| 1467 |
return {'status':'ok','message':'Payout updated'}
|
1472 |
return {'status':'ok','message':'Payout updated'}
|
| 1468 |
elif (transaction[0])['payout_status'] ==2:
|
1473 |
elif (transaction[0])['payout_status'] ==2:
|
| 1469 |
return {'status':'ok','message':'Payout already processed'}
|
1474 |
return {'status':'ok','message':'Payout already processed'}
|
| 1470 |
else:
|
1475 |
else:
|
| 1471 |
return {'status':'fail','message':'Something is wrong'}
|
1476 |
return {'status':'fail','message':'Something is wrong'}
|
| Line 1521... |
Line 1526... |
| 1521 |
except:
|
1526 |
except:
|
| 1522 |
session.rollback()
|
1527 |
session.rollback()
|
| 1523 |
print traceback.print_exc()
|
1528 |
print traceback.print_exc()
|
| 1524 |
return False
|
1529 |
return False
|
| 1525 |
finally:
|
1530 |
finally:
|
| 1526 |
if session.is_active():
|
- |
|
| 1527 |
session.close()
|
1531 |
session.close()
|
| 1528 |
|
1532 |
|
| 1529 |
def _sendAlertForAppPayouts(app_id, offerPrice, userPayout, payout):
|
1533 |
def _sendAlertForAppPayouts(app_id, offerPrice, userPayout, payout):
|
| 1530 |
m = Email('localhost')
|
1534 |
m = Email('localhost')
|
| 1531 |
mFrom = "dtr@shop2020.in"
|
1535 |
mFrom = "dtr@shop2020.in"
|
| 1532 |
m.setFrom(mFrom)
|
1536 |
m.setFrom(mFrom)
|