Subversion Repositories SmartDukaan

Rev

Rev 9841 | Rev 9945 | 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
'''
8754 vikram.rag 6
from shop2020.model.v1.catalog.impl.DataService import Insurer, SnapdealItem, Item
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, \
8739 vikram.rag 13
    EbayItem as TEbayItem, BannerUriMapping as TBannerUriMapping, Campaign as TCampaign, \
9724 kshitij.so 14
    SnapdealItem as TSnapdealItem, SnapdealItemDetails as TSnapdealItemDetails,ProductFeedSubmit as TProductFeedSubmit, \
9779 kshitij.so 15
    MarketplaceItems as TMarketplaceItems, MarketplacePercentage as TMarketplacePercentage, \
16
    MarketPlaceItemPrice as TMarketPlaceItemPrice
5110 mandeep.dh 17
from shop2020.utils.Utils import to_java_date
94 ashish 18
 
19
def to_t_item(item):
20
    t_item = Item()
576 chandransh 21
    if item is None:
22
        return t_item
94 ashish 23
    t_item.id = item.id
963 chandransh 24
    t_item.productGroup = item.product_group
25
    t_item.brand = item.brand
591 chandransh 26
    t_item.modelNumber = item.model_number
27
    t_item.modelName = item.model_name
609 chandransh 28
    t_item.color = item.color
591 chandransh 29
    t_item.category = item.category
122 ashish 30
    t_item.catalogItemId = item.catalog_item_id
31
    t_item.weight = item.weight
32
    t_item.featureId = item.feature_id
33
    t_item.featureDescription = item.feature_description
34
    if item.startDate:
35
        t_item.startDate = to_java_date(item.startDate)
5217 amit.gupta 36
    if item.comingSoonStartDate:
37
        t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)
38
    if item.expectedArrivalDate:
39
        t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)
122 ashish 40
    if item.addedOn:
41
        t_item.addedOn = to_java_date(item.addedOn)
609 chandransh 42
    if item.updatedOn:
43
        t_item.updatedOn = to_java_date(item.updatedOn)
122 ashish 44
    t_item.itemStatus = item.status
2035 rajveer 45
    t_item.status_description = item.status_description
501 rajveer 46
    if item.sellingPrice:
609 chandransh 47
        t_item.sellingPrice = item.sellingPrice
630 chandransh 48
    if item.mrp:
501 rajveer 49
        t_item.mrp = item.mrp    
122 ashish 50
 
2028 ankur.sing 51
    if item.comments:
52
        t_item.comments = item.comments
609 chandransh 53
    if item.bestDealText:
54
        t_item.bestDealText = item.bestDealText
6777 vikram.rag 55
    if item.bestDealsDetailsText:
56
        t_item.bestDealsDetailsText = item.bestDealsDetailsText
57
    if item.bestDealsDetailsLink:
58
        t_item.bestDealsDetailsLink = item.bestDealsDetailsLink 
609 chandransh 59
    if item.bestDealValue:
60
        t_item.bestDealValue = item.bestDealValue
7291 vikram.rag 61
    if item.asin:
62
        t_item.asin = item.asin    
1910 varun.gupt 63
    t_item.defaultForEntity = item.defaultForEntity
2065 ankur.sing 64
    t_item.bestSellingRank = item.bestSellingRank
2251 ankur.sing 65
    t_item.risky = item.risky
3355 chandransh 66
    t_item.expectedDelay = item.expectedDelay
4406 anupam.sin 67
    t_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
4295 varun.gupt 68
    t_item.warrantyPeriod = item.warranty_period
4506 phani.kuma 69
    t_item.preferredVendor = item.preferredVendor
5110 mandeep.dh 70
    t_item.type = ItemType._NAMES_TO_VALUES[item.type]
5385 phani.kuma 71
    t_item.hasItemNo = item.hasItemNo
7256 rajveer 72
    t_item.activeOnStore = item.activeOnStore
6241 amit.gupta 73
    t_item.showSellingPrice = item.showSellingPrice
6805 anupam.sin 74
    t_item.preferredInsurer = item.preferredInsurer
7291 vikram.rag 75
    t_item.holdInventory = item.holdInventory
76
    t_item.defaultInventory = item.defaultInventory
9841 rajveer 77
    t_item.holdOverride = item.holdOverride
94 ashish 78
    return t_item
122 ashish 79
 
6805 anupam.sin 80
def to_t_insurer(insurer):
81
    t_insurer = TInsurer()
82
    t_insurer.id = insurer.id
83
    t_insurer.name = insurer.name 
84
    t_insurer.address = insurer.address
6903 anupam.sin 85
    t_insurer.declaredAmount = insurer.declaredAmount
86
    t_insurer.creditedAmount = insurer.creditedAmount
6805 anupam.sin 87
    return t_insurer
88
 
5504 phani.kuma 89
def to_t_voucher_item_mapping(voucher):
90
    t_voucher = VoucherItemMapping()
91
    t_voucher.voucherType = voucher.voucherType
92
    t_voucher.itemId = voucher.item.id
93
    t_voucher.amount = voucher.amount
94
    return t_voucher
95
 
1970 rajveer 96
def to_t_category(category):
97
    t_category = Category()
98
    t_category.id = category.id
99
    t_category.label = category.label
100
    t_category.description = category.description
101
    t_category.parent_category_id = category.parent_category_id
4762 phani.kuma 102
    t_category.display_name = category.display_name
3557 rajveer 103
    return t_category
104
 
105
def to_t_source_item_pricing(source_item_pricing):
106
    t_source_item_pricing = SourceItemPricing()
107
    t_source_item_pricing.sourceId = source_item_pricing.source.id
108
    t_source_item_pricing.itemId = source_item_pricing.item.id
109
    t_source_item_pricing.mrp = source_item_pricing.mrp
110
    t_source_item_pricing.sellingPrice = source_item_pricing.sellingPrice
111
    return t_source_item_pricing
112
 
113
def to_t_source(source):
114
    t_source = Source()
115
    t_source.id = source.id
116
    t_source.name = source.name
117
    t_source.identifier = source.identifier
118
    return t_source
4295 varun.gupt 119
 
120
def to_t_product_notification_request(product_notification_request):
121
    t_product_notification_request = TProductNotificationRequest()
122
 
123
    if product_notification_request:
124
        t_product_notification_request.item = to_t_item(product_notification_request.item)
125
        t_product_notification_request.email = product_notification_request.email
126
        t_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)
127
 
128
    return t_product_notification_request
129
 
130
def to_t_product_notification_request_count(product_notification_request_count):
131
 
132
    t_product_notification_request_count = TProductNotificationRequestCount()
133
 
134
    if product_notification_request_count:
135
        item, count = product_notification_request_count
136
        t_product_notification_request_count.item = to_t_item(item)
137
        t_product_notification_request_count.count = count
138
 
6511 kshitij.so 139
    return t_product_notification_request_count
140
 
141
def to_t_entity_tag(entity_tag):
142
    t_entity_tag = TEntityTag()
143
    t_entity_tag.entityId = entity_tag.entityId
6848 kshitij.so 144
    t_entity_tag.tag = entity_tag.tag
145
 
146
def to_t_banner(banner):
147
    t_banner = TBanner()
148
    t_banner.bannerName = banner.bannerName
149
    t_banner.imageName = banner.imageName
150
    t_banner.link = banner.link
151
    t_banner.priority = banner.priority
152
    t_banner.hasMap = banner.hasMap
9155 kshitij.so 153
    t_banner.bannerType = banner.bannerType
6848 kshitij.so 154
    return t_banner
155
 
8579 kshitij.so 156
def to_t_banner_list(bannerList):
157
    t_banner_list = []
158
    for banner in bannerList:
159
        t_banner = TBanner()
160
        t_banner.bannerName = banner.bannerName
161
        t_banner.imageName = banner.imageName
162
        t_banner.link = banner.link
163
        t_banner.priority = banner.priority
164
        t_banner.hasMap = banner.hasMap
9155 kshitij.so 165
        t_banner.bannerType = banner.bannerType
8579 kshitij.so 166
        t_banner_list.append(t_banner)
167
    return t_banner_list
168
 
169
 
6848 kshitij.so 170
def to_t_banner_map(banner_map):
171
    t_banner_map = TBannerMap()
172
    t_banner_map.bannerName = banner_map.bannerName
173
    t_banner_map.mapLink = banner_map.mapLink
174
    t_banner_map.coordinates = banner_map.coordinates
175
    return t_banner_map
7272 amit.gupta 176
 
8579 kshitij.so 177
def to_t_uri_mapping(uriMapping):
178
    t_uri_mapping =TBannerUriMapping()
179
    t_uri_mapping.bannerName = uriMapping.bannerName
180
    t_uri_mapping.uri = uriMapping.uri
181
    t_uri_mapping.isActive = uriMapping.isActive
182
    return t_uri_mapping
183
 
184
def to_t_campaign(campaign):
185
    t_campaign = TCampaign()
186
    t_campaign.id = campaign.id
187
    t_campaign.campaignName = campaign.campaignName
188
    t_campaign.imageName = campaign.imageName
189
    return t_campaign
190
 
7281 kshitij.so 191
def to_t_Amazonlisted(Amazonlisted):
192
    t_amazonlisted = TAmazonlisted()
8362 kshitij.so 193
    if Amazonlisted is None:
194
        return t_amazonlisted
7281 kshitij.so 195
    t_amazonlisted.asin = Amazonlisted.asin
196
    t_amazonlisted.brand = Amazonlisted.brand 
197
    t_amazonlisted.itemid = Amazonlisted.itemId
198
    t_amazonlisted.model = Amazonlisted.model
199
    t_amazonlisted.manufacturer_name = Amazonlisted.manufacturer_name
200
    t_amazonlisted.upc = Amazonlisted.upc
201
    t_amazonlisted.part_number = Amazonlisted.part_number
202
    t_amazonlisted.name = Amazonlisted.name
203
    t_amazonlisted.ean = Amazonlisted.ean
204
    t_amazonlisted.fbaPrice = Amazonlisted.fbaPrice
205
    t_amazonlisted.sellingPrice = Amazonlisted.sellingPrice
206
    t_amazonlisted.isFba = Amazonlisted.isFba
207
    t_amazonlisted.isNonFba = Amazonlisted.isNonFba
208
    t_amazonlisted.isInventoryOverride = Amazonlisted.isInventoryOverride
209
    t_amazonlisted.color = Amazonlisted.color
210
    t_amazonlisted.category = Amazonlisted.category
7367 kshitij.so 211
    t_amazonlisted.handlingTime = Amazonlisted.handlingTime
212
    t_amazonlisted.isCustomTime = Amazonlisted.isCustomTime
7516 vikram.rag 213
    t_amazonlisted.category_code = Amazonlisted.category_code
7770 kshitij.so 214
    t_amazonlisted.mfnPriceLastUpdatedOn = to_java_date(Amazonlisted.mfnPriceLastUpdatedOn)
215
    t_amazonlisted.fbaPriceLastUpdatedOn = to_java_date(Amazonlisted.fbaPriceLastUpdatedOn)
216
    t_amazonlisted.mfnPriceLastUpdatedOnSc = to_java_date(Amazonlisted.mfnPriceLastUpdatedOnSc)
217
    t_amazonlisted.fbaPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbaPriceLastUpdatedOnSc)
8139 kshitij.so 218
    t_amazonlisted.suppressMfnPriceUpdate = Amazonlisted.suppressMfnPriceUpdate
8140 kshitij.so 219
    t_amazonlisted.suppressFbaPriceUpdate = Amazonlisted.suppressFbaPriceUpdate
8619 kshitij.so 220
    t_amazonlisted.taxCode = Amazonlisted.taxCode
7291 vikram.rag 221
    return t_amazonlisted
222
 
8182 amar.kumar 223
def to_t_ebay_item(ebay_item):
224
    t_ebay_item = TEbayItem()
225
    t_ebay_item.ebayListingId = ebay_item.ebayListingId
226
    t_ebay_item.itemId = ebay_item.itemId
227
    t_ebay_item.listingName = ebay_item.listingName
228
    t_ebay_item.listingPrice = ebay_item.listingPrice
229
    t_ebay_item.listingExpiryDate = to_java_date(ebay_item.listingExpiryDate)
230
    t_ebay_item.subsidy = ebay_item.subsidy
8274 amit.gupta 231
    return t_ebay_item
232
 
233
def to_t_brand_info(brand_info):
234
    t_brand_info = TBrandInfo()
235
    t_brand_info.name = brand_info.name
236
    t_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrl
8739 vikram.rag 237
    return t_brand_info
238
 
239
def to_t_snapdeal_item(snapdealitem):
8754 vikram.rag 240
    if snapdealitem is None:
8746 vikram.rag 241
        t_snapdeal_item = TSnapdealItem()
242
        return t_snapdeal_item
8739 vikram.rag 243
    t_snapdeal_item = TSnapdealItem()
8754 vikram.rag 244
    t_snapdeal_item.item_id = snapdealitem[0].item_id
8739 vikram.rag 245
    t_snapdeal_item.warehouseId = snapdealitem[0].warehouseId
246
    t_snapdeal_item.exceptionPrice = snapdealitem[0].exceptionPrice
9242 kshitij.so 247
    t_snapdeal_item.transferPrice = snapdealitem[0].transferPrice
248
    t_snapdeal_item.sellingPrice = snapdealitem[0].sellingPrice
249
    t_snapdeal_item.courierCost = snapdealitem[0].courierCost
250
    t_snapdeal_item.commission = snapdealitem[0].commission
251
    t_snapdeal_item.serviceTax = snapdealitem[0].serviceTax
252
    t_snapdeal_item.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
253
    t_snapdeal_item.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
254
    t_snapdeal_item.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9404 vikram.rag 255
    t_snapdeal_item.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 256
    t_snapdeal_item.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 257
    t_snapdeal_item.supc = snapdealitem[0].supc
9724 kshitij.so 258
    t_snapdeal_item.shippingTime = snapdealitem[0].shippingTime
9242 kshitij.so 259
    return t_snapdeal_item
260
 
9724 kshitij.so 261
def to_t_snapdeal_item_details(snapdealitem,snapdealItemInventory):
9242 kshitij.so 262
    if snapdealitem is None:
263
        t_snapdeal_item_details = TSnapdealItemDetails()
264
        return t_snapdeal_item_details
265
    t_snapdeal_item_details = TSnapdealItemDetails()
266
    t_snapdeal_item_details.item_id = snapdealitem[0].item_id
267
    t_snapdeal_item_details.warehouseId = snapdealitem[0].warehouseId
268
    t_snapdeal_item_details.exceptionPrice = snapdealitem[0].exceptionPrice
269
    t_snapdeal_item_details.transferPrice = snapdealitem[0].transferPrice
270
    t_snapdeal_item_details.sellingPrice = snapdealitem[0].sellingPrice
271
    t_snapdeal_item_details.courierCost = snapdealitem[0].courierCost
272
    t_snapdeal_item_details.commission = snapdealitem[0].commission
273
    t_snapdeal_item_details.serviceTax = snapdealitem[0].serviceTax
274
    t_snapdeal_item_details.brand = snapdealitem[1].brand
275
    t_snapdeal_item_details.model_name = snapdealitem[1].model_name
276
    t_snapdeal_item_details.model_number = snapdealitem[1].model_number
277
    t_snapdeal_item_details.color = snapdealitem[1].color
278
    t_snapdeal_item_details.risky = snapdealitem[1].risky
279
    t_snapdeal_item_details.itemStatus = snapdealitem[1].status
280
    t_snapdeal_item_details.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
281
    t_snapdeal_item_details.weight = snapdealitem[1].weight
282
    t_snapdeal_item_details.mrp = snapdealitem[1].mrp
283
    t_snapdeal_item_details.websiteSellingPrice = snapdealitem[1].sellingPrice
284
    t_snapdeal_item_details.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
285
    t_snapdeal_item_details.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9478 kshitij.so 286
    t_snapdeal_item_details.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 287
    t_snapdeal_item_details.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 288
    t_snapdeal_item_details.supc = snapdealitem[0].supc
9724 kshitij.so 289
    t_snapdeal_item_details.shippingTime = snapdealitem[0].shippingTime
290
    if snapdealItemInventory is not None:
291
        t_snapdeal_item_details.lastUpdatedInventory = snapdealItemInventory.availability
292
        t_snapdeal_item_details.lastUpdatedInventoryTimestamp = snapdealItemInventory.lastUpdatedOnSnapdeal 
9242 kshitij.so 293
    return t_snapdeal_item_details
9621 manish.sha 294
 
295
def to_t_product_feed_submit(productfeedsubmit):
296
    if productfeedsubmit is None:
297
        t_product_feed_submit = TProductFeedSubmit()
298
        return t_product_feed_submit
299
    t_product_feed_submit = TProductFeedSubmit()
300
    t_product_feed_submit.catalogItemId = productfeedsubmit.catalogItemId
301
    t_product_feed_submit.stockLinkedFeed = productfeedsubmit.stockLinkedFeed
9724 kshitij.so 302
    return t_product_feed_submit
303
 
304
def to_t_marketplace_items(marketplaceItem):
305
    t_marketplace_item = TMarketplaceItems() 
306
    if marketplaceItem is None:
307
        return t_marketplace_item
308
    t_marketplace_item.itemId = marketplaceItem.itemId
309
    t_marketplace_item.source = marketplaceItem.source
310
    t_marketplace_item.emiFee = marketplaceItem.emiFee
311
    t_marketplace_item.courierCost = marketplaceItem.courierCost
312
    t_marketplace_item.closingFee = marketplaceItem.closingFee
313
    t_marketplace_item.commission = marketplaceItem.commission
314
    t_marketplace_item.returnProvision = marketplaceItem.returnProvision
315
    t_marketplace_item.vat = marketplaceItem.vat
316
    t_marketplace_item.packagingCost = marketplaceItem.packagingCost
317
    t_marketplace_item.otherCost = marketplaceItem.otherCost
318
    t_marketplace_item.serviceTax = marketplaceItem.serviceTax
319
    t_marketplace_item.autoIncrement = marketplaceItem.autoIncrement
320
    t_marketplace_item.autoDecrement = marketplaceItem.autoDecrement
321
    t_marketplace_item.autoFavourite = marketplaceItem.autoFavourite
322
    t_marketplace_item.manualFavourite = marketplaceItem.manualFavourite
323
    t_marketplace_item.currentSp = marketplaceItem.currentSp
324
    t_marketplace_item.currentTp = marketplaceItem.currentTp
325
    t_marketplace_item.minimumPossibleSp = marketplaceItem.minimumPossibleSp
326
    t_marketplace_item.minimumPossibleTp = marketplaceItem.minimumPossibleTp
327
    t_marketplace_item.lastCheckedTimestamp = to_java_date(marketplaceItem.lastCheckedTimestamp)
9923 kshitij.so 328
    t_marketplace_item.maximumSellingPrice = marketplaceItem.maximumSellingPrice
9724 kshitij.so 329
    return t_marketplace_item
9776 vikram.rag 330
 
331
def to_t_marketplace_itemprice(marketplaceitemprice):
332
    t_marketplace_priceitem = TMarketPlaceItemPrice()    
333
    t_marketplace_priceitem.item_id = marketplaceitemprice.item_id
334
    t_marketplace_priceitem.source = marketplaceitemprice.source
335
    t_marketplace_priceitem.sellingPrice = marketplaceitemprice.sellingPrice
336
    t_marketplace_priceitem.lastUpdatedOn = to_java_date(marketplaceitemprice.lastUpdatedOn)
337
    t_marketplace_priceitem.lastUpdatedOnMarketplace = to_java_date(marketplaceitemprice.lastUpdatedOnMarketplace)
338
    t_marketplace_priceitem.isPriceOverride = marketplaceitemprice.suppressPriceFeed
339
    t_marketplace_priceitem.isListedOnSource = marketplaceitemprice.isListedOnSource
340
    return t_marketplace_priceitem 
9779 kshitij.so 341
 
342
def to_t_marketplacepercentage(marketplacePercentage):
343
    t_marketplacepercentage = TMarketplacePercentage()
344
    if marketplacePercentage is None:
345
        return t_marketplacepercentage
346
    t_marketplacepercentage.source =  marketplacePercentage.source
347
    t_marketplacepercentage.emiFee =  marketplacePercentage.emiFee
348
    t_marketplacepercentage.closingFee = marketplacePercentage.closingFee
349
    t_marketplacepercentage.returnProvision = marketplacePercentage.returnProvision
350
    t_marketplacepercentage.commission = marketplacePercentage.commission
351
    t_marketplacepercentage.serviceTax = marketplacePercentage.serviceTax
352
    return t_marketplacepercentage
353
 
9724 kshitij.so 354
 
355
 
356
 
357
 
358