| 442 |
rajveer |
1 |
from shop2020.thriftpy.logistics.ttypes import Provider as TProvider,\
|
|
|
2 |
ShipmentUpdate as TShipmentUpdate, ShipmentStatusInfo as TShipmentStatusInfo,\
|
| 472 |
rajveer |
3 |
Shipment as TShipment, ItemLogistics as TItemLogistics
|
| 442 |
rajveer |
4 |
from shop2020.logistics.service.impl.DataService import Shipment
|
|
|
5 |
from shop2020.utils.Utils import to_java_date
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
def to_t_provider(provider):
|
|
|
9 |
t_provider = TProvider()
|
|
|
10 |
t_provider.id = provider.id
|
|
|
11 |
t_provider.name = provider.name
|
|
|
12 |
return t_provider
|
|
|
13 |
|
|
|
14 |
def to_t_shipment(shipment):
|
|
|
15 |
t_shipment = TShipment()
|
|
|
16 |
t_shipment.awb = shipment.awb
|
|
|
17 |
t_shipment.destination = shipment.destination
|
|
|
18 |
t_shipment.origin = shipment.origin
|
|
|
19 |
t_shipment.recepient_address = shipment.recepient_address
|
|
|
20 |
t_shipment.recepient_name = shipment.recepient_name
|
|
|
21 |
t_shipment.recepient_phone = shipment.recepient_phone
|
|
|
22 |
t_shipment.recepient_pincode = shipment.recepient_pincode
|
|
|
23 |
t_shipment.shipment_contents = shipment.shipment_contents
|
|
|
24 |
t_shipment.shipment_weight = shipment.shipment_weight
|
|
|
25 |
t_shipment.timestamp = to_java_date(shipment.timestamp)
|
|
|
26 |
t_shipment.warehouse_name = shipment.warehouse_name
|
|
|
27 |
return t_shipment
|
|
|
28 |
|
|
|
29 |
def to_t_shipmentstatusinfo(updates):
|
|
|
30 |
t_shipment_status = TShipmentStatusInfo()
|
|
|
31 |
|
|
|
32 |
ret_updates = []
|
|
|
33 |
for update in updates:
|
|
|
34 |
ret_updates.append(to_t_shipmentupdate(update))
|
|
|
35 |
|
|
|
36 |
t_shipment_status.updates = ret_updates
|
|
|
37 |
|
|
|
38 |
t_shipment_status.awb = "129102"
|
|
|
39 |
t_shipment_status.provider_id = 1
|
| 472 |
rajveer |
40 |
t_shipment_status.currentUpdate = to_t_shipmentupdate(update) #last update is added right now
|
| 442 |
rajveer |
41 |
return t_shipment_status
|
|
|
42 |
|
|
|
43 |
def to_t_shipmentupdate(update):
|
|
|
44 |
t_update = TShipmentUpdate()
|
|
|
45 |
t_update.pin = update.pin
|
|
|
46 |
t_update.description = update.description
|
|
|
47 |
t_update.timestamp = to_java_date(update.timestamp)
|
| 472 |
rajveer |
48 |
return t_update
|
|
|
49 |
|
| 477 |
rajveer |
50 |
def to_t_itemLogistics(delivery_estimate, items_in_inventory, warehouse_id):
|
| 472 |
rajveer |
51 |
t_item_logistics = TItemLogistics()
|
| 477 |
rajveer |
52 |
t_item_logistics.warehouseId = warehouse_id
|
| 472 |
rajveer |
53 |
t_item_logistics.availability = items_in_inventory
|
|
|
54 |
t_item_logistics.shippingTime = delivery_estimate.delivery_time
|
|
|
55 |
return t_item_logistics
|