| Line 7... |
Line 7... |
| 7 |
user_actions, Brands, app_offers, approved_app_transactions, user_app_cashbacks, \
|
7 |
user_actions, Brands, app_offers, approved_app_transactions, user_app_cashbacks, \
|
| 8 |
user_app_installs, appmasters, notification_campaigns
|
8 |
user_app_installs, appmasters, notification_campaigns
|
| 9 |
from dtr.storage.MemCache import MemCache
|
9 |
from dtr.storage.MemCache import MemCache
|
| 10 |
from dtr.utils.MailSender import Email
|
10 |
from dtr.utils.MailSender import Email
|
| 11 |
from dtr.utils.utils import to_java_date, CB_PENDING, CB_APPROVED, CB_INIT, \
|
11 |
from dtr.utils.utils import to_java_date, CB_PENDING, CB_APPROVED, CB_INIT, \
|
| 12 |
to_py_date, CB_REJECTED, SUB_CATEGORY_MAP, con
|
12 |
to_py_date, CB_REJECTED, SUB_CATEGORY_MAP,CREDIT_TYPE_REFUND,CREDIT_TYPE_OFFER,CREDIT_TYPE_ADJUSTMENT,REFUND_ADJUSTMENT_MAP
|
| 13 |
from sqlalchemy.sql.expression import func, func, or_, desc, asc, case
|
13 |
from sqlalchemy.sql.expression import func, func, or_, desc, asc, case
|
| 14 |
from elixir import *
|
14 |
from elixir import *
|
| 15 |
from operator import itemgetter
|
15 |
from operator import itemgetter
|
| 16 |
from pymongo.command_cursor import CommandCursor
|
16 |
from pymongo.command_cursor import CommandCursor
|
| 17 |
import pymongo
|
17 |
import pymongo
|
| Line 22... |
Line 22... |
| 22 |
from itertools import groupby
|
22 |
from itertools import groupby
|
| 23 |
import urllib
|
23 |
import urllib
|
| 24 |
import urllib2
|
24 |
import urllib2
|
| 25 |
import json
|
25 |
import json
|
| 26 |
import collections
|
26 |
import collections
|
| 27 |
from dtr.utils import utils
|
- |
|
| 28 |
from string import lower
|
27 |
from string import lower
|
| 29 |
try:
|
28 |
try:
|
| 30 |
import ordereddict
|
29 |
import ordereddict
|
| 31 |
except:
|
30 |
except:
|
| 32 |
pass
|
31 |
pass
|
| Line 291... |
Line 290... |
| 291 |
if total_count > skip:
|
290 |
if total_count > skip:
|
| 292 |
cursor = cursor.skip(skip).limit(window).sort([('batch',-1)])
|
291 |
cursor = cursor.skip(skip).limit(window).sort([('batch',-1)])
|
| 293 |
refunds = []
|
292 |
refunds = []
|
| 294 |
for refund in cursor:
|
293 |
for refund in cursor:
|
| 295 |
del(refund["_id"])
|
294 |
del(refund["_id"])
|
| 296 |
if (refund["type"]) == utils.CREDIT_TYPE_REFUND:
|
295 |
if (refund["type"]) == CREDIT_TYPE_REFUND:
|
| 297 |
batchDetails = fetchCrmRefundByBatchId(refund["batch"])
|
296 |
batchDetails = fetchCrmRefundByBatchId(refund["batch"])
|
| 298 |
referenceNumber = batchDetails.get('reference_no')
|
297 |
referenceNumber = batchDetails.get('reference_no')
|
| 299 |
refund["description"] = "Refunded against Saholic order # %s"%(referenceNumber)
|
298 |
refund["description"] = "Refunded against Saholic order #%s"%(referenceNumber)
|
| 300 |
elif (refund["type"]) == utils.CREDIT_TYPE_ADJUSTMENT:
|
299 |
elif (refund["type"]) == CREDIT_TYPE_ADJUSTMENT:
|
| 301 |
batchDetails = fetchCrmRefundByBatchId(refund["batch"])
|
300 |
batchDetails = fetchCrmRefundByBatchId(refund["batch"])
|
| 302 |
referenceNumber = batchDetails.get('reference_no')
|
301 |
referenceNumber = batchDetails.get('reference_no')
|
| 303 |
referenceStore = batchDetails.get('store')
|
302 |
referenceStore = batchDetails.get('store')
|
| 304 |
refund["description"] = "Adjusted against %s order # %s"%(referenceStore,referenceNumber)
|
303 |
refund["description"] = "Adjusted against %s order #%s"%(referenceStore,referenceNumber)
|
| 305 |
else:
|
304 |
else:
|
| 306 |
refund["description"] = ""
|
305 |
refund["description"] = ""
|
| 307 |
refunds.append(refund)
|
306 |
refunds.append(refund)
|
| 308 |
result['credited'] = credited
|
307 |
result['credited'] = credited
|
| 309 |
result['data'] = refunds
|
308 |
result['data'] = refunds
|
| Line 3223... |
Line 3222... |
| 3223 |
referenceId = jsonReq.get('reference_no')
|
3222 |
referenceId = jsonReq.get('reference_no')
|
| 3224 |
referenceDescription = jsonReq.get('reference_description')
|
3223 |
referenceDescription = jsonReq.get('reference_description')
|
| 3225 |
if store.strip() is '':
|
3224 |
if store.strip() is '':
|
| 3226 |
store = None
|
3225 |
store = None
|
| 3227 |
if lower(refundType)=='refund':
|
3226 |
if lower(refundType)=='refund':
|
| 3228 |
refundType = utils.CREDIT_TYPE_REFUND
|
3227 |
refundType = CREDIT_TYPE_REFUND
|
| 3229 |
elif lower(refundType)=='adjustment':
|
3228 |
elif lower(refundType)=='adjustment':
|
| 3230 |
refundType = utils.CREDIT_TYPE_ADJUSTMENT
|
3229 |
refundType = CREDIT_TYPE_ADJUSTMENT
|
| 3231 |
collection = get_mongo_connection().Dtr.crmrefundwallet
|
3230 |
collection = get_mongo_connection().Dtr.crmrefundwallet
|
| 3232 |
offer1 = CrmRefundWallet(userId,emailId,mobileNumber,amount,refundType,store,referenceId,referenceDescription,utils.REFUND_ADJUSTMENT_MAP.get(0),to_java_date(datetime.now()))
|
3231 |
offer1 = CrmRefundWallet(userId,emailId,mobileNumber,amount,refundType,store,referenceId,referenceDescription,REFUND_ADJUSTMENT_MAP.get(0),to_java_date(datetime.now()))
|
| 3233 |
dict1 = todict(offer1)
|
3232 |
dict1 = todict(offer1)
|
| 3234 |
collection.save(dict1)
|
3233 |
collection.save(dict1)
|
| 3235 |
return True
|
3234 |
return True
|
| 3236 |
|
3235 |
|
| 3237 |
def updateCrmWalletStatus(status,_id,userId,batchId,approvedBy):
|
3236 |
def updateCrmWalletStatus(status,_id,userId,batchId,approvedBy):
|