| Line 9... |
Line 9... |
| 9 |
from shop2020.clients.HelperClient import HelperClient
|
9 |
from shop2020.clients.HelperClient import HelperClient
|
| 10 |
from shop2020.clients.InventoryClient import InventoryClient
|
10 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 11 |
from shop2020.config.client.ConfigClient import ConfigClient
|
11 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 12 |
from shop2020.model.v1.catalog.impl import DataService
|
12 |
from shop2020.model.v1.catalog.impl import DataService
|
| 13 |
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
|
13 |
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
|
| 14 |
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source, \
|
14 |
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source
|
| 15 |
to_t_brand_info
|
- |
|
| 16 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
15 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
| 17 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
16 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
| 18 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
17 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
| 19 |
OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
18 |
OOSTracker,EntityTag,ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
| 20 |
FreebieItem, BrandInfo, \
|
19 |
FreebieItem, BrandInfo, Amazonlisted,StorePricing
|
| 21 |
OOSTracker,EntityTag,ItemInsurerMapping, Insurer, Banner, BannerMap, FreebieItem,\
|
- |
|
| 22 |
StorePricing,Amazonlisted
|
- |
|
| 23 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
20 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
| 24 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, StorePricing as tStorePricing
|
21 |
ItemType, PremiumType, FreebieItem as t_FreebieItem,StorePricing as tStorePricing
|
| 25 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
22 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
| 26 |
InventoryServiceException, IgnoredInventoryUpdateItems
|
23 |
InventoryServiceException, IgnoredInventoryUpdateItems
|
| 27 |
from shop2020.utils import EmailAttachmentSender
|
24 |
from shop2020.utils import EmailAttachmentSender
|
| 28 |
from shop2020.utils.EmailAttachmentSender import mail
|
25 |
from shop2020.utils.EmailAttachmentSender import mail
|
| 29 |
from shop2020.utils.Utils import to_py_date, log_risky_flag
|
26 |
from shop2020.utils.Utils import to_py_date, log_risky_flag
|
| Line 32... |
Line 29... |
| 32 |
from string import Template
|
29 |
from string import Template
|
| 33 |
import datetime
|
30 |
import datetime
|
| 34 |
import sys
|
31 |
import sys
|
| 35 |
import threading
|
32 |
import threading
|
| 36 |
import urllib2
|
33 |
import urllib2
|
| - |
|
34 |
from datetime import timedelta,datetime,date
|
| 37 |
|
35 |
|
| 38 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
36 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
| 39 |
to_addresses = ["khushal.bhatia@shop2020.in", "chandan.kumar@shop2020.in", "chaitnaya.vats@shop2020.in"]
|
37 |
to_addresses = ["khushal.bhatia@shop2020.in", "chandan.kumar@shop2020.in", "chaitnaya.vats@shop2020.in"]
|
| 40 |
mail_user = "cnc.center@shop2020.in"
|
38 |
mail_user = "cnc.center@shop2020.in"
|
| 41 |
mail_password = "5h0p2o2o"
|
39 |
mail_password = "5h0p2o2o"
|
| Line 165... |
Line 163... |
| 165 |
ds_item.sellingPrice = item.sellingPrice
|
163 |
ds_item.sellingPrice = item.sellingPrice
|
| 166 |
|
164 |
|
| 167 |
ds_item.weight = item.weight
|
165 |
ds_item.weight = item.weight
|
| 168 |
ds_item.showSellingPrice = item.showSellingPrice
|
166 |
ds_item.showSellingPrice = item.showSellingPrice
|
| 169 |
|
167 |
|
| - |
|
168 |
if item.asin:
|
| - |
|
169 |
ds_item.asin = item.asin
|
| - |
|
170 |
ds_item.holdInventory = item.holdInventory
|
| - |
|
171 |
ds_item.defaultInventory = item.defaultInventory
|
| - |
|
172 |
|
| 170 |
if item.startDate:
|
173 |
if item.startDate:
|
| 171 |
ds_item.startDate = to_py_date(item.startDate)
|
174 |
ds_item.startDate = to_py_date(item.startDate)
|
| 172 |
ds_item.startDate = ds_item.startDate.replace(hour=0,second=0,minute=0)
|
175 |
ds_item.startDate = ds_item.startDate.replace(hour=0,second=0,minute=0)
|
| 173 |
if item.itemStatus == status.COMING_SOON and ds_item.startDate < datetime.datetime.now() :
|
176 |
if item.itemStatus == status.COMING_SOON and ds_item.startDate < datetime.datetime.now() :
|
| 174 |
item.itemStatus = status.ACTIVE
|
177 |
item.itemStatus = status.ACTIVE
|
| Line 250... |
Line 253... |
| 250 |
flag = "ON" if item.isWarehousePreferenceSticky else "OFF"
|
253 |
flag = "ON" if item.isWarehousePreferenceSticky else "OFF"
|
| 251 |
message += "Warehouse preference sticky is {0}.\n".format(flag)
|
254 |
message += "Warehouse preference sticky is {0}.\n".format(flag)
|
| 252 |
|
255 |
|
| 253 |
ds_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
|
256 |
ds_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
|
| 254 |
|
257 |
|
| 255 |
ds_item.updatedOn = datetime.datetime.now()
|
258 |
ds_item.updatedOn = datetime.now()
|
| 256 |
|
259 |
|
| 257 |
# if item.activeOnStore and not ds_item.activeOnStore:
|
260 |
# if item.activeOnStore and not ds_item.activeOnStore:
|
| 258 |
# add_store_pricing(ds_item)
|
261 |
# add_store_pricing(ds_item)
|
| 259 |
ds_item.activeOnStore = item.activeOnStore
|
262 |
ds_item.activeOnStore = item.activeOnStore
|
| 260 |
|
263 |
|
| Line 285... |
Line 288... |
| 285 |
ds_item.color = item.color
|
288 |
ds_item.color = item.color
|
| 286 |
if item.category:
|
289 |
if item.category:
|
| 287 |
ds_item.category = item.category
|
290 |
ds_item.category = item.category
|
| 288 |
if item.comments:
|
291 |
if item.comments:
|
| 289 |
ds_item.comments = item.comments
|
292 |
ds_item.comments = item.comments
|
| 290 |
|
- |
|
| - |
|
293 |
if item.asin:
|
| - |
|
294 |
ds_item.asin = item.asin
|
| - |
|
295 |
ds_item.holdInventory = item.holdInventory
|
| - |
|
296 |
ds_item.defaultInventory = item.defaultInventory
|
| 291 |
ds_item.addedOn = datetime.datetime.now()
|
297 |
ds_item.addedOn = datetime.now()
|
| 292 |
ds_item.updatedOn = datetime.datetime.now()
|
298 |
ds_item.updatedOn = datetime.now()
|
| 293 |
if item.startDate:
|
299 |
if item.startDate:
|
| 294 |
ds_item.startDate = to_py_date(item.startDate)
|
300 |
ds_item.startDate = to_py_date(item.startDate)
|
| 295 |
ds_item.startDate = ds_item.startDate.replace(hour=0,second=0,minute=0)
|
301 |
ds_item.startDate = ds_item.startDate.replace(hour=0,second=0,minute=0)
|
| 296 |
if item.retireDate:
|
302 |
if item.retireDate:
|
| 297 |
ds_item.retireDate = to_py_date(item.retireDate)
|
303 |
ds_item.retireDate = to_py_date(item.retireDate)
|
| Line 762... |
Line 768... |
| 762 |
if item.mrp == None or item.sellingPrice == None or item.mrp == "" or item.sellingPrice == "":
|
768 |
if item.mrp == None or item.sellingPrice == None or item.mrp == "" or item.sellingPrice == "":
|
| 763 |
return
|
769 |
return
|
| 764 |
if item.mrp < item.sellingPrice:
|
770 |
if item.mrp < item.sellingPrice:
|
| 765 |
print "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice))
|
771 |
print "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice))
|
| 766 |
raise InventoryServiceException(101, "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice)))
|
772 |
raise InventoryServiceException(101, "[BAD MRP and SP:] for {0} {1} {2} {3}. MRP={4}, SP={5}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(item.sellingPrice)))
|
| 767 |
# if minp < item.sellingPrice:
|
- |
|
| 768 |
# print "alert to store"
|
- |
|
| 769 |
# if maxp > item.mrp:
|
- |
|
| 770 |
# print "reset to mrp"
|
- |
|
| 771 |
# print "alert to store"
|
- |
|
| 772 |
return
|
773 |
return
|
| 773 |
|
774 |
|
| 774 |
def validate_vendor_prices(item, vendorPrices):
|
775 |
def validate_vendor_prices(item, vendorPrices):
|
| 775 |
if item.mrp != None and item.mrp != "" and vendorPrices.mop != "" and item.mrp < vendorPrices.mop:
|
776 |
if item.mrp != None and item.mrp != "" and vendorPrices.mop != "" and item.mrp < vendorPrices.mop:
|
| 776 |
print "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId))
|
777 |
print "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId))
|
| 777 |
raise InventoryServiceException(101, "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId)))
|
778 |
raise InventoryServiceException(101, "[BAD MRP and MOP:] for {0} {1} {2} {3}. MRP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(item.mrp), str(vendorPrices.mop), str(vendorPrices.vendorId)))
|
| 778 |
if vendorPrices.mop != "" and vendorPrices.transferPrice != "" and vendorPrices.transferPrice > vendorPrices.mop:
|
779 |
if vendorPrices.mop != "" and vendorPrices.transferPrice != "" and vendorPrices.transferPrice > vendorPrices.mop:
|
| 779 |
print "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId))
|
780 |
print "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId))
|
| 780 |
raise InventoryServiceException(101, "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId)))
|
781 |
raise InventoryServiceException(101, "[BAD MOP and TP:] for {0} {1} {2} {3}. TP={4}. MOP={5}, Vendor={6}".format(item.productGroup, item.brand, item.modelNumber, item.color, str(vendorPrices.transferPrice), str(vendorPrices.mop), str(vendorPrices.vendorId)))
|
| 781 |
# if change in dp:
|
- |
|
| 782 |
# print "alert to store"
|
- |
|
| 783 |
|
- |
|
| 784 |
return
|
782 |
return
|
| 785 |
|
783 |
|
| 786 |
def check_color_valid(color):
|
784 |
def check_color_valid(color):
|
| 787 |
if color is not None:
|
785 |
if color is not None:
|
| 788 |
color = color.strip().lower()
|
786 |
color = color.strip().lower()
|
| Line 1535... |
Line 1533... |
| 1535 |
sp.minPrice = store.minPrice
|
1533 |
sp.minPrice = store.minPrice
|
| 1536 |
sp.minAdvancePrice = store.minAdvancePrice
|
1534 |
sp.minAdvancePrice = store.minAdvancePrice
|
| 1537 |
sp.maxPrice = store.maxPrice
|
1535 |
sp.maxPrice = store.maxPrice
|
| 1538 |
return sp
|
1536 |
return sp
|
| 1539 |
|
1537 |
|
| - |
|
1538 |
|
| 1540 |
def get_all_amazon_listed_items():
|
1539 |
def get_all_amazon_listed_items():
|
| 1541 |
return session.query(Amazonlisted).all()
|
1540 |
return session.query(Amazonlisted).all()
|
| 1542 |
|
1541 |
|
| 1543 |
def get_amazon_item_details(amazonItemId):
|
1542 |
def get_amazon_item_details(amazonItemId):
|
| 1544 |
amazonlisted = Amazonlisted.get_by(itemId=amazonItemId)
|
1543 |
amazonlisted = Amazonlisted.get_by(itemId=amazonItemId)
|
| Line 1583... |
Line 1582... |
| 1583 |
amazon_item.isFba=amazonlisted.isFba
|
1582 |
amazon_item.isFba=amazonlisted.isFba
|
| 1584 |
if amazonlisted.isNonFba:
|
1583 |
if amazonlisted.isNonFba:
|
| 1585 |
amazon_item.isNonFba=amazonlisted.isNonFba
|
1584 |
amazon_item.isNonFba=amazonlisted.isNonFba
|
| 1586 |
if amazonlisted.isInventoryOverride:
|
1585 |
if amazonlisted.isInventoryOverride:
|
| 1587 |
amazon_item.isInventoryOverride=amazonlisted.isInventoryOverride
|
1586 |
amazon_item.isInventoryOverride=amazonlisted.isInventoryOverride
|
| 1588 |
if amazonlisted.color:
|
- |
|
| 1589 |
amazon_item.color=amazonlisted.color
|
- |
|
| 1590 |
if amazonlisted.category:
|
1587 |
if amazonlisted.category:
|
| 1591 |
amazon_item.color=amazonlisted.category
|
1588 |
amazon_item.category=amazonlisted.category
|
| 1592 |
session.commit()
|
1589 |
session.commit()
|
| 1593 |
|
1590 |
|
| - |
|
1591 |
def get_asin_items():
|
| - |
|
1592 |
from_date=datetime.now() - timedelta(days=10)
|
| - |
|
1593 |
return Item.query.filter(Item.updatedOn > from_date).all()
|
| 1594 |
|
1594 |
|
| - |
|
1595 |
def get_all_fba_listed_items():
|
| - |
|
1596 |
return Amazonlisted.query.filter(Amazonlisted.isFba==True).all()
|
| 1595 |
|
1597 |
|
| 1596 |
|
1598 |
def get_all_nonfba_listed_items():
|
| - |
|
1599 |
return Amazonlisted.query.filter(Amazonlisted.isNonFba==True).all()
|
| 1597 |
|
1600 |
|
| 1598 |
|
1601 |
|
| 1599 |
|
1602 |
|