| Line 265... |
Line 265... |
| 265 |
cashbackStatus = Store.CB_PENDING
|
265 |
cashbackStatus = Store.CB_PENDING
|
| 266 |
subOrder.cashBackStatus = cashbackStatus
|
266 |
subOrder.cashBackStatus = cashbackStatus
|
| 267 |
subOrder.cashBackAmount = cashbackAmount
|
267 |
subOrder.cashBackAmount = cashbackAmount
|
| 268 |
subOrder.cashBackPercentage = percentage
|
268 |
subOrder.cashBackPercentage = percentage
|
| 269 |
return subOrders
|
269 |
return subOrders
|
| - |
|
270 |
|
| - |
|
271 |
def _parseSingleOrderUsingJsonWithoutItems(self, orderId, userId, subTagId, orderObj, orderSuccessUrl):
|
| - |
|
272 |
|
| - |
|
273 |
subOrders=[]
|
| - |
|
274 |
|
| - |
|
275 |
ordertotal = long(float(orderObj['0']['total']))
|
| - |
|
276 |
ordershippingcost = long(float(orderObj['0']['shipping_cost']))
|
| - |
|
277 |
subtotal = ordertotal-ordershippingcost
|
| - |
|
278 |
placedOn = str(orderObj['0']['last_update'])
|
| - |
|
279 |
totalDiscount = long(float(orderObj['0']['discount']))
|
| - |
|
280 |
totalOrdersAmount = (ordertotal + totalDiscount) - ordershippingcost
|
| - |
|
281 |
merchantOrderId = orderObj['0']['order_id']
|
| - |
|
282 |
promotionid = orderObj['0']['promotion_ids']
|
| - |
|
283 |
promotionObj = orderObj['0']['promotions'][promotionid]
|
| - |
|
284 |
productCode = str(promotionObj['bonuses'][0]['value'])
|
| - |
|
285 |
skuData = Mongo.getItemByMerchantIdentifier(productCode, 5)
|
| - |
|
286 |
|
| - |
|
287 |
merchantOrder = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl)
|
| - |
|
288 |
merchantOrder.placedOn = placedOn
|
| - |
|
289 |
merchantOrder.merchantOrderId = str(merchantOrderId)
|
| - |
|
290 |
merchantOrder.paidAmount = ordertotal
|
| - |
|
291 |
|
| - |
|
292 |
|
| - |
|
293 |
if len(skuData)>0:
|
| - |
|
294 |
productUrl = BASE_MURL + str(urlparse(skuData.get('marketPlaceUrl')).path)
|
| - |
|
295 |
subOrder = SubOrder(skuData.get('product_name'), productUrl, placedOn, subtotal)
|
| - |
|
296 |
subOrder.merchantSubOrderId = str(merchantOrderId)+'-1'
|
| - |
|
297 |
subOrder.detailedStatus = Store.OrderStatusConfirmationMap.get(str(orderObj['0']['status']))
|
| - |
|
298 |
subOrder.imgUrl = skuData.get('thumbnail')
|
| - |
|
299 |
subOrder.offerDiscount = totalDiscount
|
| - |
|
300 |
subOrder.unitPrice = totalOrdersAmount
|
| - |
|
301 |
subOrder.productCode = productCode
|
| - |
|
302 |
subOrder.amountPaid = subtotal
|
| - |
|
303 |
subOrder.quantity = 1
|
| - |
|
304 |
subOrder.tracingkUrl = ORDER_TRACK_URL_DB + 'order_id=' +str(merchantOrderId)+'&email_id='+ str(orderObj['0']['email'])
|
| - |
|
305 |
dealRank = getDealRank(subOrder.productCode, self.store_id, merchantOrder.userId)
|
| - |
|
306 |
subOrder.dealRank = dealRank.get('rank')
|
| - |
|
307 |
subOrder.rankDesc = dealRank.get('description')
|
| - |
|
308 |
subOrders.append(subOrder)
|
| - |
|
309 |
else:
|
| - |
|
310 |
productSearch = fetchResponseUsingProxy(BASE_MURL+'/search?q='+productCode.strip())
|
| - |
|
311 |
productSearchResultPage = BeautifulSoup(productSearch)
|
| - |
|
312 |
productUrl = str(productSearchResultPage.find('a', {'class':'pd-list'})['href'])
|
| - |
|
313 |
style = productSearchResultPage.find('div', {'class':'pd-image'})['style']
|
| - |
|
314 |
imageurl = str(re.findall('url\(\"(.*?)\"\)', style)[0])
|
| - |
|
315 |
productName = str(productSearchResultPage.find('div', {'class':'pdt-name'}).text)
|
| - |
|
316 |
subOrder = SubOrder(productName, productUrl, placedOn, subtotal)
|
| - |
|
317 |
subOrder.merchantSubOrderId = str(merchantOrderId)+'-1'
|
| - |
|
318 |
subOrder.detailedStatus = Store.OrderStatusConfirmationMap.get(str(orderObj['0']['status']))
|
| - |
|
319 |
subOrder.imgUrl = imageurl
|
| - |
|
320 |
subOrder.offerDiscount = totalDiscount
|
| - |
|
321 |
subOrder.unitPrice = totalOrdersAmount
|
| - |
|
322 |
subOrder.productCode = productCode
|
| - |
|
323 |
subOrder.amountPaid = subtotal
|
| - |
|
324 |
subOrder.quantity = 1
|
| - |
|
325 |
subOrder.tracingkUrl = ORDER_TRACK_URL_DB + 'order_id=' +str(merchantOrderId)+'&email_id='+ str(orderObj['0']['email'])
|
| - |
|
326 |
dealRank = getDealRank(subOrder.productCode, self.store_id, merchantOrder.userId)
|
| - |
|
327 |
subOrder.dealRank = 0
|
| - |
|
328 |
subOrder.rankDesc = 'Not Applicable'
|
| - |
|
329 |
subOrders.append(subOrder)
|
| - |
|
330 |
|
| - |
|
331 |
merchantOrder.totalAmount = totalOrdersAmount
|
| - |
|
332 |
merchantOrder.discountApplied = totalDiscount
|
| - |
|
333 |
merchantOrder.deliveryCharges = ordershippingcost
|
| - |
|
334 |
merchantOrder.subOrders = self.updateCashbackInSubOrders(subOrders)
|
| - |
|
335 |
|
| - |
|
336 |
return merchantOrder
|
| - |
|
337 |
|
| - |
|
338 |
def _parseMultiOrderUsingJsonWithoutItems(self, orderId, userId, subTagId, orderObj, orderSuccessUrl):
|
| - |
|
339 |
pass
|
| - |
|
340 |
'''
|
| - |
|
341 |
subOrders=[]
|
| - |
|
342 |
|
| - |
|
343 |
ordertotal = long(float(orderObj['0']['total']))
|
| - |
|
344 |
ordershippingcost = long(float(orderObj['0']['shipping_cost']))
|
| - |
|
345 |
subtotal = ordertotal-ordershippingcost
|
| - |
|
346 |
placedOn = str(orderObj['0']['last_update'])
|
| - |
|
347 |
totalDiscount = long(float(orderObj['0']['discount']))
|
| - |
|
348 |
totalOrdersAmount = (ordertotal + totalDiscount) - ordershippingcost
|
| - |
|
349 |
merchantOrderId = orderObj['0']['order_id']
|
| - |
|
350 |
promotionids = orderObj['0']['promotion_ids'].split(',')
|
| - |
|
351 |
promotions = orderObj['0']['promotions']
|
| - |
|
352 |
|
| - |
|
353 |
merchantOrder = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl)
|
| - |
|
354 |
merchantOrder.placedOn = placedOn
|
| - |
|
355 |
merchantOrder.merchantOrderId = str(merchantOrderId)
|
| - |
|
356 |
merchantOrder.paidAmount = ordertotal
|
| - |
|
357 |
|
| - |
|
358 |
|
| - |
|
359 |
for promotionId in promotionids:
|
| - |
|
360 |
promotion = promotions[promotionId]
|
| - |
|
361 |
productCode = str(promotion['bonuses'][0]['value'])
|
| - |
|
362 |
skuData = Mongo.getItemByMerchantIdentifier(productCode, 5)
|
| - |
|
363 |
|
| - |
|
364 |
|
| - |
|
365 |
return None
|
| - |
|
366 |
'''
|
| 270 |
|
367 |
|
| 271 |
def _parseOrders(self, orderId, mpOrderId, subTagId, userId, page, orderSuccessUrl, orderObj):
|
368 |
def _parseOrders(self, orderId, mpOrderId, subTagId, userId, page, orderSuccessUrl, orderObj):
|
| 272 |
soup = BeautifulSoup(page)
|
369 |
soup = BeautifulSoup(page)
|
| 273 |
productDetailsMap = {}
|
370 |
productDetailsMap = {}
|
| 274 |
paymentFields = soup.findAll(attrs={'class' : 'box_paymentcalculations_row'})
|
371 |
paymentFields = soup.findAll(attrs={'class' : 'box_paymentcalculations_row'})
|
| Line 416... |
Line 513... |
| 416 |
print br1.geturl()
|
513 |
print br1.geturl()
|
| 417 |
|
514 |
|
| 418 |
br = getBrowserObject()
|
515 |
br = getBrowserObject()
|
| 419 |
url = ORDER_TRACK_URL +'&order_id=' +str(merchantOrderId)+'&email_id='+ emailId
|
516 |
url = ORDER_TRACK_URL +'&order_id=' +str(merchantOrderId)+'&email_id='+ emailId
|
| 420 |
page = br.open(url)
|
517 |
page = br.open(url)
|
| - |
|
518 |
if "trackorder" in br.geturl():
|
| - |
|
519 |
if type(orderObj['0']['items']) is list:
|
| - |
|
520 |
if len(orderObj['0']['promotions'])==1:
|
| - |
|
521 |
merchantOrder = self._parseSingleOrderUsingJsonWithoutItems(orderId, userId, subTagId, orderObj, orderSuccessUrl)
|
| - |
|
522 |
merchantOrder.orderTrackingUrl = ORDER_TRACK_URL_DB + 'order_id=' +str(merchantOrderId)+'&email_id='+ emailId
|
| - |
|
523 |
if self._saveToOrder(todict(merchantOrder)):
|
| - |
|
524 |
resp['result'] = 'ORDER_CREATED'
|
| - |
|
525 |
else:
|
| - |
|
526 |
resp['result'] = 'ORDER_ALREADY_CREATED_IGNORED'
|
| - |
|
527 |
return resp
|
| - |
|
528 |
'''
|
| - |
|
529 |
else:
|
| - |
|
530 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
| - |
|
531 |
return resp
|
| - |
|
532 |
|
| - |
|
533 |
elif len(orderObj['0']['promotions'])>1:
|
| - |
|
534 |
merchantOrder = self._parseMultiOrderUsingJsonWithoutItems(orderId, userId, subTagId, orderObj, orderSuccessUrl)
|
| - |
|
535 |
'''
|
| - |
|
536 |
|
| 421 |
headers = str(page.info()).split('\n')
|
537 |
headers = str(page.info()).split('\n')
|
| 422 |
page = ungzipResponse(page)
|
538 |
page = ungzipResponse(page)
|
| 423 |
jsonResponse = None
|
539 |
jsonResponse = None
|
| 424 |
for header in headers:
|
540 |
for header in headers:
|
| 425 |
header = header.split(':')
|
541 |
header = header.split(':')
|