| Line 12... |
Line 12... |
| 12 |
update_recharge_transaction_status
|
12 |
update_recharge_transaction_status
|
| 13 |
from shop2020.model.v1.order.impl import DataService, RechargeService
|
13 |
from shop2020.model.v1.order.impl import DataService, RechargeService
|
| 14 |
from shop2020.model.v1.order.impl.DataService import RechargeTransaction
|
14 |
from shop2020.model.v1.order.impl.DataService import RechargeTransaction
|
| 15 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
15 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
| 16 |
|
16 |
|
| 17 |
def processRechargeTransactions():
|
17 |
def processRechargeTransactions(deltaTime):
|
| 18 |
#Lets first get all recharge unknown orders irrespective of recharge mode in 30 minutes time window
|
18 |
#Lets first get all recharge unknown orders irrespective of recharge mode in 30 minutes time window
|
| 19 |
try:
|
19 |
try:
|
| 20 |
timeFilter = datetime.now() -timedelta(minutes=30)
|
20 |
timeFilter = datetime.now() -timedelta(minutes=deltaTime)
|
| 21 |
unknownOrders = RechargeTransaction.query.filter(RechargeTransaction.status == RechargeOrderStatus.RECHARGE_UNKNOWN).filter(RechargeTransaction.transactionTime >=timeFilter).all()
|
21 |
unknownOrders = RechargeTransaction.query.filter(RechargeTransaction.status == RechargeOrderStatus.RECHARGE_UNKNOWN).filter(RechargeTransaction.transactionTime >=timeFilter).all()
|
| 22 |
for unknownOrder in unknownOrders:
|
22 |
for unknownOrder in unknownOrders:
|
| 23 |
try:
|
23 |
try:
|
| 24 |
status, description = RechargeService.checkTransactionStatus('', str(unknownOrder.id))
|
24 |
status, description = RechargeService.checkTransactionStatus('', str(unknownOrder.id))
|
| 25 |
print status, description
|
25 |
print status, description
|
| Line 52... |
Line 52... |
| 52 |
except:
|
52 |
except:
|
| 53 |
print "Still unknown"
|
53 |
print "Still unknown"
|
| 54 |
finally:
|
54 |
finally:
|
| 55 |
session.close()
|
55 |
session.close()
|
| 56 |
|
56 |
|
| 57 |
def processRechargeOrders():
|
57 |
def processRechargeOrders(deltaTime):
|
| 58 |
#Lets first get all payment successful orders irrespective of recharge mode in 30 minutes time window
|
58 |
#Lets first get all payment successful orders irrespective of recharge mode in 30 minutes time window
|
| 59 |
try:
|
59 |
try:
|
| 60 |
timeFilter = datetime.now() -timedelta(minutes=30)
|
60 |
timeFilter = datetime.now() -timedelta(minutes=deltaTime)
|
| 61 |
paymentSuccessfulOrders = RechargeOrder.query.filter(RechargeOrder.status == RechargeOrderStatus.PAYMENT_SUCCESSFUL).filter(RechargeOrder.creationTimestamp >=timeFilter).all()
|
61 |
paymentSuccessfulOrders = RechargeOrder.query.filter(RechargeOrder.status == RechargeOrderStatus.PAYMENT_SUCCESSFUL).filter(RechargeOrder.creationTimestamp >=timeFilter).all()
|
| 62 |
for paymentSuccessfulOrder in paymentSuccessfulOrders:
|
62 |
for paymentSuccessfulOrder in paymentSuccessfulOrders:
|
| 63 |
try:
|
63 |
try:
|
| 64 |
status, description = RechargeService.checkTransactionStatus('', str(paymentSuccessfulOrder.id))
|
64 |
status, description = RechargeService.checkTransactionStatus('', str(paymentSuccessfulOrder.id))
|
| 65 |
print status, description
|
65 |
print status, description
|
| Line 98... |
Line 98... |
| 98 |
parser = optparse.OptionParser()
|
98 |
parser = optparse.OptionParser()
|
| 99 |
parser.add_option("-H", "--host", dest="hostname",
|
99 |
parser.add_option("-H", "--host", dest="hostname",
|
| 100 |
default="localhost",
|
100 |
default="localhost",
|
| 101 |
type="string", help="The HOST where the DB server is running",
|
101 |
type="string", help="The HOST where the DB server is running",
|
| 102 |
metavar="HOST")
|
102 |
metavar="HOST")
|
| - |
|
103 |
parser.add_option("-T", "--time", dest="time",
|
| - |
|
104 |
default=60,
|
| - |
|
105 |
type="int", help="Time in minutes to filter recharge orders/transaction",
|
| - |
|
106 |
metavar="TIME")
|
| 103 |
(options, args) = parser.parse_args()
|
107 |
(options, args) = parser.parse_args()
|
| 104 |
if len(args) != 0:
|
108 |
if len(args) != 0:
|
| 105 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
109 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
| 106 |
DataService.initialize(db_hostname=options.hostname, echoOn=True)
|
110 |
DataService.initialize(db_hostname=options.hostname, echoOn=True)
|
| 107 |
processRechargeOrders()
|
111 |
processRechargeOrders(options.time)
|
| 108 |
processRechargeTransactions()
|
112 |
processRechargeTransactions(options.time)
|
| 109 |
|
113 |
|
| 110 |
if __name__=='__main__':
|
114 |
if __name__=='__main__':
|
| 111 |
main()
|
115 |
main()
|