public static double GetAllStockPrice(double stockPrice, string currency, int deliveryToUSA, double VatValue)
        {
            var stockRecord = new StockRecord();
            var price       = ((stockPrice) * (1 - VatValue)) + deliveryToUSA;

            if (currency == "USD")
            {
                return(Math.Round(price, 2));
            }

            //stockRecord.price = (stockPrice + deliveryToUSA) * (1 - VatValue);
            //stockRecord.sellPrice = stockRecord.price;

            //var price2 = Exporter.GetPrice2(stockPrice, VatValue, deliveryToUSA, 0, currency, "USD");

            CurrencyRate currate = CurrencyRate.ReadObjectFromJsonFile();

            double curInputRate  = currate.GetCurrencyRate(currency);
            double curOutputRate = currate.GetCurrencyRate("USD");

            double curInputRateBuy   = curInputRate * 1.035;
            double curOutputRateSell = curOutputRate * 0.965;



            var resultPrice    = price * curInputRateBuy / curOutputRateSell;
            var oldResultPrice = price * curInputRate / curOutputRate;



            resultPrice = Math.Round(resultPrice, 2);
            //var resultPrice = Exporter.GetPrice(stockRecord, currency, "USD");
            return(resultPrice);
            //throw new NotImplementedException();
        }
Esempio n. 2
0
        private List <SivasSaleBonanzaRecord> CreateBonanzaRecords(List <Listing> ExportListings)
        {
            var Records = new List <SivasSaleBonanzaRecord>();

            foreach (var listing in ExportListings)
            {
                for (int i = 0; i < listing.sizes.Count; i++)
                {
                    var record = new SivasSaleBonanzaRecord();
                    var sizeUS = listing.sizes[i].us;
                    var sizeUK = listing.sizes[i].uk;
                    var sizeEU = listing.sizes[i].eu;
                    var sizeCM = listing.sizes[i].cm;

                    //id
                    record.id = listing.sku + "-" + sizeUS;

                    //description
                    var sizeString = sizeUS + " US / " + sizeUK + " UK / " + sizeEU + " EU / " + sizeCM + " CM";
                    record.description =
                        "<h3 style=\"text-align: center;\"><strong>" +
                        listing.title.ToUpper() +
                        "</strong></h3>" +
                        "<h3 style=\"text-align: center;\"><strong>" +
                        "STYLE: " + listing.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>";

                    //quantity
                    record.quantity = 2;

                    //categorySneakerFullCatalog
                    record.category = "11450"; //общая категория fashion

                    //title
                    //var sizeStrTitle = "SZ " + sizeUS + "US";
                    //var countSizeStr = sizeStrTitle.Count();
                    //var title = listing.title.Trim();
                    //var titleLength = title.Count();
                    //if (titleLength > 47 - countSizeStr)
                    //{
                    //    title = title.Substring(0, 47 - countSizeStr - 1);
                    //}
                    //title = title + " " + sizeStrTitle + " " + listing.sku;

                    string hvost = " SZ " + sizeUS + "US " + listing.sku;
                    if (listing.title.Count() + hvost.Count() < 80)
                    {
                        record.title = listing.title.ToUpper() + hvost;
                    }
                    else
                    {
                        int indexSubstringTitle = 79 - hvost.Count();
                        record.title = listing.title.ToUpper().Substring(0, indexSubstringTitle) + hvost;
                        int titlecount = record.title.Count();
                    }

                    if (listing.sku == "G61070")
                    {
                        bool test = true;
                    }

                    //price
                    //цена в евро, преобразуем её в доллары
                    var          price             = ((listing.price + DELIVERY_TO_USA + MARZHA) * 1.18); //18% комиссия примерно
                    CurrencyRate currate           = CurrencyRate.ReadObjectFromJsonFile();
                    double       curInputRate      = currate.GetCurrencyRate("EUR");
                    double       curOutputRate     = currate.GetCurrencyRate("USD");
                    double       curInputRateBuy   = curInputRate * 1.05;
                    double       curOutputRateSell = curOutputRate * 1;
                    var          priceBonanza      = (price * curInputRateBuy / curOutputRateSell) - 20;
                    priceBonanza = Math.Round(priceBonanza, 2);
                    record.price = priceBonanza.ToString("F", CultureInfo.CreateSpecificCulture("en-US"));

                    //shipping
                    record.shipping_type            = "fixed";
                    record.worldwide_shipping_type  = "fixed";
                    record.shipping_price           = 20;
                    record.worldwide_shipping_price = 20;

                    //images
                    record.image1 = HTTP_IMAGE_PATH + listing.sku + "-1.jpg";
                    record.image2 = HTTP_IMAGE_PATH + listing.sku + "-2.jpg";
                    record.image3 = HTTP_IMAGE_PATH + listing.sku + "-3.jpg";
                    record.image4 = HTTP_IMAGE_PATH + listing.sku + "-4.jpg";

                    record.brand        = listing.brand;
                    record.size         = sizeUS;
                    record.us_size      = sizeUS;
                    record.condition    = "New with box";
                    record.force_update = "true";

                    Records.Add(record);
                }
            }

            return(Records);
        }
Esempio n. 3
0
        public static double GetPrice(StockRecord record, string currencyInput, string currencyOutput, int Marzha = 0)
        {
            if (Marzha == 0)
            {
                //у еинхалба маржа 0 была замечена, надо поправить
                if (record.sellPrice == 0)
                {
                    throw new Exception("Marzha = 0 and SellPrice = 0");
                }
                //throw new Exception ("Marzha = 0");
            }
            if (currencyInput == "RUB")
            {
                bool test = true;
            }
            if (currencyInput == "USD")
            {
                bool test = true;
            }
            if (currencyInput == "EUR")
            {
                bool test = true;
            }
            if (currencyInput == "PLN")
            {
                bool test = true;
            }
            CurrencyRate currate       = CurrencyRate.ReadObjectFromJsonFile();
            double       curInputRate  = currate.GetCurrencyRate(currencyInput);
            double       curOutputRate = currate.GetCurrencyRate(currencyOutput);

            double curInputRateBuy   = curInputRate * 1.035;
            double curOutputRateSell = curOutputRate * 0.965;

            if (currencyInput == "RUB")
            {
                curInputRateBuy = 1;
                //curOutputRateSell = 1;
            }
            if (currencyOutput == "RUB")
            {
                curOutputRateSell = 1;
            }

            double sellPrice;

            if (record.sellPrice > 0)
            {
                sellPrice = record.sellPrice;
            }
            else
            {
                sellPrice = record.price + Marzha;
            }

            double resultPrice;

            if (currencyInput == currencyOutput)
            {
                resultPrice = sellPrice;
            }
            else
            {
                resultPrice = sellPrice * curInputRateBuy / curOutputRateSell;
            }

            resultPrice = Math.Round(resultPrice, 2);
            return(resultPrice);
            //if (currency == "USD")
            //{
            //    if (record.sellPrice > 0)
            //    {
            //        resultPrice = record.sellPrice;
            //        return resultPrice;
            //    }
            //    else
            //    {
            //        resultPrice = record.price + Marzha;
            //        return resultPrice;
            //        //throw new Exception("нет цены продажи sku:" + record.sku);
            //    }
            //}
            //if (currency == "EUR")
            //{
            //    if (record.sellPrice > 0)
            //    {
            //        resultPrice = record.sellPrice * Settings.EURO_BUY;
            //        return resultPrice / Settings.USD_SELL;
            //    }
            //    else
            //    {
            //        if (Marzha == 0)
            //            throw new Exception("marzha = 0. sku: " + record.sku);
            //        record.sellPrice = record.price + Marzha;
            //        resultPrice = record.sellPrice * Settings.EURO_BUY;
            //        return resultPrice / Settings.USD_SELL;
            //    }
            //}
            //if (currency == "CHF")
            //{
            //    if (record.sellPrice > 0)
            //    {
            //        resultPrice = record.sellPrice * Settings.CHF_BUY;
            //        return resultPrice / Settings.USD_SELL;
            //    }
            //    else
            //    {
            //        throw new Exception("нет цены продажи sku:" + record.sku);
            //    }
            //}
            //else if (currency == "RUB")
            //{
            //    var sneaker = catalog.GetSneakerFromSKU(record.sku);
            //    if (sneaker != null)
            //    {
            //        if (sneaker.type == "Сланцы")
            //        {
            //            resultPrice = record.price + marzha + 200;
            //            return resultPrice / Settings.USD_SELL;
            //        }
            //    }
            //    resultPrice = record.price + marzha + dostavkaFromRussia;
            //    return resultPrice / Settings.USD_SELL;
            //}
        }