Subversion Repositories SmartDukaan

Rev

Rev 6039 | Rev 6396 | 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,\
4600 varun.gupt 8
    LineItem as T_LineItem, Order as T_Order, Alert as T_Alert, OrderStatus, DelayReason, \
5527 anupam.sin 9
    PaymentSettlement as T_PaymentSettlement, CODVerificationAgent as T_CODVerificationAgent, \
10
    Attribute as T_Attribute
104 ashish 11
from shop2020.utils.Utils import to_java_date
4394 rajveer 12
from shop2020.model.v1.order.impl.DataService import Alert, Transaction
104 ashish 13
 
14
def to_t_transaction(transaction):
15
    t_transaction = T_Transaction()
16
    t_transaction.id = transaction.id
483 rajveer 17
    t_transaction.createdOn = to_java_date(transaction.createdOn)
699 chandransh 18
    t_transaction.transactionStatus = transaction.status
483 rajveer 19
    t_transaction.statusDescription = transaction.status_message
20
    t_transaction.customer_id = transaction.customer_id
21
    t_transaction.shoppingCartid = transaction.shopping_cart_id
2219 varun.gupt 22
    t_transaction.coupon_code = transaction.coupon_code
2815 vikas 23
    t_transaction.sessionSource = transaction.session_source
24
    t_transaction.sessionStartTime = to_java_date(transaction.session_start_time)
3858 vikas 25
    t_transaction.firstSource = transaction.first_source
26
    t_transaction.firstSourceTime = to_java_date(transaction.first_source_start_time)
483 rajveer 27
    t_transaction.orders = []
28
    #populate orders
29
    for order in transaction.orders:
30
        t_order = to_t_order(order)
31
        t_transaction.orders.append(t_order)
32
    return t_transaction
33
 
34
def to_t_order(order):
35
    t_order = T_Order()
36
    t_order.id = order.id
37
    t_order.warehouse_id = order.warehouse_id
38
    t_order.logistics_provider_id = order.logistics_provider_id
4815 phani.kuma 39
    if order.doa_logistics_provider_id is not None:
40
        t_order.doa_logistics_provider_id = order.doa_logistics_provider_id
483 rajveer 41
    t_order.airwaybill_no = order.airwaybill_no
42
    t_order.tracking_id = order.tracking_id
43
    t_order.expected_delivery_time = to_java_date(order.expected_delivery_time)
3986 chandransh 44
    t_order.promised_delivery_time = to_java_date(order.promised_delivery_time)
4004 chandransh 45
    t_order.expected_shipping_time = to_java_date(order.expected_shipping_time)
4102 chandransh 46
    t_order.promised_shipping_time = to_java_date(order.promised_shipping_time)
483 rajveer 47
    t_order.customer_id = order.customer_id
48
    t_order.customer_name = order.customer_name
49
    t_order.customer_mobilenumber = order.customer_mobilenumber
50
    t_order.customer_pincode = order.customer_pincode
738 chandransh 51
    t_order.customer_address1 = order.customer_address1
52
    t_order.customer_address2 = order.customer_address2
669 chandransh 53
    t_order.customer_city = order.customer_city
54
    t_order.customer_state = order.customer_state
483 rajveer 55
    t_order.customer_email = order.customer_email    
699 chandransh 56
    t_order.status = order.status 
483 rajveer 57
    t_order.statusDescription = order.statusDescription
58
    t_order.total_amount = order.total_amount
6318 rajveer 59
    t_order.gvAmount = order.gvAmount
483 rajveer 60
    t_order.total_weight = order.total_weight
61
    t_order.created_timestamp = to_java_date(order.created_timestamp)
62
    t_order.invoice_number = order.invoice_number
63
    t_order.billed_by = order.billed_by
986 chandransh 64
    t_order.accepted_timestamp = to_java_date(order.accepted_timestamp)
65
    t_order.billing_timestamp = to_java_date(order.billing_timestamp)
66
    t_order.shipping_timestamp = to_java_date(order.shipping_timestamp)
67
    t_order.delivery_timestamp = to_java_date(order.delivery_timestamp)
1208 chandransh 68
    t_order.outofstock_timestamp = to_java_date(order.outofstock_timestamp)
4004 chandransh 69
    t_order.verification_timestamp = to_java_date(order.verification_timestamp)
642 chandransh 70
    t_order.jacket_number = order.jacket_number
1220 chandransh 71
    t_order.receiver = order.receiver
72
    t_order.batchNo = order.batchNo
73
    t_order.serialNo = order.serialNo
2536 chandransh 74
    t_order.doaFlag = order.doaFlag
75
    t_order.pickupRequestNo = order.pickupRequestNo
3064 chandransh 76
    t_order.cod = order.cod
5062 varun.gupt 77
    t_order.originalOrderId = order.originalOrderId
3581 chandransh 78
    if order.delay_reason:
79
        t_order.delayReason = DelayReason._NAMES_TO_VALUES[order.delay_reason]
4647 rajveer 80
    t_order.delayReasonText = order.delayReasonText
2676 vikas 81
    t_order.transactionId = order.transaction_id
483 rajveer 82
    t_order.lineitems = []
83
    for lineitem in order.lineitems:
84
        t_lineitem = to_t_lineitem(lineitem)
85
        t_order.lineitems.append(t_lineitem)
4192 anupam.sin 86
    if order.reship_timestamp:
87
        t_order.reship_timestamp = to_java_date(order.reship_timestamp)
88
    if order.refund_timestamp:
89
        t_order.refund_timestamp = to_java_date(order.refund_timestamp)
4506 phani.kuma 90
    if order.doa_auth_timestamp:
91
        t_order.doa_auth_timestamp = to_java_date(order.doa_auth_timestamp)
4192 anupam.sin 92
    if order.new_order_id:
93
        t_order.new_order_id = order.new_order_id
4581 phani.kuma 94
    t_order.pickup_timestamp = to_java_date(order.pickup_timestamp)
4269 anupam.sin 95
    t_order.previousStatus = order.previousStatus
96
    t_order.vendorId = order.vendorId
4709 rajveer 97
    t_order.refundReason = order.refund_reason
5110 mandeep.dh 98
    t_order.fulfilmentWarehouseId = order.fulfilmentWarehouseId
5189 varun.gupt 99
    t_order.vendorPaid = order.vendor_paid
4758 mandeep.dh 100
    if order.purchase_order_id:
101
        t_order.purchaseOrderId = order.purchase_order_id
5354 anupam.sin 102
    if order.received_return_timestamp:
103
        t_order.received_return_timestamp = to_java_date(order.received_return_timestamp)
104
    if order.first_dlvyatmp_timestamp:
105
        t_order.first_attempt_timestamp = to_java_date(order.first_dlvyatmp_timestamp)
5527 anupam.sin 106
    t_order.orderType = order.orderType
5555 rajveer 107
    t_order.pickupStoreId = order.pickupStoreId
108
    t_order.logisticsCod = not order.pickupStoreId and order.cod
483 rajveer 109
    return t_order
110
 
111
def to_t_lineitem(lineitem):
112
    t_lineitem = T_LineItem()
113
    t_lineitem.id = lineitem.id
699 chandransh 114
    t_lineitem.item_id = lineitem.item_id
970 chandransh 115
    t_lineitem.productGroup = lineitem.productGroup
116
    t_lineitem.brand = lineitem.brand
117
    t_lineitem.model_number = lineitem.model_number
118
    t_lineitem.color = lineitem.color
119
    t_lineitem.model_name = lineitem.model_name
120
    t_lineitem.extra_info = lineitem.extra_info
483 rajveer 121
    t_lineitem.unit_weight = lineitem.unit_weight
122
    t_lineitem.unit_price = lineitem.unit_price
123
    t_lineitem.total_price = lineitem.total_price
996 varun.gupt 124
    t_lineitem.transfer_price = lineitem.transfer_price
483 rajveer 125
    t_lineitem.total_weight = lineitem.total_weight 
669 chandransh 126
    t_lineitem.quantity = lineitem.quantity
2783 chandransh 127
    t_lineitem.item_number = lineitem.item_number
4658 mandeep.dh 128
    t_lineitem.serial_number = lineitem.serial_number
4172 rajveer 129
    t_lineitem.dealText = lineitem.dealText
4295 varun.gupt 130
    t_lineitem.warrantry_expiry_timestamp = to_java_date(lineitem.warranty_expiry_timestamp)
6039 amit.gupta 131
    t_lineitem.vatRate = lineitem.vatRate
4295 varun.gupt 132
 
483 rajveer 133
    return t_lineitem
134
 
135
def to_t_alert(alert):
136
    t_alert = T_Alert()
137
    t_alert.id = alert.id
4394 rajveer 138
    t_alert.description = alert.description
483 rajveer 139
    try:
4394 rajveer 140
        t_alert.timestamp = to_java_date(alert.timestamp)
483 rajveer 141
    except:
142
        pass
143
    t_alert.type = alert.type
4394 rajveer 144
    t_alert.status = alert.status
2783 chandransh 145
    return t_alert
4600 varun.gupt 146
 
147
def to_t_payment_settlement(payment_settlement):
148
    t_payment_settlement = T_PaymentSettlement()
149
 
150
    if payment_settlement:
4905 varun.gupt 151
        t_payment_settlement.referenceId = payment_settlement.referenceId
4600 varun.gupt 152
        t_payment_settlement.paymentGatewayId = payment_settlement.paymentGatewayId
153
        t_payment_settlement.settlementDate = to_java_date(payment_settlement.settlementDate)
154
        t_payment_settlement.serviceTax = payment_settlement.serviceTax
155
        t_payment_settlement.otherCharges = payment_settlement.otherCharges
156
        t_payment_settlement.netCollection = payment_settlement.netCollection
5447 anupam.sin 157
    return t_payment_settlement
158
 
159
def to_t_verification_agent(codVerificationAgent):
160
    t_verification_agent = T_CODVerificationAgent()
161
 
162
    if codVerificationAgent:
163
        t_verification_agent.orderId = codVerificationAgent.orderId
164
        t_verification_agent.agentEmailId = codVerificationAgent.verificationAgent
5527 anupam.sin 165
    return t_verification_agent    
166
 
167
def to_t_attribute(attribute):
168
    t_attribute = T_Attribute()
169
 
170
    if attribute:
171
        t_attribute.name = attribute.name
172
        t_attribute.value = attribute.value
173
    return t_attribute