| Line 15... |
Line 15... |
| 15 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
15 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
| 16 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
16 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
| 17 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
17 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
| 18 |
OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
18 |
OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
| 19 |
FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
|
19 |
FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
|
| 20 |
PageViewEvents, CartEvents
|
20 |
PageViewEvents, CartEvents, EbayItem
|
| 21 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
21 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
| 22 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
22 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
| 23 |
StorePricing as tStorePricing, CatalogServiceException
|
23 |
StorePricing as tStorePricing, CatalogServiceException
|
| 24 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
24 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
| 25 |
InventoryServiceException, IgnoredInventoryUpdateItems
|
25 |
InventoryServiceException, IgnoredInventoryUpdateItems
|
| Line 1049... |
Line 1049... |
| 1049 |
|
1049 |
|
| 1050 |
def send_product_notifications():
|
1050 |
def send_product_notifications():
|
| 1051 |
product_notifications = ProductNotification.query.order_by(ProductNotification.addedOn).all()
|
1051 |
product_notifications = ProductNotification.query.order_by(ProductNotification.addedOn).all()
|
| 1052 |
itemcountmap = {}
|
1052 |
itemcountmap = {}
|
| 1053 |
itemstatusmap = {}
|
1053 |
itemstatusmap = {}
|
| - |
|
1054 |
#print "size of prduct notifications = " + str(len(product_notifications))
|
| 1054 |
for product_notification in product_notifications:
|
1055 |
for product_notification in product_notifications:
|
| 1055 |
item = product_notification.item
|
1056 |
item = product_notification.item
|
| 1056 |
if itemcountmap.has_key(item.id):
|
1057 |
if itemcountmap.has_key(item.id):
|
| 1057 |
itemcountmap[item.id] = itemcountmap.get(item.id) + 1
|
1058 |
itemcountmap[item.id] = itemcountmap.get(item.id) + 1
|
| 1058 |
else:
|
1059 |
else:
|
| 1059 |
client = InventoryClient().get_client()
|
1060 |
client = InventoryClient().get_client()
|
| 1060 |
availability = client.getItemAvailabilityAtLocation(item.id, sourceId)[4]
|
1061 |
availability = client.getItemAvailabilityAtLocation(item.id, sourceId)[4]
|
| - |
|
1062 |
#print "Item status " + str(item.status) + " item.risky " + str(item.risky) + " availability = " + str(availability)
|
| 1061 |
if item.status == status.ACTIVE and (not item.risky or availability > 0):
|
1063 |
if item.status == status.ACTIVE and (not item.risky or availability > 0):
|
| - |
|
1064 |
#print "item status map has new entry " + str(item.id)
|
| 1062 |
itemstatusmap[item.id] = True
|
1065 |
itemstatusmap[item.id] = True
|
| 1063 |
else:
|
1066 |
else:
|
| 1064 |
itemstatusmap[item.id] = False
|
1067 |
itemstatusmap[item.id] = False
|
| 1065 |
itemcountmap[item.id] = 1
|
1068 |
itemcountmap[item.id] = 1
|
| 1066 |
if itemcountmap[item.id] > 1000:
|
1069 |
if itemcountmap[item.id] > 1000:
|
| 1067 |
continue
|
1070 |
continue
|
| 1068 |
|
1071 |
|
| 1069 |
if itemstatusmap[item.id]:
|
1072 |
if itemstatusmap[item.id]:
|
| - |
|
1073 |
#print product_notification.email, __get_product_name(item) , product_notification.addedOn, __get_product_url(item), item.id
|
| 1070 |
__enque_product_notification_email(product_notification.email, __get_product_name(item) , product_notification.addedOn, __get_product_url(item), item.id)
|
1074 |
__enque_product_notification_email(product_notification.email, __get_product_name(item) , product_notification.addedOn, __get_product_url(item), item.id)
|
| 1071 |
product_notification.delete()
|
1075 |
product_notification.delete()
|
| 1072 |
session.commit()
|
1076 |
session.commit()
|
| 1073 |
return True
|
1077 |
return True
|
| 1074 |
|
1078 |
|
| Line 1137... |
Line 1141... |
| 1137 |
try:
|
1141 |
try:
|
| 1138 |
helper_client = HelperClient().get_client()
|
1142 |
helper_client = HelperClient().get_client()
|
| 1139 |
helper_client.saveUserEmailForSending([email], "", "Product requested by you is available now.", html, str(itemId), "ProductNotification", [], [])
|
1143 |
helper_client.saveUserEmailForSending([email], "", "Product requested by you is available now.", html, str(itemId), "ProductNotification", [], [])
|
| 1140 |
except Exception as e:
|
1144 |
except Exception as e:
|
| 1141 |
print e
|
1145 |
print e
|
| - |
|
1146 |
print sys.exc_info()[0]
|
| 1142 |
|
1147 |
|
| 1143 |
def get_all_sources():
|
1148 |
def get_all_sources():
|
| 1144 |
sources = Source.query.all()
|
1149 |
sources = Source.query.all()
|
| 1145 |
return [to_t_source(source) for source in sources]
|
1150 |
return [to_t_source(source) for source in sources]
|
| 1146 |
|
1151 |
|
| Line 1850... |
Line 1855... |
| 1850 |
amazon_item.suppressFbaPriceUpdate = amazonlisted.suppressFbaPriceUpdate
|
1855 |
amazon_item.suppressFbaPriceUpdate = amazonlisted.suppressFbaPriceUpdate
|
| 1851 |
session.commit()
|
1856 |
session.commit()
|
| 1852 |
return True
|
1857 |
return True
|
| 1853 |
|
1858 |
|
| 1854 |
|
1859 |
|
| - |
|
1860 |
def insert_ebay_item(ebayItem):
|
| - |
|
1861 |
ebay_item = EbayItem()
|
| - |
|
1862 |
ebay_item.ebayListingId = ebayItem.ebayListingId
|
| - |
|
1863 |
ebay_item.itemId = ebayItem.itemId
|
| - |
|
1864 |
ebay_item.listingName = ebayItem.listingName
|
| - |
|
1865 |
ebay_item.listingPrice = ebayItem.listingPrice
|
| - |
|
1866 |
ebay_item.listingExpiryDate = ebayItem.listingExpiryDate
|
| - |
|
1867 |
ebay_item.subsidy = ebayItem.subsidy
|
| - |
|
1868 |
ebay_item.defaultWarehouseId = ebayItem.defaultWarehouseId
|
| - |
|
1869 |
session.commit()
|
| - |
|
1870 |
|
| 1855 |
|
1871 |
|
| 1856 |
|
1872 |
def get_ebay_item(listing_id):
|
| - |
|
1873 |
ebay_item = EbayItem.get_by(ebayListingId = listing_id)
|
| 1857 |
|
1874 |
return ebay_item
|
| 1858 |
|
1875 |
|
| 1859 |
|
1876 |
|
| 1860 |
|
1877 |
def update_ebay_item(ebayItem):
|
| - |
|
1878 |
ebay_item = EbayItem.get_by(ebayListingId = ebayItem.ebayListingId)
|
| - |
|
1879 |
#if ebay_item.listingExpiryDate < datetime.datetime.now():
|
| - |
|
1880 |
ebay_item.listingName = ebayItem.listingName
|
| - |
|
1881 |
ebay_item.listingPrice = ebayItem.listingPrice
|
| - |
|
1882 |
ebay_item.listingExpiryDate = ebayItem.listingExpiryDate
|
| 1861 |
|
1883 |
ebay_item.subsidy = ebayItem.subsidy
|
| - |
|
1884 |
ebay_item.defaultWarehouseId = ebayItem.defaultWarehouseId
|
| 1862 |
|
1885 |
session.commit()
|
| 1863 |
|
1886 |
#else:
|
| - |
|
1887 |
# raise CatalogServiceException(1,"Can't update item once listing is expired")
|
| 1864 |
|
1888 |
|