| Line 88... |
Line 88... |
| 88 |
def trackOrdersForUser(self, userId, url, rawHtml):
|
88 |
def trackOrdersForUser(self, userId, url, rawHtml):
|
| 89 |
executeBulk = False
|
89 |
executeBulk = False
|
| 90 |
ordermap = json.loads(rawHtml).get("order")
|
90 |
ordermap = json.loads(rawHtml).get("order")
|
| 91 |
merchantOrderId = str(ordermap.get("id"))
|
91 |
merchantOrderId = str(ordermap.get("id"))
|
| 92 |
merchantOrder = self.db.merchantOrder.findOne({"merchantOrderId":merchantOrderId})
|
92 |
merchantOrder = self.db.merchantOrder.findOne({"merchantOrderId":merchantOrderId})
|
| - |
|
93 |
try:
|
| 93 |
bulk = self.db.merchantOrder.initialize_ordered_bulk_op()
|
94 |
bulk = self.db.merchantOrder.initialize_ordered_bulk_op()
|
| 94 |
closed=True
|
95 |
closed=True
|
| 95 |
for item in ordermap.get("items"):
|
96 |
for item in ordermap.get("items"):
|
| 96 |
merchantSubOrderId = item.get("id")
|
97 |
merchantSubOrderId = item.get("id")
|
| 97 |
for subOrder in merchantOrder.get("subOrders"):
|
98 |
for subOrder in merchantOrder.get("subOrders"):
|
| 98 |
if not subOrder.get("closed"):
|
99 |
if not subOrder.get("closed"):
|
| 99 |
if merchantSubOrderId == subOrder.get("merchantSubOrderId") and item.get("status_text") != subOrder.get("detailedStatus"):
|
100 |
if merchantSubOrderId == subOrder.get("merchantSubOrderId") and item.get("status_text") != subOrder.get("detailedStatus"):
|
| 100 |
executeBulk = True
|
101 |
executeBulk = True
|
| 101 |
findMap = {"orderId":merchantOrder.get("orderId"), "subOrders.merchantSubOrderId":subOrder.get("merchantSubOrderId")}
|
102 |
findMap = {"orderId":merchantOrder.get("orderId"), "subOrders.merchantSubOrderId":subOrder.get("merchantSubOrderId")}
|
| 102 |
newSub = {}
|
103 |
newSub = {}
|
| 103 |
detailedStatus = item.get("status_text")
|
104 |
detailedStatus = item.get("status_text")
|
| 104 |
newSub['detailedStatus'] = detailedStatus
|
105 |
newSub['detailedStatus'] = detailedStatus
|
| 105 |
status = self._getStatusFromDetailedStatus(detailedStatus)
|
106 |
status = self._getStatusFromDetailedStatus(detailedStatus)
|
| 106 |
newSub['status'] = status if status else subOrder.get("status")
|
107 |
newSub['status'] = status if status else subOrder.get("status")
|
| 107 |
updateMap = self.getUpdateMap(newSub, subOrder.get("cashBackStatus"))
|
108 |
updateMap = self.getUpdateMap(newSub, subOrder.get("cashBackStatus"))
|
| 108 |
bulk.find(findMap).update({'$set' : updateMap})
|
109 |
bulk.find(findMap).update({'$set' : updateMap})
|
| 109 |
closed = closed and newSub['closed']
|
110 |
closed = closed and newSub['closed']
|
| 110 |
break
|
111 |
break
|
| 111 |
else:
|
112 |
else:
|
| 112 |
continue
|
113 |
continue
|
| 113 |
if executeBulk:
|
114 |
if executeBulk:
|
| 114 |
bulk.find({"orderId":merchantOrder.get("orderId")}).update({"$set":{"closed":closed, "parseError":False}})
|
115 |
bulk.find({"orderId":merchantOrder.get("orderId")}).update({"$set":{"closed":closed, "parseError":False}})
|
| 115 |
bulk.execute()
|
116 |
bulk.execute()
|
| - |
|
117 |
except:
|
| - |
|
118 |
tprint("Could not update " + str(merchantOrder['orderId']) + " For store " + self.getName())
|
| - |
|
119 |
self.db.merchantOrder.update({"orderId":merchantOrder['orderId']}, {"$set":{"parseError":True}})
|
| - |
|
120 |
traceback.print_exc()
|
| 116 |
|
121 |
|
| 117 |
def parseOrderRawHtml(self, orderId, subTagId, userId, rawHtml, orderSuccessUrl):
|
122 |
def parseOrderRawHtml(self, orderId, subTagId, userId, rawHtml, orderSuccessUrl):
|
| 118 |
try:
|
123 |
try:
|
| 119 |
resp = {}
|
124 |
resp = {}
|
| 120 |
#orderSuccessUrl = "https://paytm.com/shop/orderdetail/1155961075?actions=1&channel=web&version=2"
|
125 |
#orderSuccessUrl = "https://paytm.com/shop/orderdetail/1155961075?actions=1&channel=web&version=2"
|