| 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, \
|
| 7080 |
anupam.sin |
10 |
Attribute as T_Attribute, EmiScheme as T_EmiScheme, RechargeTransaction as T_rechargeTransaction, \
|
| 7096 |
anupam.sin |
11 |
FRC as T_FRC, HotspotStore as T_HotSpotStore
|
| 104 |
ashish |
12 |
from shop2020.utils.Utils import to_java_date
|
| 4394 |
rajveer |
13 |
from shop2020.model.v1.order.impl.DataService import Alert, Transaction
|
| 104 |
ashish |
14 |
|
|
|
15 |
def to_t_transaction(transaction):
|
|
|
16 |
t_transaction = T_Transaction()
|
|
|
17 |
t_transaction.id = transaction.id
|
| 483 |
rajveer |
18 |
t_transaction.createdOn = to_java_date(transaction.createdOn)
|
| 699 |
chandransh |
19 |
t_transaction.transactionStatus = transaction.status
|
| 483 |
rajveer |
20 |
t_transaction.statusDescription = transaction.status_message
|
|
|
21 |
t_transaction.customer_id = transaction.customer_id
|
|
|
22 |
t_transaction.shoppingCartid = transaction.shopping_cart_id
|
| 2219 |
varun.gupt |
23 |
t_transaction.coupon_code = transaction.coupon_code
|
| 2815 |
vikas |
24 |
t_transaction.sessionSource = transaction.session_source
|
|
|
25 |
t_transaction.sessionStartTime = to_java_date(transaction.session_start_time)
|
| 3858 |
vikas |
26 |
t_transaction.firstSource = transaction.first_source
|
|
|
27 |
t_transaction.firstSourceTime = to_java_date(transaction.first_source_start_time)
|
| 483 |
rajveer |
28 |
t_transaction.orders = []
|
|
|
29 |
#populate orders
|
|
|
30 |
for order in transaction.orders:
|
|
|
31 |
t_order = to_t_order(order)
|
|
|
32 |
t_transaction.orders.append(t_order)
|
|
|
33 |
return t_transaction
|
|
|
34 |
|
|
|
35 |
def to_t_order(order):
|
|
|
36 |
t_order = T_Order()
|
|
|
37 |
t_order.id = order.id
|
|
|
38 |
t_order.warehouse_id = order.warehouse_id
|
|
|
39 |
t_order.logistics_provider_id = order.logistics_provider_id
|
| 4815 |
phani.kuma |
40 |
if order.doa_logistics_provider_id is not None:
|
|
|
41 |
t_order.doa_logistics_provider_id = order.doa_logistics_provider_id
|
| 483 |
rajveer |
42 |
t_order.airwaybill_no = order.airwaybill_no
|
|
|
43 |
t_order.tracking_id = order.tracking_id
|
|
|
44 |
t_order.expected_delivery_time = to_java_date(order.expected_delivery_time)
|
| 3986 |
chandransh |
45 |
t_order.promised_delivery_time = to_java_date(order.promised_delivery_time)
|
| 4004 |
chandransh |
46 |
t_order.expected_shipping_time = to_java_date(order.expected_shipping_time)
|
| 4102 |
chandransh |
47 |
t_order.promised_shipping_time = to_java_date(order.promised_shipping_time)
|
| 6726 |
rajveer |
48 |
t_order.courier_delivery_time = to_java_date(order.courier_delivery_time)
|
| 483 |
rajveer |
49 |
t_order.customer_id = order.customer_id
|
|
|
50 |
t_order.customer_name = order.customer_name
|
|
|
51 |
t_order.customer_mobilenumber = order.customer_mobilenumber
|
|
|
52 |
t_order.customer_pincode = order.customer_pincode
|
| 738 |
chandransh |
53 |
t_order.customer_address1 = order.customer_address1
|
|
|
54 |
t_order.customer_address2 = order.customer_address2
|
| 669 |
chandransh |
55 |
t_order.customer_city = order.customer_city
|
|
|
56 |
t_order.customer_state = order.customer_state
|
| 483 |
rajveer |
57 |
t_order.customer_email = order.customer_email
|
| 699 |
chandransh |
58 |
t_order.status = order.status
|
| 483 |
rajveer |
59 |
t_order.statusDescription = order.statusDescription
|
|
|
60 |
t_order.total_amount = order.total_amount
|
| 6318 |
rajveer |
61 |
t_order.gvAmount = order.gvAmount
|
| 483 |
rajveer |
62 |
t_order.total_weight = order.total_weight
|
|
|
63 |
t_order.created_timestamp = to_java_date(order.created_timestamp)
|
|
|
64 |
t_order.invoice_number = order.invoice_number
|
|
|
65 |
t_order.billed_by = order.billed_by
|
| 986 |
chandransh |
66 |
t_order.accepted_timestamp = to_java_date(order.accepted_timestamp)
|
|
|
67 |
t_order.billing_timestamp = to_java_date(order.billing_timestamp)
|
|
|
68 |
t_order.shipping_timestamp = to_java_date(order.shipping_timestamp)
|
|
|
69 |
t_order.delivery_timestamp = to_java_date(order.delivery_timestamp)
|
| 1208 |
chandransh |
70 |
t_order.outofstock_timestamp = to_java_date(order.outofstock_timestamp)
|
| 4004 |
chandransh |
71 |
t_order.verification_timestamp = to_java_date(order.verification_timestamp)
|
| 642 |
chandransh |
72 |
t_order.jacket_number = order.jacket_number
|
| 1220 |
chandransh |
73 |
t_order.receiver = order.receiver
|
|
|
74 |
t_order.batchNo = order.batchNo
|
|
|
75 |
t_order.serialNo = order.serialNo
|
| 2536 |
chandransh |
76 |
t_order.doaFlag = order.doaFlag
|
|
|
77 |
t_order.pickupRequestNo = order.pickupRequestNo
|
| 3064 |
chandransh |
78 |
t_order.cod = order.cod
|
| 5062 |
varun.gupt |
79 |
t_order.originalOrderId = order.originalOrderId
|
| 3581 |
chandransh |
80 |
if order.delay_reason:
|
|
|
81 |
t_order.delayReason = DelayReason._NAMES_TO_VALUES[order.delay_reason]
|
| 4647 |
rajveer |
82 |
t_order.delayReasonText = order.delayReasonText
|
| 2676 |
vikas |
83 |
t_order.transactionId = order.transaction_id
|
| 483 |
rajveer |
84 |
t_order.lineitems = []
|
|
|
85 |
for lineitem in order.lineitems:
|
|
|
86 |
t_lineitem = to_t_lineitem(lineitem)
|
|
|
87 |
t_order.lineitems.append(t_lineitem)
|
| 4192 |
anupam.sin |
88 |
if order.reship_timestamp:
|
|
|
89 |
t_order.reship_timestamp = to_java_date(order.reship_timestamp)
|
|
|
90 |
if order.refund_timestamp:
|
|
|
91 |
t_order.refund_timestamp = to_java_date(order.refund_timestamp)
|
| 4506 |
phani.kuma |
92 |
if order.doa_auth_timestamp:
|
|
|
93 |
t_order.doa_auth_timestamp = to_java_date(order.doa_auth_timestamp)
|
| 4192 |
anupam.sin |
94 |
if order.new_order_id:
|
|
|
95 |
t_order.new_order_id = order.new_order_id
|
| 4581 |
phani.kuma |
96 |
t_order.pickup_timestamp = to_java_date(order.pickup_timestamp)
|
| 4269 |
anupam.sin |
97 |
t_order.previousStatus = order.previousStatus
|
|
|
98 |
t_order.vendorId = order.vendorId
|
| 4709 |
rajveer |
99 |
t_order.refundReason = order.refund_reason
|
| 5110 |
mandeep.dh |
100 |
t_order.fulfilmentWarehouseId = order.fulfilmentWarehouseId
|
| 5189 |
varun.gupt |
101 |
t_order.vendorPaid = order.vendor_paid
|
| 4758 |
mandeep.dh |
102 |
if order.purchase_order_id:
|
|
|
103 |
t_order.purchaseOrderId = order.purchase_order_id
|
| 5354 |
anupam.sin |
104 |
if order.received_return_timestamp:
|
|
|
105 |
t_order.received_return_timestamp = to_java_date(order.received_return_timestamp)
|
|
|
106 |
if order.first_dlvyatmp_timestamp:
|
|
|
107 |
t_order.first_attempt_timestamp = to_java_date(order.first_dlvyatmp_timestamp)
|
| 5527 |
anupam.sin |
108 |
t_order.orderType = order.orderType
|
| 5555 |
rajveer |
109 |
t_order.pickupStoreId = order.pickupStoreId
|
|
|
110 |
t_order.logisticsCod = not order.pickupStoreId and order.cod
|
| 6525 |
rajveer |
111 |
t_order.otg = order.otg
|
| 6903 |
anupam.sin |
112 |
t_order.insurer = order.insurer
|
|
|
113 |
t_order.insuranceAmount = order.insuranceAmount
|
| 483 |
rajveer |
114 |
return t_order
|
|
|
115 |
|
|
|
116 |
def to_t_lineitem(lineitem):
|
|
|
117 |
t_lineitem = T_LineItem()
|
|
|
118 |
t_lineitem.id = lineitem.id
|
| 699 |
chandransh |
119 |
t_lineitem.item_id = lineitem.item_id
|
| 970 |
chandransh |
120 |
t_lineitem.productGroup = lineitem.productGroup
|
|
|
121 |
t_lineitem.brand = lineitem.brand
|
|
|
122 |
t_lineitem.model_number = lineitem.model_number
|
|
|
123 |
t_lineitem.color = lineitem.color
|
|
|
124 |
t_lineitem.model_name = lineitem.model_name
|
|
|
125 |
t_lineitem.extra_info = lineitem.extra_info
|
| 483 |
rajveer |
126 |
t_lineitem.unit_weight = lineitem.unit_weight
|
|
|
127 |
t_lineitem.unit_price = lineitem.unit_price
|
|
|
128 |
t_lineitem.total_price = lineitem.total_price
|
| 996 |
varun.gupt |
129 |
t_lineitem.transfer_price = lineitem.transfer_price
|
| 483 |
rajveer |
130 |
t_lineitem.total_weight = lineitem.total_weight
|
| 669 |
chandransh |
131 |
t_lineitem.quantity = lineitem.quantity
|
| 2783 |
chandransh |
132 |
t_lineitem.item_number = lineitem.item_number
|
| 4658 |
mandeep.dh |
133 |
t_lineitem.serial_number = lineitem.serial_number
|
| 4172 |
rajveer |
134 |
t_lineitem.dealText = lineitem.dealText
|
| 4295 |
varun.gupt |
135 |
t_lineitem.warrantry_expiry_timestamp = to_java_date(lineitem.warranty_expiry_timestamp)
|
| 6039 |
amit.gupta |
136 |
t_lineitem.vatRate = lineitem.vatRate
|
| 4295 |
varun.gupt |
137 |
|
| 483 |
rajveer |
138 |
return t_lineitem
|
|
|
139 |
|
|
|
140 |
def to_t_alert(alert):
|
|
|
141 |
t_alert = T_Alert()
|
|
|
142 |
t_alert.id = alert.id
|
| 4394 |
rajveer |
143 |
t_alert.description = alert.description
|
| 483 |
rajveer |
144 |
try:
|
| 4394 |
rajveer |
145 |
t_alert.timestamp = to_java_date(alert.timestamp)
|
| 483 |
rajveer |
146 |
except:
|
|
|
147 |
pass
|
|
|
148 |
t_alert.type = alert.type
|
| 4394 |
rajveer |
149 |
t_alert.status = alert.status
|
| 2783 |
chandransh |
150 |
return t_alert
|
| 4600 |
varun.gupt |
151 |
|
|
|
152 |
def to_t_payment_settlement(payment_settlement):
|
|
|
153 |
t_payment_settlement = T_PaymentSettlement()
|
|
|
154 |
|
|
|
155 |
if payment_settlement:
|
| 4905 |
varun.gupt |
156 |
t_payment_settlement.referenceId = payment_settlement.referenceId
|
| 4600 |
varun.gupt |
157 |
t_payment_settlement.paymentGatewayId = payment_settlement.paymentGatewayId
|
|
|
158 |
t_payment_settlement.settlementDate = to_java_date(payment_settlement.settlementDate)
|
|
|
159 |
t_payment_settlement.serviceTax = payment_settlement.serviceTax
|
|
|
160 |
t_payment_settlement.otherCharges = payment_settlement.otherCharges
|
|
|
161 |
t_payment_settlement.netCollection = payment_settlement.netCollection
|
| 5447 |
anupam.sin |
162 |
return t_payment_settlement
|
|
|
163 |
|
|
|
164 |
def to_t_verification_agent(codVerificationAgent):
|
|
|
165 |
t_verification_agent = T_CODVerificationAgent()
|
|
|
166 |
|
|
|
167 |
if codVerificationAgent:
|
|
|
168 |
t_verification_agent.orderId = codVerificationAgent.orderId
|
|
|
169 |
t_verification_agent.agentEmailId = codVerificationAgent.verificationAgent
|
| 5527 |
anupam.sin |
170 |
return t_verification_agent
|
|
|
171 |
|
|
|
172 |
def to_t_attribute(attribute):
|
| 6396 |
amit.gupta |
173 |
t_attribute = T_Attribute()
|
| 5527 |
anupam.sin |
174 |
if attribute:
|
|
|
175 |
t_attribute.name = attribute.name
|
|
|
176 |
t_attribute.value = attribute.value
|
| 6396 |
amit.gupta |
177 |
return t_attribute
|
|
|
178 |
|
|
|
179 |
def to_t_emi_scheme(emi_scheme):
|
|
|
180 |
t_emi_scheme = T_EmiScheme()
|
|
|
181 |
if emi_scheme:
|
|
|
182 |
t_emi_scheme.id = emi_scheme.id
|
|
|
183 |
t_emi_scheme.bankId = emi_scheme.bankId
|
|
|
184 |
t_emi_scheme.bankName = emi_scheme.bankName
|
|
|
185 |
t_emi_scheme.gatewayId = emi_scheme.gatewayId
|
|
|
186 |
t_emi_scheme.tenure = emi_scheme.tenure
|
|
|
187 |
t_emi_scheme.tenureDescription = emi_scheme.tenureDescription
|
|
|
188 |
t_emi_scheme.minAmount = emi_scheme.minAmount
|
|
|
189 |
t_emi_scheme.chargeType = emi_scheme.chargeType
|
|
|
190 |
t_emi_scheme.chargeValue = emi_scheme.chargeValue
|
| 7073 |
anupam.sin |
191 |
return t_emi_scheme
|
|
|
192 |
|
|
|
193 |
def to_t_rechargeTransaction(rechargeTransaction):
|
|
|
194 |
t_recharge = T_rechargeTransaction()
|
|
|
195 |
if rechargeTransaction:
|
| 7080 |
anupam.sin |
196 |
t_recharge.id = rechargeTransaction.id
|
|
|
197 |
t_recharge.amount = rechargeTransaction.amount
|
| 7075 |
rajveer |
198 |
t_recharge.circleId = rechargeTransaction.circleId
|
|
|
199 |
t_recharge.operatorId = rechargeTransaction.operatorId
|
|
|
200 |
t_recharge.plan = rechargeTransaction.plan
|
| 7073 |
anupam.sin |
201 |
t_recharge.deviceNum = rechargeTransaction.deviceNum
|
|
|
202 |
t_recharge.deviceType = rechargeTransaction.deviceType
|
|
|
203 |
t_recharge.discount = rechargeTransaction.discount
|
|
|
204 |
t_recharge.email = rechargeTransaction.email
|
|
|
205 |
t_recharge.name = rechargeTransaction.name
|
|
|
206 |
t_recharge.cafNum = rechargeTransaction.cafNum
|
|
|
207 |
t_recharge.simNum = rechargeTransaction.simNum
|
|
|
208 |
t_recharge.isFrc = rechargeTransaction.isFrc
|
|
|
209 |
t_recharge.status = rechargeTransaction.status
|
|
|
210 |
t_recharge.storeId = rechargeTransaction.storeId
|
| 7080 |
anupam.sin |
211 |
t_recharge.alternateNum = rechargeTransaction.alternateNumber
|
|
|
212 |
t_recharge.transactionTime = to_java_date(rechargeTransaction.transactionTime)
|
| 7096 |
anupam.sin |
213 |
t_recharge.description = rechargeTransaction.description
|
| 7080 |
anupam.sin |
214 |
return t_recharge
|
|
|
215 |
|
|
|
216 |
def to_t_frc(frc):
|
|
|
217 |
t_frc = T_FRC()
|
|
|
218 |
if frc:
|
|
|
219 |
t_frc.id = frc.id
|
|
|
220 |
t_frc.operatorId =frc.operatorId
|
|
|
221 |
t_frc.circleId = frc.circleId
|
|
|
222 |
t_frc.denomination = frc.denomination
|
|
|
223 |
t_frc.maxDiscount = frc.maxDiscount
|
| 7096 |
anupam.sin |
224 |
return t_frc
|
|
|
225 |
|
|
|
226 |
def to_t_hotspot(hotspot):
|
|
|
227 |
t_hotspot = T_HotSpotStore();
|
|
|
228 |
if hotspot:
|
|
|
229 |
t_hotspot.id = hotspot.id
|
|
|
230 |
t_hotspot.hotspotId = hotspot.hotspotId
|
|
|
231 |
t_hotspot.companyId = hotspot.companyId
|
|
|
232 |
t_hotspot.name = hotspot.name
|
|
|
233 |
t_hotspot.city = hotspot.city
|
|
|
234 |
t_hotspot.collectedAmount = hotspot.collectedAmount
|
|
|
235 |
t_hotspot.availableLimit = hotspot.availableLimit
|
|
|
236 |
t_hotspot.creditLimit = hotspot.creditLimit
|
|
|
237 |
t_hotspot.salt = hotspot.salt
|
|
|
238 |
t_hotspot.password = hotspot.password
|
|
|
239 |
t_hotspot.isActive = hotspot.isActive
|
|
|
240 |
t_hotspot.circleId = hotspot.circleId
|
|
|
241 |
return t_hotspot
|