Subversion Repositories SmartDukaan

Rev

Rev 19479 | Rev 19484 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19479 Rev 19482
Line 2392... Line 2392...
2392
            value = int(jsonReq.get('amount'))
2392
            value = int(jsonReq.get('amount'))
2393
            userAmountMap = {}
2393
            userAmountMap = {}
2394
            datetimeNow = datetime.now()
2394
            datetimeNow = datetime.now()
2395
            batchId = int(time.mktime(datetimeNow.timetuple()))
2395
            batchId = int(time.mktime(datetimeNow.timetuple()))
2396
            userAmountMap[user_id] = value
2396
            userAmountMap[user_id] = value
-
 
2397
            Mongo.updateCrmWalletStatus(status, _id,user_id,None)
2397
            if refundToWallet(batchId,userAmountMap):
2398
            if refundToWallet(batchId,userAmountMap):
2398
                Mongo.updateCrmWalletStatus(status, _id,user_id)
-
 
2399
                refundType = jsonReq.get('type')
2399
                refundType = jsonReq.get('type')
2400
                get_mongo_connection().Dtr.refund.insert({"userId": user_id, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S"), "type":refundType})
2400
                get_mongo_connection().Dtr.refund.insert({"userId": user_id, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S"), "type":refundType})
2401
                get_mongo_connection().Dtr.user.update({"userId":user_id}, {"$inc": { "credited": value, refundType:value}}, upsert=True)
2401
                get_mongo_connection().Dtr.user.update({"userId":user_id}, {"$inc": { "credited": value, refundType:value}}, upsert=True)
-
 
2402
                Mongo.updateCrmWalletStatus(utils.REFUND_ADJUSTMENT_MAP.get(3), _id,user_id,batchId)
2402
                print user_id,value                
2403
                print user_id,value                
2403
                Mongo.sendNotification([user_id], 'Batch Credit', 'Cashback Credited for %ss'%(str(refundType)), 'Rs.%s has been added to your wallet'%(value),'url', 'http://api.profittill.com/cashbacks/mine?user_id=%s'%(user_id), '2999-01-01', True, "TRAN_SMS Dear Customer, Cashback Credited for %ss. Rs.%s has been added to your wallet"%(refundType,value))
2404
                Mongo.sendNotification([user_id], 'Batch Credit', 'Cashback Credited for %ss'%(str(refundType)), 'Rs.%s has been added to your wallet'%(value),'url', 'http://api.profittill.com/cashbacks/mine?user_id=%s'%(user_id), '2999-01-01', True, "TRAN_SMS Dear Customer, Cashback Credited for %ss. Rs.%s has been added to your wallet"%(refundType,value))
2404
                resp.body = "{\"result\":\"success\"}"
2405
                resp.body = "{\"result\":\"success\"}"
2405
            else:
2406
            else:
2406
                resp.body = "{\"result\":\"failed\"}"
2407
                resp.body = "{\"result\":\"failed\"}"