Subversion Repositories SmartDukaan

Rev

Rev 12449 | Rev 12663 | 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
'''
12620 amit.gupta 6
from shop2020.model.v1.catalog.impl.DataService import Insurer, SnapdealItem, Item,\
7
    ExclusiveAffiliateItemInfo
6511 kshitij.so 8
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, Category, \
9
    SourceItemPricing, Source, ItemType, \
5110 mandeep.dh 10
    ProductNotificationRequest as TProductNotificationRequest, \
11
    ProductNotificationRequestCount as TProductNotificationRequestCount, \
7281 kshitij.so 12
    VoucherItemMapping, EntityTag as TEntityTag, Banner as TBanner, BannerMap as TBannerMap, \
8182 amar.kumar 13
    Insurer as TInsurer, BrandInfo as TBrandInfo, Amazonlisted as TAmazonlisted, \
8739 vikram.rag 14
    EbayItem as TEbayItem, BannerUriMapping as TBannerUriMapping, Campaign as TCampaign, \
9724 kshitij.so 15
    SnapdealItem as TSnapdealItem, SnapdealItemDetails as TSnapdealItemDetails,ProductFeedSubmit as TProductFeedSubmit, \
9779 kshitij.so 16
    MarketplaceItems as TMarketplaceItems, MarketplacePercentage as TMarketplacePercentage, \
10097 kshitij.so 17
    MarketPlaceItemPrice as TMarketPlaceItemPrice, FlipkartItem as TFlipkartItem,\
11531 vikram.rag 18
    FlipkartItemDetails as TFlipkartItemDetails,MarketplaceHistory as TMarketplaceHistory,\
12363 kshitij.so 19
    PrivateDeal as TPrivateDeal, AmazonOutOfSync as TAmazonOutOfSync, PdPriceComp as TPdPriceComp, CompetitorPricing as TCompetitorPricing, \
12620 amit.gupta 20
    AmazonPromotion as TAmazonPromotion, ExclusiveAffiliateItemInfo as TExclusiveAffiliateItemInfo 
21
 
5110 mandeep.dh 22
from shop2020.utils.Utils import to_java_date
12363 kshitij.so 23
import datetime
94 ashish 24
 
25
def to_t_item(item):
26
    t_item = Item()
576 chandransh 27
    if item is None:
28
        return t_item
94 ashish 29
    t_item.id = item.id
963 chandransh 30
    t_item.productGroup = item.product_group
31
    t_item.brand = item.brand
591 chandransh 32
    t_item.modelNumber = item.model_number
33
    t_item.modelName = item.model_name
609 chandransh 34
    t_item.color = item.color
591 chandransh 35
    t_item.category = item.category
122 ashish 36
    t_item.catalogItemId = item.catalog_item_id
37
    t_item.weight = item.weight
38
    t_item.featureId = item.feature_id
39
    t_item.featureDescription = item.feature_description
40
    if item.startDate:
41
        t_item.startDate = to_java_date(item.startDate)
5217 amit.gupta 42
    if item.comingSoonStartDate:
43
        t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)
44
    if item.expectedArrivalDate:
45
        t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)
122 ashish 46
    if item.addedOn:
47
        t_item.addedOn = to_java_date(item.addedOn)
609 chandransh 48
    if item.updatedOn:
49
        t_item.updatedOn = to_java_date(item.updatedOn)
122 ashish 50
    t_item.itemStatus = item.status
2035 rajveer 51
    t_item.status_description = item.status_description
501 rajveer 52
    if item.sellingPrice:
609 chandransh 53
        t_item.sellingPrice = item.sellingPrice
630 chandransh 54
    if item.mrp:
501 rajveer 55
        t_item.mrp = item.mrp    
122 ashish 56
 
2028 ankur.sing 57
    if item.comments:
58
        t_item.comments = item.comments
609 chandransh 59
    if item.bestDealText:
60
        t_item.bestDealText = item.bestDealText
6777 vikram.rag 61
    if item.bestDealsDetailsText:
62
        t_item.bestDealsDetailsText = item.bestDealsDetailsText
63
    if item.bestDealsDetailsLink:
64
        t_item.bestDealsDetailsLink = item.bestDealsDetailsLink 
609 chandransh 65
    if item.bestDealValue:
66
        t_item.bestDealValue = item.bestDealValue
7291 vikram.rag 67
    if item.asin:
68
        t_item.asin = item.asin    
1910 varun.gupt 69
    t_item.defaultForEntity = item.defaultForEntity
2065 ankur.sing 70
    t_item.bestSellingRank = item.bestSellingRank
2251 ankur.sing 71
    t_item.risky = item.risky
3355 chandransh 72
    t_item.expectedDelay = item.expectedDelay
4406 anupam.sin 73
    t_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
4295 varun.gupt 74
    t_item.warrantyPeriod = item.warranty_period
4506 phani.kuma 75
    t_item.preferredVendor = item.preferredVendor
5110 mandeep.dh 76
    t_item.type = ItemType._NAMES_TO_VALUES[item.type]
5385 phani.kuma 77
    t_item.hasItemNo = item.hasItemNo
7256 rajveer 78
    t_item.activeOnStore = item.activeOnStore
6241 amit.gupta 79
    t_item.showSellingPrice = item.showSellingPrice
6805 anupam.sin 80
    t_item.preferredInsurer = item.preferredInsurer
7291 vikram.rag 81
    t_item.holdInventory = item.holdInventory
82
    t_item.defaultInventory = item.defaultInventory
9841 rajveer 83
    t_item.holdOverride = item.holdOverride
94 ashish 84
    return t_item
122 ashish 85
 
6805 anupam.sin 86
def to_t_insurer(insurer):
87
    t_insurer = TInsurer()
88
    t_insurer.id = insurer.id
89
    t_insurer.name = insurer.name 
90
    t_insurer.address = insurer.address
6903 anupam.sin 91
    t_insurer.declaredAmount = insurer.declaredAmount
92
    t_insurer.creditedAmount = insurer.creditedAmount
6805 anupam.sin 93
    return t_insurer
94
 
5504 phani.kuma 95
def to_t_voucher_item_mapping(voucher):
96
    t_voucher = VoucherItemMapping()
97
    t_voucher.voucherType = voucher.voucherType
98
    t_voucher.itemId = voucher.item.id
99
    t_voucher.amount = voucher.amount
100
    return t_voucher
101
 
1970 rajveer 102
def to_t_category(category):
103
    t_category = Category()
104
    t_category.id = category.id
105
    t_category.label = category.label
106
    t_category.description = category.description
107
    t_category.parent_category_id = category.parent_category_id
4762 phani.kuma 108
    t_category.display_name = category.display_name
3557 rajveer 109
    return t_category
110
 
111
def to_t_source_item_pricing(source_item_pricing):
112
    t_source_item_pricing = SourceItemPricing()
113
    t_source_item_pricing.sourceId = source_item_pricing.source.id
114
    t_source_item_pricing.itemId = source_item_pricing.item.id
115
    t_source_item_pricing.mrp = source_item_pricing.mrp
116
    t_source_item_pricing.sellingPrice = source_item_pricing.sellingPrice
117
    return t_source_item_pricing
118
 
119
def to_t_source(source):
120
    t_source = Source()
121
    t_source.id = source.id
122
    t_source.name = source.name
123
    t_source.identifier = source.identifier
124
    return t_source
4295 varun.gupt 125
 
126
def to_t_product_notification_request(product_notification_request):
127
    t_product_notification_request = TProductNotificationRequest()
128
 
129
    if product_notification_request:
130
        t_product_notification_request.item = to_t_item(product_notification_request.item)
131
        t_product_notification_request.email = product_notification_request.email
132
        t_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)
133
 
134
    return t_product_notification_request
135
 
136
def to_t_product_notification_request_count(product_notification_request_count):
137
 
138
    t_product_notification_request_count = TProductNotificationRequestCount()
139
 
140
    if product_notification_request_count:
141
        item, count = product_notification_request_count
142
        t_product_notification_request_count.item = to_t_item(item)
143
        t_product_notification_request_count.count = count
144
 
6511 kshitij.so 145
    return t_product_notification_request_count
146
 
147
def to_t_entity_tag(entity_tag):
148
    t_entity_tag = TEntityTag()
149
    t_entity_tag.entityId = entity_tag.entityId
6848 kshitij.so 150
    t_entity_tag.tag = entity_tag.tag
151
 
152
def to_t_banner(banner):
153
    t_banner = TBanner()
154
    t_banner.bannerName = banner.bannerName
155
    t_banner.imageName = banner.imageName
156
    t_banner.link = banner.link
157
    t_banner.priority = banner.priority
158
    t_banner.hasMap = banner.hasMap
9155 kshitij.so 159
    t_banner.bannerType = banner.bannerType
6848 kshitij.so 160
    return t_banner
161
 
8579 kshitij.so 162
def to_t_banner_list(bannerList):
163
    t_banner_list = []
164
    for banner in bannerList:
165
        t_banner = TBanner()
166
        t_banner.bannerName = banner.bannerName
167
        t_banner.imageName = banner.imageName
168
        t_banner.link = banner.link
169
        t_banner.priority = banner.priority
170
        t_banner.hasMap = banner.hasMap
9155 kshitij.so 171
        t_banner.bannerType = banner.bannerType
8579 kshitij.so 172
        t_banner_list.append(t_banner)
173
    return t_banner_list
174
 
175
 
6848 kshitij.so 176
def to_t_banner_map(banner_map):
177
    t_banner_map = TBannerMap()
178
    t_banner_map.bannerName = banner_map.bannerName
179
    t_banner_map.mapLink = banner_map.mapLink
180
    t_banner_map.coordinates = banner_map.coordinates
181
    return t_banner_map
7272 amit.gupta 182
 
8579 kshitij.so 183
def to_t_uri_mapping(uriMapping):
184
    t_uri_mapping =TBannerUriMapping()
185
    t_uri_mapping.bannerName = uriMapping.bannerName
186
    t_uri_mapping.uri = uriMapping.uri
187
    t_uri_mapping.isActive = uriMapping.isActive
10097 kshitij.so 188
    t_uri_mapping.target = uriMapping.target
8579 kshitij.so 189
    return t_uri_mapping
190
 
191
def to_t_campaign(campaign):
192
    t_campaign = TCampaign()
193
    t_campaign.id = campaign.id
194
    t_campaign.campaignName = campaign.campaignName
195
    t_campaign.imageName = campaign.imageName
196
    return t_campaign
197
 
7281 kshitij.so 198
def to_t_Amazonlisted(Amazonlisted):
199
    t_amazonlisted = TAmazonlisted()
8362 kshitij.so 200
    if Amazonlisted is None:
201
        return t_amazonlisted
7281 kshitij.so 202
    t_amazonlisted.asin = Amazonlisted.asin
203
    t_amazonlisted.brand = Amazonlisted.brand 
204
    t_amazonlisted.itemid = Amazonlisted.itemId
205
    t_amazonlisted.model = Amazonlisted.model
206
    t_amazonlisted.manufacturer_name = Amazonlisted.manufacturer_name
207
    t_amazonlisted.upc = Amazonlisted.upc
208
    t_amazonlisted.part_number = Amazonlisted.part_number
209
    t_amazonlisted.name = Amazonlisted.name
210
    t_amazonlisted.ean = Amazonlisted.ean
211
    t_amazonlisted.fbaPrice = Amazonlisted.fbaPrice
10909 vikram.rag 212
    t_amazonlisted.fbbPrice = Amazonlisted.fbbPrice
7281 kshitij.so 213
    t_amazonlisted.sellingPrice = Amazonlisted.sellingPrice
214
    t_amazonlisted.isFba = Amazonlisted.isFba
10909 vikram.rag 215
    t_amazonlisted.isFbb = Amazonlisted.isFbb
7281 kshitij.so 216
    t_amazonlisted.isNonFba = Amazonlisted.isNonFba
217
    t_amazonlisted.isInventoryOverride = Amazonlisted.isInventoryOverride
218
    t_amazonlisted.color = Amazonlisted.color
219
    t_amazonlisted.category = Amazonlisted.category
7367 kshitij.so 220
    t_amazonlisted.handlingTime = Amazonlisted.handlingTime
221
    t_amazonlisted.isCustomTime = Amazonlisted.isCustomTime
7516 vikram.rag 222
    t_amazonlisted.category_code = Amazonlisted.category_code
7770 kshitij.so 223
    t_amazonlisted.mfnPriceLastUpdatedOn = to_java_date(Amazonlisted.mfnPriceLastUpdatedOn)
224
    t_amazonlisted.fbaPriceLastUpdatedOn = to_java_date(Amazonlisted.fbaPriceLastUpdatedOn)
10909 vikram.rag 225
    t_amazonlisted.fbbPriceLastUpdatedOn = to_java_date(Amazonlisted.fbbPriceLastUpdatedOn)
7770 kshitij.so 226
    t_amazonlisted.mfnPriceLastUpdatedOnSc = to_java_date(Amazonlisted.mfnPriceLastUpdatedOnSc)
10909 vikram.rag 227
    t_amazonlisted.fbbPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbbPriceLastUpdatedOnSc)
7770 kshitij.so 228
    t_amazonlisted.fbaPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbaPriceLastUpdatedOnSc)
8139 kshitij.so 229
    t_amazonlisted.suppressMfnPriceUpdate = Amazonlisted.suppressMfnPriceUpdate
8140 kshitij.so 230
    t_amazonlisted.suppressFbaPriceUpdate = Amazonlisted.suppressFbaPriceUpdate
10909 vikram.rag 231
    t_amazonlisted.suppressFbbPriceUpdate = Amazonlisted.suppressFbbPriceUpdate
8619 kshitij.so 232
    t_amazonlisted.taxCode = Amazonlisted.taxCode
10918 vikram.rag 233
    t_amazonlisted.fbbtaxCode = Amazonlisted.fbbtaxCode
12363 kshitij.so 234
    t_amazonlisted.overrrideWanlc = Amazonlisted.overrrideWanlc
235
    t_amazonlisted.exceptionalWanlc = Amazonlisted.exceptionalWanlc
12396 kshitij.so 236
    t_amazonlisted.autoDecrement = Amazonlisted.autoDecrement
237
    t_amazonlisted.autoIncrement = Amazonlisted.autoIncrement
238
    t_amazonlisted.autoFavourite = Amazonlisted.autoFavourite
239
    t_amazonlisted.manualFavourite = Amazonlisted.manualFavourite
12449 kshitij.so 240
    t_amazonlisted.otherCost = Amazonlisted.otherCost
7291 vikram.rag 241
    return t_amazonlisted
242
 
8182 amar.kumar 243
def to_t_ebay_item(ebay_item):
244
    t_ebay_item = TEbayItem()
245
    t_ebay_item.ebayListingId = ebay_item.ebayListingId
246
    t_ebay_item.itemId = ebay_item.itemId
247
    t_ebay_item.listingName = ebay_item.listingName
248
    t_ebay_item.listingPrice = ebay_item.listingPrice
249
    t_ebay_item.listingExpiryDate = to_java_date(ebay_item.listingExpiryDate)
250
    t_ebay_item.subsidy = ebay_item.subsidy
8274 amit.gupta 251
    return t_ebay_item
252
 
253
def to_t_brand_info(brand_info):
254
    t_brand_info = TBrandInfo()
255
    t_brand_info.name = brand_info.name
256
    t_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrl
8739 vikram.rag 257
    return t_brand_info
258
 
259
def to_t_snapdeal_item(snapdealitem):
8754 vikram.rag 260
    if snapdealitem is None:
8746 vikram.rag 261
        t_snapdeal_item = TSnapdealItem()
262
        return t_snapdeal_item
8739 vikram.rag 263
    t_snapdeal_item = TSnapdealItem()
8754 vikram.rag 264
    t_snapdeal_item.item_id = snapdealitem[0].item_id
8739 vikram.rag 265
    t_snapdeal_item.warehouseId = snapdealitem[0].warehouseId
266
    t_snapdeal_item.exceptionPrice = snapdealitem[0].exceptionPrice
9242 kshitij.so 267
    t_snapdeal_item.transferPrice = snapdealitem[0].transferPrice
268
    t_snapdeal_item.sellingPrice = snapdealitem[0].sellingPrice
269
    t_snapdeal_item.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 270
    t_snapdeal_item.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 271
    t_snapdeal_item.commission = snapdealitem[0].commission
272
    t_snapdeal_item.serviceTax = snapdealitem[0].serviceTax
273
    t_snapdeal_item.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
274
    t_snapdeal_item.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
275
    t_snapdeal_item.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9404 vikram.rag 276
    t_snapdeal_item.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 277
    t_snapdeal_item.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 278
    t_snapdeal_item.supc = snapdealitem[0].supc
9724 kshitij.so 279
    t_snapdeal_item.shippingTime = snapdealitem[0].shippingTime
9242 kshitij.so 280
    return t_snapdeal_item
281
 
9724 kshitij.so 282
def to_t_snapdeal_item_details(snapdealitem,snapdealItemInventory):
9242 kshitij.so 283
    if snapdealitem is None:
284
        t_snapdeal_item_details = TSnapdealItemDetails()
285
        return t_snapdeal_item_details
286
    t_snapdeal_item_details = TSnapdealItemDetails()
287
    t_snapdeal_item_details.item_id = snapdealitem[0].item_id
288
    t_snapdeal_item_details.warehouseId = snapdealitem[0].warehouseId
289
    t_snapdeal_item_details.exceptionPrice = snapdealitem[0].exceptionPrice
290
    t_snapdeal_item_details.transferPrice = snapdealitem[0].transferPrice
291
    t_snapdeal_item_details.sellingPrice = snapdealitem[0].sellingPrice
292
    t_snapdeal_item_details.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 293
    t_snapdeal_item_details.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 294
    t_snapdeal_item_details.commission = snapdealitem[0].commission
295
    t_snapdeal_item_details.serviceTax = snapdealitem[0].serviceTax
296
    t_snapdeal_item_details.brand = snapdealitem[1].brand
297
    t_snapdeal_item_details.model_name = snapdealitem[1].model_name
298
    t_snapdeal_item_details.model_number = snapdealitem[1].model_number
299
    t_snapdeal_item_details.color = snapdealitem[1].color
300
    t_snapdeal_item_details.risky = snapdealitem[1].risky
301
    t_snapdeal_item_details.itemStatus = snapdealitem[1].status
302
    t_snapdeal_item_details.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
303
    t_snapdeal_item_details.weight = snapdealitem[1].weight
304
    t_snapdeal_item_details.mrp = snapdealitem[1].mrp
305
    t_snapdeal_item_details.websiteSellingPrice = snapdealitem[1].sellingPrice
306
    t_snapdeal_item_details.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
307
    t_snapdeal_item_details.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9478 kshitij.so 308
    t_snapdeal_item_details.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 309
    t_snapdeal_item_details.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 310
    t_snapdeal_item_details.supc = snapdealitem[0].supc
9724 kshitij.so 311
    t_snapdeal_item_details.shippingTime = snapdealitem[0].shippingTime
312
    if snapdealItemInventory is not None:
313
        t_snapdeal_item_details.lastUpdatedInventory = snapdealItemInventory.availability
314
        t_snapdeal_item_details.lastUpdatedInventoryTimestamp = snapdealItemInventory.lastUpdatedOnSnapdeal 
9242 kshitij.so 315
    return t_snapdeal_item_details
9621 manish.sha 316
 
317
def to_t_product_feed_submit(productfeedsubmit):
318
    if productfeedsubmit is None:
319
        t_product_feed_submit = TProductFeedSubmit()
320
        return t_product_feed_submit
321
    t_product_feed_submit = TProductFeedSubmit()
322
    t_product_feed_submit.catalogItemId = productfeedsubmit.catalogItemId
323
    t_product_feed_submit.stockLinkedFeed = productfeedsubmit.stockLinkedFeed
9724 kshitij.so 324
    return t_product_feed_submit
325
 
326
def to_t_marketplace_items(marketplaceItem):
327
    t_marketplace_item = TMarketplaceItems() 
328
    if marketplaceItem is None:
329
        return t_marketplace_item
330
    t_marketplace_item.itemId = marketplaceItem.itemId
331
    t_marketplace_item.source = marketplaceItem.source
332
    t_marketplace_item.emiFee = marketplaceItem.emiFee
333
    t_marketplace_item.courierCost = marketplaceItem.courierCost
11095 kshitij.so 334
    t_marketplace_item.courierCostMarketplace = marketplaceItem.courierCostMarketplace
9724 kshitij.so 335
    t_marketplace_item.closingFee = marketplaceItem.closingFee
336
    t_marketplace_item.commission = marketplaceItem.commission
337
    t_marketplace_item.returnProvision = marketplaceItem.returnProvision
338
    t_marketplace_item.vat = marketplaceItem.vat
339
    t_marketplace_item.packagingCost = marketplaceItem.packagingCost
340
    t_marketplace_item.otherCost = marketplaceItem.otherCost
341
    t_marketplace_item.serviceTax = marketplaceItem.serviceTax
342
    t_marketplace_item.autoIncrement = marketplaceItem.autoIncrement
343
    t_marketplace_item.autoDecrement = marketplaceItem.autoDecrement
344
    t_marketplace_item.autoFavourite = marketplaceItem.autoFavourite
345
    t_marketplace_item.manualFavourite = marketplaceItem.manualFavourite
346
    t_marketplace_item.currentSp = marketplaceItem.currentSp
347
    t_marketplace_item.currentTp = marketplaceItem.currentTp
348
    t_marketplace_item.minimumPossibleSp = marketplaceItem.minimumPossibleSp
349
    t_marketplace_item.minimumPossibleTp = marketplaceItem.minimumPossibleTp
350
    t_marketplace_item.lastCheckedTimestamp = to_java_date(marketplaceItem.lastCheckedTimestamp)
9923 kshitij.so 351
    t_marketplace_item.maximumSellingPrice = marketplaceItem.maximumSellingPrice
10287 kshitij.so 352
    t_marketplace_item.pgFee = marketplaceItem.pgFee
9724 kshitij.so 353
    return t_marketplace_item
9776 vikram.rag 354
 
355
def to_t_marketplace_itemprice(marketplaceitemprice):
356
    t_marketplace_priceitem = TMarketPlaceItemPrice()    
357
    t_marketplace_priceitem.item_id = marketplaceitemprice.item_id
358
    t_marketplace_priceitem.source = marketplaceitemprice.source
359
    t_marketplace_priceitem.sellingPrice = marketplaceitemprice.sellingPrice
360
    t_marketplace_priceitem.lastUpdatedOn = to_java_date(marketplaceitemprice.lastUpdatedOn)
361
    t_marketplace_priceitem.lastUpdatedOnMarketplace = to_java_date(marketplaceitemprice.lastUpdatedOnMarketplace)
362
    t_marketplace_priceitem.isPriceOverride = marketplaceitemprice.suppressPriceFeed
363
    t_marketplace_priceitem.isListedOnSource = marketplaceitemprice.isListedOnSource
364
    return t_marketplace_priceitem 
9779 kshitij.so 365
 
366
def to_t_marketplacepercentage(marketplacePercentage):
367
    t_marketplacepercentage = TMarketplacePercentage()
368
    if marketplacePercentage is None:
369
        return t_marketplacepercentage
370
    t_marketplacepercentage.source =  marketplacePercentage.source
371
    t_marketplacepercentage.emiFee =  marketplacePercentage.emiFee
372
    t_marketplacepercentage.closingFee = marketplacePercentage.closingFee
373
    t_marketplacepercentage.returnProvision = marketplacePercentage.returnProvision
374
    t_marketplacepercentage.commission = marketplacePercentage.commission
375
    t_marketplacepercentage.serviceTax = marketplacePercentage.serviceTax
10287 kshitij.so 376
    t_marketplacepercentage.pgFee = marketplacePercentage.pgFee
9779 kshitij.so 377
    return t_marketplacepercentage
9945 vikram.rag 378
 
379
def to_t_flipkart_item(flipkartItem):
380
    t_flipkartitem = TFlipkartItem()
381
    if flipkartItem is None:
382
        return t_flipkartitem
10097 kshitij.so 383
    t_flipkartitem.item_id = flipkartItem[0].item_id  
384
    t_flipkartitem.exceptionPrice = flipkartItem[0].exceptionPrice
385
    t_flipkartitem.warehouseId = flipkartItem[0].warehouseId
386
    t_flipkartitem.commissionValue  =  flipkartItem[0].commissionValue
387
    t_flipkartitem.serviceTaxValue  =  flipkartItem[0].serviceTaxValue
388
    t_flipkartitem.maxNlc = flipkartItem[0].maxNlc
389
    t_flipkartitem.skuAtFlipkart = flipkartItem[0].skuAtFlipkart
390
    t_flipkartitem.isListedOnFlipkart = flipkartItem[0].isListedOnFlipkart
391
    t_flipkartitem.suppressPriceFeed = flipkartItem[0].suppressPriceFeed
392
    t_flipkartitem.suppressInventoryFeed = flipkartItem[0].suppressInventoryFeed
393
    #t_flipkartitem.updatedOn = to_java_date(flipkartItem.updatedOn)
394
    t_flipkartitem.updatedBy = flipkartItem[0].updatedBy
395
    t_flipkartitem.flipkartSerialNumber = flipkartItem[0].flipkartSerialNumber
9945 vikram.rag 396
    return t_flipkartitem
10097 kshitij.so 397
 
398
def to_t_flipkart_item_details(flipkartitem,flipkartItemInventory):
399
    if flipkartitem is None:
400
        t_flipkart_item_details = TFlipkartItemDetails()
401
        return t_flipkart_item_details
402
    t_flipkart_item_details = TFlipkartItemDetails()
403
    t_flipkart_item_details.item_id = flipkartitem[0].item_id
404
    t_flipkart_item_details.warehouseId = flipkartitem[0].warehouseId
405
    t_flipkart_item_details.exceptionPrice = flipkartitem[0].exceptionPrice
406
    t_flipkart_item_details.commission = flipkartitem[0].commissionValue
407
    t_flipkart_item_details.serviceTax = flipkartitem[0].serviceTaxValue
408
    t_flipkart_item_details.brand = flipkartitem[1].brand
409
    t_flipkart_item_details.model_name = flipkartitem[1].model_name
410
    t_flipkart_item_details.model_number = flipkartitem[1].model_number
411
    t_flipkart_item_details.color = flipkartitem[1].color
412
    t_flipkart_item_details.risky = flipkartitem[1].risky
413
    t_flipkart_item_details.itemStatus = flipkartitem[1].status
414
    t_flipkart_item_details.isListedOnFlipkart = flipkartitem[0].isListedOnFlipkart
415
    t_flipkart_item_details.weight = flipkartitem[1].weight
416
    t_flipkart_item_details.mrp = flipkartitem[1].mrp
417
    t_flipkart_item_details.websiteSellingPrice = flipkartitem[1].sellingPrice
418
    t_flipkart_item_details.suppressPriceFeed = flipkartitem[0].suppressPriceFeed
419
    t_flipkart_item_details.suppressInventoryFeed = flipkartitem[0].suppressInventoryFeed
420
    t_flipkart_item_details.maxNlc = flipkartitem[0].maxNlc
421
    t_flipkart_item_details.skuAtFlipkart = flipkartitem[0].skuAtFlipkart
422
    t_flipkart_item_details.flipkartSerialNumber = flipkartitem[0].flipkartSerialNumber
10156 amar.kumar 423
    t_flipkart_item_details.category = flipkartitem[1].category
10097 kshitij.so 424
    if flipkartItemInventory is not None:
425
        t_flipkart_item_details.lastUpdatedInventory = flipkartItemInventory.availability
426
        #t_flipkart_item_details.lastUpdatedInventoryTimestamp = flipkartItemInventory.lastUpdatedOnFlipkart 
427
    return t_flipkart_item_details
11015 kshitij.so 428
 
429
def to_t_market_place_history(marketplaceHistory):
430
    t_marketplace_history = TMarketplaceHistory()
431
    if marketplaceHistory is None:
432
        return t_marketplace_history
433
    t_marketplace_history.item_id = marketplaceHistory.item_id
434
    t_marketplace_history.source = marketplaceHistory.source
435
    t_marketplace_history.timestamp = to_java_date(marketplaceHistory.timestamp)
11076 kshitij.so 436
    if marketplaceHistory.lowestPossibleTp is None:
437
        t_marketplace_history.lowest_possible_tp =0
438
    else:
439
        t_marketplace_history.lowest_possible_tp = int(marketplaceHistory.lowestPossibleTp)
440
    if marketplaceHistory.lowestPossibleSp is None:
441
        t_marketplace_history.lowest_possible_sp = 0
442
    else:
443
        t_marketplace_history.lowest_possible_sp = int(marketplaceHistory.lowestPossibleSp)
11015 kshitij.so 444
    t_marketplace_history.ourInventory = marketplaceHistory.ourInventory
445
    t_marketplace_history.otherInventory = marketplaceHistory.otherInventory
446
    t_marketplace_history.secondLowestInventory = marketplaceHistory.secondLowestInventory
447
    t_marketplace_history.ourRank = marketplaceHistory.ourRank
11076 kshitij.so 448
    if marketplaceHistory.ourOfferPrice is None:
449
        t_marketplace_history.ourOfferPrice = 0
450
    else: 
451
        t_marketplace_history.ourOfferPrice = int(marketplaceHistory.ourOfferPrice)
452
    if marketplaceHistory.ourSellingPrice is None:
453
        t_marketplace_history.ourSellingPrice = 0
454
    else:
455
        t_marketplace_history.ourSellingPrice = int(marketplaceHistory.ourSellingPrice)
456
    if marketplaceHistory.ourTp is None:
457
        t_marketplace_history.ourTp = 0
458
    else:
459
        t_marketplace_history.ourTp = int(marketplaceHistory.ourTp)
460
    if marketplaceHistory.ourNlc is None:
461
        t_marketplace_history.ourNlc = 0
462
    else:
463
        t_marketplace_history.ourNlc = int(marketplaceHistory.ourNlc)
11015 kshitij.so 464
    t_marketplace_history.competitiveCategory = marketplaceHistory.competitiveCategory
465
    t_marketplace_history.risky = marketplaceHistory.risky
11076 kshitij.so 466
    if marketplaceHistory.lowestOfferPrice is None:
467
        t_marketplace_history.lowestOfferPrice = 0
468
    else:
469
        t_marketplace_history.lowestOfferPrice = int(marketplaceHistory.lowestOfferPrice)
470
    if marketplaceHistory.lowestSellingPrice is None:
471
        t_marketplace_history.lowestSellingPrice = 0
472
    else:
473
        t_marketplace_history.lowestSellingPrice = int(marketplaceHistory.lowestSellingPrice)
474
    if marketplaceHistory.lowestTp is None:
475
        t_marketplace_history.lowestTp = 0
476
    else:
477
        t_marketplace_history.lowestTp = int(marketplaceHistory.lowestTp)
11015 kshitij.so 478
    if marketplaceHistory.lowestSellerName is None:
479
        t_marketplace_history.lowestSellerName = ''
480
    else:
481
        t_marketplace_history.lowestSellerName = marketplaceHistory.lowestSellerName
11076 kshitij.so 482
    if marketplaceHistory.proposedSellingPrice is None:
483
        t_marketplace_history.proposedSellingPrice = 0
484
    else:
485
        t_marketplace_history.proposedSellingPrice = int(marketplaceHistory.proposedSellingPrice)
486
    if marketplaceHistory.proposedTp is None:
487
        t_marketplace_history.proposedTp = 0
488
    else:
489
        t_marketplace_history.proposedTp = int(marketplaceHistory.proposedTp)
490
    if marketplaceHistory.targetNlc is None:
491
        t_marketplace_history.targetNlc = 0
492
    else:
493
        t_marketplace_history.targetNlc = int(marketplaceHistory.targetNlc)
11015 kshitij.so 494
    t_marketplace_history.salesPotential = marketplaceHistory.salesPotential
495
    if marketplaceHistory.secondLowestSellerName is None:
496
        t_marketplace_history.secondLowestSellerName = ''
497
    else:
498
        t_marketplace_history.secondLowestSellerName = marketplaceHistory.secondLowestSellerName
11017 kshitij.so 499
    if marketplaceHistory.secondLowestSellingPrice is None:
11076 kshitij.so 500
        t_marketplace_history.secondLowestSellingPrice=0
11017 kshitij.so 501
    else:
11076 kshitij.so 502
        t_marketplace_history.secondLowestSellingPrice = int(marketplaceHistory.secondLowestSellingPrice)
11017 kshitij.so 503
    if marketplaceHistory.secondLowestOfferPrice is None:
11076 kshitij.so 504
        t_marketplace_history.secondLowestOfferPrice = 0
11017 kshitij.so 505
    else:
11076 kshitij.so 506
        t_marketplace_history.secondLowestOfferPrice = int(marketplaceHistory.secondLowestOfferPrice)
11017 kshitij.so 507
    if marketplaceHistory.secondLowestTp is None:
11076 kshitij.so 508
        t_marketplace_history.secondLowestTp=0
11017 kshitij.so 509
    else:
11076 kshitij.so 510
        t_marketplace_history.secondLowestTp = int(marketplaceHistory.secondLowestTp)
11015 kshitij.so 511
    t_marketplace_history.marginIncreasedPotential = marketplaceHistory.marginIncreasedPotential
11076 kshitij.so 512
    if marketplaceHistory.margin is None:
513
        t_marketplace_history.margin = 0
514
    else:
515
        t_marketplace_history.margin = int(marketplaceHistory.margin)
11015 kshitij.so 516
    t_marketplace_history.ourEnoughStock = marketplaceHistory.ourEnoughStock
517
    t_marketplace_history.totalSeller = marketplaceHistory.totalSeller
518
    t_marketplace_history.averageSale = marketplaceHistory.avgSales
519
    t_marketplace_history.toGroup = marketplaceHistory.toGroup
11076 kshitij.so 520
    t_marketplace_history.decision = marketplaceHistory.decision
521
    t_marketplace_history.reason = marketplaceHistory.reason
11015 kshitij.so 522
    return t_marketplace_history
9945 vikram.rag 523
 
11531 vikram.rag 524
def to_t_private_deal(private_deal_item):
525
    if private_deal_item is None:
526
        t_private_deal_item = TPrivateDeal()
527
        return t_private_deal_item
528
    t_private_deal_item = TPrivateDeal()
529
    t_private_deal_item.item_id = private_deal_item.item_id
530
    t_private_deal_item.dealPrice = private_deal_item.dealPrice
531
    t_private_deal_item.dealFreebieItemId = private_deal_item.dealFreebieItemId
11579 vikram.rag 532
    t_private_deal_item.startDate = to_java_date(private_deal_item.startDate)
533
    t_private_deal_item.endDate = to_java_date(private_deal_item.endDate)
11566 vikram.rag 534
    t_private_deal_item.dealTextOption = private_deal_item.dealTextOption
11635 vikram.rag 535
    if private_deal_item.dealText is None: 
11613 vikram.rag 536
        t_private_deal_item.dealText = ''
537
    else:
538
        t_private_deal_item.dealText = private_deal_item.dealText    
11531 vikram.rag 539
    t_private_deal_item.isCod = private_deal_item.isCod
540
    t_private_deal_item.rank = private_deal_item.rank
11566 vikram.rag 541
    t_private_deal_item.dealFreebieOption = private_deal_item.dealFreebieOption
11606 vikram.rag 542
    t_private_deal_item.isActive = private_deal_item.isActive
11905 kshitij.so 543
    return t_private_deal_item
544
 
545
def to_t_amazonoutofsync(amazonOutOfSync):
546
    t_amazonoutofsync = TAmazonOutOfSync()
547
    if amazonOutOfSync is None:
548
        return t_amazonoutofsync
549
    else:
550
        t_amazonoutofsync.item_id = amazonOutOfSync.item_id
551
        t_amazonoutofsync.mfn = amazonOutOfSync.mfn
552
        t_amazonoutofsync.fba = amazonOutOfSync.fba
553
        t_amazonoutofsync.fbb = amazonOutOfSync.fbb
554
        return t_amazonoutofsync
555
 
556
def to_t_private_deals_comparison(item):
557
    xstr = lambda s: s or ""
558
    t_pdcomp = TPdPriceComp()
559
    pdComp = item[0]
560
    catItem  = item[1]
561
    t_pdcomp.item_id = pdComp.item_id
562
    t_pdcomp.dealPrice = pdComp.dealPrice
563
    t_pdcomp.saholicPrice = pdComp.saholicPrice
564
    t_pdcomp.sdPrice = pdComp.sdPrice
565
    t_pdcomp.fkPrice = pdComp.fkPrice
566
    t_pdcomp.amazonPrice = pdComp.amazonPrice
567
    t_pdcomp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
12169 kshitij.so 568
    t_pdcomp.lastProcessedTimestamp = to_java_date(pdComp.lastProcessedTimestamp)
11905 kshitij.so 569
    return t_pdcomp
570
 
12133 kshitij.so 571
def to_t_snapdeal_marketplace_item(item):
572
    mpItem = item[1]
573
    dItem = item[2]
574
    t_sd_item = to_t_snapdeal_item(item)
575
    t_sd_item.marketplaceItems = to_t_marketplace_items(mpItem)
576
    t_sd_item.item = to_t_item(dItem)
577
    return t_sd_item
578
 
579
def to_t_flipkart_marketplace_item(item):
580
    mpItem = item[1]
581
    dItem = item[2]
582
    t_fk_item = to_t_flipkart_item(item)
583
    t_fk_item.marketplaceItems = to_t_marketplace_items(mpItem)
584
    t_fk_item.item = to_t_item(dItem)
585
    return t_fk_item
12243 kshitij.so 586
 
12256 kshitij.so 587
def to_t_competitor_pricing(compPricing):
588
    xstr = lambda s: s or ""
589
    item = compPricing[0]
590
    catItem = compPricing[1]
591
    t_comp = TCompetitorPricing()
592
    t_comp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
593
    t_comp.item_id = item.item_id
594
    t_comp.lowestSnapdealPrice = item.lowestSnapdealPrice
595
    t_comp.lowestFlipkartPrice = item.lowestFlipkartPrice
596
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
597
    t_comp.ourSnapdealPrice = item.ourSnapdealPrice
598
    t_comp.ourSnapdealOfferPrice = item.ourSnapdealOfferPrice
599
    t_comp.ourSnapdealInventory = item.ourSnapdealInventory
600
    t_comp.lowestSnapdealOfferPrice = item.lowestSnapdealOfferPrice
601
    if item.lowestSnapdealSeller is None:
602
        t_comp.lowestSnapdealSeller=''
603
    else:
604
        t_comp.lowestSnapdealSeller = item.lowestSnapdealSeller
605
    t_comp.lowestSnapdealSellerInventory = item.lowestSnapdealSellerInventory
606
    t_comp.ourFlipkartPrice = item.ourFlipkartPrice
607
    t_comp.ourFlipkartInventory = item.ourFlipkartInventory
608
    if item.lowestFlipkartSeller is None:
609
        t_comp.lowestFlipkartSeller=''
610
    else:
611
        t_comp.lowestFlipkartSeller = item.lowestFlipkartSeller
612
    t_comp.ourMfnPrice = item.ourMfnPrice
613
    t_comp.ourFbaPrice = item.ourFbaPrice
614
    t_comp.ourMfnInventory = item.ourMfnInventory
615
    t_comp.ourFbaInventory = item.ourFbaInventory
616
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
617
    if item.lowestAmazonSeller is None:
618
        t_comp.lowestAmazonSeller=''
619
    else:
620
        t_comp.lowestAmazonSeller = item.lowestAmazonSeller
621
    return t_comp
12363 kshitij.so 622
 
623
def to_t_amazon_promotion(amazonPromotion):
624
    t_amazonPromotion = TAmazonPromotion()
625
    t_amazonPromotion.sku = amazonPromotion.sku
626
    t_amazonPromotion.startDate = to_java_date(datetime.datetime.combine(amazonPromotion.startDate, datetime.datetime.min.time()))
627
    t_amazonPromotion.endDate = to_java_date(datetime.datetime.combine(amazonPromotion.endDate, datetime.datetime.min.time()))
628
    t_amazonPromotion.updatedOnMarketplace = to_java_date(amazonPromotion.updatedOnMarketplace)
629
    t_amazonPromotion.promotionActive = amazonPromotion.promotionActive
630
    t_amazonPromotion.addedOn = to_java_date(amazonPromotion.addedOn)
631
    t_amazonPromotion.standardPrice = amazonPromotion.standardPrice
632
    t_amazonPromotion.salePrice = amazonPromotion.salePrice
633
    t_amazonPromotion.stateId = amazonPromotion.stateId
634
    t_amazonPromotion.promotionType = amazonPromotion.promotionType
635
    return t_amazonPromotion
636
 
637
def to_t_Amazonlisted_promo(amazonDetails):
638
    amazonlisted = amazonDetails[0]
639
    fbaPromo = amazonDetails[1]
640
    fbbPromo = amazonDetails[2]
641
    t_amazon = to_t_Amazonlisted(amazonlisted)
642
    if not (fbaPromo is None or len(fbaPromo)==0):
643
        t_amazon.fbaSalePrice = fbaPromo[0].salePrice
644
    if not (fbbPromo is None or len(fbbPromo)==0):
645
        t_amazon.fbbSalePrice = fbbPromo[0].salePrice
646
    return t_amazon
12620 amit.gupta 647
 
648
def to_t_exclusive_affiliate_item_info(afItemInfo):
649
    tinfo = TExclusiveAffiliateItemInfo()
650
    tinfo.affiliateId = afItemInfo[0].affiliateId
651
    tinfo.active = afItemInfo[0].isActive
652
    tinfo.affiliateName = afItemInfo[1]
653
    tinfo.offerImageUrl = afItemInfo[0].offerUrl
654
    tinfo.offerText = afItemInfo[0].offerText
655
    tinfo.itemId = afItemInfo[0].itemId
656
    tinfo.mOfferImageUrl = afItemInfo[0].mOfferUrl
657
    tinfo.mOfferText = afItemInfo[0].mOfferText
658
    tinfo.affiliateUrl = afItemInfo[0].affiliateUrl
659
    return tinfo
12363 kshitij.so 660
 
661
 
12256 kshitij.so 662