Subversion Repositories SmartDukaan

Rev

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