Subversion Repositories SmartDukaan

Rev

Rev 12663 | Rev 13709 | 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
12663 kshitij.so 241
    t_amazonlisted.fbaPromoPrice = Amazonlisted.fbaPromoPrice
242
    t_amazonlisted.fbbPromoPrice = Amazonlisted.fbbPromoPrice
243
    t_amazonlisted.fbaPromoStartDate = to_java_date(Amazonlisted.fbaPromoStartDate)
244
    t_amazonlisted.fbaPromoEndDate = to_java_date(Amazonlisted.fbaPromoEndDate)
245
    t_amazonlisted.fbbPromoStartDate = to_java_date(Amazonlisted.fbbPromoStartDate)
246
    t_amazonlisted.fbbPromoEndDate = to_java_date(Amazonlisted.fbbPromoEndDate)
247
    t_amazonlisted.isFbaPromotionActive = Amazonlisted.fbaPromotionActive
248
    t_amazonlisted.isFbbPromotionActive = Amazonlisted.fbbPromotionActive
12888 kshitij.so 249
    t_amazonlisted.fbgPrice = Amazonlisted.fbgPrice
250
    t_amazonlisted.isFbg = Amazonlisted.isFbg
251
    t_amazonlisted.fbgtaxCode = Amazonlisted.fbgtaxCode
252
    t_amazonlisted.suppressFbgPriceUpdate = Amazonlisted.suppressFbgPriceUpdate
253
    t_amazonlisted.fbgPriceLastUpdatedOn = to_java_date(Amazonlisted.fbgPriceLastUpdatedOn)
254
    t_amazonlisted.fbgPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbgPriceLastUpdatedOnSc)
255
    t_amazonlisted.fbgPromoPrice = Amazonlisted.fbgPromoPrice
256
    t_amazonlisted.fbgPromoStartDate = to_java_date(Amazonlisted.fbgPromoStartDate)
257
    t_amazonlisted.fbgPromoEndDate = to_java_date(Amazonlisted.fbgPromoEndDate)
258
    t_amazonlisted.isFbgPromotionActive = Amazonlisted.fbgPromotionActive 
7291 vikram.rag 259
    return t_amazonlisted
260
 
8182 amar.kumar 261
def to_t_ebay_item(ebay_item):
262
    t_ebay_item = TEbayItem()
263
    t_ebay_item.ebayListingId = ebay_item.ebayListingId
264
    t_ebay_item.itemId = ebay_item.itemId
265
    t_ebay_item.listingName = ebay_item.listingName
266
    t_ebay_item.listingPrice = ebay_item.listingPrice
267
    t_ebay_item.listingExpiryDate = to_java_date(ebay_item.listingExpiryDate)
268
    t_ebay_item.subsidy = ebay_item.subsidy
8274 amit.gupta 269
    return t_ebay_item
270
 
271
def to_t_brand_info(brand_info):
272
    t_brand_info = TBrandInfo()
273
    t_brand_info.name = brand_info.name
274
    t_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrl
8739 vikram.rag 275
    return t_brand_info
276
 
277
def to_t_snapdeal_item(snapdealitem):
8754 vikram.rag 278
    if snapdealitem is None:
8746 vikram.rag 279
        t_snapdeal_item = TSnapdealItem()
280
        return t_snapdeal_item
8739 vikram.rag 281
    t_snapdeal_item = TSnapdealItem()
8754 vikram.rag 282
    t_snapdeal_item.item_id = snapdealitem[0].item_id
8739 vikram.rag 283
    t_snapdeal_item.warehouseId = snapdealitem[0].warehouseId
284
    t_snapdeal_item.exceptionPrice = snapdealitem[0].exceptionPrice
9242 kshitij.so 285
    t_snapdeal_item.transferPrice = snapdealitem[0].transferPrice
286
    t_snapdeal_item.sellingPrice = snapdealitem[0].sellingPrice
287
    t_snapdeal_item.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 288
    t_snapdeal_item.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 289
    t_snapdeal_item.commission = snapdealitem[0].commission
290
    t_snapdeal_item.serviceTax = snapdealitem[0].serviceTax
291
    t_snapdeal_item.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
292
    t_snapdeal_item.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
293
    t_snapdeal_item.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9404 vikram.rag 294
    t_snapdeal_item.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 295
    t_snapdeal_item.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 296
    t_snapdeal_item.supc = snapdealitem[0].supc
9724 kshitij.so 297
    t_snapdeal_item.shippingTime = snapdealitem[0].shippingTime
9242 kshitij.so 298
    return t_snapdeal_item
299
 
9724 kshitij.so 300
def to_t_snapdeal_item_details(snapdealitem,snapdealItemInventory):
9242 kshitij.so 301
    if snapdealitem is None:
302
        t_snapdeal_item_details = TSnapdealItemDetails()
303
        return t_snapdeal_item_details
304
    t_snapdeal_item_details = TSnapdealItemDetails()
305
    t_snapdeal_item_details.item_id = snapdealitem[0].item_id
306
    t_snapdeal_item_details.warehouseId = snapdealitem[0].warehouseId
307
    t_snapdeal_item_details.exceptionPrice = snapdealitem[0].exceptionPrice
308
    t_snapdeal_item_details.transferPrice = snapdealitem[0].transferPrice
309
    t_snapdeal_item_details.sellingPrice = snapdealitem[0].sellingPrice
310
    t_snapdeal_item_details.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 311
    t_snapdeal_item_details.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 312
    t_snapdeal_item_details.commission = snapdealitem[0].commission
313
    t_snapdeal_item_details.serviceTax = snapdealitem[0].serviceTax
314
    t_snapdeal_item_details.brand = snapdealitem[1].brand
315
    t_snapdeal_item_details.model_name = snapdealitem[1].model_name
316
    t_snapdeal_item_details.model_number = snapdealitem[1].model_number
317
    t_snapdeal_item_details.color = snapdealitem[1].color
318
    t_snapdeal_item_details.risky = snapdealitem[1].risky
319
    t_snapdeal_item_details.itemStatus = snapdealitem[1].status
320
    t_snapdeal_item_details.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
321
    t_snapdeal_item_details.weight = snapdealitem[1].weight
322
    t_snapdeal_item_details.mrp = snapdealitem[1].mrp
323
    t_snapdeal_item_details.websiteSellingPrice = snapdealitem[1].sellingPrice
324
    t_snapdeal_item_details.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
325
    t_snapdeal_item_details.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9478 kshitij.so 326
    t_snapdeal_item_details.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 327
    t_snapdeal_item_details.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 328
    t_snapdeal_item_details.supc = snapdealitem[0].supc
9724 kshitij.so 329
    t_snapdeal_item_details.shippingTime = snapdealitem[0].shippingTime
330
    if snapdealItemInventory is not None:
331
        t_snapdeal_item_details.lastUpdatedInventory = snapdealItemInventory.availability
332
        t_snapdeal_item_details.lastUpdatedInventoryTimestamp = snapdealItemInventory.lastUpdatedOnSnapdeal 
9242 kshitij.so 333
    return t_snapdeal_item_details
9621 manish.sha 334
 
335
def to_t_product_feed_submit(productfeedsubmit):
336
    if productfeedsubmit is None:
337
        t_product_feed_submit = TProductFeedSubmit()
338
        return t_product_feed_submit
339
    t_product_feed_submit = TProductFeedSubmit()
340
    t_product_feed_submit.catalogItemId = productfeedsubmit.catalogItemId
341
    t_product_feed_submit.stockLinkedFeed = productfeedsubmit.stockLinkedFeed
9724 kshitij.so 342
    return t_product_feed_submit
343
 
344
def to_t_marketplace_items(marketplaceItem):
345
    t_marketplace_item = TMarketplaceItems() 
346
    if marketplaceItem is None:
347
        return t_marketplace_item
348
    t_marketplace_item.itemId = marketplaceItem.itemId
349
    t_marketplace_item.source = marketplaceItem.source
350
    t_marketplace_item.emiFee = marketplaceItem.emiFee
351
    t_marketplace_item.courierCost = marketplaceItem.courierCost
11095 kshitij.so 352
    t_marketplace_item.courierCostMarketplace = marketplaceItem.courierCostMarketplace
9724 kshitij.so 353
    t_marketplace_item.closingFee = marketplaceItem.closingFee
354
    t_marketplace_item.commission = marketplaceItem.commission
355
    t_marketplace_item.returnProvision = marketplaceItem.returnProvision
356
    t_marketplace_item.vat = marketplaceItem.vat
357
    t_marketplace_item.packagingCost = marketplaceItem.packagingCost
358
    t_marketplace_item.otherCost = marketplaceItem.otherCost
359
    t_marketplace_item.serviceTax = marketplaceItem.serviceTax
360
    t_marketplace_item.autoIncrement = marketplaceItem.autoIncrement
361
    t_marketplace_item.autoDecrement = marketplaceItem.autoDecrement
362
    t_marketplace_item.autoFavourite = marketplaceItem.autoFavourite
363
    t_marketplace_item.manualFavourite = marketplaceItem.manualFavourite
364
    t_marketplace_item.currentSp = marketplaceItem.currentSp
365
    t_marketplace_item.currentTp = marketplaceItem.currentTp
366
    t_marketplace_item.minimumPossibleSp = marketplaceItem.minimumPossibleSp
367
    t_marketplace_item.minimumPossibleTp = marketplaceItem.minimumPossibleTp
368
    t_marketplace_item.lastCheckedTimestamp = to_java_date(marketplaceItem.lastCheckedTimestamp)
9923 kshitij.so 369
    t_marketplace_item.maximumSellingPrice = marketplaceItem.maximumSellingPrice
10287 kshitij.so 370
    t_marketplace_item.pgFee = marketplaceItem.pgFee
9724 kshitij.so 371
    return t_marketplace_item
9776 vikram.rag 372
 
373
def to_t_marketplace_itemprice(marketplaceitemprice):
374
    t_marketplace_priceitem = TMarketPlaceItemPrice()    
375
    t_marketplace_priceitem.item_id = marketplaceitemprice.item_id
376
    t_marketplace_priceitem.source = marketplaceitemprice.source
377
    t_marketplace_priceitem.sellingPrice = marketplaceitemprice.sellingPrice
378
    t_marketplace_priceitem.lastUpdatedOn = to_java_date(marketplaceitemprice.lastUpdatedOn)
379
    t_marketplace_priceitem.lastUpdatedOnMarketplace = to_java_date(marketplaceitemprice.lastUpdatedOnMarketplace)
380
    t_marketplace_priceitem.isPriceOverride = marketplaceitemprice.suppressPriceFeed
381
    t_marketplace_priceitem.isListedOnSource = marketplaceitemprice.isListedOnSource
382
    return t_marketplace_priceitem 
9779 kshitij.so 383
 
384
def to_t_marketplacepercentage(marketplacePercentage):
385
    t_marketplacepercentage = TMarketplacePercentage()
386
    if marketplacePercentage is None:
387
        return t_marketplacepercentage
388
    t_marketplacepercentage.source =  marketplacePercentage.source
389
    t_marketplacepercentage.emiFee =  marketplacePercentage.emiFee
390
    t_marketplacepercentage.closingFee = marketplacePercentage.closingFee
391
    t_marketplacepercentage.returnProvision = marketplacePercentage.returnProvision
392
    t_marketplacepercentage.commission = marketplacePercentage.commission
393
    t_marketplacepercentage.serviceTax = marketplacePercentage.serviceTax
10287 kshitij.so 394
    t_marketplacepercentage.pgFee = marketplacePercentage.pgFee
9779 kshitij.so 395
    return t_marketplacepercentage
9945 vikram.rag 396
 
397
def to_t_flipkart_item(flipkartItem):
398
    t_flipkartitem = TFlipkartItem()
399
    if flipkartItem is None:
400
        return t_flipkartitem
10097 kshitij.so 401
    t_flipkartitem.item_id = flipkartItem[0].item_id  
402
    t_flipkartitem.exceptionPrice = flipkartItem[0].exceptionPrice
403
    t_flipkartitem.warehouseId = flipkartItem[0].warehouseId
404
    t_flipkartitem.commissionValue  =  flipkartItem[0].commissionValue
405
    t_flipkartitem.serviceTaxValue  =  flipkartItem[0].serviceTaxValue
406
    t_flipkartitem.maxNlc = flipkartItem[0].maxNlc
407
    t_flipkartitem.skuAtFlipkart = flipkartItem[0].skuAtFlipkart
408
    t_flipkartitem.isListedOnFlipkart = flipkartItem[0].isListedOnFlipkart
409
    t_flipkartitem.suppressPriceFeed = flipkartItem[0].suppressPriceFeed
410
    t_flipkartitem.suppressInventoryFeed = flipkartItem[0].suppressInventoryFeed
411
    #t_flipkartitem.updatedOn = to_java_date(flipkartItem.updatedOn)
412
    t_flipkartitem.updatedBy = flipkartItem[0].updatedBy
413
    t_flipkartitem.flipkartSerialNumber = flipkartItem[0].flipkartSerialNumber
9945 vikram.rag 414
    return t_flipkartitem
10097 kshitij.so 415
 
416
def to_t_flipkart_item_details(flipkartitem,flipkartItemInventory):
417
    if flipkartitem is None:
418
        t_flipkart_item_details = TFlipkartItemDetails()
419
        return t_flipkart_item_details
420
    t_flipkart_item_details = TFlipkartItemDetails()
421
    t_flipkart_item_details.item_id = flipkartitem[0].item_id
422
    t_flipkart_item_details.warehouseId = flipkartitem[0].warehouseId
423
    t_flipkart_item_details.exceptionPrice = flipkartitem[0].exceptionPrice
424
    t_flipkart_item_details.commission = flipkartitem[0].commissionValue
425
    t_flipkart_item_details.serviceTax = flipkartitem[0].serviceTaxValue
426
    t_flipkart_item_details.brand = flipkartitem[1].brand
427
    t_flipkart_item_details.model_name = flipkartitem[1].model_name
428
    t_flipkart_item_details.model_number = flipkartitem[1].model_number
429
    t_flipkart_item_details.color = flipkartitem[1].color
430
    t_flipkart_item_details.risky = flipkartitem[1].risky
431
    t_flipkart_item_details.itemStatus = flipkartitem[1].status
432
    t_flipkart_item_details.isListedOnFlipkart = flipkartitem[0].isListedOnFlipkart
433
    t_flipkart_item_details.weight = flipkartitem[1].weight
434
    t_flipkart_item_details.mrp = flipkartitem[1].mrp
435
    t_flipkart_item_details.websiteSellingPrice = flipkartitem[1].sellingPrice
436
    t_flipkart_item_details.suppressPriceFeed = flipkartitem[0].suppressPriceFeed
437
    t_flipkart_item_details.suppressInventoryFeed = flipkartitem[0].suppressInventoryFeed
438
    t_flipkart_item_details.maxNlc = flipkartitem[0].maxNlc
439
    t_flipkart_item_details.skuAtFlipkart = flipkartitem[0].skuAtFlipkart
440
    t_flipkart_item_details.flipkartSerialNumber = flipkartitem[0].flipkartSerialNumber
10156 amar.kumar 441
    t_flipkart_item_details.category = flipkartitem[1].category
10097 kshitij.so 442
    if flipkartItemInventory is not None:
443
        t_flipkart_item_details.lastUpdatedInventory = flipkartItemInventory.availability
444
        #t_flipkart_item_details.lastUpdatedInventoryTimestamp = flipkartItemInventory.lastUpdatedOnFlipkart 
445
    return t_flipkart_item_details
11015 kshitij.so 446
 
447
def to_t_market_place_history(marketplaceHistory):
448
    t_marketplace_history = TMarketplaceHistory()
449
    if marketplaceHistory is None:
450
        return t_marketplace_history
451
    t_marketplace_history.item_id = marketplaceHistory.item_id
452
    t_marketplace_history.source = marketplaceHistory.source
453
    t_marketplace_history.timestamp = to_java_date(marketplaceHistory.timestamp)
11076 kshitij.so 454
    if marketplaceHistory.lowestPossibleTp is None:
455
        t_marketplace_history.lowest_possible_tp =0
456
    else:
457
        t_marketplace_history.lowest_possible_tp = int(marketplaceHistory.lowestPossibleTp)
458
    if marketplaceHistory.lowestPossibleSp is None:
459
        t_marketplace_history.lowest_possible_sp = 0
460
    else:
461
        t_marketplace_history.lowest_possible_sp = int(marketplaceHistory.lowestPossibleSp)
11015 kshitij.so 462
    t_marketplace_history.ourInventory = marketplaceHistory.ourInventory
463
    t_marketplace_history.otherInventory = marketplaceHistory.otherInventory
464
    t_marketplace_history.secondLowestInventory = marketplaceHistory.secondLowestInventory
465
    t_marketplace_history.ourRank = marketplaceHistory.ourRank
11076 kshitij.so 466
    if marketplaceHistory.ourOfferPrice is None:
467
        t_marketplace_history.ourOfferPrice = 0
468
    else: 
469
        t_marketplace_history.ourOfferPrice = int(marketplaceHistory.ourOfferPrice)
470
    if marketplaceHistory.ourSellingPrice is None:
471
        t_marketplace_history.ourSellingPrice = 0
472
    else:
473
        t_marketplace_history.ourSellingPrice = int(marketplaceHistory.ourSellingPrice)
474
    if marketplaceHistory.ourTp is None:
475
        t_marketplace_history.ourTp = 0
476
    else:
477
        t_marketplace_history.ourTp = int(marketplaceHistory.ourTp)
478
    if marketplaceHistory.ourNlc is None:
479
        t_marketplace_history.ourNlc = 0
480
    else:
481
        t_marketplace_history.ourNlc = int(marketplaceHistory.ourNlc)
11015 kshitij.so 482
    t_marketplace_history.competitiveCategory = marketplaceHistory.competitiveCategory
483
    t_marketplace_history.risky = marketplaceHistory.risky
11076 kshitij.so 484
    if marketplaceHistory.lowestOfferPrice is None:
485
        t_marketplace_history.lowestOfferPrice = 0
486
    else:
487
        t_marketplace_history.lowestOfferPrice = int(marketplaceHistory.lowestOfferPrice)
488
    if marketplaceHistory.lowestSellingPrice is None:
489
        t_marketplace_history.lowestSellingPrice = 0
490
    else:
491
        t_marketplace_history.lowestSellingPrice = int(marketplaceHistory.lowestSellingPrice)
492
    if marketplaceHistory.lowestTp is None:
493
        t_marketplace_history.lowestTp = 0
494
    else:
495
        t_marketplace_history.lowestTp = int(marketplaceHistory.lowestTp)
11015 kshitij.so 496
    if marketplaceHistory.lowestSellerName is None:
497
        t_marketplace_history.lowestSellerName = ''
498
    else:
499
        t_marketplace_history.lowestSellerName = marketplaceHistory.lowestSellerName
11076 kshitij.so 500
    if marketplaceHistory.proposedSellingPrice is None:
501
        t_marketplace_history.proposedSellingPrice = 0
502
    else:
503
        t_marketplace_history.proposedSellingPrice = int(marketplaceHistory.proposedSellingPrice)
504
    if marketplaceHistory.proposedTp is None:
505
        t_marketplace_history.proposedTp = 0
506
    else:
507
        t_marketplace_history.proposedTp = int(marketplaceHistory.proposedTp)
508
    if marketplaceHistory.targetNlc is None:
509
        t_marketplace_history.targetNlc = 0
510
    else:
511
        t_marketplace_history.targetNlc = int(marketplaceHistory.targetNlc)
11015 kshitij.so 512
    t_marketplace_history.salesPotential = marketplaceHistory.salesPotential
513
    if marketplaceHistory.secondLowestSellerName is None:
514
        t_marketplace_history.secondLowestSellerName = ''
515
    else:
516
        t_marketplace_history.secondLowestSellerName = marketplaceHistory.secondLowestSellerName
11017 kshitij.so 517
    if marketplaceHistory.secondLowestSellingPrice is None:
11076 kshitij.so 518
        t_marketplace_history.secondLowestSellingPrice=0
11017 kshitij.so 519
    else:
11076 kshitij.so 520
        t_marketplace_history.secondLowestSellingPrice = int(marketplaceHistory.secondLowestSellingPrice)
11017 kshitij.so 521
    if marketplaceHistory.secondLowestOfferPrice is None:
11076 kshitij.so 522
        t_marketplace_history.secondLowestOfferPrice = 0
11017 kshitij.so 523
    else:
11076 kshitij.so 524
        t_marketplace_history.secondLowestOfferPrice = int(marketplaceHistory.secondLowestOfferPrice)
11017 kshitij.so 525
    if marketplaceHistory.secondLowestTp is None:
11076 kshitij.so 526
        t_marketplace_history.secondLowestTp=0
11017 kshitij.so 527
    else:
11076 kshitij.so 528
        t_marketplace_history.secondLowestTp = int(marketplaceHistory.secondLowestTp)
11015 kshitij.so 529
    t_marketplace_history.marginIncreasedPotential = marketplaceHistory.marginIncreasedPotential
11076 kshitij.so 530
    if marketplaceHistory.margin is None:
531
        t_marketplace_history.margin = 0
532
    else:
533
        t_marketplace_history.margin = int(marketplaceHistory.margin)
11015 kshitij.so 534
    t_marketplace_history.ourEnoughStock = marketplaceHistory.ourEnoughStock
535
    t_marketplace_history.totalSeller = marketplaceHistory.totalSeller
536
    t_marketplace_history.averageSale = marketplaceHistory.avgSales
537
    t_marketplace_history.toGroup = marketplaceHistory.toGroup
11076 kshitij.so 538
    t_marketplace_history.decision = marketplaceHistory.decision
539
    t_marketplace_history.reason = marketplaceHistory.reason
11015 kshitij.so 540
    return t_marketplace_history
9945 vikram.rag 541
 
11531 vikram.rag 542
def to_t_private_deal(private_deal_item):
543
    if private_deal_item is None:
544
        t_private_deal_item = TPrivateDeal()
545
        return t_private_deal_item
546
    t_private_deal_item = TPrivateDeal()
547
    t_private_deal_item.item_id = private_deal_item.item_id
548
    t_private_deal_item.dealPrice = private_deal_item.dealPrice
549
    t_private_deal_item.dealFreebieItemId = private_deal_item.dealFreebieItemId
11579 vikram.rag 550
    t_private_deal_item.startDate = to_java_date(private_deal_item.startDate)
551
    t_private_deal_item.endDate = to_java_date(private_deal_item.endDate)
11566 vikram.rag 552
    t_private_deal_item.dealTextOption = private_deal_item.dealTextOption
11635 vikram.rag 553
    if private_deal_item.dealText is None: 
11613 vikram.rag 554
        t_private_deal_item.dealText = ''
555
    else:
556
        t_private_deal_item.dealText = private_deal_item.dealText    
11531 vikram.rag 557
    t_private_deal_item.isCod = private_deal_item.isCod
558
    t_private_deal_item.rank = private_deal_item.rank
11566 vikram.rag 559
    t_private_deal_item.dealFreebieOption = private_deal_item.dealFreebieOption
11606 vikram.rag 560
    t_private_deal_item.isActive = private_deal_item.isActive
11905 kshitij.so 561
    return t_private_deal_item
562
 
563
def to_t_amazonoutofsync(amazonOutOfSync):
564
    t_amazonoutofsync = TAmazonOutOfSync()
565
    if amazonOutOfSync is None:
566
        return t_amazonoutofsync
567
    else:
568
        t_amazonoutofsync.item_id = amazonOutOfSync.item_id
569
        t_amazonoutofsync.mfn = amazonOutOfSync.mfn
570
        t_amazonoutofsync.fba = amazonOutOfSync.fba
571
        t_amazonoutofsync.fbb = amazonOutOfSync.fbb
572
        return t_amazonoutofsync
573
 
574
def to_t_private_deals_comparison(item):
575
    xstr = lambda s: s or ""
576
    t_pdcomp = TPdPriceComp()
577
    pdComp = item[0]
578
    catItem  = item[1]
579
    t_pdcomp.item_id = pdComp.item_id
580
    t_pdcomp.dealPrice = pdComp.dealPrice
581
    t_pdcomp.saholicPrice = pdComp.saholicPrice
582
    t_pdcomp.sdPrice = pdComp.sdPrice
583
    t_pdcomp.fkPrice = pdComp.fkPrice
584
    t_pdcomp.amazonPrice = pdComp.amazonPrice
585
    t_pdcomp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
12169 kshitij.so 586
    t_pdcomp.lastProcessedTimestamp = to_java_date(pdComp.lastProcessedTimestamp)
11905 kshitij.so 587
    return t_pdcomp
588
 
12133 kshitij.so 589
def to_t_snapdeal_marketplace_item(item):
590
    mpItem = item[1]
591
    dItem = item[2]
592
    t_sd_item = to_t_snapdeal_item(item)
593
    t_sd_item.marketplaceItems = to_t_marketplace_items(mpItem)
594
    t_sd_item.item = to_t_item(dItem)
595
    return t_sd_item
596
 
597
def to_t_flipkart_marketplace_item(item):
598
    mpItem = item[1]
599
    dItem = item[2]
600
    t_fk_item = to_t_flipkart_item(item)
601
    t_fk_item.marketplaceItems = to_t_marketplace_items(mpItem)
602
    t_fk_item.item = to_t_item(dItem)
603
    return t_fk_item
12243 kshitij.so 604
 
12256 kshitij.so 605
def to_t_competitor_pricing(compPricing):
606
    xstr = lambda s: s or ""
607
    item = compPricing[0]
608
    catItem = compPricing[1]
609
    t_comp = TCompetitorPricing()
610
    t_comp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
611
    t_comp.item_id = item.item_id
612
    t_comp.lowestSnapdealPrice = item.lowestSnapdealPrice
613
    t_comp.lowestFlipkartPrice = item.lowestFlipkartPrice
614
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
615
    t_comp.ourSnapdealPrice = item.ourSnapdealPrice
616
    t_comp.ourSnapdealOfferPrice = item.ourSnapdealOfferPrice
617
    t_comp.ourSnapdealInventory = item.ourSnapdealInventory
618
    t_comp.lowestSnapdealOfferPrice = item.lowestSnapdealOfferPrice
619
    if item.lowestSnapdealSeller is None:
620
        t_comp.lowestSnapdealSeller=''
621
    else:
622
        t_comp.lowestSnapdealSeller = item.lowestSnapdealSeller
623
    t_comp.lowestSnapdealSellerInventory = item.lowestSnapdealSellerInventory
624
    t_comp.ourFlipkartPrice = item.ourFlipkartPrice
625
    t_comp.ourFlipkartInventory = item.ourFlipkartInventory
626
    if item.lowestFlipkartSeller is None:
627
        t_comp.lowestFlipkartSeller=''
628
    else:
629
        t_comp.lowestFlipkartSeller = item.lowestFlipkartSeller
630
    t_comp.ourMfnPrice = item.ourMfnPrice
631
    t_comp.ourFbaPrice = item.ourFbaPrice
632
    t_comp.ourMfnInventory = item.ourMfnInventory
633
    t_comp.ourFbaInventory = item.ourFbaInventory
634
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
635
    if item.lowestAmazonSeller is None:
636
        t_comp.lowestAmazonSeller=''
637
    else:
638
        t_comp.lowestAmazonSeller = item.lowestAmazonSeller
639
    return t_comp
12363 kshitij.so 640
 
641
def to_t_amazon_promotion(amazonPromotion):
642
    t_amazonPromotion = TAmazonPromotion()
643
    t_amazonPromotion.sku = amazonPromotion.sku
644
    t_amazonPromotion.startDate = to_java_date(datetime.datetime.combine(amazonPromotion.startDate, datetime.datetime.min.time()))
645
    t_amazonPromotion.endDate = to_java_date(datetime.datetime.combine(amazonPromotion.endDate, datetime.datetime.min.time()))
646
    t_amazonPromotion.updatedOnMarketplace = to_java_date(amazonPromotion.updatedOnMarketplace)
647
    t_amazonPromotion.promotionActive = amazonPromotion.promotionActive
648
    t_amazonPromotion.addedOn = to_java_date(amazonPromotion.addedOn)
649
    t_amazonPromotion.standardPrice = amazonPromotion.standardPrice
650
    t_amazonPromotion.salePrice = amazonPromotion.salePrice
651
    t_amazonPromotion.stateId = amazonPromotion.stateId
652
    t_amazonPromotion.promotionType = amazonPromotion.promotionType
653
    return t_amazonPromotion
654
 
655
def to_t_Amazonlisted_promo(amazonDetails):
656
    amazonlisted = amazonDetails[0]
657
    fbaPromo = amazonDetails[1]
658
    fbbPromo = amazonDetails[2]
12888 kshitij.so 659
    fbgPromo = amazonDetails[3]
12363 kshitij.so 660
    t_amazon = to_t_Amazonlisted(amazonlisted)
661
    if not (fbaPromo is None or len(fbaPromo)==0):
12663 kshitij.so 662
        t_amazon.maxFbaSalePrice = fbaPromo[0].salePrice
12363 kshitij.so 663
    if not (fbbPromo is None or len(fbbPromo)==0):
12663 kshitij.so 664
        t_amazon.maxFbbSalePrice = fbbPromo[0].salePrice
12888 kshitij.so 665
    if not (fbgPromo is None or len(fbgPromo)==0):
666
        t_amazon.maxFbgSalePrice = fbgPromo[0].salePrice
12363 kshitij.so 667
    return t_amazon
12620 amit.gupta 668
 
669
def to_t_exclusive_affiliate_item_info(afItemInfo):
670
    tinfo = TExclusiveAffiliateItemInfo()
671
    tinfo.affiliateId = afItemInfo[0].affiliateId
672
    tinfo.active = afItemInfo[0].isActive
673
    tinfo.affiliateName = afItemInfo[1]
674
    tinfo.offerImageUrl = afItemInfo[0].offerUrl
675
    tinfo.offerText = afItemInfo[0].offerText
676
    tinfo.itemId = afItemInfo[0].itemId
677
    tinfo.mOfferImageUrl = afItemInfo[0].mOfferUrl
678
    tinfo.mOfferText = afItemInfo[0].mOfferText
679
    tinfo.affiliateUrl = afItemInfo[0].affiliateUrl
680
    return tinfo
12363 kshitij.so 681
 
682
 
12256 kshitij.so 683