Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
94 ashish 1
'''
2
Created on 23-Mar-2010
3
 
4
@author: ashish
5
'''
7272 amit.gupta 6
from shop2020.model.v1.catalog.impl.DataService import Insurer
6511 kshitij.so 7
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, Category, \
8
    SourceItemPricing, Source, ItemType, \
5110 mandeep.dh 9
    ProductNotificationRequest as TProductNotificationRequest, \
10
    ProductNotificationRequestCount as TProductNotificationRequestCount, \
7281 kshitij.so 11
    VoucherItemMapping, EntityTag as TEntityTag, Banner as TBanner, BannerMap as TBannerMap, \
8182 amar.kumar 12
    Insurer as TInsurer, BrandInfo as TBrandInfo, Amazonlisted as TAmazonlisted, \
8579 kshitij.so 13
    EbayItem as TEbayItem, BannerUriMapping as TBannerUriMapping, Campaign as TCampaign
5110 mandeep.dh 14
from shop2020.utils.Utils import to_java_date
94 ashish 15
 
16
def to_t_item(item):
17
    t_item = Item()
576 chandransh 18
    if item is None:
19
        return t_item
94 ashish 20
    t_item.id = item.id
963 chandransh 21
    t_item.productGroup = item.product_group
22
    t_item.brand = item.brand
591 chandransh 23
    t_item.modelNumber = item.model_number
24
    t_item.modelName = item.model_name
609 chandransh 25
    t_item.color = item.color
591 chandransh 26
    t_item.category = item.category
122 ashish 27
    t_item.catalogItemId = item.catalog_item_id
28
    t_item.weight = item.weight
29
    t_item.featureId = item.feature_id
30
    t_item.featureDescription = item.feature_description
31
    if item.startDate:
32
        t_item.startDate = to_java_date(item.startDate)
5217 amit.gupta 33
    if item.comingSoonStartDate:
34
        t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)
35
    if item.expectedArrivalDate:
36
        t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)
122 ashish 37
    if item.addedOn:
38
        t_item.addedOn = to_java_date(item.addedOn)
609 chandransh 39
    if item.updatedOn:
40
        t_item.updatedOn = to_java_date(item.updatedOn)
122 ashish 41
    t_item.itemStatus = item.status
2035 rajveer 42
    t_item.status_description = item.status_description
501 rajveer 43
    if item.sellingPrice:
609 chandransh 44
        t_item.sellingPrice = item.sellingPrice
630 chandransh 45
    if item.mrp:
501 rajveer 46
        t_item.mrp = item.mrp    
122 ashish 47
 
2028 ankur.sing 48
    if item.comments:
49
        t_item.comments = item.comments
609 chandransh 50
    if item.bestDealText:
51
        t_item.bestDealText = item.bestDealText
6777 vikram.rag 52
    if item.bestDealsDetailsText:
53
        t_item.bestDealsDetailsText = item.bestDealsDetailsText
54
    if item.bestDealsDetailsLink:
55
        t_item.bestDealsDetailsLink = item.bestDealsDetailsLink 
609 chandransh 56
    if item.bestDealValue:
57
        t_item.bestDealValue = item.bestDealValue
7291 vikram.rag 58
    if item.asin:
59
        t_item.asin = item.asin    
1910 varun.gupt 60
    t_item.defaultForEntity = item.defaultForEntity
2065 ankur.sing 61
    t_item.bestSellingRank = item.bestSellingRank
2251 ankur.sing 62
    t_item.risky = item.risky
3355 chandransh 63
    t_item.expectedDelay = item.expectedDelay
4406 anupam.sin 64
    t_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
4295 varun.gupt 65
    t_item.warrantyPeriod = item.warranty_period
4506 phani.kuma 66
    t_item.preferredVendor = item.preferredVendor
5110 mandeep.dh 67
    t_item.type = ItemType._NAMES_TO_VALUES[item.type]
5385 phani.kuma 68
    t_item.hasItemNo = item.hasItemNo
7256 rajveer 69
    t_item.activeOnStore = item.activeOnStore
6241 amit.gupta 70
    t_item.showSellingPrice = item.showSellingPrice
6805 anupam.sin 71
    t_item.preferredInsurer = item.preferredInsurer
7291 vikram.rag 72
    t_item.holdInventory = item.holdInventory
73
    t_item.defaultInventory = item.defaultInventory
94 ashish 74
    return t_item
122 ashish 75
 
6805 anupam.sin 76
def to_t_insurer(insurer):
77
    t_insurer = TInsurer()
78
    t_insurer.id = insurer.id
79
    t_insurer.name = insurer.name 
80
    t_insurer.address = insurer.address
6903 anupam.sin 81
    t_insurer.declaredAmount = insurer.declaredAmount
82
    t_insurer.creditedAmount = insurer.creditedAmount
6805 anupam.sin 83
    return t_insurer
84
 
5504 phani.kuma 85
def to_t_voucher_item_mapping(voucher):
86
    t_voucher = VoucherItemMapping()
87
    t_voucher.voucherType = voucher.voucherType
88
    t_voucher.itemId = voucher.item.id
89
    t_voucher.amount = voucher.amount
90
    return t_voucher
91
 
1970 rajveer 92
def to_t_category(category):
93
    t_category = Category()
94
    t_category.id = category.id
95
    t_category.label = category.label
96
    t_category.description = category.description
97
    t_category.parent_category_id = category.parent_category_id
4762 phani.kuma 98
    t_category.display_name = category.display_name
3557 rajveer 99
    return t_category
100
 
101
def to_t_source_item_pricing(source_item_pricing):
102
    t_source_item_pricing = SourceItemPricing()
103
    t_source_item_pricing.sourceId = source_item_pricing.source.id
104
    t_source_item_pricing.itemId = source_item_pricing.item.id
105
    t_source_item_pricing.mrp = source_item_pricing.mrp
106
    t_source_item_pricing.sellingPrice = source_item_pricing.sellingPrice
107
    return t_source_item_pricing
108
 
109
def to_t_source(source):
110
    t_source = Source()
111
    t_source.id = source.id
112
    t_source.name = source.name
113
    t_source.identifier = source.identifier
114
    return t_source
4295 varun.gupt 115
 
116
def to_t_product_notification_request(product_notification_request):
117
    t_product_notification_request = TProductNotificationRequest()
118
 
119
    if product_notification_request:
120
        t_product_notification_request.item = to_t_item(product_notification_request.item)
121
        t_product_notification_request.email = product_notification_request.email
122
        t_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)
123
 
124
    return t_product_notification_request
125
 
126
def to_t_product_notification_request_count(product_notification_request_count):
127
 
128
    t_product_notification_request_count = TProductNotificationRequestCount()
129
 
130
    if product_notification_request_count:
131
        item, count = product_notification_request_count
132
        t_product_notification_request_count.item = to_t_item(item)
133
        t_product_notification_request_count.count = count
134
 
6511 kshitij.so 135
    return t_product_notification_request_count
136
 
137
def to_t_entity_tag(entity_tag):
138
    t_entity_tag = TEntityTag()
139
    t_entity_tag.entityId = entity_tag.entityId
6848 kshitij.so 140
    t_entity_tag.tag = entity_tag.tag
141
 
142
def to_t_banner(banner):
143
    t_banner = TBanner()
144
    t_banner.bannerName = banner.bannerName
145
    t_banner.imageName = banner.imageName
146
    t_banner.link = banner.link
147
    t_banner.priority = banner.priority
148
    t_banner.hasMap = banner.hasMap
149
    return t_banner
150
 
8579 kshitij.so 151
def to_t_banner_list(bannerList):
152
    t_banner_list = []
153
    for banner in bannerList:
154
        t_banner = TBanner()
155
        t_banner.bannerName = banner.bannerName
156
        t_banner.imageName = banner.imageName
157
        t_banner.link = banner.link
158
        t_banner.priority = banner.priority
159
        t_banner.hasMap = banner.hasMap
160
        t_banner_list.append(t_banner)
161
    return t_banner_list
162
 
163
 
6848 kshitij.so 164
def to_t_banner_map(banner_map):
165
    t_banner_map = TBannerMap()
166
    t_banner_map.bannerName = banner_map.bannerName
167
    t_banner_map.mapLink = banner_map.mapLink
168
    t_banner_map.coordinates = banner_map.coordinates
169
    return t_banner_map
7272 amit.gupta 170
 
8579 kshitij.so 171
def to_t_uri_mapping(uriMapping):
172
    t_uri_mapping =TBannerUriMapping()
173
    t_uri_mapping.bannerName = uriMapping.bannerName
174
    t_uri_mapping.uri = uriMapping.uri
175
    t_uri_mapping.isActive = uriMapping.isActive
176
    return t_uri_mapping
177
 
178
def to_t_campaign(campaign):
179
    t_campaign = TCampaign()
180
    t_campaign.id = campaign.id
181
    t_campaign.campaignName = campaign.campaignName
182
    t_campaign.imageName = campaign.imageName
183
    return t_campaign
184
 
7281 kshitij.so 185
def to_t_Amazonlisted(Amazonlisted):
186
    t_amazonlisted = TAmazonlisted()
8362 kshitij.so 187
    if Amazonlisted is None:
188
        return t_amazonlisted
7281 kshitij.so 189
    t_amazonlisted.asin = Amazonlisted.asin
190
    t_amazonlisted.brand = Amazonlisted.brand 
191
    t_amazonlisted.itemid = Amazonlisted.itemId
192
    t_amazonlisted.model = Amazonlisted.model
193
    t_amazonlisted.manufacturer_name = Amazonlisted.manufacturer_name
194
    t_amazonlisted.upc = Amazonlisted.upc
195
    t_amazonlisted.part_number = Amazonlisted.part_number
196
    t_amazonlisted.name = Amazonlisted.name
197
    t_amazonlisted.ean = Amazonlisted.ean
198
    t_amazonlisted.fbaPrice = Amazonlisted.fbaPrice
199
    t_amazonlisted.sellingPrice = Amazonlisted.sellingPrice
200
    t_amazonlisted.isFba = Amazonlisted.isFba
201
    t_amazonlisted.isNonFba = Amazonlisted.isNonFba
202
    t_amazonlisted.isInventoryOverride = Amazonlisted.isInventoryOverride
203
    t_amazonlisted.color = Amazonlisted.color
204
    t_amazonlisted.category = Amazonlisted.category
7367 kshitij.so 205
    t_amazonlisted.handlingTime = Amazonlisted.handlingTime
206
    t_amazonlisted.isCustomTime = Amazonlisted.isCustomTime
7516 vikram.rag 207
    t_amazonlisted.category_code = Amazonlisted.category_code
7770 kshitij.so 208
    t_amazonlisted.mfnPriceLastUpdatedOn = to_java_date(Amazonlisted.mfnPriceLastUpdatedOn)
209
    t_amazonlisted.fbaPriceLastUpdatedOn = to_java_date(Amazonlisted.fbaPriceLastUpdatedOn)
210
    t_amazonlisted.mfnPriceLastUpdatedOnSc = to_java_date(Amazonlisted.mfnPriceLastUpdatedOnSc)
211
    t_amazonlisted.fbaPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbaPriceLastUpdatedOnSc)
8139 kshitij.so 212
    t_amazonlisted.suppressMfnPriceUpdate = Amazonlisted.suppressMfnPriceUpdate
8140 kshitij.so 213
    t_amazonlisted.suppressFbaPriceUpdate = Amazonlisted.suppressFbaPriceUpdate
7291 vikram.rag 214
    return t_amazonlisted
215
 
8182 amar.kumar 216
def to_t_ebay_item(ebay_item):
217
    t_ebay_item = TEbayItem()
218
    t_ebay_item.ebayListingId = ebay_item.ebayListingId
219
    t_ebay_item.itemId = ebay_item.itemId
220
    t_ebay_item.listingName = ebay_item.listingName
221
    t_ebay_item.listingPrice = ebay_item.listingPrice
222
    t_ebay_item.listingExpiryDate = to_java_date(ebay_item.listingExpiryDate)
223
    t_ebay_item.subsidy = ebay_item.subsidy
8274 amit.gupta 224
    return t_ebay_item
225
 
226
def to_t_brand_info(brand_info):
227
    t_brand_info = TBrandInfo()
228
    t_brand_info.name = brand_info.name
229
    t_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrl
230
    return t_brand_info