Subversion Repositories SmartDukaan

Rev

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

Rev 17347 Rev 17348
Line 33... Line 33...
33
THANKYOU_URL = 'https://www.amazon.in/gp/buy/thankyou/handlers/display.html'
33
THANKYOU_URL = 'https://www.amazon.in/gp/buy/thankyou/handlers/display.html'
34
AMAZON_AFF_URL = 'https://assoc-datafeeds-eu.amazon.com/datafeed/listReports'
34
AMAZON_AFF_URL = 'https://assoc-datafeeds-eu.amazon.com/datafeed/listReports'
35
AMAZON_AFF_FILE_URL = 'https://assoc-datafeeds-eu.amazon.com/datafeed/getReport?filename=saholic-21-orders-report-%s.tsv.gz'
35
AMAZON_AFF_FILE_URL = 'https://assoc-datafeeds-eu.amazon.com/datafeed/getReport?filename=saholic-21-orders-report-%s.tsv.gz'
36
class Store(MStore):
36
class Store(MStore):
37
    
37
    
38
    orderStatusRegexMap = { MStore.ORDER_PLACED : ['ordered from', 'not yet dispatched','dispatching now', 'preparing for dispatch'],
38
    orderStatusRegexMap = { MStore.ORDER_PLACED : ['ordered from', 'not yet dispatched','dispatching now', 'preparing for dispatch', 'order received'],
39
                            MStore.ORDER_SHIPPED : ['dispatched on','dispatched', 'on the way', 'out for delivery', 'Out for delivery'],
39
                            MStore.ORDER_SHIPPED : ['dispatched on','dispatched', 'on the way', 'out for delivery', 'Out for delivery'],
40
                            MStore.ORDER_CANCELLED : ['return complete', 'refunded', 'cancelled', 'replacement complete', 'return received'],
40
                            MStore.ORDER_CANCELLED : ['return complete', 'refunded', 'cancelled', 'replacement complete', 'return received'],
41
                            MStore.ORDER_DELIVERED : ['delivered', 'your package was delivered', 'package was handed directly to customer']
41
                            MStore.ORDER_DELIVERED : ['delivered', 'your package was delivered', 'package was handed directly to customer']
42
                           }
42
                           }
43
 
43
 
Line 492... Line 492...
492
                                            dateString = sdivs[0].span.text.strip().split("Arriving ")[1].split("by")[0].strip()
492
                                            dateString = sdivs[0].span.text.strip().split("Arriving ")[1].split("by")[0].strip()
493
                                            status = MStore.ORDER_SHIPPED
493
                                            status = MStore.ORDER_SHIPPED
494
                                            deliveryEstimate = datetime.strftime(getDateStringArriving(dateString), '%d-%b-%y')
494
                                            deliveryEstimate = datetime.strftime(getDateStringArriving(dateString), '%d-%b-%y')
495
                                        except:
495
                                        except:
496
                                            print "Unknown status Alert -", orderStatus
496
                                            print "Unknown status Alert -", orderStatus
497
                                print "Order Status", orderStatus
497
                                print merchantOrderId, "Order Status", orderStatus
498
                                try:
498
                                try:
499
                                    orderStatusDesc = sdivs[0].findAll('div')[1].div.text.strip()
499
                                    orderStatusDesc = sdivs[0].findAll('div')[1].div.text.strip()
500
                                except:
500
                                except:
501
                                    try:
501
                                    try:
502
                                        orderStatusDesc = sdivs[0].findAll('div')[1].text.strip()
502
                                        orderStatusDesc = sdivs[0].findAll('div')[1].text.strip()
503
                                    except:
503
                                    except:
504
                                        print "Order Status Description None or empty for", merchantOrderId, "and User", userId
504
                                        print "Order Status Description None or empty for", merchantOrderId, "and User", userId
505
 
505
 
506
                                if orderStatusDesc: 
506
                                if orderStatusDesc: 
-
 
507
                                    print merchantOrderId, "Order status desc", orderStatusDesc
-
 
508
                                    try:
-
 
509
                                        status = self._getStatusFromDetailedStatus(orderStatus)
-
 
510
                                    except:
-
 
511
                                        pass
507
                                    try:
512
                                    try:
508
                                        if "Dispatch estimate" in orderStatusDesc:
513
                                        if "Dispatch estimate" in orderStatusDesc:
509
                                            shippingEstimate = orderStatus.split("Dispatch estimate").split("-")[0].strip()
514
                                            shippingEstimate = orderStatus.split("Dispatch estimate").split("-")[0].strip()
510
                                        elif "Delivery estimate" in orderStatus:
515
                                        elif "Delivery estimate" in orderStatus:
511
                                            deliveryEstimate = orderStatus.split("Delivery estimate").split("-")[0].strip()
516
                                            deliveryEstimate = orderStatus.split("Delivery estimate").split("-")[0].strip()
Line 536... Line 541...
536
                                            updateMap = {}
541
                                            updateMap = {}
537
                                            closedStatus = False
542
                                            closedStatus = False
538
                                            updateMap['subOrders.$.imgUrl'] = imgUrl
543
                                            updateMap['subOrders.$.imgUrl'] = imgUrl
539
                                            updateMap['subOrders.$.lastTracked'] = timestamp
544
                                            updateMap['subOrders.$.lastTracked'] = timestamp
540
                                            if status:
545
                                            if status:
541
                                                updateMap['subOrders.$.detailedStatus'] = status
546
                                                updateMap['subOrders.$.detailedStatus'] = orderStatus
542
                                                updateMap['subOrders.$.status'] = status 
547
                                                updateMap['subOrders.$.status'] = status 
543
                                                cashbackStatus = subOrder.get("cashBackStatus")
548
                                                cashbackStatus = subOrder.get("cashBackStatus")
544
                                        
549
                                        
545
                                            if status==MStore.ORDER_DELIVERED:
550
                                            if status==MStore.ORDER_DELIVERED:
546
                                                if deliveredOn:                               
551
                                                if deliveredOn:                               
Line 745... Line 750...
745
#        if summaryFile is None:
750
#        if summaryFile is None:
746
#            print "No summary for", userId
751
#            print "No summary for", userId
747
#        else:
752
#        else:
748
#            print userId, directory+summaryFile
753
#            print userId, directory+summaryFile
749
#            store.trackOrdersForUser(userId, 'https://www.amazon.in/gp/css/order-history', readSSh(directory + summaryFile))
754
#            store.trackOrdersForUser(userId, 'https://www.amazon.in/gp/css/order-history', readSSh(directory + summaryFile))
750
    for orderId in store.db.merchantOrder.find({"storeId":1, "status":"html_required"}).distinct("orderId"):
755
    for orderId in store.db.merchantOrder.find({"storeId":1, "status":"parse_failed", "subOrders":{"$exists":False}}).distinct("orderId"):
751
        try:
756
        try:
752
            o = session.query(OrdersRaw).filter_by(id = orderId).one()
757
            o = session.query(OrdersRaw).filter_by(id = orderId).one()
753
            store.parseOrderRawHtml(o.id, o.sub_tag, o.user_id, o.rawhtml, o.order_url)
758
            store.parseOrderRawHtml(o.id, o.sub_tag, o.user_id, o.rawhtml, o.order_url)
754
        except:
759
        except:
755
            print "Could not parse", orderId
760
            print "Could not parse", orderId