Subversion Repositories SmartDukaan

Rev

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

Rev 19469 Rev 19470
Line 2386... Line 2386...
2386
        status = req.get_param('status')
2386
        status = req.get_param('status')
2387
        jsonReq = json.loads(req.stream.read(), encoding='utf-8')
2387
        jsonReq = json.loads(req.stream.read(), encoding='utf-8')
2388
        print jsonReq        
2388
        print jsonReq        
2389
        userId = jsonReq.get('user_id')
2389
        userId = jsonReq.get('user_id')
2390
        _id = jsonReq.get('_id')
2390
        _id = jsonReq.get('_id')
2391
        conn = get_mongo_connection()
2391
        conn = get_mongo_connection().Dtr
2392
        if status == utils.REFUND_ADJUSTMENT_MAP.get(1):
2392
        if status == utils.REFUND_ADJUSTMENT_MAP.get(1):
2393
            Mongo.updateCrmWalletStatus(status, _id,userId)
2393
            Mongo.updateCrmWalletStatus(status, _id,userId)
2394
            value = jsonReq.get('amount')
2394
            value = jsonReq.get('amount')
2395
            datetimeNow = datetime.now()
2395
            datetimeNow = datetime.now()
2396
            batchId = int(time.mktime(datetimeNow.timetuple()))
2396
            batchId = int(time.mktime(datetimeNow.timetuple()))
2397
            user_id = jsonReq.get('user_id')
2397
            user_id = jsonReq.get('user_id')
2398
            value = jsonReq.get('amount')
2398
            value = jsonReq.get('amount')
2399
            type = jsonReq.get('type')            
2399
            type = jsonReq.get('type')            
2400
            conn.refund.insert({"userId": user_id, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S"), "type":type})
2400
            conn.refund.insert({"userId": user_id, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S"), "type":type})
2401
            conn.Dtr.user.update({"userId":user_id}, {"$inc": { "credited": value, type:value}}, upsert=True)
2401
            conn.user.update({"userId":user_id}, {"$inc": { "credited": value, type:value}}, upsert=True)
2402
            resp.body = "{\"result\":\"success\"}"
2402
            resp.body = "{\"result\":\"success\"}"
2403
        elif status == utils.REFUND_ADJUSTMENT_MAP.get(2):
2403
        elif status == utils.REFUND_ADJUSTMENT_MAP.get(2):
2404
            Mongo.updateCrmWalletStatus(status, _id,userId)
2404
            Mongo.updateCrmWalletStatus(status, _id,userId)
2405
            resp.body = "{\"result\":\"success\"}"
2405
            resp.body = "{\"result\":\"success\"}"
2406
        else:
2406
        else: