Beispiel #1
0
        private static string GetBonanzaRecordDescription(AllStockSize asSize, AllStockSneaker asSneaker, FullCatalogRoot fullCatalog)
        {
            var boothUrl = System.Configuration.ConfigurationManager.AppSettings["bonanzaBoothUrl"];
            var title    = asSneaker.title;
            var sku      = asSneaker.sku;
            var size     = SizeChart.GetSizeStatic(new Size(asSneaker.brand, asSneaker.category, asSize.us, null, null, null, null));

            if (size == null)
            {
                _logger.Warn("Ошибка в размере. sku: " + asSneaker.sku);
                return(null);
            }

            var sizeString = size.GetSizeStringUsEuUkCm();

            string description =
                "<h3 style=\"text-align: center;\"><strong>" +
                title.ToUpper() +
                "</strong></h3>" +
                "<h3 style=\"text-align: center;\"><strong>" +
                "STYLE: " + sku +
                "</strong></h3>" +
                "<h3 style=\"text-align: center;\"><strong>" +
                "SIZE: " + sizeString +
                "</strong></h3>" +
                "<h3 style=\"text-align: center;\"><strong>" +
                "100% AUTHENTIC" +
                "</strong></h3>" +
                "<h3 style=\"text-align: center;\"><strong>" +
                "WORLDWIDE SHIPPING FOR 5-10 DAYS IN DOUBLE BOX WITH TRACKING NUMBER.<br>" +
                "</strong></h3>" +
                "<h3 style=\"text-align: center;\"><strong>" +
                "SHIP IN 2 BUSINESS DAY." +
                "</strong></h3>";

            //description += "<h3 style=\"text-align: center;\"><strong>All sizes of this model available in stock</strong></h3>";

            //if (sizeList != null)
            //{
            //    if (sizeList.Count > 0)
            //    {
            //        foreach (var size in sizeList)
            //        {
            //            //725076-301+6.5US
            //            description += "<h4 style=\"text-align: center;\"><strong><a href=\"" + boothUrl + "?utf8=%E2%9C%93&amp;item_sort_options%5Bfilter_string%5D=" + sku + "+" + size + "US&amp;item_sort_options%5Bfilter_category_id%5D=&amp;item_sort_options%5Bcustom_category_id%5D=&amp;commit=Go\" rel=\"nofollow\" target=\"_blank\">Size " + size + " US</a></strong></h4>";
            //        }
            //    }
            //}

            description += "<h3 style=\"text-align: center;\"><strong>" +
                           "Other sizes of this model available in out stock: " +
                           "<a href=\"" + boothUrl + "?utf8=%E2%9C%93&amp;item_sort_options%5Bfilter_string%5D=" + sku + "&amp;item_sort_options%5Bfilter_category_id%5D=&amp;item_sort_options%5Bcustom_category_id%5D=&amp;commit=Go\" rel=\"nofollow\" target=\"_blank\">Link</a>" +
                           "</strong></h3>";

            description += "<h3 style=\"text-align: center;\"><strong>" + "Please feel free to ask any questions and see <a href=\"" + boothUrl + "\" rel=\"nofollow\" target=\"_blank\">all our listings</a> for more great deals." + "</strong></h3>";

            //throw new NotImplementedException();
            return(description);
        }
Beispiel #2
0
 private static AllStockOffer GetNonRussianOffer(AllStockSize asSize)
 {
     if (asSize.offers[0].currency != "RUB")
     {
         return(asSize.offers[0]);
     }
     foreach (var offer in asSize.offers)
     {
         if (offer.currency != "RUB")
         {
             return(offer);
         }
     }
     return(null);
 }
Beispiel #3
0
        private static AllStockOffer GetFirstActiveOffer(AllStockSize asSize, ShopCatalogRoot shopCatalog)
        {
            var bonanzaShops = shopCatalog.markets.FindAll(x => x.active_marketplace_list.Find(y => y == "bonanza") != null);

            //if (asSize.offers[0].currency != "RUB")
            //{
            //    return asSize.offers[0];
            //}
            foreach (var offer in asSize.offers)
            {
                //if (offer.currency != "RUB")
                if (bonanzaShops.Find(x => x.name == offer.stock_name) != null)
                {
                    return(offer);
                }
            }
            return(null);
        }
Beispiel #4
0
        private static AllStockSize CreateSize(ListingSize size, AllStockSneaker sneaker, Listing listing, RootParsingObject market, Shop jsonMarket)
        {
            var sizeAllStock = new AllStockSize();

            if (size.us == null)
            {
                size.us = SizeConverters.SizeConverter.GetSizeUs(sneaker.brand, sneaker.category, size.eu, size.uk, size.cm);
            }
            if (size.us == null)
            {
                //значит размер левый или его нет в таблице размеров
                return(null);
            }
            else
            {
                if (listing.category != sneaker.category)
                {
                    Program.Logger.Warn("wrong category. SKU:" + listing.sku + "\n"
                                        + "Listing Category: " + listing.category + ".\n"
                                        + "FullCatalog Category:" + sneaker.category + "\n"
                                        + "ListingTite: " + listing.title + "\n"
                                        + "Listing Link:" + listing.url);
                    return(null);
                }
                var schSize = SizeChart.GetSizeStatic(new Size(sneaker.brand, sneaker.category, size.us, size.eu, size.uk, size.cm, size.ru));
                if (schSize == null)
                {
                    Program.Logger.Warn("wrong size. SKU:" + listing.sku + "\n"
                                        + "Listing Category: " + listing.category + ".\n"
                                        + "FullCatalog Category:" + sneaker.category + "\n"
                                        + "ListingTite: " + listing.title + "\n"
                                        + "Listing Link:" + listing.url);
                    return(null);
                }
                sizeAllStock.us   = size.us;
                sizeAllStock.sku2 = sneaker.sku + "-" + size.us;
                sizeAllStock.upc  = size.upc;
                var offer = CreateOffer(listing, market, jsonMarket);
                sizeAllStock.offers.Add(offer);
                return(sizeAllStock);
            }
        }
Beispiel #5
0
        private static Model.BonanzaModel.BonanzaRecord GetBonanzaRecord(AllStockSize asSize, AllStockSneaker asSneaker, FullCatalogRoot fullCatalog, ShopCatalogRoot shopCatalog)
        {
            var fcSneaker = fullCatalog.records.Find(x => x.sku == asSneaker.sku);

            if (fcSneaker == null)
            {
                _logger.Warn("Артикул не найден в фулкаталоге. sku:" + asSneaker.sku);
                return(null);
            }
            var bRecord = new Model.BonanzaModel.BonanzaRecord();

            //standart data
            bRecord.quantity     = 5;
            bRecord.condition    = "New with box";
            bRecord.force_update = "true";
            bRecord.brand        = fcSneaker.brand;
            //shipping
            bRecord.shipping_price   = 29;
            bRecord.shipping_type    = "flat";
            bRecord.shipping_carrier = "usps";
            bRecord.shipping_service = "EconomyShipping";
            bRecord.shipping_package = "normal";
            //bRecord.worldwide_shipping_type = "flat";
            //bRecord.worldwide_shipping_price = 29;

            bRecord.id          = asSize.sku2;
            bRecord.description = GetBonanzaRecordDescription(asSize, asSneaker, fullCatalog);
            if (bRecord.description == null)
            {
                _logger.Warn("Пустое описание. sku2:" + bRecord.id);
                return(null);
            }

            bRecord.category = GetBonanzaCategory(asSneaker.category, fcSneaker.sex);
            bRecord.width    = GetBonanzaWidth(asSneaker.category);
            bRecord.title    = GetTitle(asSneaker.brand, asSize.us, asSneaker.sku, asSneaker.title);

            //price
            var offer = GetFirstActiveOffer(asSize, shopCatalog);

            //var offer = GetNonRussianOffer(asSize); //отфильтруем русские магазы
            if (offer == null)
            {
                return(null);
            }
            bRecord.price = GetPrice(offer);
            //double priceWithMargin = offer.price_usd_with_delivery_to_usa_and_minus_vat + MARGIN_USD;
            //double priceWithFeeMinusBonanzaDelivery = (priceWithMargin * 1.18) - 29;
            //priceWithFeeMinusBonanzaDelivery = Math.Round(priceWithFeeMinusBonanzaDelivery, 2);
            //bRecord.price = priceWithFeeMinusBonanzaDelivery.ToString("F", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"));

            //images
            if (fcSneaker.images.Count == 0)
            {
                _logger.Warn("Нет изображений. sku2:" + bRecord.id);
                return(null);
            }
            bRecord.image1 = fcSneaker.images[0];
            if (fcSneaker.images.Count > 1)
            {
                bRecord.image2 = fcSneaker.images[1];
            }
            if (fcSneaker.images.Count > 2)
            {
                bRecord.image3 = fcSneaker.images[2];
            }
            if (fcSneaker.images.Count > 3)
            {
                bRecord.image4 = fcSneaker.images[3];
            }


            bRecord.size    = asSize.us;
            bRecord.traits  = "[[US Size:" + asSize.us + "]] ";
            bRecord.upc     = asSize.upc;
            bRecord.MPN     = fcSneaker.sku; //это вроде не работает
            bRecord.traits += "[[MPN:" + fcSneaker.sku + "]] ";


            return(bRecord);
        }