Rev 23156 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 23-Mar-2010@author: ashish'''from shop2020.model.v1.catalog.impl.DataService import Insurer, SnapdealItem, Item,\ExclusiveAffiliateItemInfofrom shop2020.thriftpy.model.v1.catalog.ttypes import Item, Category, \SourceItemPricing, Source, ItemType, \ProductNotificationRequest as TProductNotificationRequest, \ProductNotificationRequestCount as TProductNotificationRequestCount, \VoucherItemMapping, EntityTag as TEntityTag, Banner as TBanner, BannerMap as TBannerMap, \Insurer as TInsurer, BrandInfo as TBrandInfo, Amazonlisted as TAmazonlisted, \EbayItem as TEbayItem, BannerUriMapping as TBannerUriMapping, Campaign as TCampaign, \SnapdealItem as TSnapdealItem, SnapdealItemDetails as TSnapdealItemDetails,ProductFeedSubmit as TProductFeedSubmit, \MarketplaceItems as TMarketplaceItems, MarketplacePercentage as TMarketplacePercentage, \MarketPlaceItemPrice as TMarketPlaceItemPrice, FlipkartItem as TFlipkartItem,\FlipkartItemDetails as TFlipkartItemDetails,MarketplaceHistory as TMarketplaceHistory,\PrivateDeal as TPrivateDeal, AmazonOutOfSync as TAmazonOutOfSync, PdPriceComp as TPdPriceComp, CompetitorPricing as TCompetitorPricing, \AmazonPromotion as TAmazonPromotion, ExclusiveAffiliateItemInfo as TExclusiveAffiliateItemInfo, \HsItem as THsItem, VoiSnapdealItemInfo as TVoiSnapdealItemInfo, BulkItemPricing as TBulkItemPricing, DtrPricing as TDtrPricing, \CategoryHsnCode as TCategoryHsnCode, StateGstRatefrom shop2020.utils.Utils import to_java_date, to_py_dateimport datetimedef to_t_item(item, dealPrice=None):t_item = Item()if item is None:return t_itemt_item.id = item.idt_item.dealPrice = dealPricet_item.productGroup = item.product_groupt_item.brand = item.brandt_item.modelNumber = item.model_numbert_item.modelName = item.model_namet_item.color = item.colort_item.category = item.categoryt_item.catalogItemId = item.catalog_item_idt_item.weight = item.weightt_item.featureId = item.feature_idt_item.featureDescription = item.feature_descriptionif item.startDate:t_item.startDate = to_java_date(item.startDate)if item.comingSoonStartDate:t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)if item.expectedArrivalDate:t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)if item.addedOn:t_item.addedOn = to_java_date(item.addedOn)if item.updatedOn:t_item.updatedOn = to_java_date(item.updatedOn)t_item.itemStatus = item.statust_item.status_description = item.status_descriptionif item.sellingPrice:t_item.sellingPrice = item.sellingPriceif item.mrp:t_item.mrp = item.mrpif item.comments:t_item.comments = item.commentsif item.bestDealText:t_item.bestDealText = item.bestDealTextif item.bestDealsDetailsText:t_item.bestDealsDetailsText = item.bestDealsDetailsTextif item.bestDealsDetailsLink:t_item.bestDealsDetailsLink = item.bestDealsDetailsLinkif item.bestDealValue:t_item.bestDealValue = item.bestDealValueif item.asin:t_item.asin = item.asint_item.defaultForEntity = item.defaultForEntityt_item.bestSellingRank = item.bestSellingRankt_item.risky = item.riskyt_item.expectedDelay = item.expectedDelayt_item.isWarehousePreferenceSticky = item.isWarehousePreferenceStickyt_item.warrantyPeriod = item.warranty_periodt_item.preferredVendor = item.preferredVendort_item.type = ItemType._NAMES_TO_VALUES[item.type]t_item.hasItemNo = item.hasItemNot_item.activeOnStore = item.activeOnStoret_item.showSellingPrice = item.showSellingPricet_item.preferredInsurer = item.preferredInsurert_item.holdInventory = item.holdInventoryt_item.defaultInventory = item.defaultInventoryt_item.holdOverride = item.holdOverridet_item.packQuantity = item.packQuantityt_item.quantityStep = item.quantityStept_item.minimumBuyQuantity = item.minimumBuyQuantityt_item.maximumBuyQuantity = item.maximumBuyQuantityt_item.hsnCode = item.hsnCodereturn t_itemdef to_t_insurer(insurer):t_insurer = TInsurer()t_insurer.id = insurer.idt_insurer.name = insurer.namet_insurer.address = insurer.addresst_insurer.declaredAmount = insurer.declaredAmountt_insurer.creditedAmount = insurer.creditedAmountreturn t_insurerdef to_t_state_gst_rate(stateGstRate):t_state_gst_rate = StateGstRate()t_state_gst_rate.itemId = stateGstRate.itemIdt_state_gst_rate.stateId = stateGstRate.stateIdt_state_gst_rate.igstRate = stateGstRate.igstRatet_state_gst_rate.cgstRate = stateGstRate.cgstRatet_state_gst_rate.sgstRate = stateGstRate.sgstRatereturn t_state_gst_ratedef to_t_voucher_item_mapping(voucher):t_voucher = VoucherItemMapping()t_voucher.voucherType = voucher.voucherTypet_voucher.itemId = voucher.item.idt_voucher.amount = voucher.amountreturn t_voucherdef to_t_category(category):t_category = Category()t_category.id = category.idt_category.label = category.labelt_category.description = category.descriptiont_category.parent_category_id = category.parent_category_idt_category.display_name = category.display_namereturn t_categorydef to_t_source_item_pricing(source_item_pricing):t_source_item_pricing = SourceItemPricing()t_source_item_pricing.sourceId = source_item_pricing.source.idt_source_item_pricing.itemId = source_item_pricing.item.idt_source_item_pricing.mrp = source_item_pricing.mrpt_source_item_pricing.sellingPrice = source_item_pricing.sellingPricereturn t_source_item_pricingdef to_t_source(source):t_source = Source()t_source.id = source.idt_source.name = source.namet_source.identifier = source.identifierreturn t_sourcedef to_t_product_notification_request(product_notification_request):t_product_notification_request = TProductNotificationRequest()if product_notification_request:t_product_notification_request.item = to_t_item(product_notification_request.item)t_product_notification_request.email = product_notification_request.emailt_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)return t_product_notification_requestdef to_t_product_notification_request_count(product_notification_request_count):t_product_notification_request_count = TProductNotificationRequestCount()if product_notification_request_count:item, count = product_notification_request_countt_product_notification_request_count.item = to_t_item(item)t_product_notification_request_count.count = countreturn t_product_notification_request_countdef to_t_entity_tag(entity_tag):t_entity_tag = TEntityTag()t_entity_tag.entityId = entity_tag.entityIdt_entity_tag.tag = entity_tag.tagdef to_t_banner(banner):t_banner = TBanner()t_banner.bannerName = banner.bannerNamet_banner.imageName = banner.imageNamet_banner.link = banner.linkt_banner.priority = banner.priorityt_banner.hasMap = banner.hasMapt_banner.bannerType = banner.bannerTypereturn t_bannerdef to_t_banner_list(bannerList):t_banner_list = []for banner in bannerList:t_banner = TBanner()t_banner.bannerName = banner.bannerNamet_banner.imageName = banner.imageNamet_banner.link = banner.linkt_banner.priority = banner.priorityt_banner.hasMap = banner.hasMapt_banner.bannerType = banner.bannerTypet_banner_list.append(t_banner)return t_banner_listdef to_t_banner_map(banner_map):t_banner_map = TBannerMap()t_banner_map.bannerName = banner_map.bannerNamet_banner_map.mapLink = banner_map.mapLinkt_banner_map.coordinates = banner_map.coordinatesreturn t_banner_mapdef to_t_uri_mapping(uriMapping):t_uri_mapping =TBannerUriMapping()t_uri_mapping.bannerName = uriMapping.bannerNamet_uri_mapping.uri = uriMapping.urit_uri_mapping.isActive = uriMapping.isActivet_uri_mapping.target = uriMapping.targetreturn t_uri_mappingdef to_t_campaign(campaign):t_campaign = TCampaign()t_campaign.id = campaign.idt_campaign.campaignName = campaign.campaignNamet_campaign.imageName = campaign.imageNamereturn t_campaigndef to_t_Amazonlisted(Amazonlisted):t_amazonlisted = TAmazonlisted()if Amazonlisted is None:return t_amazonlistedt_amazonlisted.asin = Amazonlisted.asint_amazonlisted.brand = Amazonlisted.brandt_amazonlisted.itemid = Amazonlisted.itemIdt_amazonlisted.model = Amazonlisted.modelt_amazonlisted.manufacturer_name = Amazonlisted.manufacturer_namet_amazonlisted.upc = Amazonlisted.upct_amazonlisted.part_number = Amazonlisted.part_numbert_amazonlisted.name = Amazonlisted.namet_amazonlisted.ean = Amazonlisted.eant_amazonlisted.fbaPrice = Amazonlisted.fbaPricet_amazonlisted.fbbPrice = Amazonlisted.fbbPricet_amazonlisted.sellingPrice = Amazonlisted.sellingPricet_amazonlisted.isFba = Amazonlisted.isFbat_amazonlisted.isFbb = Amazonlisted.isFbbt_amazonlisted.isNonFba = Amazonlisted.isNonFbat_amazonlisted.isInventoryOverride = Amazonlisted.isInventoryOverridet_amazonlisted.color = Amazonlisted.colort_amazonlisted.category = Amazonlisted.categoryt_amazonlisted.handlingTime = Amazonlisted.handlingTimet_amazonlisted.isCustomTime = Amazonlisted.isCustomTimet_amazonlisted.category_code = Amazonlisted.category_codet_amazonlisted.mfnPriceLastUpdatedOn = to_java_date(Amazonlisted.mfnPriceLastUpdatedOn)t_amazonlisted.fbaPriceLastUpdatedOn = to_java_date(Amazonlisted.fbaPriceLastUpdatedOn)t_amazonlisted.fbbPriceLastUpdatedOn = to_java_date(Amazonlisted.fbbPriceLastUpdatedOn)t_amazonlisted.mfnPriceLastUpdatedOnSc = to_java_date(Amazonlisted.mfnPriceLastUpdatedOnSc)t_amazonlisted.fbbPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbbPriceLastUpdatedOnSc)t_amazonlisted.fbaPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbaPriceLastUpdatedOnSc)t_amazonlisted.suppressMfnPriceUpdate = Amazonlisted.suppressMfnPriceUpdatet_amazonlisted.suppressFbaPriceUpdate = Amazonlisted.suppressFbaPriceUpdatet_amazonlisted.suppressFbbPriceUpdate = Amazonlisted.suppressFbbPriceUpdatet_amazonlisted.taxCode = Amazonlisted.taxCodet_amazonlisted.fbbtaxCode = Amazonlisted.fbbtaxCodet_amazonlisted.overrrideWanlc = Amazonlisted.overrrideWanlct_amazonlisted.exceptionalWanlc = Amazonlisted.exceptionalWanlct_amazonlisted.autoDecrement = Amazonlisted.autoDecrementt_amazonlisted.autoIncrement = Amazonlisted.autoIncrementt_amazonlisted.autoFavourite = Amazonlisted.autoFavouritet_amazonlisted.manualFavourite = Amazonlisted.manualFavouritet_amazonlisted.otherCost = Amazonlisted.otherCostt_amazonlisted.fbaPromoPrice = Amazonlisted.fbaPromoPricet_amazonlisted.fbbPromoPrice = Amazonlisted.fbbPromoPricet_amazonlisted.fbaPromoStartDate = to_java_date(Amazonlisted.fbaPromoStartDate)t_amazonlisted.fbaPromoEndDate = to_java_date(Amazonlisted.fbaPromoEndDate)t_amazonlisted.fbbPromoStartDate = to_java_date(Amazonlisted.fbbPromoStartDate)t_amazonlisted.fbbPromoEndDate = to_java_date(Amazonlisted.fbbPromoEndDate)t_amazonlisted.isFbaPromotionActive = Amazonlisted.fbaPromotionActivet_amazonlisted.isFbbPromotionActive = Amazonlisted.fbbPromotionActivet_amazonlisted.fbgPrice = Amazonlisted.fbgPricet_amazonlisted.isFbg = Amazonlisted.isFbgt_amazonlisted.fbgtaxCode = Amazonlisted.fbgtaxCodet_amazonlisted.suppressFbgPriceUpdate = Amazonlisted.suppressFbgPriceUpdatet_amazonlisted.fbgPriceLastUpdatedOn = to_java_date(Amazonlisted.fbgPriceLastUpdatedOn)t_amazonlisted.fbgPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbgPriceLastUpdatedOnSc)t_amazonlisted.fbgPromoPrice = Amazonlisted.fbgPromoPricet_amazonlisted.fbgPromoStartDate = to_java_date(Amazonlisted.fbgPromoStartDate)t_amazonlisted.fbgPromoEndDate = to_java_date(Amazonlisted.fbgPromoEndDate)t_amazonlisted.isFbgPromotionActive = Amazonlisted.fbgPromotionActivet_amazonlisted.fbdPrice = Amazonlisted.fbdPricet_amazonlisted.isFbd = Amazonlisted.isFbdt_amazonlisted.fbdtaxCode = Amazonlisted.fbdtaxCodet_amazonlisted.suppressFbdPriceUpdate = Amazonlisted.suppressFbdPriceUpdatet_amazonlisted.fbdPriceLastUpdatedOn = to_java_date(Amazonlisted.fbdPriceLastUpdatedOn)t_amazonlisted.fbdPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbdPriceLastUpdatedOnSc)t_amazonlisted.fbdPromoPrice = Amazonlisted.fbdPromoPricet_amazonlisted.fbdPromoStartDate = to_java_date(Amazonlisted.fbdPromoStartDate)t_amazonlisted.fbdPromoEndDate = to_java_date(Amazonlisted.fbdPromoEndDate)t_amazonlisted.isFbdPromotionActive = Amazonlisted.fbdPromotionActivereturn t_amazonlisteddef to_t_ebay_item(ebay_item):t_ebay_item = TEbayItem()t_ebay_item.ebayListingId = ebay_item.ebayListingIdt_ebay_item.itemId = ebay_item.itemIdt_ebay_item.listingName = ebay_item.listingNamet_ebay_item.listingPrice = ebay_item.listingPricet_ebay_item.listingExpiryDate = to_java_date(ebay_item.listingExpiryDate)t_ebay_item.subsidy = ebay_item.subsidyreturn t_ebay_itemdef to_t_brand_info(brand_info):t_brand_info = TBrandInfo()t_brand_info.name = brand_info.namet_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrlreturn t_brand_infodef to_t_snapdeal_item(snapdealitem):if snapdealitem is None:t_snapdeal_item = TSnapdealItem()return t_snapdeal_itemt_snapdeal_item = TSnapdealItem()t_snapdeal_item.item_id = snapdealitem[0].item_idt_snapdeal_item.warehouseId = snapdealitem[0].warehouseIdt_snapdeal_item.exceptionPrice = snapdealitem[0].exceptionPricet_snapdeal_item.transferPrice = snapdealitem[0].transferPricet_snapdeal_item.sellingPrice = snapdealitem[0].sellingPricet_snapdeal_item.courierCost = snapdealitem[0].courierCostt_snapdeal_item.courierCostMarketplace = snapdealitem[0].courierCostMarketplacet_snapdeal_item.commission = snapdealitem[0].commissiont_snapdeal_item.serviceTax = snapdealitem[0].serviceTaxt_snapdeal_item.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdealt_snapdeal_item.suppressPriceFeed = snapdealitem[0].suppressPriceFeedt_snapdeal_item.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeedt_snapdeal_item.maxNlc = snapdealitem[0].maxNlct_snapdeal_item.skuAtSnapdeal = snapdealitem[0].skuAtSnapdealt_snapdeal_item.supc = snapdealitem[0].supct_snapdeal_item.shippingTime = snapdealitem[0].shippingTimet_snapdeal_item.isVoiListed = snapdealitem[0].isVoiListedt_snapdeal_item.voiSellingPrice = snapdealitem[0].voiSellingPricet_snapdeal_item.suppressVoiPriceFeed = snapdealitem[0].suppressVoiPriceFeedt_snapdeal_item.voiPriceLastUpdatedOn = to_java_date(snapdealitem[0].voiPriceLastUpdatedOn)t_snapdeal_item.voiSkuAtSnapdeal = snapdealitem[0].voiSkuAtSnapdealt_snapdeal_item.minimumPossibleSpVoi = snapdealitem[0].minimumPossibleSpVoit_snapdeal_item.minimumPossibleTpVoi = snapdealitem[0].minimumPossibleTpVoit_snapdeal_item.courierCostVoi = snapdealitem[0].courierCostVoit_snapdeal_item.serviceTaxVoi = snapdealitem[0].serviceTaxVoit_snapdeal_item.transferPriceVoi = snapdealitem[0].transferPriceVoit_snapdeal_item.commissionVoi = snapdealitem[0].commissionVoit_snapdeal_item.courierCostMarketplaceVoi = snapdealitem[0].courierCostMarketplaceVoit_snapdeal_item.commissionPercentageVoi = snapdealitem[0].commissionPercentageVoireturn t_snapdeal_itemdef to_t_snapdeal_item_details(snapdealitem,snapdealItemInventory):if snapdealitem is None:t_snapdeal_item_details = TSnapdealItemDetails()return t_snapdeal_item_detailst_snapdeal_item_details = TSnapdealItemDetails()t_snapdeal_item_details.item_id = snapdealitem[0].item_idt_snapdeal_item_details.warehouseId = snapdealitem[0].warehouseIdt_snapdeal_item_details.exceptionPrice = snapdealitem[0].exceptionPricet_snapdeal_item_details.transferPrice = snapdealitem[0].transferPricet_snapdeal_item_details.sellingPrice = snapdealitem[0].sellingPricet_snapdeal_item_details.courierCost = snapdealitem[0].courierCostt_snapdeal_item_details.courierCostMarketplace = snapdealitem[0].courierCostMarketplacet_snapdeal_item_details.commission = snapdealitem[0].commissiont_snapdeal_item_details.serviceTax = snapdealitem[0].serviceTaxt_snapdeal_item_details.brand = snapdealitem[1].brandt_snapdeal_item_details.model_name = snapdealitem[1].model_namet_snapdeal_item_details.model_number = snapdealitem[1].model_numbert_snapdeal_item_details.color = snapdealitem[1].colort_snapdeal_item_details.risky = snapdealitem[1].riskyt_snapdeal_item_details.itemStatus = snapdealitem[1].statust_snapdeal_item_details.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdealt_snapdeal_item_details.weight = snapdealitem[1].weightt_snapdeal_item_details.mrp = snapdealitem[1].mrpt_snapdeal_item_details.websiteSellingPrice = snapdealitem[1].sellingPricet_snapdeal_item_details.suppressPriceFeed = snapdealitem[0].suppressPriceFeedt_snapdeal_item_details.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeedt_snapdeal_item_details.maxNlc = snapdealitem[0].maxNlct_snapdeal_item_details.skuAtSnapdeal = snapdealitem[0].skuAtSnapdealt_snapdeal_item_details.supc = snapdealitem[0].supct_snapdeal_item_details.shippingTime = snapdealitem[0].shippingTimet_snapdeal_item_details.isVoiListed = snapdealitem[0].isVoiListedif snapdealItemInventory is not None:t_snapdeal_item_details.lastUpdatedInventory = snapdealItemInventory.availabilityt_snapdeal_item_details.lastUpdatedInventoryTimestamp = snapdealItemInventory.lastUpdatedOnSnapdealreturn t_snapdeal_item_detailsdef to_t_product_feed_submit(productfeedsubmit):if productfeedsubmit is None:t_product_feed_submit = TProductFeedSubmit()return t_product_feed_submitt_product_feed_submit = TProductFeedSubmit()t_product_feed_submit.catalogItemId = productfeedsubmit.catalogItemIdt_product_feed_submit.stockLinkedFeed = productfeedsubmit.stockLinkedFeedreturn t_product_feed_submitdef to_t_marketplace_items(marketplaceItem):t_marketplace_item = TMarketplaceItems()if marketplaceItem is None:return t_marketplace_itemt_marketplace_item.itemId = marketplaceItem.itemIdt_marketplace_item.source = marketplaceItem.sourcet_marketplace_item.emiFee = marketplaceItem.emiFeet_marketplace_item.courierCost = marketplaceItem.courierCostt_marketplace_item.courierCostMarketplace = marketplaceItem.courierCostMarketplacet_marketplace_item.closingFee = marketplaceItem.closingFeet_marketplace_item.commission = marketplaceItem.commissiont_marketplace_item.returnProvision = marketplaceItem.returnProvisiont_marketplace_item.vat = marketplaceItem.vatt_marketplace_item.packagingCost = marketplaceItem.packagingCostt_marketplace_item.otherCost = marketplaceItem.otherCostt_marketplace_item.serviceTax = marketplaceItem.serviceTaxt_marketplace_item.autoIncrement = marketplaceItem.autoIncrementt_marketplace_item.autoDecrement = marketplaceItem.autoDecrementt_marketplace_item.autoFavourite = marketplaceItem.autoFavouritet_marketplace_item.manualFavourite = marketplaceItem.manualFavouritet_marketplace_item.currentSp = marketplaceItem.currentSpt_marketplace_item.currentTp = marketplaceItem.currentTpt_marketplace_item.minimumPossibleSp = marketplaceItem.minimumPossibleSpt_marketplace_item.minimumPossibleTp = marketplaceItem.minimumPossibleTpt_marketplace_item.lastCheckedTimestamp = to_java_date(marketplaceItem.lastCheckedTimestamp)t_marketplace_item.maximumSellingPrice = marketplaceItem.maximumSellingPricet_marketplace_item.pgFee = marketplaceItem.pgFeereturn t_marketplace_itemdef to_t_marketplace_itemprice(marketplaceitemprice):t_marketplace_priceitem = TMarketPlaceItemPrice()t_marketplace_priceitem.item_id = marketplaceitemprice.item_idt_marketplace_priceitem.source = marketplaceitemprice.sourcet_marketplace_priceitem.sellingPrice = marketplaceitemprice.sellingPricet_marketplace_priceitem.lastUpdatedOn = to_java_date(marketplaceitemprice.lastUpdatedOn)t_marketplace_priceitem.lastUpdatedOnMarketplace = to_java_date(marketplaceitemprice.lastUpdatedOnMarketplace)t_marketplace_priceitem.isPriceOverride = marketplaceitemprice.suppressPriceFeedt_marketplace_priceitem.isListedOnSource = marketplaceitemprice.isListedOnSourcereturn t_marketplace_priceitemdef to_t_marketplacepercentage(marketplacePercentage):t_marketplacepercentage = TMarketplacePercentage()if marketplacePercentage is None:return t_marketplacepercentaget_marketplacepercentage.source = marketplacePercentage.sourcet_marketplacepercentage.emiFee = marketplacePercentage.emiFeet_marketplacepercentage.closingFee = marketplacePercentage.closingFeet_marketplacepercentage.returnProvision = marketplacePercentage.returnProvisiont_marketplacepercentage.commission = marketplacePercentage.commissiont_marketplacepercentage.serviceTax = marketplacePercentage.serviceTaxt_marketplacepercentage.pgFee = marketplacePercentage.pgFeereturn t_marketplacepercentagedef to_t_flipkart_item(flipkartItem):t_flipkartitem = TFlipkartItem()if flipkartItem is None:return t_flipkartitemt_flipkartitem.item_id = flipkartItem[0].item_idt_flipkartitem.exceptionPrice = flipkartItem[0].exceptionPricet_flipkartitem.warehouseId = flipkartItem[0].warehouseIdt_flipkartitem.commissionValue = flipkartItem[0].commissionValuet_flipkartitem.serviceTaxValue = flipkartItem[0].serviceTaxValuet_flipkartitem.maxNlc = flipkartItem[0].maxNlct_flipkartitem.skuAtFlipkart = flipkartItem[0].skuAtFlipkartt_flipkartitem.isListedOnFlipkart = flipkartItem[0].isListedOnFlipkartt_flipkartitem.suppressPriceFeed = flipkartItem[0].suppressPriceFeedt_flipkartitem.suppressInventoryFeed = flipkartItem[0].suppressInventoryFeed#t_flipkartitem.updatedOn = to_java_date(flipkartItem.updatedOn)t_flipkartitem.updatedBy = flipkartItem[0].updatedByt_flipkartitem.flipkartSerialNumber = flipkartItem[0].flipkartSerialNumbert_flipkartitem.isFaListed = flipkartItem[0].isFaListedreturn t_flipkartitemdef to_t_flipkart_item_details(flipkartitem,flipkartItemInventory):if flipkartitem is None:t_flipkart_item_details = TFlipkartItemDetails()return t_flipkart_item_detailst_flipkart_item_details = TFlipkartItemDetails()t_flipkart_item_details.item_id = flipkartitem[0].item_idt_flipkart_item_details.warehouseId = flipkartitem[0].warehouseIdt_flipkart_item_details.exceptionPrice = flipkartitem[0].exceptionPricet_flipkart_item_details.commission = flipkartitem[0].commissionValuet_flipkart_item_details.serviceTax = flipkartitem[0].serviceTaxValuet_flipkart_item_details.brand = flipkartitem[1].brandt_flipkart_item_details.model_name = flipkartitem[1].model_namet_flipkart_item_details.model_number = flipkartitem[1].model_numbert_flipkart_item_details.color = flipkartitem[1].colort_flipkart_item_details.risky = flipkartitem[1].riskyt_flipkart_item_details.itemStatus = flipkartitem[1].statust_flipkart_item_details.isListedOnFlipkart = flipkartitem[0].isListedOnFlipkartt_flipkart_item_details.weight = flipkartitem[1].weightt_flipkart_item_details.mrp = flipkartitem[1].mrpt_flipkart_item_details.websiteSellingPrice = flipkartitem[1].sellingPricet_flipkart_item_details.suppressPriceFeed = flipkartitem[0].suppressPriceFeedt_flipkart_item_details.suppressInventoryFeed = flipkartitem[0].suppressInventoryFeedt_flipkart_item_details.maxNlc = flipkartitem[0].maxNlct_flipkart_item_details.skuAtFlipkart = flipkartitem[0].skuAtFlipkartt_flipkart_item_details.flipkartSerialNumber = flipkartitem[0].flipkartSerialNumbert_flipkart_item_details.category = flipkartitem[1].categoryt_flipkart_item_details.isFaListed = flipkartitem[0].isFaListedif flipkartItemInventory is not None:t_flipkart_item_details.lastUpdatedInventory = flipkartItemInventory.availability#t_flipkart_item_details.lastUpdatedInventoryTimestamp = flipkartItemInventory.lastUpdatedOnFlipkartreturn t_flipkart_item_detailsdef to_t_market_place_history(marketplaceHistory):t_marketplace_history = TMarketplaceHistory()if marketplaceHistory is None:return t_marketplace_historyt_marketplace_history.item_id = marketplaceHistory.item_idt_marketplace_history.source = marketplaceHistory.sourcet_marketplace_history.timestamp = to_java_date(marketplaceHistory.timestamp)if marketplaceHistory.lowestPossibleTp is None:t_marketplace_history.lowest_possible_tp =0else:t_marketplace_history.lowest_possible_tp = int(marketplaceHistory.lowestPossibleTp)if marketplaceHistory.lowestPossibleSp is None:t_marketplace_history.lowest_possible_sp = 0else:t_marketplace_history.lowest_possible_sp = int(marketplaceHistory.lowestPossibleSp)t_marketplace_history.ourInventory = marketplaceHistory.ourInventoryt_marketplace_history.otherInventory = marketplaceHistory.otherInventoryt_marketplace_history.secondLowestInventory = marketplaceHistory.secondLowestInventoryt_marketplace_history.ourRank = marketplaceHistory.ourRankif marketplaceHistory.ourOfferPrice is None:t_marketplace_history.ourOfferPrice = 0else:t_marketplace_history.ourOfferPrice = int(marketplaceHistory.ourOfferPrice)if marketplaceHistory.ourSellingPrice is None:t_marketplace_history.ourSellingPrice = 0else:t_marketplace_history.ourSellingPrice = int(marketplaceHistory.ourSellingPrice)if marketplaceHistory.ourTp is None:t_marketplace_history.ourTp = 0else:t_marketplace_history.ourTp = int(marketplaceHistory.ourTp)if marketplaceHistory.ourNlc is None:t_marketplace_history.ourNlc = 0else:t_marketplace_history.ourNlc = int(marketplaceHistory.ourNlc)t_marketplace_history.competitiveCategory = marketplaceHistory.competitiveCategoryt_marketplace_history.risky = marketplaceHistory.riskyif marketplaceHistory.lowestOfferPrice is None:t_marketplace_history.lowestOfferPrice = 0else:t_marketplace_history.lowestOfferPrice = int(marketplaceHistory.lowestOfferPrice)if marketplaceHistory.lowestSellingPrice is None:t_marketplace_history.lowestSellingPrice = 0else:t_marketplace_history.lowestSellingPrice = int(marketplaceHistory.lowestSellingPrice)if marketplaceHistory.lowestTp is None:t_marketplace_history.lowestTp = 0else:t_marketplace_history.lowestTp = int(marketplaceHistory.lowestTp)if marketplaceHistory.lowestSellerName is None:t_marketplace_history.lowestSellerName = ''else:t_marketplace_history.lowestSellerName = marketplaceHistory.lowestSellerNameif marketplaceHistory.proposedSellingPrice is None:t_marketplace_history.proposedSellingPrice = 0else:t_marketplace_history.proposedSellingPrice = int(marketplaceHistory.proposedSellingPrice)if marketplaceHistory.proposedTp is None:t_marketplace_history.proposedTp = 0else:t_marketplace_history.proposedTp = int(marketplaceHistory.proposedTp)if marketplaceHistory.targetNlc is None:t_marketplace_history.targetNlc = 0else:t_marketplace_history.targetNlc = int(marketplaceHistory.targetNlc)t_marketplace_history.salesPotential = marketplaceHistory.salesPotentialif marketplaceHistory.secondLowestSellerName is None:t_marketplace_history.secondLowestSellerName = ''else:t_marketplace_history.secondLowestSellerName = marketplaceHistory.secondLowestSellerNameif marketplaceHistory.secondLowestSellingPrice is None:t_marketplace_history.secondLowestSellingPrice=0else:t_marketplace_history.secondLowestSellingPrice = int(marketplaceHistory.secondLowestSellingPrice)if marketplaceHistory.secondLowestOfferPrice is None:t_marketplace_history.secondLowestOfferPrice = 0else:t_marketplace_history.secondLowestOfferPrice = int(marketplaceHistory.secondLowestOfferPrice)if marketplaceHistory.secondLowestTp is None:t_marketplace_history.secondLowestTp=0else:t_marketplace_history.secondLowestTp = int(marketplaceHistory.secondLowestTp)t_marketplace_history.marginIncreasedPotential = marketplaceHistory.marginIncreasedPotentialif marketplaceHistory.margin is None:t_marketplace_history.margin = 0else:t_marketplace_history.margin = int(marketplaceHistory.margin)t_marketplace_history.ourEnoughStock = marketplaceHistory.ourEnoughStockt_marketplace_history.totalSeller = marketplaceHistory.totalSellert_marketplace_history.averageSale = marketplaceHistory.avgSalest_marketplace_history.toGroup = marketplaceHistory.toGroupt_marketplace_history.decision = marketplaceHistory.decisiont_marketplace_history.reason = marketplaceHistory.reasonreturn t_marketplace_historydef to_t_private_deal(private_deal_item):if private_deal_item is None:t_private_deal_item = TPrivateDeal()return t_private_deal_itemt_private_deal_item = TPrivateDeal()t_private_deal_item.item_id = private_deal_item.item_idt_private_deal_item.dealPrice = private_deal_item.dealPricet_private_deal_item.dealFreebieItemId = private_deal_item.dealFreebieItemIdt_private_deal_item.startDate = to_java_date(private_deal_item.startDate)t_private_deal_item.endDate = to_java_date(private_deal_item.endDate)t_private_deal_item.dealTextOption = private_deal_item.dealTextOptionif private_deal_item.dealText is None:t_private_deal_item.dealText = ''else:t_private_deal_item.dealText = private_deal_item.dealTextt_private_deal_item.isCod = private_deal_item.isCodt_private_deal_item.rank = private_deal_item.rankt_private_deal_item.dealFreebieOption = private_deal_item.dealFreebieOptiont_private_deal_item.isActive = private_deal_item.isActivereturn t_private_deal_itemdef to_t_amazonoutofsync(amazonOutOfSync):t_amazonoutofsync = TAmazonOutOfSync()if amazonOutOfSync is None:return t_amazonoutofsyncelse:t_amazonoutofsync.item_id = amazonOutOfSync.item_idt_amazonoutofsync.mfn = amazonOutOfSync.mfnt_amazonoutofsync.fba = amazonOutOfSync.fbat_amazonoutofsync.fbb = amazonOutOfSync.fbbreturn t_amazonoutofsyncdef to_t_private_deals_comparison(item):xstr = lambda s: s or ""t_pdcomp = TPdPriceComp()pdComp = item[0]catItem = item[1]t_pdcomp.item_id = pdComp.item_idt_pdcomp.dealPrice = pdComp.dealPricet_pdcomp.saholicPrice = pdComp.saholicPricet_pdcomp.sdPrice = pdComp.sdPricet_pdcomp.fkPrice = pdComp.fkPricet_pdcomp.amazonPrice = pdComp.amazonPricet_pdcomp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)t_pdcomp.lastProcessedTimestamp = to_java_date(pdComp.lastProcessedTimestamp)return t_pdcompdef to_t_snapdeal_marketplace_item(item):mpItem = item[1]dItem = item[2]t_sd_item = to_t_snapdeal_item(item)t_sd_item.marketplaceItems = to_t_marketplace_items(mpItem)t_sd_item.item = to_t_item(dItem)return t_sd_item'''def to_t_deal_tag(dealTag):t_deal_tag = TDealTag()t_deal_tag.id = dealTag.idt_deal_tag.name = dealTag.namereturn t_deal_tagdef to_t_item_tag(itemTag):t_item_tag = TItemTag()t_item_tag.itemId = itemTag.itemIdt_item_tag.tagId = itemTag.tagIdt_item_tag.startDate = to_java_date(itemTag.startDate)t_item_tag.endDate = to_java_date(itemTag.endDate)t_item_tag.status = itemTag.statusreturn t_item_tag'''def to_t_flipkart_marketplace_item(item):mpItem = item[1]dItem = item[2]t_fk_item = to_t_flipkart_item(item)t_fk_item.marketplaceItems = to_t_marketplace_items(mpItem)t_fk_item.item = to_t_item(dItem)return t_fk_itemdef to_t_competitor_pricing(compPricing):xstr = lambda s: s or ""item = compPricing[0]catItem = compPricing[1]t_comp = TCompetitorPricing()t_comp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)t_comp.item_id = item.item_idt_comp.lowestSnapdealPrice = item.lowestSnapdealPricet_comp.lowestFlipkartPrice = item.lowestFlipkartPricet_comp.lowestAmazonPrice = item.lowestAmazonPricet_comp.ourSnapdealPrice = item.ourSnapdealPricet_comp.ourSnapdealOfferPrice = item.ourSnapdealOfferPricet_comp.ourSnapdealInventory = item.ourSnapdealInventoryt_comp.lowestSnapdealOfferPrice = item.lowestSnapdealOfferPriceif item.lowestSnapdealSeller is None:t_comp.lowestSnapdealSeller=''else:t_comp.lowestSnapdealSeller = item.lowestSnapdealSellert_comp.lowestSnapdealSellerInventory = item.lowestSnapdealSellerInventoryt_comp.ourFlipkartPrice = item.ourFlipkartPricet_comp.ourFlipkartInventory = item.ourFlipkartInventoryif item.lowestFlipkartSeller is None:t_comp.lowestFlipkartSeller=''else:t_comp.lowestFlipkartSeller = item.lowestFlipkartSellert_comp.ourAmazonPrice = item.ourAmazonPricet_comp.lowestAmazonPrice = item.lowestAmazonPriceif item.lowestAmazonSeller is None:t_comp.lowestAmazonSeller=''else:t_comp.lowestAmazonSeller = item.lowestAmazonSellerreturn t_compdef to_t_amazon_promotion(amazonPromotion):t_amazonPromotion = TAmazonPromotion()t_amazonPromotion.sku = amazonPromotion.skut_amazonPromotion.startDate = to_java_date(datetime.datetime.combine(amazonPromotion.startDate, datetime.datetime.min.time()))t_amazonPromotion.endDate = to_java_date(datetime.datetime.combine(amazonPromotion.endDate, datetime.datetime.min.time()))t_amazonPromotion.updatedOnMarketplace = to_java_date(amazonPromotion.updatedOnMarketplace)t_amazonPromotion.promotionActive = amazonPromotion.promotionActivet_amazonPromotion.addedOn = to_java_date(amazonPromotion.addedOn)t_amazonPromotion.standardPrice = amazonPromotion.standardPricet_amazonPromotion.salePrice = amazonPromotion.salePricet_amazonPromotion.stateId = amazonPromotion.stateIdt_amazonPromotion.promotionType = amazonPromotion.promotionTypereturn t_amazonPromotiondef to_t_Amazonlisted_promo(amazonDetails):amazonlisted = amazonDetails[0]fbaPromo = amazonDetails[1]fbbPromo = amazonDetails[2]fbgPromo = amazonDetails[3]fbdPromo = amazonDetails[4]t_amazon = to_t_Amazonlisted(amazonlisted)if not (fbaPromo is None or len(fbaPromo)==0):t_amazon.maxFbaSalePrice = fbaPromo[0].salePriceif not (fbbPromo is None or len(fbbPromo)==0):t_amazon.maxFbbSalePrice = fbbPromo[0].salePriceif not (fbgPromo is None or len(fbgPromo)==0):t_amazon.maxFbgSalePrice = fbgPromo[0].salePriceif not (fbdPromo is None or len(fbdPromo)==0):t_amazon.maxFbdSalePrice = fbdPromo[0].salePricereturn t_amazondef to_t_exclusive_affiliate_item_info(afItemInfo):tinfo = TExclusiveAffiliateItemInfo()tinfo.affiliateId = afItemInfo[0].affiliateIdtinfo.active = afItemInfo[0].isActivetinfo.affiliateName = afItemInfo[1]tinfo.offerImageUrl = afItemInfo[0].offerUrltinfo.offerText = afItemInfo[0].offerTexttinfo.itemId = afItemInfo[0].itemIdtinfo.mOfferImageUrl = afItemInfo[0].mOfferUrltinfo.mOfferText = afItemInfo[0].mOfferTexttinfo.affiliateUrl = afItemInfo[0].affiliateUrlreturn tinfodef to_t_hsItem(hsItem):t_hsItem = THsItem()t_hsItem.itemId = hsItem.item_idt_hsItem.listingPrice = hsItem.selling_pricereturn t_hsItemdef to_t_voiSnapdealItemInfo(voiSnapdealItemInfo):t_voiSnapdealItemInfo = TVoiSnapdealItemInfo()t_voiSnapdealItemInfo.item_id = voiSnapdealItemInfo.item_idt_voiSnapdealItemInfo.voiSkuAtSnapdeal = voiSnapdealItemInfo.voiSkuAtSnapdealt_voiSnapdealItemInfo.sellingPriceSnapdeal = voiSnapdealItemInfo.sellingPriceSnapdealt_voiSnapdealItemInfo.transferPriceSnapdeal = voiSnapdealItemInfo.transferPriceSnapdealt_voiSnapdealItemInfo.fixedMargin = voiSnapdealItemInfo.fixedMargint_voiSnapdealItemInfo.fixedMarginPercentage = voiSnapdealItemInfo.fixedMarginPercentaget_voiSnapdealItemInfo.logisticCostSnapdeal = voiSnapdealItemInfo.logisticCostSnapdealt_voiSnapdealItemInfo.woodenPackagingCost = voiSnapdealItemInfo.woodenPackagingCostt_voiSnapdealItemInfo.weightSnapdeal = voiSnapdealItemInfo.weightSnapdealreturn t_voiSnapdealItemInfodef to_t_bulk_pricing(bulkPricing):t_bulkpricing = TBulkItemPricing()t_bulkpricing.id = bulkPricing.idt_bulkpricing.item_id = bulkPricing.item_idt_bulkpricing.quantity = bulkPricing.quantityt_bulkpricing.price = bulkPricing.pricereturn t_bulkpricingdef to_t_categoryHsnCode(categoryHsnCode):t_categoryHsnCode = TCategoryHsnCode()t_categoryHsnCode.categoryId = categoryHsnCode.categoryIdt_categoryHsnCode.hsnCode = categoryHsnCode.hsnCodet_categoryHsnCode.description = categoryHsnCode.descriptionreturn t_categoryHsnCodedef to_t_dtr_pricing(dtrPricing):d_item, bulkPricingMap = dtrPricingt_dtr_pricing = TDtrPricing()if d_item is None:return t_dtr_pricingt_dtr_pricing.catalog_item_id = d_item.catalog_item_idt_dtr_pricing.bulkPricing = bulkPricingMapt_dtr_pricing.sellingPrice = d_item.sellingPricet_dtr_pricing.minimumBuyQuantity = d_item.minimumBuyQuantityt_dtr_pricing.maximumBuyQuantity = d_item.maximumBuyQuantityreturn t_dtr_pricing