Subversion Repositories SmartDukaan

Rev

Rev 4394 | Rev 4581 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
104 ashish 1
'''
2
Created on 29-Mar-2010
3
 
4
@author: ashish
5
'''
6
 
7
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
3581 chandransh 8
    LineItem as T_LineItem, Order as T_Order, Alert as T_Alert, OrderStatus, DelayReason
104 ashish 9
from shop2020.utils.Utils import to_java_date
4394 rajveer 10
from shop2020.model.v1.order.impl.DataService import Alert, Transaction
104 ashish 11
 
12
def to_t_transaction(transaction):
13
    t_transaction = T_Transaction()
14
    t_transaction.id = transaction.id
483 rajveer 15
    t_transaction.createdOn = to_java_date(transaction.createdOn)
699 chandransh 16
    t_transaction.transactionStatus = transaction.status
483 rajveer 17
    t_transaction.statusDescription = transaction.status_message
18
    t_transaction.customer_id = transaction.customer_id
19
    t_transaction.shoppingCartid = transaction.shopping_cart_id
2219 varun.gupt 20
    t_transaction.coupon_code = transaction.coupon_code
2815 vikas 21
    t_transaction.sessionSource = transaction.session_source
22
    t_transaction.sessionStartTime = to_java_date(transaction.session_start_time)
3858 vikas 23
    t_transaction.firstSource = transaction.first_source
24
    t_transaction.firstSourceTime = to_java_date(transaction.first_source_start_time)
483 rajveer 25
    t_transaction.orders = []
26
    #populate orders
27
    for order in transaction.orders:
28
        t_order = to_t_order(order)
29
        t_transaction.orders.append(t_order)
30
    return t_transaction
31
 
32
def to_t_order(order):
33
    t_order = T_Order()
34
    t_order.id = order.id
35
    t_order.warehouse_id = order.warehouse_id
36
    t_order.logistics_provider_id = order.logistics_provider_id
37
    t_order.airwaybill_no = order.airwaybill_no
38
    t_order.tracking_id = order.tracking_id
39
    t_order.expected_delivery_time = to_java_date(order.expected_delivery_time)
3986 chandransh 40
    t_order.promised_delivery_time = to_java_date(order.promised_delivery_time)
4004 chandransh 41
    t_order.expected_shipping_time = to_java_date(order.expected_shipping_time)
4102 chandransh 42
    t_order.promised_shipping_time = to_java_date(order.promised_shipping_time)
483 rajveer 43
    t_order.customer_id = order.customer_id
44
    t_order.customer_name = order.customer_name
45
    t_order.customer_mobilenumber = order.customer_mobilenumber
46
    t_order.customer_pincode = order.customer_pincode
738 chandransh 47
    t_order.customer_address1 = order.customer_address1
48
    t_order.customer_address2 = order.customer_address2
669 chandransh 49
    t_order.customer_city = order.customer_city
50
    t_order.customer_state = order.customer_state
483 rajveer 51
    t_order.customer_email = order.customer_email    
699 chandransh 52
    t_order.status = order.status 
483 rajveer 53
    t_order.statusDescription = order.statusDescription
54
    t_order.total_amount = order.total_amount
55
    t_order.total_weight = order.total_weight
56
    t_order.created_timestamp = to_java_date(order.created_timestamp)
57
    t_order.invoice_number = order.invoice_number
58
    t_order.billed_by = order.billed_by
986 chandransh 59
    t_order.accepted_timestamp = to_java_date(order.accepted_timestamp)
60
    t_order.billing_timestamp = to_java_date(order.billing_timestamp)
61
    t_order.shipping_timestamp = to_java_date(order.shipping_timestamp)
62
    t_order.delivery_timestamp = to_java_date(order.delivery_timestamp)
1208 chandransh 63
    t_order.outofstock_timestamp = to_java_date(order.outofstock_timestamp)
4004 chandransh 64
    t_order.verification_timestamp = to_java_date(order.verification_timestamp)
642 chandransh 65
    t_order.jacket_number = order.jacket_number
1220 chandransh 66
    t_order.receiver = order.receiver
67
    t_order.batchNo = order.batchNo
68
    t_order.serialNo = order.serialNo
2536 chandransh 69
    t_order.doaFlag = order.doaFlag
70
    t_order.pickupRequestNo = order.pickupRequestNo
3064 chandransh 71
    t_order.cod = order.cod
3581 chandransh 72
    if order.delay_reason:
73
        t_order.delayReason = DelayReason._NAMES_TO_VALUES[order.delay_reason]
2676 vikas 74
    t_order.transactionId = order.transaction_id
483 rajveer 75
    t_order.lineitems = []
76
    for lineitem in order.lineitems:
77
        t_lineitem = to_t_lineitem(lineitem)
78
        t_order.lineitems.append(t_lineitem)
4192 anupam.sin 79
    if order.reship_timestamp:
80
        t_order.reship_timestamp = to_java_date(order.reship_timestamp)
81
    if order.refund_timestamp:
82
        t_order.refund_timestamp = to_java_date(order.refund_timestamp)
4506 phani.kuma 83
    if order.doa_auth_timestamp:
84
        t_order.doa_auth_timestamp = to_java_date(order.doa_auth_timestamp)
4192 anupam.sin 85
    if order.new_order_id:
86
        t_order.new_order_id = order.new_order_id
4247 rajveer 87
 
4269 anupam.sin 88
    t_order.previousStatus = order.previousStatus
89
    t_order.vendorId = order.vendorId
483 rajveer 90
    return t_order
91
 
92
def to_t_lineitem(lineitem):
93
    t_lineitem = T_LineItem()
94
    t_lineitem.id = lineitem.id
699 chandransh 95
    t_lineitem.item_id = lineitem.item_id
970 chandransh 96
    t_lineitem.productGroup = lineitem.productGroup
97
    t_lineitem.brand = lineitem.brand
98
    t_lineitem.model_number = lineitem.model_number
99
    t_lineitem.color = lineitem.color
100
    t_lineitem.model_name = lineitem.model_name
101
    t_lineitem.extra_info = lineitem.extra_info
483 rajveer 102
    t_lineitem.unit_weight = lineitem.unit_weight
103
    t_lineitem.unit_price = lineitem.unit_price
104
    t_lineitem.total_price = lineitem.total_price
996 varun.gupt 105
    t_lineitem.transfer_price = lineitem.transfer_price
483 rajveer 106
    t_lineitem.total_weight = lineitem.total_weight 
669 chandransh 107
    t_lineitem.quantity = lineitem.quantity
2783 chandransh 108
    t_lineitem.item_number = lineitem.item_number
109
    if lineitem.imei_number is not None:
110
        t_lineitem.imei_number = int(lineitem.imei_number)
4172 rajveer 111
    t_lineitem.dealText = lineitem.dealText
4295 varun.gupt 112
    t_lineitem.warrantry_expiry_timestamp = to_java_date(lineitem.warranty_expiry_timestamp)
113
 
483 rajveer 114
    return t_lineitem
115
 
116
def to_t_alert(alert):
117
    t_alert = T_Alert()
118
    t_alert.id = alert.id
4394 rajveer 119
    t_alert.description = alert.description
483 rajveer 120
    try:
4394 rajveer 121
        t_alert.timestamp = to_java_date(alert.timestamp)
483 rajveer 122
    except:
123
        pass
124
    t_alert.type = alert.type
4394 rajveer 125
    t_alert.status = alert.status
2783 chandransh 126
    return t_alert