Subversion Repositories SmartDukaan

Rev

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