| 9254 |
rajveer |
1 |
#!/usr/bin/python
|
|
|
2 |
|
|
|
3 |
import optparse
|
|
|
4 |
import sys
|
|
|
5 |
import datetime
|
|
|
6 |
from datetime import timedelta
|
|
|
7 |
from elixir import *
|
|
|
8 |
from sqlalchemy.sql import func
|
|
|
9 |
import urllib
|
|
|
10 |
import httplib
|
|
|
11 |
from shop2020.utils.EmailAttachmentSender import mail, mail_html
|
|
|
12 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import UserWalletHistory
|
|
|
13 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
|
|
14 |
from shop2020.utils.Utils import to_java_date, to_py_date
|
|
|
15 |
from shop2020.clients.PaymentClient import PaymentClient
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
if __name__ == '__main__' and __package__ is None:
|
|
|
20 |
import os
|
|
|
21 |
sys.path.insert(0, os.getcwd())
|
|
|
22 |
from datetime import date, timedelta
|
|
|
23 |
from shop2020.clients.HelperClient import HelperClient
|
|
|
24 |
from shop2020.clients.TransactionClient import TransactionClient
|
|
|
25 |
from shop2020.thriftpy.model.v1.order.ttypes import RechargeOrderStatus,\
|
|
|
26 |
OrderType
|
|
|
27 |
from shop2020.model.v1.order.impl.DataAccessors import get_recharge_orders_for_status, update_recharge_order_status,\
|
|
|
28 |
update_recharge_transaction_status, get_next_invoice_number
|
|
|
29 |
from shop2020.model.v1.order.impl import DataService
|
|
|
30 |
from shop2020.model.v1.order.impl.DataService import RechargeTransaction, HotspotStore,\
|
|
|
31 |
WalletForCompany, WalletHistoryForCompany, RechargeCollection, Company, HotspotServiceMatrix,\
|
|
|
32 |
RechargeVoucherTracker
|
|
|
33 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
|
|
34 |
from shop2020.model.v1.order.impl.RechargeService import checkTransactionStatus, getRefunds, getBalance
|
|
|
35 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct, cast, between
|
|
|
36 |
|
|
|
37 |
def main():
|
|
|
38 |
paymentrecon()
|
|
|
39 |
|
|
|
40 |
def paymentrecon():
|
|
|
41 |
today = datetime.datetime.now()
|
|
|
42 |
dateTo = datetime.datetime(today.year, today.month, today.day)
|
|
|
43 |
dateFrom = dateTo - datetime.timedelta(days = 7)
|
|
|
44 |
pc = PaymentClient().get_client()
|
| 13753 |
manish.sha |
45 |
hdfcPayments = pc.getPayments(to_java_date(dateFrom), to_java_date(dateTo), 0, 1) + pc.getPayments(to_java_date(dateFrom), to_java_date(dateTo), 3, 1)
|
|
|
46 |
mail_data = "Problem\tPaymentId\tTransactionId\tAmount\tDateTime\tIsDigital\tPaymentGateway"
|
|
|
47 |
for payment in hdfcPayments:
|
| 9254 |
rajveer |
48 |
if payment.isDigital:
|
|
|
49 |
gstatus = pc.getPaymentStatusAtGateway(payment.merchantTxnId, payment.amount, payment.isDigital)
|
|
|
50 |
if gstatus in(0,3):
|
|
|
51 |
continue
|
|
|
52 |
else:
|
|
|
53 |
print "Problem", str(payment.paymentId), str(payment.merchantTxnId), str(payment.amount), str(payment.isDigital)
|
| 13753 |
manish.sha |
54 |
mail_data += "\nProblem\t" + str(payment.paymentId) + "\t" + str(payment.merchantTxnId) + "\t" + str(payment.amount) + "\t" + str(to_py_date(payment.initTimestamp)) + "\t" + str(payment.isDigital)+"\tHDFC"
|
| 9254 |
rajveer |
55 |
#pc.refundPayment(payment.merchantTxnId, payment.amount, payment.isDigital)
|
|
|
56 |
|
| 13902 |
manish.sha |
57 |
payuPayments = pc.getPayments(to_java_date(dateFrom), to_java_date(dateTo), 0, 20) + pc.getPayments(to_java_date(dateFrom), to_java_date(dateTo), 3, 20)
|
| 13753 |
manish.sha |
58 |
for payment in payuPayments:
|
|
|
59 |
if payment.isDigital:
|
|
|
60 |
gstatus = pc.getPaymentStatusAtGateway(payment.merchantTxnId, payment.amount, payment.isDigital)
|
|
|
61 |
if gstatus in(0,3):
|
|
|
62 |
continue
|
|
|
63 |
else:
|
|
|
64 |
print "Problem", str(payment.paymentId), str(payment.merchantTxnId), str(payment.amount), str(payment.isDigital)
|
|
|
65 |
mail_data += "\nProblem\t" + str(payment.paymentId) + "\t" + str(payment.merchantTxnId) + "\t" + str(payment.amount) + "\t" + str(to_py_date(payment.initTimestamp)) + "\t" + str(payment.isDigital)+"\tPayU"
|
|
|
66 |
#pc.refundPayment(payment.merchantTxnId, payment.amount, payment.isDigital)
|
| 9254 |
rajveer |
67 |
|
| 13753 |
manish.sha |
68 |
|
|
|
69 |
mail("adwords@shop2020.in", "adwords_shop2020", ["amit.sirohi@shop2020.in","amit.gupta@shop2020.in","manish.sharma@shop2020.in"], "HDFC-PayU Payment Status Mismatch", mail_data, [], [], [])
|
| 9254 |
rajveer |
70 |
if __name__ == '__main__':
|
|
|
71 |
main()
|