| 94 |
ashish |
1 |
'''
|
|
|
2 |
Created on 23-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
| 6511 |
kshitij.so |
6 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, Category, \
|
|
|
7 |
SourceItemPricing, Source, ItemType, \
|
| 5110 |
mandeep.dh |
8 |
ProductNotificationRequest as TProductNotificationRequest, \
|
|
|
9 |
ProductNotificationRequestCount as TProductNotificationRequestCount, \
|
| 6511 |
kshitij.so |
10 |
VoucherItemMapping, EntityTag as TEntityTag
|
| 5110 |
mandeep.dh |
11 |
from shop2020.utils.Utils import to_java_date
|
| 94 |
ashish |
12 |
|
|
|
13 |
def to_t_item(item):
|
|
|
14 |
t_item = Item()
|
| 576 |
chandransh |
15 |
if item is None:
|
|
|
16 |
return t_item
|
| 94 |
ashish |
17 |
t_item.id = item.id
|
| 963 |
chandransh |
18 |
t_item.productGroup = item.product_group
|
|
|
19 |
t_item.brand = item.brand
|
| 591 |
chandransh |
20 |
t_item.modelNumber = item.model_number
|
|
|
21 |
t_item.modelName = item.model_name
|
| 609 |
chandransh |
22 |
t_item.color = item.color
|
| 591 |
chandransh |
23 |
t_item.category = item.category
|
| 122 |
ashish |
24 |
t_item.catalogItemId = item.catalog_item_id
|
|
|
25 |
t_item.weight = item.weight
|
|
|
26 |
t_item.featureId = item.feature_id
|
|
|
27 |
t_item.featureDescription = item.feature_description
|
|
|
28 |
if item.startDate:
|
|
|
29 |
t_item.startDate = to_java_date(item.startDate)
|
| 5217 |
amit.gupta |
30 |
if item.comingSoonStartDate:
|
|
|
31 |
t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)
|
|
|
32 |
if item.expectedArrivalDate:
|
|
|
33 |
t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)
|
| 122 |
ashish |
34 |
if item.addedOn:
|
|
|
35 |
t_item.addedOn = to_java_date(item.addedOn)
|
| 609 |
chandransh |
36 |
if item.updatedOn:
|
|
|
37 |
t_item.updatedOn = to_java_date(item.updatedOn)
|
| 122 |
ashish |
38 |
t_item.itemStatus = item.status
|
| 2035 |
rajveer |
39 |
t_item.status_description = item.status_description
|
| 501 |
rajveer |
40 |
if item.sellingPrice:
|
| 609 |
chandransh |
41 |
t_item.sellingPrice = item.sellingPrice
|
| 630 |
chandransh |
42 |
if item.mrp:
|
| 501 |
rajveer |
43 |
t_item.mrp = item.mrp
|
| 122 |
ashish |
44 |
|
| 2028 |
ankur.sing |
45 |
if item.comments:
|
|
|
46 |
t_item.comments = item.comments
|
| 609 |
chandransh |
47 |
if item.bestDealText:
|
|
|
48 |
t_item.bestDealText = item.bestDealText
|
|
|
49 |
if item.bestDealValue:
|
|
|
50 |
t_item.bestDealValue = item.bestDealValue
|
|
|
51 |
|
| 1910 |
varun.gupt |
52 |
t_item.defaultForEntity = item.defaultForEntity
|
| 2065 |
ankur.sing |
53 |
t_item.bestSellingRank = item.bestSellingRank
|
| 2251 |
ankur.sing |
54 |
t_item.risky = item.risky
|
| 3355 |
chandransh |
55 |
t_item.expectedDelay = item.expectedDelay
|
| 4406 |
anupam.sin |
56 |
t_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
|
| 4295 |
varun.gupt |
57 |
t_item.warrantyPeriod = item.warranty_period
|
| 4506 |
phani.kuma |
58 |
t_item.preferredVendor = item.preferredVendor
|
| 5110 |
mandeep.dh |
59 |
t_item.type = ItemType._NAMES_TO_VALUES[item.type]
|
| 5385 |
phani.kuma |
60 |
t_item.hasItemNo = item.hasItemNo
|
| 5460 |
phani.kuma |
61 |
t_item.clearance = item.clearance
|
| 6241 |
amit.gupta |
62 |
t_item.showSellingPrice = item.showSellingPrice
|
| 2065 |
ankur.sing |
63 |
|
| 94 |
ashish |
64 |
return t_item
|
| 122 |
ashish |
65 |
|
| 5504 |
phani.kuma |
66 |
def to_t_voucher_item_mapping(voucher):
|
|
|
67 |
t_voucher = VoucherItemMapping()
|
|
|
68 |
t_voucher.voucherType = voucher.voucherType
|
|
|
69 |
t_voucher.itemId = voucher.item.id
|
|
|
70 |
t_voucher.amount = voucher.amount
|
|
|
71 |
return t_voucher
|
|
|
72 |
|
| 1970 |
rajveer |
73 |
def to_t_category(category):
|
|
|
74 |
t_category = Category()
|
|
|
75 |
t_category.id = category.id
|
|
|
76 |
t_category.label = category.label
|
|
|
77 |
t_category.description = category.description
|
|
|
78 |
t_category.parent_category_id = category.parent_category_id
|
| 4762 |
phani.kuma |
79 |
t_category.display_name = category.display_name
|
| 3557 |
rajveer |
80 |
return t_category
|
|
|
81 |
|
|
|
82 |
def to_t_source_item_pricing(source_item_pricing):
|
|
|
83 |
t_source_item_pricing = SourceItemPricing()
|
|
|
84 |
t_source_item_pricing.sourceId = source_item_pricing.source.id
|
|
|
85 |
t_source_item_pricing.itemId = source_item_pricing.item.id
|
|
|
86 |
t_source_item_pricing.mrp = source_item_pricing.mrp
|
|
|
87 |
t_source_item_pricing.sellingPrice = source_item_pricing.sellingPrice
|
|
|
88 |
return t_source_item_pricing
|
|
|
89 |
|
|
|
90 |
def to_t_source(source):
|
|
|
91 |
t_source = Source()
|
|
|
92 |
t_source.id = source.id
|
|
|
93 |
t_source.name = source.name
|
|
|
94 |
t_source.identifier = source.identifier
|
|
|
95 |
return t_source
|
| 4295 |
varun.gupt |
96 |
|
|
|
97 |
def to_t_product_notification_request(product_notification_request):
|
|
|
98 |
t_product_notification_request = TProductNotificationRequest()
|
|
|
99 |
|
|
|
100 |
if product_notification_request:
|
|
|
101 |
t_product_notification_request.item = to_t_item(product_notification_request.item)
|
|
|
102 |
t_product_notification_request.email = product_notification_request.email
|
|
|
103 |
t_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)
|
|
|
104 |
|
|
|
105 |
return t_product_notification_request
|
|
|
106 |
|
|
|
107 |
def to_t_product_notification_request_count(product_notification_request_count):
|
|
|
108 |
|
|
|
109 |
t_product_notification_request_count = TProductNotificationRequestCount()
|
|
|
110 |
|
|
|
111 |
if product_notification_request_count:
|
|
|
112 |
item, count = product_notification_request_count
|
|
|
113 |
t_product_notification_request_count.item = to_t_item(item)
|
|
|
114 |
t_product_notification_request_count.count = count
|
|
|
115 |
|
| 6511 |
kshitij.so |
116 |
return t_product_notification_request_count
|
|
|
117 |
|
|
|
118 |
def to_t_entity_tag(entity_tag):
|
|
|
119 |
t_entity_tag = TEntityTag()
|
|
|
120 |
t_entity_tag.entityId = entity_tag.entityId
|
|
|
121 |
t_entity_tag.tag = entity_tag.tag
|