| Line 8... |
Line 8... |
| 8 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
8 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 9 |
from shop2020.clients.PromotionClient import PromotionClient
|
9 |
from shop2020.clients.PromotionClient import PromotionClient
|
| 10 |
from shop2020.clients.TransactionClient import TransactionClient
|
10 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 11 |
from shop2020.model.v1 import user
|
11 |
from shop2020.model.v1 import user
|
| 12 |
from shop2020.model.v1.user.impl.Dataservice import Cart, Line, Address, User, \
|
12 |
from shop2020.model.v1.user.impl.Dataservice import Cart, Line, Address, User, \
|
| 13 |
Discount, InsuranceDetails
|
13 |
Discount, InsuranceDetails, PrivateDealUser
|
| 14 |
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException, \
|
14 |
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException, \
|
| 15 |
DeliveryType
|
15 |
DeliveryType
|
| 16 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, InsurerType
|
16 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, InsurerType
|
| 17 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as TTransaction, \
|
17 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as TTransaction, \
|
| 18 |
TransactionStatus as TTransactionStatus, Order as TOrder, LineItem as TLineItem, \
|
18 |
TransactionStatus as TTransactionStatus, Order as TOrder, LineItem as TLineItem, \
|
| Line 211... |
Line 211... |
| 211 |
line.dealText = t_line.dealText
|
211 |
line.dealText = t_line.dealText
|
| 212 |
line.freebieId = t_line.freebieId
|
212 |
line.freebieId = t_line.freebieId
|
| 213 |
|
213 |
|
| 214 |
cart.total_price = t_cart.totalPrice
|
214 |
cart.total_price = t_cart.totalPrice
|
| 215 |
cart.discounted_price = t_cart.discountedPrice
|
215 |
cart.discounted_price = t_cart.discountedPrice
|
| 216 |
cart.coupon_code = coupon_code
|
- |
|
| 217 |
session.commit()
|
216 |
session.commit()
|
| 218 |
|
217 |
|
| 219 |
def remove_coupon(cart_id):
|
218 |
def remove_coupon(cart_id):
|
| 220 |
cart = get_cart_by_id(cart_id)
|
219 |
cart = get_cart_by_id(cart_id)
|
| 221 |
if not cart:
|
220 |
if not cart:
|
| Line 382... |
Line 381... |
| 382 |
|
381 |
|
| 383 |
t_line_item.warrantry_expiry_timestamp = to_java_date(expiry_date)
|
382 |
t_line_item.warrantry_expiry_timestamp = to_java_date(expiry_date)
|
| 384 |
|
383 |
|
| 385 |
return t_line_item
|
384 |
return t_line_item
|
| 386 |
|
385 |
|
| 387 |
def validate_cart(cartId, sourceId):
|
386 |
def validate_cart(cartId, sourceId, couponCode):
|
| 388 |
inventory_client = CatalogClient().get_client()
|
387 |
inventory_client = CatalogClient().get_client()
|
| 389 |
logistics_client = LogisticsClient().get_client()
|
388 |
logistics_client = LogisticsClient().get_client()
|
| 390 |
promotion_client = PromotionClient().get_client()
|
389 |
promotion_client = PromotionClient().get_client()
|
| 391 |
retval = ""
|
390 |
retval = ""
|
| 392 |
emival = ""
|
391 |
emival = ""
|
| Line 401... |
Line 400... |
| 401 |
store = logistics_client.getPickupStore(cart.pickupStoreId)
|
400 |
store = logistics_client.getPickupStore(cart.pickupStoreId)
|
| 402 |
customer_pincode = store.pin
|
401 |
customer_pincode = store.pin
|
| 403 |
if cart.address_id != None and customer_pincode == None:
|
402 |
if cart.address_id != None and customer_pincode == None:
|
| 404 |
address = Address.get_by(id=cart.address_id)
|
403 |
address = Address.get_by(id=cart.address_id)
|
| 405 |
customer_pincode = address.pin
|
404 |
customer_pincode = address.pin
|
| - |
|
405 |
if couponCode and not cart.coupon_code:
|
| - |
|
406 |
cart.coupon_code = couponCode
|
| 406 |
if not customer_pincode:
|
407 |
if not customer_pincode:
|
| 407 |
user = User.get_by(active_cart_id = cartId)
|
408 |
user = User.get_by(active_cart_id = cartId)
|
| 408 |
default_address_id = user.default_address_id
|
409 |
default_address_id = user.default_address_id
|
| 409 |
if default_address_id:
|
410 |
if default_address_id:
|
| 410 |
address = Address.get_by(id = default_address_id)
|
411 |
address = Address.get_by(id = default_address_id)
|
| Line 662... |
Line 663... |
| 662 |
except:
|
663 |
except:
|
| 663 |
print("Error : Unable to get insurance details for addressId : " + str(addressId))
|
664 |
print("Error : Unable to get insurance details for addressId : " + str(addressId))
|
| 664 |
return False
|
665 |
return False
|
| 665 |
return True
|
666 |
return True
|
| 666 |
|
667 |
|
| 667 |
def validate_cart_plus(cart_id, source_id):
|
668 |
def validate_cart_plus(cart_id, source_id, couponCode):
|
| 668 |
try:
|
669 |
try:
|
| 669 |
cart_messages = validate_cart(cart_id, source_id)
|
670 |
cart_messages = validate_cart(cart_id, source_id, couponCode)
|
| 670 |
found_cart = Cart.get_by(id=cart_id)
|
671 |
found_cart = Cart.get_by(id=cart_id)
|
| 671 |
pincode = "110001"
|
672 |
pincode = "110001"
|
| 672 |
default_address_id = User.get_by(active_cart_id = cart_id).default_address_id
|
673 |
default_address_id = User.get_by(active_cart_id = cart_id).default_address_id
|
| 673 |
|
674 |
|
| 674 |
default_address = None
|
675 |
default_address = None
|