| Line 16... |
Line 16... |
| 16 |
import mechanize
|
16 |
import mechanize
|
| 17 |
import time
|
17 |
import time
|
| 18 |
import traceback
|
18 |
import traceback
|
| 19 |
import urllib
|
19 |
import urllib
|
| 20 |
import urllib2
|
20 |
import urllib2
|
| - |
|
21 |
from dtr.utils import utils
|
| 21 |
sourceMap = {1:"amazon", 2:"flipkart", 3:"snapdeal", 4:"spice", 5:"shopclues", 6:"paytm"}
|
22 |
sourceMap = {1:"amazon", 2:"flipkart", 3:"snapdeal", 4:"spice", 5:"shopclues", 6:"paytm"}
|
| 22 |
headers = {
|
23 |
headers = {
|
| 23 |
'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
24 |
'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
| 24 |
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
25 |
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
| 25 |
'Accept-Language' : 'en-US,en;q=0.8',
|
26 |
'Accept-Language' : 'en-US,en;q=0.8',
|
| Line 281... |
Line 282... |
| 281 |
bulk = client.Dtr.merchantOrder.initialize_ordered_bulk_op()
|
282 |
bulk = client.Dtr.merchantOrder.initialize_ordered_bulk_op()
|
| 282 |
for searchMap in searchMapList:
|
283 |
for searchMap in searchMapList:
|
| 283 |
bulk.find(searchMap).update({'$set' : {'subOrders.$.cashBackStatus':Store.CB_CREDITED, "subOrders.$.batchId":batchId}})
|
284 |
bulk.find(searchMap).update({'$set' : {'subOrders.$.cashBackStatus':Store.CB_CREDITED, "subOrders.$.batchId":batchId}})
|
| 284 |
print bulk.execute()
|
285 |
print bulk.execute()
|
| 285 |
for key, value in userAmountMap.iteritems():
|
286 |
for key, value in userAmountMap.iteritems():
|
| 286 |
client.Dtr.refund.insert({"userId": key, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S")})
|
287 |
client.Dtr.refund.insert({"userId": key, "batch":batchId, "userAmount":value, "timestamp":datetime.strftime(datetimeNow,"%Y-%m-%d %H:%M:%S"), "type":utils.CREDIT_TYPE_ORDER})
|
| 287 |
client.Dtr.user.update({"userId":key}, {'$inc': { "credited": value}}, upsert=True)
|
288 |
client.Dtr.user.update({"userId":key}, {"$inc": { "credited": value, utils.CREDIT_TYPE_ORDER:value}}, upsert=True)
|
| 288 |
tprint("PayBack Settled")
|
289 |
tprint("PayBack Settled")
|
| 289 |
else:
|
290 |
else:
|
| 290 |
tprint("Error Occurred while running batch. Rolling Back")
|
291 |
tprint("Error Occurred while running batch. Rolling Back")
|
| 291 |
bulk = client.Dtr.merchantOrder.initialize_ordered_bulk_op()
|
292 |
bulk = client.Dtr.merchantOrder.initialize_ordered_bulk_op()
|
| 292 |
for searchMap in searchMapList:
|
293 |
for searchMap in searchMapList:
|