Subversion Repositories SmartDukaan

Rev

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