Rev 19556 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on Apr 28, 2015@author: amit'''from dtr.main import clientfrom dtr.storage.Mongo import sendNotificationimport sysimport getoptimport tracebackfrom dtr.main import tprintmongoHost = "192.168.161.154"def main(argv):#scrapepaytm()credittype = 'Order'try:opts, args = getopt.getopt(argv,"ht:",["credittype="])except getopt.GetoptError:print 'pushbatchcreditnotification.py -t <Order|App>'sys.exit(2)for opt, arg in opts:if opt == '-h':print 'pushbatchcreditnotification.py -t <Order|App>'sys.exit()elif opt == '-t':credittype = argtprint("Sending notification", credittype)try:send_Notification(credittype)except:tprint("Error")traceback.print_exc()def send_Notification(credittype):db = client.DtrbatchId = db.refund.find_one({"$query":{"type":credittype},"$orderby":{"batch":-1}}).get("batch")print "Batch Id recently Credited", batchIdif batchId is None:returnrefunds = db.refund.find({"batch":batchId})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))#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))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))for ref in refunds:print ref.get("userId"), ref.get("userAmount")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"))))if __name__ == '__main__':main(sys.argv[1:])