| Line 16... |
Line 16... |
| 16 |
if __name__ == '__main__' and __package__ is None:
|
16 |
if __name__ == '__main__' and __package__ is None:
|
| 17 |
import os
|
17 |
import os
|
| 18 |
sys.path.insert(0, os.getcwd())
|
18 |
sys.path.insert(0, os.getcwd())
|
| 19 |
|
19 |
|
| 20 |
from shop2020.thriftpy.model.v1.order.ttypes import RechargeOrderStatus
|
20 |
from shop2020.thriftpy.model.v1.order.ttypes import RechargeOrderStatus
|
| 21 |
from shop2020.model.v1.order.impl.DataAccessors import get_recharge_orders_for_status, update_recharge_order_status
|
21 |
from shop2020.model.v1.order.impl.DataAccessors import get_recharge_orders_for_status, update_recharge_order_status,\
|
| - |
|
22 |
update_amount_in_wallet
|
| 22 |
from shop2020.model.v1.order.impl import DataService
|
23 |
from shop2020.model.v1.order.impl import DataService
|
| 23 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
24 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
| 24 |
from shop2020.model.v1.order.impl.RechargeService import checkTransactionStatus, getRefunds
|
25 |
from shop2020.model.v1.order.impl.RechargeService import checkTransactionStatus, getRefunds
|
| 25 |
|
26 |
|
| 26 |
|
27 |
|
| Line 38... |
Line 39... |
| 38 |
help="")
|
39 |
help="")
|
| 39 |
|
40 |
|
| 40 |
(options, args) = parser.parse_args()
|
41 |
(options, args) = parser.parse_args()
|
| 41 |
if len(args) != 0:
|
42 |
if len(args) != 0:
|
| 42 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
43 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
| - |
|
44 |
DataService.initialize(db_hostname=options.hostname, echoOn=True)
|
| 43 |
|
45 |
|
| 44 |
if options.refund:
|
46 |
if options.refund:
|
| 45 |
processRefunds()
|
47 |
processRefunds()
|
| 46 |
if options.unknown:
|
48 |
if options.unknown:
|
| 47 |
processUnknownTransactions()
|
49 |
processUnknownTransactions()
|
| 48 |
|
50 |
|
| 49 |
def processRefunds():
|
51 |
def processRefunds():
|
| 50 |
DataService.initialize(db_hostname=options.hostname, echoOn=True)
|
- |
|
| 51 |
todate = datetime.datetime.now()
|
52 |
todate = datetime.datetime.now()
|
| 52 |
for i in range(15):
|
53 |
for i in range(15):
|
| 53 |
orderDate = todate + datetime.timedelta(days= -i)
|
54 |
orderDate = todate + datetime.timedelta(days= -i)
|
| 54 |
refunds = getRefunds(orderDate)
|
55 |
refunds = getRefunds(orderDate)
|
| 55 |
for key in refunds.keys():
|
56 |
for key in refunds.keys():
|
| Line 67... |
Line 68... |
| 67 |
print "Refund amount is not same as transaction amount"
|
68 |
print "Refund amount is not same as transaction amount"
|
| 68 |
continue
|
69 |
continue
|
| 69 |
order.status = RechargeOrderStatus.RECHARGE_FAILED_REFUNDED
|
70 |
order.status = RechargeOrderStatus.RECHARGE_FAILED_REFUNDED
|
| 70 |
order.responseTimestamp = refundDate
|
71 |
order.responseTimestamp = refundDate
|
| 71 |
session.commit()
|
72 |
session.commit()
|
| - |
|
73 |
update_amount_in_wallet(order.userId, order.walletAmount, order.id)
|
| - |
|
74 |
update_amount_in_wallet(order.userId, order.totalAmount - order.walletAmount, order.id)
|
| - |
|
75 |
|
| 72 |
|
76 |
|
| 73 |
def processUnknownTransactions():
|
77 |
def processUnknownTransactions():
|
| 74 |
DataService.initialize(db_hostname=options.hostname, echoOn=True)
|
- |
|
| 75 |
orders = get_recharge_orders_for_status(RechargeOrderStatus.PAYMENT_SUCCESSFUL)
|
78 |
orders = get_recharge_orders_for_status(RechargeOrderStatus.PAYMENT_SUCCESSFUL)
|
| 76 |
for order in orders:
|
79 |
for order in orders:
|
| 77 |
if order.creationTimestamp + datetime.timedelta(minutes=10) < datetime.datetime.now():
|
80 |
if order.creationTimestamp + datetime.timedelta(minutes=10) < datetime.datetime.now():
|
| 78 |
status, description = checkTransactionStatus('', str(order.id))
|
81 |
status, description = checkTransactionStatus('', str(order.id))
|
| 79 |
print status, description
|
82 |
print status, description
|