| Line 1... |
Line 1... |
| 1 |
from elixir import *
|
1 |
from elixir import *
|
| 2 |
from dtr.storage.MemCache import MemCache
|
2 |
from dtr.storage.MemCache import MemCache
|
| 3 |
from shop2020.model.v1.catalog.impl import DataService as CatalogDataService
|
3 |
from shop2020.model.v1.catalog.impl import DataService as CatalogDataService
|
| 4 |
from shop2020.model.v1.inventory.impl import DataService as InventoryDataService
|
4 |
from shop2020.model.v1.inventory.impl import DataService as InventoryDataService
|
| 5 |
from shop2020.model.v1.catalog.impl.DataService import Item, PrivateDeals
|
5 |
from shop2020.model.v1.catalog.impl.DataService import Item, PrivateDeals, BulkItemPricing
|
| 6 |
from shop2020.model.v1.inventory.impl.DataService import ItemAvailabilityCache
|
6 |
from shop2020.model.v1.inventory.impl.DataService import ItemAvailabilityCache
|
| 7 |
from dtr.utils.utils import get_mongo_connection, SOURCE_MAP
|
7 |
from dtr.utils.utils import get_mongo_connection, SOURCE_MAP
|
| 8 |
import optparse
|
8 |
import optparse
|
| 9 |
import traceback
|
9 |
import traceback
|
| 10 |
from datetime import datetime
|
10 |
from datetime import datetime
|
| Line 83... |
Line 83... |
| 83 |
sellingPrice = d_item.sellingPrice
|
83 |
sellingPrice = d_item.sellingPrice
|
| 84 |
sellingPriceType = "Normal"
|
84 |
sellingPriceType = "Normal"
|
| 85 |
if d_privatedeal is not None and d_privatedeal.isActive==1 and d_privatedeal.startDate < datetime.now() and d_privatedeal.endDate > datetime.now() and d_privatedeal.dealPrice >0:
|
85 |
if d_privatedeal is not None and d_privatedeal.isActive==1 and d_privatedeal.startDate < datetime.now() and d_privatedeal.endDate > datetime.now() and d_privatedeal.dealPrice >0:
|
| 86 |
sellingPrice = d_privatedeal.dealPrice
|
86 |
sellingPrice = d_privatedeal.dealPrice
|
| 87 |
sellingPriceType = "Private deal price"
|
87 |
sellingPriceType = "Private deal price"
|
| 88 |
tempList.append({'item_id':d_item.id,'color':d_item.color,'sellingPrice':sellingPrice,'sellingPriceType':sellingPriceType})
|
88 |
tempList.append({'item_id':d_item.id,'color':d_item.color,'sellingPrice':sellingPrice,'sellingPriceType':sellingPriceType,'minBuyQuantity':d_item.minimumBuyQuantity,'quantityStep':d_item.quantityStep})
|
| 89 |
if toBreak:
|
89 |
if toBreak:
|
| 90 |
print "Breaking"
|
90 |
print "Breaking"
|
| 91 |
break
|
91 |
break
|
| 92 |
start = fetch
|
92 |
start = fetch
|
| 93 |
fetch = start + fetch
|
93 |
fetch = start + fetch
|
| Line 115... |
Line 115... |
| 115 |
for item in v:
|
115 |
for item in v:
|
| 116 |
availability = inventoryMap.get(item.get('item_id'))
|
116 |
availability = inventoryMap.get(item.get('item_id'))
|
| 117 |
if availability is None:
|
117 |
if availability is None:
|
| 118 |
flaggedItems.append(item.get('item_id'))
|
118 |
flaggedItems.append(item.get('item_id'))
|
| 119 |
|
119 |
|
| - |
|
120 |
def addBulkPricingInfo():
|
| - |
|
121 |
bulkItemsMap = {}
|
| - |
|
122 |
bulkItems = session.query(BulkItemPricing).all()
|
| - |
|
123 |
for item in bulkItems:
|
| - |
|
124 |
if bulkItemsMap.has_key(item.item_id):
|
| - |
|
125 |
temp_list = bulkItemsMap.get(item.item_id)
|
| - |
|
126 |
temp_list.append({'quantity':item.quantity,'price':item.price})
|
| - |
|
127 |
else:
|
| - |
|
128 |
bulkItemsMap[item.item_id] = [{'quantity':item.quantity,'price':item.price}]
|
| - |
|
129 |
for k, v in bundleMap.iteritems():
|
| - |
|
130 |
for item in v:
|
| - |
|
131 |
bulkPricing = bulkItemsMap.get(item.get('item_id'))
|
| - |
|
132 |
if bulkPricing is None:
|
| - |
|
133 |
item['bulkPricing'] = []
|
| - |
|
134 |
else:
|
| - |
|
135 |
item['bulkPricing'] = bulkPricing
|
| - |
|
136 |
|
| 120 |
|
137 |
|
| 121 |
def fetchItemAvailablity():
|
138 |
def fetchItemAvailablity():
|
| 122 |
global inventoryMap
|
139 |
global inventoryMap
|
| 123 |
try:
|
140 |
try:
|
| 124 |
InventoryDataService.initialize(db_hostname=options.hostname,setup=False)
|
141 |
InventoryDataService.initialize(db_hostname=options.hostname,setup=False)
|
| 125 |
allInventory = session.query(ItemAvailabilityCache).filter(ItemAvailabilityCache.sourceId==1).all()
|
142 |
allInventory = session.query(ItemAvailabilityCache).filter(ItemAvailabilityCache.sourceId==1).all()
|
| 126 |
for itemInventory in allInventory:
|
143 |
for itemInventory in allInventory:
|
| 127 |
inventoryMap[itemInventory.itemId] = itemInventory.totalAvailability
|
144 |
inventoryMap[itemInventory.itemId] = itemInventory.totalAvailability
|
| 128 |
finally:
|
145 |
finally:
|
| 129 |
session.close()
|
146 |
session.close()
|
| 130 |
|
147 |
|
| 131 |
if __name__ == '__main__':
|
148 |
if __name__ == '__main__':
|
| 132 |
populateSaholicBundles()
|
149 |
populateSaholicBundles()
|
| 133 |
addItemIdInfo()
|
150 |
addItemIdInfo()
|
| - |
|
151 |
addBulkPricingInfo()
|
| 134 |
fetchItemAvailablity()
|
152 |
fetchItemAvailablity()
|
| 135 |
flagNoAvailableItems()
|
153 |
flagNoAvailableItems()
|
| 136 |
if len(flaggedItems) > 0:
|
154 |
if len(flaggedItems) > 0:
|
| 137 |
print "Flagged items ",flaggedItems
|
155 |
print "Flagged items ",flaggedItems
|
| 138 |
get_inventory_client().updateItemAvailabilityForItemIds(flaggedItems)
|
156 |
get_inventory_client().updateItemAvailabilityForItemIds(flaggedItems)
|