Rev 8579 | Rev 8619 | Go to most recent revision | 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 Insurerfrom 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 TCampaignfrom shop2020.utils.Utils import to_java_datedef to_t_item(item):t_item = Item()if item is None:return t_itemt_item.id = item.idt_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.isListedOnSnapdeal = item.isListedOnSnapdealreturn 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_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.hasMapreturn 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_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.isActivereturn 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.sellingPrice = Amazonlisted.sellingPricet_amazonlisted.isFba = Amazonlisted.isFbat_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.mfnPriceLastUpdatedOnSc = to_java_date(Amazonlisted.mfnPriceLastUpdatedOnSc)t_amazonlisted.fbaPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbaPriceLastUpdatedOnSc)t_amazonlisted.suppressMfnPriceUpdate = Amazonlisted.suppressMfnPriceUpdatet_amazonlisted.suppressFbaPriceUpdate = Amazonlisted.suppressFbaPriceUpdatereturn 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_info