| Line 39... |
Line 39... |
| 39 |
'''
|
39 |
'''
|
| 40 |
OrderStatusMap = {
|
40 |
OrderStatusMap = {
|
| 41 |
MStore.ORDER_PLACED : ['in progress', 'pending for verification', 'not available', 'in process', 'processing', 'processed'],
|
41 |
MStore.ORDER_PLACED : ['in progress', 'pending for verification', 'not available', 'in process', 'processing', 'processed'],
|
| 42 |
MStore.ORDER_DELIVERED : ['delivered'],
|
42 |
MStore.ORDER_DELIVERED : ['delivered'],
|
| 43 |
MStore.ORDER_SHIPPED : ['in transit', 'dispatched'],
|
43 |
MStore.ORDER_SHIPPED : ['in transit', 'dispatched'],
|
| 44 |
MStore.ORDER_CANCELLED : ['closed for vendor reallocation', 'cancelled', 'product returned by courier', 'returned', 'n/a', 'courier returned']
|
44 |
MStore.ORDER_CANCELLED : ['closed for vendor reallocation', 'cancelled', 'product returned by courier', 'returned', 'n/a', 'courier returned', 'a new order placed with a different seller']
|
| 45 |
}
|
45 |
}
|
| 46 |
|
46 |
|
| 47 |
CONF_CB_AMOUNT = MStore.CONF_CB_DISCOUNTED_PRICE
|
47 |
CONF_CB_AMOUNT = MStore.CONF_CB_DISCOUNTED_PRICE
|
| 48 |
def __init__(self,store_id):
|
48 |
def __init__(self,store_id):
|
| 49 |
super(Store, self).__init__(store_id)
|
49 |
super(Store, self).__init__(store_id)
|
| Line 283... |
Line 283... |
| 283 |
|
283 |
|
| 284 |
productUrl = imgDiv.a['href']
|
284 |
productUrl = imgDiv.a['href']
|
| 285 |
subOrder = SubOrder(productTitle, productUrl, placedOn, amountPaid)
|
285 |
subOrder = SubOrder(productTitle, productUrl, placedOn, amountPaid)
|
| 286 |
subOrder.merchantSubOrderId = prodDivs[0].text.split(':')[1].strip()
|
286 |
subOrder.merchantSubOrderId = prodDivs[0].text.split(':')[1].strip()
|
| 287 |
subOrder.detailedStatus = otherDiv.find('div',{'class':'orderStatus'}).span.text.strip()
|
287 |
subOrder.detailedStatus = otherDiv.find('div',{'class':'orderStatus'}).span.text.strip()
|
| - |
|
288 |
if subOrder.detailedStatus.lower() == "processing":
|
| - |
|
289 |
processingDetailedStatus = subOrderElement.find('div', {'class':'trackingMessage'}).text.strip()
|
| - |
|
290 |
if processingDetailedStatus.lower() == 'a new order placed with a different seller':
|
| - |
|
291 |
subOrder.detailedStatus = processingDetailedStatus
|
| 288 |
deliveryStatus = otherDiv.find('div',{'class':'orderDelivery'})
|
292 |
deliveryStatus = otherDiv.find('div',{'class':'orderDelivery'})
|
| 289 |
if deliveryStatus is not None:
|
293 |
if deliveryStatus is not None:
|
| 290 |
delString = deliveryStatus.text.strip()
|
294 |
delString = deliveryStatus.text.strip()
|
| 291 |
arr = delString.split(':')
|
295 |
arr = delString.split(':')
|
| 292 |
if "On" in arr[0]:
|
296 |
if "On" in arr[0]:
|
| Line 515... |
Line 519... |
| 515 |
updateMap["subOrders.$.detailedStatus"] = detailedStatus
|
519 |
updateMap["subOrders.$.detailedStatus"] = detailedStatus
|
| 516 |
status = self._getStatusFromDetailedStatus(detailedStatus)
|
520 |
status = self._getStatusFromDetailedStatus(detailedStatus)
|
| 517 |
closedStatus = status in [Store.ORDER_DELIVERED, Store.ORDER_CANCELLED]
|
521 |
closedStatus = status in [Store.ORDER_DELIVERED, Store.ORDER_CANCELLED]
|
| 518 |
if status is not None:
|
522 |
if status is not None:
|
| 519 |
updateMap["subOrders.$.status"] = status
|
523 |
updateMap["subOrders.$.status"] = status
|
| 520 |
if 'A New Order Placed With A Different Seller' in str(trackBlock):
|
524 |
if 'A new order placed with a different seller' in str(trackBlock):
|
| 521 |
#if it is more than 6hours mark closed.
|
525 |
#if it is more than 6hours mark closed.
|
| 522 |
closeAt = subOrder.get("closeAt")
|
526 |
closeAt = subOrder.get("closeAt")
|
| 523 |
if closeAt is None:
|
527 |
if closeAt is None:
|
| 524 |
closeAt = datetime.now() + timedelta(hours=6)
|
528 |
closeAt = datetime.now() + timedelta(hours=6)
|
| 525 |
updateMap["subOrders.$.closeAt"] = datetime.strftime(closeAt,"%Y-%m-%d %H:%M:%S")
|
529 |
updateMap["subOrders.$.closeAt"] = datetime.strftime(closeAt,"%Y-%m-%d %H:%M:%S")
|
| 526 |
else:
|
530 |
else:
|
| 527 |
closeAt = datetime.strptime(closeAt,"%Y-%m-%d %H:%M:%S")
|
531 |
closeAt = datetime.strptime(closeAt,"%Y-%m-%d %H:%M:%S")
|
| 528 |
if datetime.now() > closeAt:
|
532 |
if datetime.now() > closeAt:
|
| 529 |
closedStatus = True
|
533 |
closedStatus = True
|
| 530 |
updateMap["subOrders.$.status"] = Store.ORDER_CANCELLED
|
534 |
updateMap["subOrders.$.status"] = Store.ORDER_CANCELLED
|
| - |
|
535 |
updateMap["subOrders.$.detailedStatus"] = 'A new order placed with a different seller'
|
| 531 |
|
536 |
|
| 532 |
|
537 |
|
| 533 |
if closedStatus:
|
538 |
if closedStatus:
|
| 534 |
#if status is closed then change the paybackStatus accordingly
|
539 |
#if status is closed then change the paybackStatus accordingly
|
| 535 |
updateMap["subOrders.$.closed"] = True
|
540 |
updateMap["subOrders.$.closed"] = True
|
| Line 631... |
Line 636... |
| 631 |
return urllib.urlencode(parameters)
|
636 |
return urllib.urlencode(parameters)
|
| 632 |
|
637 |
|
| 633 |
def main():
|
638 |
def main():
|
| 634 |
#print todict([1,2,"3"])
|
639 |
#print todict([1,2,"3"])
|
| 635 |
store = getStore(3)
|
640 |
store = getStore(3)
|
| 636 |
#store.parseOrderRawHtml(332221, "3232311", 2, "32311243", "https://m.snapdeal.com/orderSummary?code=0d13e4b5535211c3ece929595f1281d3&order=7124223282")
|
641 |
#store.parseOrderRawHtml(332221, "3232311", 2, "32311243", "https://m.snapdeal.com/orderSummary?code=3fbc8a02a1c4d3c4e906f46886de0464&order=5808451506")
|
| 637 |
#store.scrapeStoreOrders()
|
642 |
store.scrapeStoreOrders()
|
| 638 |
#store._isSubOrderActive(8, "5970688907")
|
643 |
#store._isSubOrderActive(8, "5970688907")
|
| 639 |
#store.scrapeAffiliate()
|
644 |
#store.scrapeAffiliate()
|
| 640 |
#store.scrapeStoreOrders()
|
645 |
#store.scrapeStoreOrders()
|
| 641 |
|
646 |
|
| 642 |
|
647 |
|