| Line 3... |
Line 3... |
| 3 |
|
3 |
|
| 4 |
@author: ashish
|
4 |
@author: ashish
|
| 5 |
'''
|
5 |
'''
|
| 6 |
|
6 |
|
| 7 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
7 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
| 8 |
LineItem as T_LineItem, Order as T_Order, Alert as T_Alert
|
8 |
LineItem as T_LineItem, Order as T_Order, Alert as T_Alert, OrderStatus
|
| 9 |
from shop2020.utils.Utils import to_java_date
|
9 |
from shop2020.utils.Utils import to_java_date
|
| 10 |
from shop2020.utils import OrderStatus
|
- |
|
| 11 |
from shop2020.model.v1.order.impl.DataService import Alerts
|
10 |
from shop2020.model.v1.order.impl.DataService import Alerts
|
| 12 |
|
11 |
|
| 13 |
from shop2020.utils.OrderStatus import get_t_status
|
12 |
from shop2020.utils.OrderStatus import get_t_status
|
| 14 |
|
13 |
|
| 15 |
def to_t_transaction(transaction):
|
14 |
def to_t_transaction(transaction):
|
| 16 |
t_transaction = T_Transaction()
|
15 |
t_transaction = T_Transaction()
|
| 17 |
t_transaction.id = transaction.id
|
16 |
t_transaction.id = transaction.id
|
| 18 |
t_transaction.createdOn = to_java_date(transaction.createdOn)
|
17 |
t_transaction.createdOn = to_java_date(transaction.createdOn)
|
| 19 |
t_transaction.transactionStatus = OrderStatus.get_t_status(transaction.status)
|
18 |
t_transaction.transactionStatus = transaction.status
|
| 20 |
t_transaction.statusDescription = transaction.status_message
|
19 |
t_transaction.statusDescription = transaction.status_message
|
| 21 |
t_transaction.customer_id = transaction.customer_id
|
20 |
t_transaction.customer_id = transaction.customer_id
|
| 22 |
t_transaction.shoppingCartid = transaction.shopping_cart_id
|
21 |
t_transaction.shoppingCartid = transaction.shopping_cart_id
|
| 23 |
t_transaction.orders = []
|
22 |
t_transaction.orders = []
|
| 24 |
#populate orders
|
23 |
#populate orders
|
| 25 |
for order in transaction.orders:
|
24 |
for order in transaction.orders:
|
| 26 |
t_order = to_t_order(order)
|
25 |
t_order = to_t_order(order)
|
| 27 |
t_transaction.orders.append(t_order)
|
26 |
t_transaction.orders.append(t_order)
|
| 28 |
|
- |
|
| 29 |
return t_transaction
|
27 |
return t_transaction
|
| 30 |
|
28 |
|
| 31 |
def to_t_order(order):
|
29 |
def to_t_order(order):
|
| 32 |
t_order = T_Order()
|
30 |
t_order = T_Order()
|
| 33 |
t_order.id = order.id
|
31 |
t_order.id = order.id
|
| Line 42... |
Line 40... |
| 42 |
t_order.customer_pincode = order.customer_pincode
|
40 |
t_order.customer_pincode = order.customer_pincode
|
| 43 |
t_order.customer_address = order.customer_address
|
41 |
t_order.customer_address = order.customer_address
|
| 44 |
t_order.customer_city = order.customer_city
|
42 |
t_order.customer_city = order.customer_city
|
| 45 |
t_order.customer_state = order.customer_state
|
43 |
t_order.customer_state = order.customer_state
|
| 46 |
t_order.customer_email = order.customer_email
|
44 |
t_order.customer_email = order.customer_email
|
| 47 |
t_order.status = OrderStatus.get_t_status(order.status)
|
45 |
t_order.status = order.status
|
| 48 |
t_order.statusDescription = order.statusDescription
|
46 |
t_order.statusDescription = order.statusDescription
|
| 49 |
t_order.total_amount = order.total_amount
|
47 |
t_order.total_amount = order.total_amount
|
| 50 |
t_order.total_weight = order.total_weight
|
48 |
t_order.total_weight = order.total_weight
|
| 51 |
t_order.created_timestamp = to_java_date(order.created_timestamp)
|
49 |
t_order.created_timestamp = to_java_date(order.created_timestamp)
|
| 52 |
t_order.invoice_number = order.invoice_number
|
50 |
t_order.invoice_number = order.invoice_number
|
| Line 64... |
Line 62... |
| 64 |
return t_order
|
62 |
return t_order
|
| 65 |
|
63 |
|
| 66 |
def to_t_lineitem(lineitem):
|
64 |
def to_t_lineitem(lineitem):
|
| 67 |
t_lineitem = T_LineItem()
|
65 |
t_lineitem = T_LineItem()
|
| 68 |
t_lineitem.id = lineitem.id
|
66 |
t_lineitem.id = lineitem.id
|
| 69 |
t_lineitem.sku_id = lineitem.sku_id
|
67 |
t_lineitem.item_id = lineitem.item_id
|
| 70 |
t_lineitem.unit_weight = lineitem.unit_weight
|
68 |
t_lineitem.unit_weight = lineitem.unit_weight
|
| 71 |
t_lineitem.unit_price = lineitem.unit_price
|
69 |
t_lineitem.unit_price = lineitem.unit_price
|
| 72 |
t_lineitem.total_price = lineitem.total_price
|
70 |
t_lineitem.total_price = lineitem.total_price
|
| 73 |
t_lineitem.total_weight = lineitem.total_weight
|
71 |
t_lineitem.total_weight = lineitem.total_weight
|
| 74 |
t_lineitem.quantity = lineitem.quantity
|
72 |
t_lineitem.quantity = lineitem.quantity
|