| Line 4... |
Line 4... |
| 4 |
from shop2020.model.v1.catalog.impl import DataService
|
4 |
from shop2020.model.v1.catalog.impl import DataService
|
| 5 |
from shop2020.model.v1.catalog.impl.DataService import Amazonlisted, Item, \
|
5 |
from shop2020.model.v1.catalog.impl.DataService import Amazonlisted, Item, \
|
| 6 |
Category, SourcePercentageMaster,SourceCategoryPercentage, SourceItemPercentage, AmazonPromotion, AmazonScrapingHistory, \
|
6 |
Category, SourcePercentageMaster,SourceCategoryPercentage, SourceItemPercentage, AmazonPromotion, AmazonScrapingHistory, \
|
| 7 |
ItemVatMaster, CategoryVatMaster
|
7 |
ItemVatMaster, CategoryVatMaster
|
| 8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
| 9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, SalesPotential,\
|
9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, \
|
| 10 |
Decision, RunType, AmazonPromotionType
|
10 |
Decision, RunType, AmazonPromotionType
|
| 11 |
from shop2020.model.v1.catalog.script import SellerCentralInventoryReport, AmazonAsyncScraper
|
11 |
from shop2020.model.v1.catalog.script import AmazonAsyncScraper
|
| 12 |
from shop2020.clients.CatalogClient import CatalogClient
|
- |
|
| 13 |
from shop2020.clients.InventoryClient import InventoryClient
|
12 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 14 |
from shop2020.clients.TransactionClient import TransactionClient
|
13 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 15 |
import urllib2
|
- |
|
| 16 |
import time
|
14 |
import time
|
| 17 |
from datetime import date, datetime, timedelta
|
15 |
from datetime import date, datetime, timedelta
|
| 18 |
from shop2020.utils import EmailAttachmentSender
|
- |
|
| 19 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part
|
- |
|
| 20 |
import math
|
16 |
import math
|
| 21 |
import simplejson as json
|
17 |
import simplejson as json
|
| 22 |
import xlwt
|
18 |
import xlwt
|
| 23 |
import optparse
|
19 |
import optparse
|
| 24 |
import sys
|
20 |
import sys
|
| 25 |
import smtplib
|
- |
|
| 26 |
from email.mime.text import MIMEText
|
21 |
from operator import itemgetter
|
| 27 |
import email
|
- |
|
| 28 |
from email.mime.multipart import MIMEMultipart
|
- |
|
| 29 |
import email.encoders
|
- |
|
| 30 |
import mechanize
|
- |
|
| 31 |
import cookielib
|
- |
|
| 32 |
|
22 |
|
| 33 |
|
23 |
|
| 34 |
config_client = ConfigClient()
|
24 |
config_client = ConfigClient()
|
| 35 |
host = config_client.get_property('staging_hostname')
|
25 |
host = config_client.get_property('staging_hostname')
|
| 36 |
syncPrice=config_client.get_property('sync_price_on_marketplace')
|
26 |
syncPrice=config_client.get_property('sync_price_on_marketplace')
|
| Line 39... |
Line 29... |
| 39 |
amazonLongTermActivePromotions = []
|
29 |
amazonLongTermActivePromotions = []
|
| 40 |
amazonShortTermActivePromotions = []
|
30 |
amazonShortTermActivePromotions = []
|
| 41 |
saleMap = {}
|
31 |
saleMap = {}
|
| 42 |
DataService.initialize(db_hostname=host)
|
32 |
DataService.initialize(db_hostname=host)
|
| 43 |
|
33 |
|
| 44 |
amScraper = AmazonAsyncScraper.AmazonAsyncScraper()
|
34 |
amScraper = AmazonAsyncScraper.Products("AKIAII3SGRXBJDPCHSGQ", "B92xTbNBTYygbGs98w01nFQUhbec1pNCkCsKVfpg", "AF6E3O0VE0X4D")
|
| 45 |
|
- |
|
| 46 |
class __AmazonAsinPrice:
|
- |
|
| 47 |
def __init__(self, asin, price):
|
- |
|
| 48 |
self.asin = asin
|
- |
|
| 49 |
self.price = price
|
- |
|
| 50 |
|
35 |
|
| 51 |
class __AmazonItemInfo:
|
36 |
class __AmazonItemInfo:
|
| 52 |
|
37 |
|
| 53 |
def __init__(self, asin, nlc, courierCost, sku, product_group, brand, model_name, model_number, color, weight, parent_category, risky, vatRate, runType, parent_category_name, sourcePercentage, ourInventory, state_id):
|
38 |
def __init__(self, asin, nlc, courierCost, sku, product_group, brand, model_name, model_number, color, weight, parent_category, risky, vatRate, runType, parent_category_name, sourcePercentage, ourInventory, state_id):
|
| 54 |
self.asin = asin
|
39 |
self.asin = asin
|
| Line 69... |
Line 54... |
| 69 |
self.sourcePercentage = sourcePercentage
|
54 |
self.sourcePercentage = sourcePercentage
|
| 70 |
self.ourInventory = ourInventory
|
55 |
self.ourInventory = ourInventory
|
| 71 |
self.state_id = state_id
|
56 |
self.state_id = state_id
|
| 72 |
|
57 |
|
| 73 |
class __AmazonDetails:
|
58 |
class __AmazonDetails:
|
| 74 |
def __init__(self, sku, ourSp, ourRank, lowestSellerName,lowestSellerSp,secondLowestSellerName, secondLowestSellerSp, thirdLowestSellerName, thirdLowestSellerSp, totalSeller, multipleListings):
|
59 |
def __init__(self, sku, ourSp, ourRank, lowestSellerName,lowestSellerSp,secondLowestSellerName, secondLowestSellerSp, thirdLowestSellerName, thirdLowestSellerSp, totalSeller, multipleListings, \
|
| - |
|
60 |
promoPrice, isPromotion, lowestSellerShippingTime, lowestSellerRating, secondLowestSellerShippingTime, secondLowestSellerRating, thirdLowestSellerShippingTime , \
|
| - |
|
61 |
thirdLowestSellerRating, lowestSellerType, secondLowestSellerType, thirdLowestSellerType):
|
| 75 |
self.sku =sku
|
62 |
self.sku =sku
|
| 76 |
self.ourSp = ourSp
|
63 |
self.ourSp = ourSp
|
| 77 |
self.ourRank = ourRank
|
64 |
self.ourRank = ourRank
|
| 78 |
self.lowestSellerName = lowestSellerName
|
65 |
self.lowestSellerName = lowestSellerName
|
| 79 |
self.lowestSellerSp = lowestSellerSp
|
66 |
self.lowestSellerSp = lowestSellerSp
|
| 80 |
self.secondLowestSellerName = secondLowestSellerName
|
67 |
self.secondLowestSellerName = secondLowestSellerName
|
| 81 |
self.secondLowestSellerSp = secondLowestSellerSp
|
68 |
self.secondLowestSellerSp = secondLowestSellerSp
|
| 82 |
self.thirdLowestSellerName = thirdLowestSellerName
|
69 |
self.thirdLowestSellerName = thirdLowestSellerName
|
| 83 |
self.thirdLowestSellerSp = thirdLowestSellerSp
|
70 |
self.thirdLowestSellerSp = thirdLowestSellerSp
|
| 84 |
self.totalSeller = totalSeller
|
71 |
self.totalSeller = totalSeller
|
| 85 |
self.multipleListings = multipleListings
|
72 |
self.multipleListings = multipleListings
|
| - |
|
73 |
self.promoPrice = promoPrice
|
| - |
|
74 |
self.isPromotion = isPromotion
|
| - |
|
75 |
self.lowestSellerShippingTime =lowestSellerShippingTime
|
| - |
|
76 |
self.lowestSellerRating = lowestSellerRating
|
| - |
|
77 |
self.secondLowestSellerShippingTime = secondLowestSellerShippingTime
|
| - |
|
78 |
self.secondLowestSellerRating = secondLowestSellerRating
|
| - |
|
79 |
self.thirdLowestSellerShippingTime= thirdLowestSellerShippingTime
|
| - |
|
80 |
self.thirdLowestSellerRating = thirdLowestSellerRating
|
| - |
|
81 |
self.lowestSellerType = lowestSellerType
|
| - |
|
82 |
self.secondLowestSellerType = secondLowestSellerType
|
| - |
|
83 |
self.thirdLowestSellerType = thirdLowestSellerType
|
| - |
|
84 |
|
| 86 |
|
85 |
|
| 87 |
class __AmazonPricing:
|
86 |
class __AmazonPricing:
|
| 88 |
|
87 |
|
| 89 |
def __init__(self, ourSp, ourTp, lowestPossibleTp, lowestPossibleSp):
|
88 |
def __init__(self, ourSp, ourTp, lowestPossibleTp, lowestPossibleSp):
|
| 90 |
self.ourTp = ourTp
|
89 |
self.ourTp = ourTp
|
| Line 214... |
Line 213... |
| 214 |
if fbaSaleSnapshot.item_id==0:
|
213 |
if fbaSaleSnapshot.item_id==0:
|
| 215 |
return 0
|
214 |
return 0
|
| 216 |
else:
|
215 |
else:
|
| 217 |
return fbaSaleSnapshot.totalOrderCount
|
216 |
return fbaSaleSnapshot.totalOrderCount
|
| 218 |
|
217 |
|
| 219 |
def syncAsin():
|
218 |
#def syncAsin():
|
| 220 |
# notListedOnAmazon = []
|
219 |
## notListedOnAmazon = []
|
| 221 |
# diffAsins = []
|
220 |
## diffAsins = []
|
| 222 |
# login_url = "https://sellercentral.amazon.in/gp/homepage.html"
|
221 |
## login_url = "https://sellercentral.amazon.in/gp/homepage.html"
|
| 223 |
# br = SellerCentralInventoryReport.login(login_url)
|
222 |
## br = SellerCentralInventoryReport.login(login_url)
|
| 224 |
# report_url = "https://sellercentral.amazon.in/gp/upload-download-utils/requestReport.html?type=OpenListingReport&marketplaceID=44571&Request+Report="
|
223 |
## report_url = "https://sellercentral.amazon.in/gp/upload-download-utils/requestReport.html?type=OpenListingReport&marketplaceID=44571&Request+Report="
|
| 225 |
# br = SellerCentralInventoryReport.requestReport(br,report_url)
|
224 |
## br = SellerCentralInventoryReport.requestReport(br,report_url)
|
| 226 |
# status_url="https://sellercentral.amazon.in/gp/upload-download-utils/reportStatusData.html"
|
225 |
## status_url="https://sellercentral.amazon.in/gp/upload-download-utils/reportStatusData.html"
|
| 227 |
# br, page = SellerCentralInventoryReport.checkStatus(br,status_url)
|
226 |
## br, page = SellerCentralInventoryReport.checkStatus(br,status_url)
|
| 228 |
# br, batchId = SellerCentralInventoryReport.getReportBatchId(br,page)
|
227 |
## br, batchId = SellerCentralInventoryReport.getReportBatchId(br,page)
|
| 229 |
# print "*********************************"
|
228 |
## print "*********************************"
|
| 230 |
# print "Batch Id for request is ",batchId
|
229 |
## print "Batch Id for request is ",batchId
|
| 231 |
# print "*********************************"
|
230 |
## print "*********************************"
|
| 232 |
# ready = False
|
231 |
## ready = False
|
| 233 |
# retryCount = 0
|
232 |
## retryCount = 0
|
| 234 |
# while not ready:
|
233 |
## while not ready:
|
| 235 |
# if retryCount == 10:
|
234 |
## if retryCount == 10:
|
| 236 |
# print "File not available for download after multiple retries"
|
235 |
## print "File not available for download after multiple retries"
|
| 237 |
# sys.exit(1)
|
236 |
## sys.exit(1)
|
| 238 |
# br, download_link = SellerCentralInventoryReport.downloadReport(br,batchId,status_url)
|
237 |
## br, download_link = SellerCentralInventoryReport.downloadReport(br,batchId,status_url)
|
| 239 |
# if download_link is not None:
|
238 |
## if download_link is not None:
|
| 240 |
# ready= True
|
239 |
## ready= True
|
| 241 |
# continue
|
240 |
## continue
|
| 242 |
# print "File not ready for download yet.Will try again after 30 seconds."
|
241 |
## print "File not ready for download yet.Will try again after 30 seconds."
|
| 243 |
# retryCount+=1
|
242 |
## retryCount+=1
|
| 244 |
# time.sleep(30)
|
243 |
## time.sleep(30)
|
| 245 |
# fPath = SellerCentralInventoryReport.fetchFile(download_link['href'],br,batchId)
|
244 |
## fPath = SellerCentralInventoryReport.fetchFile(download_link['href'],br,batchId)
|
| 246 |
fPath = "/tmp/9940651090.txt"
|
245 |
# fPath = "/tmp/9940651090.txt"
|
| 247 |
global amazonAsinPrice
|
246 |
# global amazonAsinPrice
|
| 248 |
for line in open(fPath):
|
247 |
# for line in open(fPath):
|
| 249 |
l = line.split('\t')
|
248 |
# l = line.split('\t')
|
| 250 |
if (str(l[0]).startswith('FBA') or str(l[0]).startswith('FBB')):
|
249 |
# if (str(l[0]).startswith('FBA') or str(l[0]).startswith('FBB')):
|
| 251 |
obj = __AmazonAsinPrice(l[1],l[2])
|
250 |
# obj = __AmazonAsinPrice(l[1],l[2])
|
| 252 |
amazonAsinPrice[l[0]] = obj
|
251 |
# amazonAsinPrice[l[0]] = obj
|
| 253 |
#Can be used to sync asins, not doing due to multiple asins corresponding to one itemId
|
252 |
##Can be used to sync asins, not doing due to multiple asins corresponding to one itemId
|
| 254 |
# systemAsins = session.query(Item,Amazonlisted).join((Amazonlisted,Item.id==Amazonlisted.itemId)).all()
|
253 |
## systemAsins = session.query(Item,Amazonlisted).join((Amazonlisted,Item.id==Amazonlisted.itemId)).all()
|
| 255 |
# for systemAsin in systemAsins:
|
254 |
## for systemAsin in systemAsins:
|
| 256 |
# item = systemAsin[0]
|
255 |
## item = systemAsin[0]
|
| 257 |
# amListed = systemAsin[1]
|
256 |
## amListed = systemAsin[1]
|
| 258 |
# if amazonAsinPrice.get('FBA'+str(item.id)) is None:
|
257 |
## if amazonAsinPrice.get('FBA'+str(item.id)) is None:
|
| 259 |
# temp=[]
|
258 |
## temp=[]
|
| 260 |
# temp.append(item)
|
259 |
## temp.append(item)
|
| 261 |
# temp.append(amListed)
|
260 |
## temp.append(amListed)
|
| 262 |
# notListedOnAmazon.append(temp)
|
261 |
## notListedOnAmazon.append(temp)
|
| 263 |
# continue
|
262 |
## continue
|
| 264 |
# else:
|
263 |
## else:
|
| 265 |
# temp=[]
|
264 |
## temp=[]
|
| 266 |
# temp.append(item)
|
265 |
## temp.append(item)
|
| 267 |
# temp.append(amListed)
|
266 |
## temp.append(amListed)
|
| 268 |
# if item.asin!=((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip():
|
267 |
## if item.asin!=((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip():
|
| 269 |
# diffAsins.append(temp)
|
268 |
## diffAsins.append(temp)
|
| 270 |
# continue
|
269 |
## continue
|
| 271 |
#
|
270 |
##
|
| 272 |
# for diffAsin in diffAsins:
|
271 |
## for diffAsin in diffAsins:
|
| 273 |
# item = diffAsin[0]
|
272 |
## item = diffAsin[0]
|
| 274 |
# amListed = diffAsin[1]
|
273 |
## amListed = diffAsin[1]
|
| 275 |
# item.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
274 |
## item.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
| 276 |
# amListed.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
275 |
## amListed.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
| 277 |
# session.commit()
|
276 |
## session.commit()
|
| 278 |
# session.close()
|
277 |
## session.close()
|
| 279 |
|
278 |
|
| 280 |
def fetchFbaSale():
|
279 |
def fetchFbaSale():
|
| 281 |
global saleMap
|
280 |
global saleMap
|
| 282 |
transaction_client = TransactionClient().get_client()
|
281 |
transaction_client = TransactionClient().get_client()
|
| 283 |
fbaSaleSnapshot = transaction_client.getAmazonFbaSalesSnapshotForDays(4)
|
282 |
fbaSaleSnapshot = transaction_client.getAmazonFbaSalesSnapshotForDays(4)
|
| Line 323... |
Line 322... |
| 323 |
global amazonLongTermActivePromotions
|
322 |
global amazonLongTermActivePromotions
|
| 324 |
global amazonShortTermActivePromotions
|
323 |
global amazonShortTermActivePromotions
|
| 325 |
itemInfo = []
|
324 |
itemInfo = []
|
| 326 |
inventory_client = InventoryClient().get_client()
|
325 |
inventory_client = InventoryClient().get_client()
|
| 327 |
fbaAvailableInventorySnapshot = inventory_client.getAllAvailableAmazonFbaItemInventory()
|
326 |
fbaAvailableInventorySnapshot = inventory_client.getAllAvailableAmazonFbaItemInventory()
|
| 328 |
print "length****"
|
- |
|
| 329 |
print len(fbaAvailableInventorySnapshot)
|
327 |
print len(fbaAvailableInventorySnapshot)
|
| 330 |
for fbaInventoryItem in fbaAvailableInventorySnapshot:
|
328 |
for fbaInventoryItem in fbaAvailableInventorySnapshot:
|
| 331 |
d_amazon_listed = Amazonlisted.get_by(itemId=fbaInventoryItem.item_id)
|
329 |
d_amazon_listed = Amazonlisted.get_by(itemId=fbaInventoryItem.item_id)
|
| 332 |
if d_amazon_listed is None:
|
330 |
if d_amazon_listed is None:
|
| 333 |
print "amazon listed is none"
|
- |
|
| 334 |
continue
|
331 |
continue
|
| 335 |
if d_amazon_listed.overrrideWanlc:
|
332 |
if d_amazon_listed.overrrideWanlc:
|
| 336 |
wanlc = d_amazon_listed.exceptionalWanlc
|
333 |
wanlc = d_amazon_listed.exceptionalWanlc
|
| 337 |
else:
|
334 |
else:
|
| 338 |
wanlc = inventory_client.getWanNlcForSource(fbaInventoryItem.item_id,OrderSource.AMAZON)
|
335 |
wanlc = inventory_client.getWanNlcForSource(fbaInventoryItem.item_id,OrderSource.AMAZON)
|
| Line 343... |
Line 340... |
| 343 |
if scp is not None:
|
340 |
if scp is not None:
|
| 344 |
sourcePercentage = scp
|
341 |
sourcePercentage = scp
|
| 345 |
else:
|
342 |
else:
|
| 346 |
spm = SourcePercentageMaster.get_by(source=OrderSource.AMAZON)
|
343 |
spm = SourcePercentageMaster.get_by(source=OrderSource.AMAZON)
|
| 347 |
sourcePercentage = spm
|
344 |
sourcePercentage = spm
|
| 348 |
print "$$$$$$$$$$$$$$$$$"
|
- |
|
| 349 |
print fbaInventoryItem
|
- |
|
| 350 |
if fbaInventoryItem.location==0:
|
345 |
if fbaInventoryItem.location==0:
|
| 351 |
sku = 'FBA'+str(fbaInventoryItem.item_id)
|
346 |
sku = 'FBA'+str(fbaInventoryItem.item_id)
|
| 352 |
state_id = 1
|
347 |
state_id = 1
|
| 353 |
elif fbaInventoryItem.location==1:
|
348 |
elif fbaInventoryItem.location==1:
|
| 354 |
sku = 'FBB'+str(fbaInventoryItem.item_id)
|
349 |
sku = 'FBB'+str(fbaInventoryItem.item_id)
|
| 355 |
state_id = 2
|
350 |
state_id = 2
|
| 356 |
else:
|
351 |
else:
|
| 357 |
print "continue*****"
|
- |
|
| 358 |
continue
|
352 |
continue
|
| 359 |
cc = computeCourierCost(it.weight)
|
353 |
cc = computeCourierCost(it.weight)
|
| 360 |
if amazonAsinPrice.get(sku) is None:
|
- |
|
| 361 |
asin = ''
|
- |
|
| 362 |
elif amazonAsinPrice.get(sku).asin is None:
|
- |
|
| 363 |
asin = ''
|
- |
|
| 364 |
else:
|
- |
|
| 365 |
asin = amazonAsinPrice.get(sku).asin
|
- |
|
| 366 |
|
354 |
|
| 367 |
amazonItemInfo = __AmazonItemInfo(asin, wanlc,cc, sku, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, None, runType, parent_category.display_name,sourcePercentage,fbaInventoryItem.availability,state_id)
|
355 |
amazonItemInfo = __AmazonItemInfo(None, wanlc,cc, sku, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, None, runType, parent_category.display_name,sourcePercentage,fbaInventoryItem.availability,state_id)
|
| 368 |
print amazonItemInfo
|
- |
|
| 369 |
itemInfo.append(amazonItemInfo)
|
356 |
itemInfo.append(amazonItemInfo)
|
| 370 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
357 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
| 371 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
358 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| 372 |
for amPromotion in amPromotions:
|
359 |
for amPromotion in amPromotions:
|
| 373 |
amazonLongTermActivePromotions.append(amPromotion.sku)
|
360 |
amazonLongTermActivePromotions.append(amPromotion.sku)
|
| 374 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
361 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
| 375 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
362 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| 376 |
for amPromotion in amPromotions:
|
363 |
for amPromotion in amPromotions:
|
| 377 |
amazonShortTermActivePromotions.append(amPromotion.sku)
|
364 |
amazonShortTermActivePromotions.append(amPromotion.sku)
|
| 378 |
session.close()
|
365 |
session.close()
|
| 379 |
print "item info length"
|
- |
|
| 380 |
print len(itemInfo)
|
- |
|
| 381 |
return itemInfo
|
366 |
return itemInfo
|
| 382 |
|
367 |
|
| - |
|
368 |
def getPriceAndAsin(itemInfo):
|
| - |
|
369 |
skus = []
|
| - |
|
370 |
for item in itemInfo:
|
| - |
|
371 |
skus.append(item.sku)
|
| - |
|
372 |
ourPricingForSku = amScraper.get_my_pricing_for_sku('A21TJRUUN4KGV', skus)
|
| - |
|
373 |
for item in itemInfo:
|
| - |
|
374 |
ourPricing = ourPricingForSku.get(item.sku)
|
| - |
|
375 |
if len(ourPricing.keys())==0:
|
| - |
|
376 |
item.ourSp = 0
|
| - |
|
377 |
item.promoPrice = 0
|
| - |
|
378 |
item.isPromotion = False
|
| - |
|
379 |
else:
|
| - |
|
380 |
item.ourSp = ourPricing.get('sellingPrice')
|
| - |
|
381 |
item.promoPrice = ourPricing.get('promoPrice')
|
| - |
|
382 |
item.isPromotion = ourPricing.get('promotion')
|
| - |
|
383 |
|
| - |
|
384 |
|
| 383 |
def decideCategory(itemInfo):
|
385 |
def decideCategory(itemInfo):
|
| 384 |
exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete = [],[],[],[],[],[],[]
|
386 |
exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete = [],[],[],[],[],[],[]
|
| 385 |
skuUrls = []
|
387 |
skus = []
|
| 386 |
#skuAsinMap = {}
|
- |
|
| 387 |
for item in itemInfo:
|
388 |
for item in itemInfo:
|
| 388 |
if item.asin is None or len(item.asin)==0:
|
- |
|
| 389 |
temp = []
|
- |
|
| 390 |
temp.append(item)
|
389 |
skus.append(item.sku)
|
| 391 |
temp.append("Asin not available")
|
- |
|
| 392 |
exceptionList.append(temp)
|
- |
|
| 393 |
continue
|
- |
|
| 394 |
skuUrls.append('http://www.amazon.in/gp/offer-listing/'+item.asin+'/ref=olp_sort_ps')
|
390 |
aggResponse = amScraper.get_competitive_pricing_for_sku('A21TJRUUN4KGV', skus)
|
| 395 |
aggResponse = amScraper.read(skuUrls, True)
|
391 |
ourPricingForSku = amScraper.get_my_pricing_for_sku('A21TJRUUN4KGV', skus)
|
| 396 |
|
392 |
|
| 397 |
for val in itemInfo:
|
393 |
for val in itemInfo:
|
| 398 |
print "Trying to get details of ",val.sku
|
- |
|
| 399 |
if val.asin is None or len(val.asin)==0:
|
- |
|
| 400 |
continue
|
- |
|
| 401 |
scrapInfo = aggResponse.get(val.asin)
|
394 |
scrapInfo = aggResponse.get(val.sku)
|
| 402 |
print "Scraped info for asin is ",scrapInfo
|
- |
|
| 403 |
if val.sku in amazonLongTermActivePromotions:
|
- |
|
| 404 |
print "Sku in promotion, will handle it later.Moving to other..."
|
- |
|
| 405 |
continue
|
- |
|
| 406 |
if scrapInfo is None or val.nlc==0:
|
395 |
if len(scrapInfo)==0 or val.nlc==0 or len(ourPricingForSku.get(val.sku).keys())==0:
|
| 407 |
temp = []
|
396 |
temp = []
|
| 408 |
temp.append(val)
|
397 |
temp.append(val)
|
| 409 |
if val.nlc==0 or val.nlc is None:
|
398 |
if val.nlc==0 or val.nlc is None:
|
| 410 |
temp.append("WANLC is 0")
|
399 |
temp.append("WANLC is 0")
|
| - |
|
400 |
elif len(ourPricingForSku.get(val.sku).keys())==0:
|
| - |
|
401 |
temp.append("Unable to fetch our price")
|
| 411 |
else:
|
402 |
else:
|
| 412 |
temp.append("Not able to fetch")
|
403 |
temp.append("Unable to fetch competitive pricing")
|
| 413 |
exceptionList.append(temp)
|
404 |
exceptionList.append(temp)
|
| 414 |
continue
|
405 |
continue
|
| - |
|
406 |
val.asin = ourPricingForSku.get(val.sku).get('asin')
|
| - |
|
407 |
val.ourSp = ourPricingForSku.get(val.sku).get('sellingPrice')
|
| - |
|
408 |
val.promoPrice = ourPricingForSku.get(val.sku).get('promoPrice')
|
| - |
|
409 |
val.isPromo = ourPricingForSku.get(val.sku).get('promotion')
|
| 415 |
iterator = 0
|
410 |
iterator = 0
|
| 416 |
sku, lowestSellerName,secondLowestSellerName, thirdLowestSellerName = ('',)*4
|
411 |
sku, lowestSellerName,secondLowestSellerName, thirdLowestSellerName = ('',)*4
|
| 417 |
ourSp, ourRank, lowestSellerSp, secondLowestSellerSp, thirdLowestSellerSp, ourTp, lowestPossibleSp, lowestPossibleTp = (0,)*8
|
412 |
ourSp, ourRank, lowestSellerSp, secondLowestSellerSp, thirdLowestSellerSp, ourTp, lowestPossibleSp, lowestPossibleTp = (0,)*8
|
| - |
|
413 |
lowestSellerShippingTime, lowestSellerRating, secondLowestSellerShippingTime, secondLowestSellerRating, thirdLowestSellerShippingTime , \
|
| - |
|
414 |
thirdLowestSellerRating, lowestSellerType, secondLowestSellerType, thirdLowestSellerType = (0,)*9
|
| - |
|
415 |
isPromo = False
|
| 418 |
sku = val.sku
|
416 |
sku = val.sku
|
| 419 |
scrapedSkuLocation = None
|
417 |
scrapedSkuLocation = None
|
| 420 |
multipleListings = False
|
418 |
multipleListings = False
|
| 421 |
for info in scrapInfo:
|
- |
|
| 422 |
print "iterating scrap info"
|
419 |
ourSkuDetails = ourPricingForSku.get(val.sku)
|
| 423 |
if iterator ==3:
|
420 |
scrapInfo.append(ourSkuDetails)
|
| 424 |
break
|
- |
|
| 425 |
if (info['sellerName']).strip()=='Saholic':
|
421 |
sortedScrapInfo = sorted(scrapInfo, key=itemgetter('promoPrice','notOurSku'))
|
| 426 |
if ourRank>0:
|
422 |
for info in sortedScrapInfo:
|
| 427 |
multipleListings = True
|
423 |
if not info.notOurSku:
|
| 428 |
ourSp = info['sellerPrice']
|
424 |
ourSp = info.sellingPrice
|
| 429 |
ourRank = iterator+1
|
425 |
promoPrice = info.promoPrice
|
| 430 |
if val.state_id==1:
|
- |
|
| 431 |
#It means sku starts with FBA
|
- |
|
| 432 |
fbaPrice = (amazonAsinPrice.get(val.sku)).price
|
- |
|
| 433 |
try:
|
- |
|
| 434 |
if ourSp==fbaPrice:
|
- |
|
| 435 |
scrapedSkuLocation = val.state_id
|
- |
|
| 436 |
except:
|
- |
|
| 437 |
scrapedSkuLocation = None
|
- |
|
| 438 |
elif val.state_id==2:
|
- |
|
| 439 |
#It means sku starts with FBB
|
- |
|
| 440 |
fbbPrice = (amazonAsinPrice.get(val.sku)).price
|
- |
|
| 441 |
try:
|
- |
|
| 442 |
if ourSp==fbbPrice:
|
426 |
isPromo = info.promotion
|
| 443 |
scrapedSkuLocation = val.state_id
|
- |
|
| 444 |
except:
|
- |
|
| 445 |
scrapedSkuLocation = None
|
- |
|
| 446 |
else:
|
- |
|
| 447 |
scrapedSkuLocation = None
|
427 |
ourRank = iterator + 1
|
| 448 |
if scrapedSkuLocation is None:
|
- |
|
| 449 |
print "fishy...confused for ", val.sku
|
- |
|
| 450 |
|
428 |
|
| 451 |
if iterator == 0:
|
429 |
if iterator == 0:
|
| 452 |
lowestSellerName = info['sellerName']
|
430 |
lowestSellerSp = info['promoPrice']
|
| - |
|
431 |
lowestSellerShippingTime = info['shippingTime']
|
| 453 |
lowestSellerSp = info['sellerPrice']
|
432 |
lowestSellerRating = info['rating']
|
| - |
|
433 |
lowestSellerType = info['fulfillmentChannel']
|
| 454 |
|
434 |
|
| 455 |
if iterator == 1:
|
435 |
if iterator == 1:
|
| 456 |
secondLowestSellerName = info['sellerName']
|
436 |
secondLowestSellerSp = info['promoPrice']
|
| - |
|
437 |
secondLowestSellerShippingTime = info['shippingTime']
|
| 457 |
secondLowestSellerSp = info['sellerPrice']
|
438 |
secondLowestSellerRating = info['rating']
|
| - |
|
439 |
secondLowestSellerType = info['fulfillmentChannel']
|
| 458 |
|
440 |
|
| 459 |
if iterator == 2:
|
441 |
if iterator == 2:
|
| 460 |
thirdLowestSellerName = info['sellerName']
|
442 |
thirdLowestSellerSp = info['promoPrice']
|
| - |
|
443 |
thirdLowestSellerShippingTime = info['shippingTime']
|
| 461 |
thirdLowestSellerSp = info['sellerPrice']
|
444 |
thirdLowestSellerRating = info['rating']
|
| - |
|
445 |
thirdLowestSellerType = info['fulfillmentChannel']
|
| 462 |
|
446 |
|
| 463 |
iterator += 1
|
447 |
iterator += 1
|
| 464 |
print "terminating iterator"
|
448 |
print "terminating iterator"
|
| 465 |
#if cheapestSkuLocation!=val.state_id
|
- |
|
| 466 |
|
449 |
|
| 467 |
if ourSp==0 or scrapedSkuLocation is None:
|
- |
|
| 468 |
print "Sku not present in top 3.Getting price from amazonAsinPrice...or multiple listings"
|
- |
|
| 469 |
if ourSp==0:
|
- |
|
| 470 |
ourRank = 999 #Due to pagination and large no of sellers.Taking it as dummy value, means we are not in top 3
|
- |
|
| 471 |
ourSp = (amazonAsinPrice.get(val.sku)).price
|
- |
|
| 472 |
if ourSp is None or ourSp==0:
|
- |
|
| 473 |
temp = []
|
- |
|
| 474 |
temp.append(val)
|
- |
|
| 475 |
temp.append("Price not available")
|
- |
|
| 476 |
exceptionList.append(temp)
|
- |
|
| 477 |
continue
|
- |
|
| 478 |
else:
|
- |
|
| 479 |
#determine rank
|
- |
|
| 480 |
if ourSp <= lowestSellerSp or lowestSellerSp==0:
|
- |
|
| 481 |
ourRank = 1
|
- |
|
| 482 |
elif ourSp > lowestSellerSp and (ourSp <= secondLowestSellerSp or secondLowestSellerSp==0):
|
- |
|
| 483 |
ourRank = 2
|
- |
|
| 484 |
elif ourSp > secondLowestSellerSp and (ourSp<=thirdLowestSellerSp or thirdLowestSellerSp==0):
|
- |
|
| 485 |
ourRank = 3
|
- |
|
| 486 |
else:
|
- |
|
| 487 |
ourRank = 999
|
- |
|
| 488 |
|
- |
|
| 489 |
if multipleListings:
|
- |
|
| 490 |
print "multiple listings..."
|
- |
|
| 491 |
ourSp = (amazonAsinPrice.get(val.sku)).price
|
- |
|
| 492 |
if ourSp is None or ourSp==0:
|
- |
|
| 493 |
temp = []
|
- |
|
| 494 |
temp.append(val)
|
- |
|
| 495 |
temp.append("Price not available")
|
- |
|
| 496 |
exceptionList.append(temp)
|
- |
|
| 497 |
continue
|
- |
|
| 498 |
if ourSp <= lowestSellerSp:
|
- |
|
| 499 |
ourRank = 1
|
- |
|
| 500 |
elif ourSp > lowestSellerSp and (ourSp <= secondLowestSellerSp or secondLowestSellerSp==0):
|
- |
|
| 501 |
ourRank = 2
|
- |
|
| 502 |
elif ourSp > secondLowestSellerSp and (ourSp<=thirdLowestSellerSp or thirdLowestSellerSp==0):
|
- |
|
| 503 |
ourRank = 3
|
- |
|
| 504 |
else:
|
- |
|
| 505 |
ourRank = 999
|
- |
|
| 506 |
|
- |
|
| 507 |
|
450 |
|
| 508 |
print "Creating object am details",val.sku
|
451 |
print "Creating object am details",val.sku
|
| 509 |
amDetails = __AmazonDetails(sku, float(ourSp), ourRank, lowestSellerName,float(lowestSellerSp),secondLowestSellerName, float(secondLowestSellerSp), thirdLowestSellerName, float(thirdLowestSellerSp),len(scrapInfo),multipleListings)
|
452 |
amDetails = __AmazonDetails(sku, float(ourSp), ourRank, lowestSellerName,float(lowestSellerSp),secondLowestSellerName, float(secondLowestSellerSp), thirdLowestSellerName, float(thirdLowestSellerSp),len(scrapInfo),multipleListings,promoPrice,isPromo, \
|
| - |
|
453 |
lowestSellerShippingTime ,lowestSellerRating, secondLowestSellerShippingTime, secondLowestSellerRating, thirdLowestSellerShippingTime , thirdLowestSellerRating, lowestSellerType, secondLowestSellerType, thirdLowestSellerType)
|
| 510 |
print "am details obj created"
|
454 |
print "am details obj created"
|
| 511 |
try:
|
455 |
try:
|
| 512 |
print "inside val getter"
|
456 |
print "inside val getter"
|
| 513 |
itemVatMaster = ItemVatMaster.query.filter(and_(ItemVatMaster.itemId==int(val.sku[3:]), ItemVatMaster.stateId==val.state_id)).first()
|
457 |
itemVatMaster = ItemVatMaster.query.filter(and_(ItemVatMaster.itemId==int(val.sku[3:]), ItemVatMaster.stateId==val.state_id)).first()
|
| 514 |
if itemVatMaster is None:
|
458 |
if itemVatMaster is None:
|
| 515 |
d_item = Item.query.filter_by(id=int(val.sku[3:])).first()
|
459 |
d_item = Item.query.filter_by(id=int(val.sku[3:])).first()
|
| 516 |
if d_item is None:
|
460 |
if d_item is None:
|
| 517 |
raise
|
461 |
raise
|
| 518 |
else:
|
462 |
else:
|
| 519 |
vatMaster = CategoryVatMaster.query.filter(and_(CategoryVatMaster.categoryId==d_item.category, CategoryVatMaster.minVal<=amDetails.ourSp, CategoryVatMaster.maxVal>=amDetails.ourSp, CategoryVatMaster.stateId == val.state_id)).first()
|
463 |
vatMaster = CategoryVatMaster.query.filter(and_(CategoryVatMaster.categoryId==d_item.category, CategoryVatMaster.minVal<=amDetails.promoPrice, CategoryVatMaster.maxVal>=amDetails.promoPrice, CategoryVatMaster.stateId == val.state_id)).first()
|
| 520 |
if vatMaster is None:
|
464 |
if vatMaster is None:
|
| 521 |
raise
|
465 |
raise
|
| 522 |
else:
|
466 |
else:
|
| 523 |
val.vatRate = vatMaster.vatPercent
|
467 |
val.vatRate = vatMaster.vatPercent
|
| 524 |
print "vat fetched"
|
468 |
print "vat fetched"
|
| Line 529... |
Line 473... |
| 529 |
print "vat exception"
|
473 |
print "vat exception"
|
| 530 |
temp = []
|
474 |
temp = []
|
| 531 |
temp.append(val)
|
475 |
temp.append(val)
|
| 532 |
temp.append("Vat not available")
|
476 |
temp.append("Vat not available")
|
| 533 |
exceptionList.append(temp)
|
477 |
exceptionList.append(temp)
|
| 534 |
print "added in exception list"
|
- |
|
| 535 |
continue
|
478 |
continue
|
| 536 |
|
479 |
|
| 537 |
ourTp = getOurTp(amDetails,val,val.sourcePercentage)
|
480 |
ourTp = getOurTp(amDetails,val,val.sourcePercentage)
|
| 538 |
lowestPossibleTp = getLowestPossibleTp(amDetails,val,val.sourcePercentage)
|
481 |
lowestPossibleTp = getLowestPossibleTp(amDetails,val,val.sourcePercentage)
|
| 539 |
lowestPossibleSp = getLowestPossibleSp(amDetails,val,val.sourcePercentage)
|
482 |
lowestPossibleSp = getLowestPossibleSp(amDetails,val,val.sourcePercentage)
|
| Line 554... |
Line 497... |
| 554 |
temp.append(amDetails)
|
497 |
temp.append(amDetails)
|
| 555 |
temp.append(amPricing)
|
498 |
temp.append(amPricing)
|
| 556 |
cheapest.append(temp)
|
499 |
cheapest.append(temp)
|
| 557 |
continue
|
500 |
continue
|
| 558 |
|
501 |
|
| 559 |
if (amDetails.lowestSellerSp > amPricing.lowestPossibleSp) and ((((float(amDetails.ourSp - amDetails.lowestSellerSp))/amDetails.ourSp)<=.01) or ((amDetails.ourSp - amDetails.lowestSellerSp)<=25)):
|
502 |
if (amDetails.lowestSellerSp > amPricing.lowestPossibleSp) and ((((float(amDetails.promoPrice - amDetails.lowestSellerSp))/amDetails.promoPrice)<=.01) or ((amDetails.promoPrice - amDetails.lowestSellerSp)<=25)):
|
| 560 |
temp = []
|
503 |
temp = []
|
| 561 |
temp.append(val)
|
504 |
temp.append(val)
|
| 562 |
temp.append(amDetails)
|
505 |
temp.append(amDetails)
|
| 563 |
temp.append(amPricing)
|
506 |
temp.append(amPricing)
|
| 564 |
amongCheapestAndCanCompete.append(temp)
|
507 |
amongCheapestAndCanCompete.append(temp)
|
| Line 589... |
Line 532... |
| 589 |
print "Created category..."
|
532 |
print "Created category..."
|
| 590 |
|
533 |
|
| 591 |
return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
|
534 |
return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
|
| 592 |
|
535 |
|
| 593 |
def getOurTp(amazonDetails,val,spm):
|
536 |
def getOurTp(amazonDetails,val,spm):
|
| 594 |
ourTp = amazonDetails.ourSp- amazonDetails.ourSp*(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost)*(1+(spm.serviceTax/100))*(1+(spm.serviceTax/100));
|
537 |
ourTp = amazonDetails.promoPrice- amazonDetails.promoPrice*(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost)*(1+(spm.serviceTax/100))*(1+(spm.serviceTax/100));
|
| 595 |
return round(ourTp,2)
|
538 |
return round(ourTp,2)
|
| 596 |
|
539 |
|
| 597 |
def getLowestPossibleTp(amazonDetails,val,spm):
|
540 |
def getLowestPossibleTp(amazonDetails,val,spm):
|
| 598 |
vat = (amazonDetails.ourSp/(1+(val.vatRate/100))-(val.nlc/(1+(val.vatRate/100))))*(val.vatRate/100)
|
541 |
vat = (amazonDetails.promoPrice/(1+(val.vatRate/100))-(val.nlc/(1+(val.vatRate/100))))*(val.vatRate/100)
|
| 599 |
inHouseCost = 15+vat+(spm.returnProvision/100)*amazonDetails.ourSp
|
542 |
inHouseCost = 15+vat+(spm.returnProvision/100)*amazonDetails.promoPrice
|
| 600 |
lowest_possible_tp = val.nlc+inHouseCost
|
543 |
lowest_possible_tp = val.nlc+inHouseCost
|
| 601 |
return round(lowest_possible_tp,2)
|
544 |
return round(lowest_possible_tp,2)
|
| 602 |
|
545 |
|
| 603 |
def getLowestPossibleSp(amazonDetails,val,spm):
|
546 |
def getLowestPossibleSp(amazonDetails,val,spm):
|
| 604 |
lowestPossibleSp = (val.nlc+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15)*(1+(val.vatRate)/100))/(1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100));
|
547 |
lowestPossibleSp = (val.nlc+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15)*(1+(val.vatRate)/100))/(1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100));
|
| Line 675... |
Line 618... |
| 675 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
618 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 676 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
619 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| 677 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
620 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
| 678 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
621 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
| 679 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
622 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
| - |
|
623 |
amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
|
| - |
|
624 |
amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
|
| - |
|
625 |
amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
|
| 680 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
626 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
| 681 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
627 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
| - |
|
628 |
amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
|
| - |
|
629 |
amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
|
| - |
|
630 |
amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
|
| 682 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
631 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
| 683 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
632 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
| - |
|
633 |
amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
|
| - |
|
634 |
amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
|
| - |
|
635 |
amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
|
| 684 |
amazonScrapingHistory.wanlc = val.nlc
|
636 |
amazonScrapingHistory.wanlc = val.nlc
|
| 685 |
amazonScrapingHistory.commission = spm.commission
|
637 |
amazonScrapingHistory.commission = spm.commission
|
| 686 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
638 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
| 687 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
639 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
| 688 |
amazonScrapingHistory.courierCost = val.courierCost
|
640 |
amazonScrapingHistory.courierCost = val.courierCost
|
| Line 690... |
Line 642... |
| 690 |
amazonScrapingHistory.runType = RunType._NAMES_TO_VALUES.get(runType)
|
642 |
amazonScrapingHistory.runType = RunType._NAMES_TO_VALUES.get(runType)
|
| 691 |
amazonScrapingHistory.totalSeller = amDetails.totalSeller
|
643 |
amazonScrapingHistory.totalSeller = amDetails.totalSeller
|
| 692 |
amazonScrapingHistory.competitiveCategory = CompetitionCategory.BUY_BOX
|
644 |
amazonScrapingHistory.competitiveCategory = CompetitionCategory.BUY_BOX
|
| 693 |
amazonScrapingHistory.timestamp = timestamp
|
645 |
amazonScrapingHistory.timestamp = timestamp
|
| 694 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
646 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| 695 |
if amDetails.secondLowestSellerName!='Saholic':
|
- |
|
| 696 |
competitorSp = amDetails.secondLowestSellerSp
|
- |
|
| 697 |
else:
|
- |
|
| 698 |
competitorSp = amDetails.thirdLowestSellerSp
|
- |
|
| 699 |
proposed_sp = max(competitorSp - max((20, competitorSp*0.002)), amPricing.lowestPossibleSp)
|
647 |
proposed_sp = max(amDetails.secondLowestSellerSp - max((20, amDetails.secondLowestSellerSp*0.002)), amPricing.lowestPossibleSp)
|
| 700 |
proposed_tp = getTargetTp(proposed_sp,spm,val)
|
648 |
proposed_tp = getTargetTp(proposed_sp,spm,val)
|
| 701 |
amazonScrapingHistory.proposedSp = proposed_sp
|
649 |
amazonScrapingHistory.proposedSp = proposed_sp
|
| 702 |
amazonScrapingHistory.proposedTp = proposed_tp
|
650 |
amazonScrapingHistory.proposedTp = proposed_tp
|
| 703 |
amazonScrapingHistory.marginIncreasedPotential = proposed_tp - amPricing.ourTp
|
651 |
amazonScrapingHistory.marginIncreasedPotential = proposed_tp - amPricing.ourTp
|
| 704 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
652 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| Line 723... |
Line 671... |
| 723 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
671 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 724 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
672 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| 725 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
673 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
| 726 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
674 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
| 727 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
675 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
| - |
|
676 |
amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
|
| - |
|
677 |
amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
|
| - |
|
678 |
amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
|
| 728 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
679 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
| 729 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
680 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
| - |
|
681 |
amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
|
| - |
|
682 |
amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
|
| - |
|
683 |
amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
|
| 730 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
684 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
| 731 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
685 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
| - |
|
686 |
amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
|
| - |
|
687 |
amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
|
| - |
|
688 |
amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
|
| 732 |
amazonScrapingHistory.wanlc = val.nlc
|
689 |
amazonScrapingHistory.wanlc = val.nlc
|
| 733 |
amazonScrapingHistory.commission = spm.commission
|
690 |
amazonScrapingHistory.commission = spm.commission
|
| 734 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
691 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
| 735 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
692 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
| 736 |
amazonScrapingHistory.courierCost = val.courierCost
|
693 |
amazonScrapingHistory.courierCost = val.courierCost
|
| Line 764... |
Line 721... |
| 764 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
721 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 765 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
722 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| 766 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
723 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
| 767 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
724 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
| 768 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
725 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
| - |
|
726 |
amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
|
| - |
|
727 |
amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
|
| - |
|
728 |
amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
|
| 769 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
729 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
| 770 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
730 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
| - |
|
731 |
amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
|
| - |
|
732 |
amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
|
| - |
|
733 |
amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
|
| 771 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
734 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
| 772 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
735 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
| - |
|
736 |
amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
|
| - |
|
737 |
amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
|
| - |
|
738 |
amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
|
| 773 |
amazonScrapingHistory.wanlc = val.nlc
|
739 |
amazonScrapingHistory.wanlc = val.nlc
|
| 774 |
amazonScrapingHistory.commission = spm.commission
|
740 |
amazonScrapingHistory.commission = spm.commission
|
| 775 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
741 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
| 776 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
742 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
| 777 |
amazonScrapingHistory.courierCost = val.courierCost
|
743 |
amazonScrapingHistory.courierCost = val.courierCost
|
| Line 805... |
Line 771... |
| 805 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
771 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 806 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
772 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| 807 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
773 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
| 808 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
774 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
| 809 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
775 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
| - |
|
776 |
amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
|
| - |
|
777 |
amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
|
| - |
|
778 |
amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
|
| 810 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
779 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
| 811 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
780 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
| - |
|
781 |
amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
|
| - |
|
782 |
amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
|
| - |
|
783 |
amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
|
| 812 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
784 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
| 813 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
785 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
| - |
|
786 |
amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
|
| - |
|
787 |
amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
|
| - |
|
788 |
amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
|
| 814 |
amazonScrapingHistory.wanlc = val.nlc
|
789 |
amazonScrapingHistory.wanlc = val.nlc
|
| 815 |
amazonScrapingHistory.commission = spm.commission
|
790 |
amazonScrapingHistory.commission = spm.commission
|
| 816 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
791 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
| 817 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
792 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
| 818 |
amazonScrapingHistory.courierCost = val.courierCost
|
793 |
amazonScrapingHistory.courierCost = val.courierCost
|
| Line 849... |
Line 824... |
| 849 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
824 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 850 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
825 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| 851 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
826 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
| 852 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
827 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
| 853 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
828 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
| - |
|
829 |
amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
|
| - |
|
830 |
amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
|
| - |
|
831 |
amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
|
| 854 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
832 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
| 855 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
833 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
| - |
|
834 |
amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
|
| - |
|
835 |
amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
|
| - |
|
836 |
amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
|
| 856 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
837 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
| 857 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
838 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
| - |
|
839 |
amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
|
| - |
|
840 |
amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
|
| - |
|
841 |
amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
|
| 858 |
amazonScrapingHistory.wanlc = val.nlc
|
842 |
amazonScrapingHistory.wanlc = val.nlc
|
| 859 |
amazonScrapingHistory.commission = spm.commission
|
843 |
amazonScrapingHistory.commission = spm.commission
|
| 860 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
844 |
amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
|
| 861 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
845 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
| 862 |
amazonScrapingHistory.courierCost = val.courierCost
|
846 |
amazonScrapingHistory.courierCost = val.courierCost
|
| Line 1482... |
Line 1466... |
| 1482 |
if options.runType not in ('FULL','FAVOURITE'):
|
1466 |
if options.runType not in ('FULL','FAVOURITE'):
|
| 1483 |
print "Run type argument illegal."
|
1467 |
print "Run type argument illegal."
|
| 1484 |
sys.exit(1)
|
1468 |
sys.exit(1)
|
| 1485 |
time.sleep(5)
|
1469 |
time.sleep(5)
|
| 1486 |
timestamp = datetime.now()
|
1470 |
timestamp = datetime.now()
|
| 1487 |
syncAsin()
|
- |
|
| 1488 |
fetchFbaSale()
|
1471 |
fetchFbaSale()
|
| 1489 |
itemInfo = populateStuff(timestamp,options.runType)
|
1472 |
itemInfo = populateStuff(timestamp,options.runType)
|
| 1490 |
itemsToPopulate = 0
|
1473 |
itemsToPopulate = 0
|
| - |
|
1474 |
toSync = 0
|
| 1491 |
print len(itemInfo)
|
1475 |
lenItems = len(itemInfo)
|
| - |
|
1476 |
while(toSync < lenItems):
|
| - |
|
1477 |
oldSync = toSync
|
| - |
|
1478 |
if lenItems >= 20:
|
| - |
|
1479 |
toSync = 20
|
| - |
|
1480 |
else:
|
| - |
|
1481 |
toSync = lenItems - oldSync
|
| - |
|
1482 |
getPriceAndAsin(itemInfo[oldSync:toSync+oldSync])
|
| - |
|
1483 |
toSync = oldSync + toSync
|
| - |
|
1484 |
|
| 1492 |
while (len(itemInfo)>0):
|
1485 |
while (len(itemInfo)>0):
|
| 1493 |
if len(itemInfo) > 50:
|
1486 |
if len(itemInfo) >= 20:
|
| 1494 |
itemsToPopulate = 50
|
1487 |
itemsToPopulate = 20
|
| 1495 |
else:
|
1488 |
else:
|
| 1496 |
itemsToPopulate = len(itemInfo)
|
1489 |
itemsToPopulate = len(itemInfo)
|
| 1497 |
print itemsToPopulate
|
1490 |
print itemsToPopulate
|
| 1498 |
exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete = decideCategory(itemInfo[0:itemsToPopulate])
|
1491 |
exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete = decideCategory(itemInfo[0:itemsToPopulate])
|
| 1499 |
itemInfo[0:itemsToPopulate] = []
|
1492 |
itemInfo[0:itemsToPopulate] = []
|