| 14995 |
amit.gupta |
1 |
'''
|
|
|
2 |
Created on Apr 28, 2015
|
|
|
3 |
|
|
|
4 |
@author: amit
|
|
|
5 |
'''
|
|
|
6 |
from dtr.main import client
|
| 17280 |
manish.sha |
7 |
from dtr.storage.Mongo import sendNotification
|
| 17072 |
manish.sha |
8 |
import sys
|
|
|
9 |
import getopt
|
|
|
10 |
import traceback
|
| 17073 |
manish.sha |
11 |
from dtr.main import tprint
|
| 17072 |
manish.sha |
12 |
|
| 24383 |
amit.gupta |
13 |
mongoHost = "192.168.158.89"
|
| 19338 |
manish.sha |
14 |
|
| 17072 |
manish.sha |
15 |
def main(argv):
|
| 14995 |
amit.gupta |
16 |
#scrapepaytm()
|
| 17072 |
manish.sha |
17 |
credittype = 'Order'
|
|
|
18 |
try:
|
|
|
19 |
opts, args = getopt.getopt(argv,"ht:",["credittype="])
|
|
|
20 |
except getopt.GetoptError:
|
|
|
21 |
print 'pushbatchcreditnotification.py -t <Order|App>'
|
|
|
22 |
sys.exit(2)
|
|
|
23 |
for opt, arg in opts:
|
|
|
24 |
if opt == '-h':
|
|
|
25 |
print 'pushbatchcreditnotification.py -t <Order|App>'
|
|
|
26 |
sys.exit()
|
|
|
27 |
elif opt == '-t':
|
|
|
28 |
credittype = arg
|
|
|
29 |
|
|
|
30 |
tprint("Sending notification", credittype)
|
|
|
31 |
|
|
|
32 |
try:
|
|
|
33 |
send_Notification(credittype)
|
|
|
34 |
except:
|
|
|
35 |
tprint("Error")
|
|
|
36 |
traceback.print_exc()
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
def send_Notification(credittype):
|
| 14995 |
amit.gupta |
40 |
db = client.Dtr
|
| 16651 |
amit.gupta |
41 |
|
| 17072 |
manish.sha |
42 |
batchId = db.refund.find_one({"$query":{"type":credittype},"$orderby":{"batch":-1}}).get("batch")
|
| 16651 |
amit.gupta |
43 |
print "Batch Id recently Credited", batchId
|
| 14995 |
amit.gupta |
44 |
if batchId is None:
|
|
|
45 |
return
|
|
|
46 |
refunds = db.refund.find({"batch":batchId})
|
| 19556 |
manas |
47 |
sendNotification([8], 'Batch Credit', 'Cashback Credited for %ss'%(str(credittype)), 'Rs.%s has been added to your wallet'%(250), 'url', 'http://api.profittill.com/cashbacks/mine?user_id=%s'%(8), '2999-01-01', True, "TRAN_SMS Dear Customer, Cashback credited for %ss. Rs.%s has been added to your wallet"%(str(credittype),250))
|
| 18384 |
amit.gupta |
48 |
#sendNotification([14], 'Batch Credit', 'Cashback Credited for %ss'%(str(credittype)), 'Rs.%s has been added to your wallet'%(250), 'url', 'http://api.profittill.com/cashbacks/mine?user_id=%s'%(14))
|
| 19556 |
manas |
49 |
sendNotification([14], 'Batch Credit', 'Cashback Credited for %ss'%(str(credittype)), 'Rs.%s has been added to your wallet'%(250), 'url', 'http://api.profittill.com/cashbacks/mine?user_id=%s'%(8), '2999-01-01',True, "TRAN_SMS Dear Customer, Cashback credited for %ss. Rs.%s has been added to your wallet"%(str(credittype),250))
|
| 14995 |
amit.gupta |
50 |
for ref in refunds:
|
|
|
51 |
print ref.get("userId"), ref.get("userAmount")
|
| 19556 |
manas |
52 |
sendNotification([ref.get("userId")], 'Batch Credit', 'Cashback Credited for %ss'%(str(credittype)), 'Rs.%s has been added to your wallet'%(int(ref.get("userAmount"))), 'url', 'http://api.profittill.com/cashbacks/mine?user_id=%s'%(ref.get("userId")), '2999-01-01', True, "TRAN_SMS Dear Customer, Cashback Credited for %ss. Rs.%s has been added to your wallet"%(str(credittype),int(ref.get("userAmount"))))
|
| 14995 |
amit.gupta |
53 |
|
|
|
54 |
if __name__ == '__main__':
|
| 17072 |
manish.sha |
55 |
main(sys.argv[1:])
|