public ProductInventoryNew GetInventoryByProductNo(string productNo)
        {
            ProductInventoryNew pinventory = new ProductInventoryNew();
            string xml = string.Empty;

            try
            {
                StockWebService.StockWebService stock = new StockWebService.StockWebService();
                if (AppSettingManager.AppSettings["InventoryFlag"].ToLower() == "true")
                {
                    stock.Url = AppSettingManager.AppSettings["ErpInventoryService"];
                    xml       = stock.GetInventorySumByProductNo(productNo, 1); //1,正品;2,残次品;3,赠品
                }
                else
                {
                    xml = stock.GetInventorySumByProductNo(productNo, 1);//1,正品;2,残次品;3,赠品
                }
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);

                int sumQuantity     = 0; //库存总数
                int sumLockQuantity = 0; //锁定的总库存
                int inventory       = 0; //库存总数 减去 锁定的总库存

                if (doc != null)
                {
                    XmlNodeList inventoryNodeList = doc.SelectNodes("/ErpInventorySums/ErpInventorySum");
                    if (inventoryNodeList != null && inventoryNodeList.Count > 0)
                    {
                        string nodeName          = string.Empty;
                        int    inventoryQuantity = 0;
                        int    lockQuantity      = 0;
                        foreach (XmlNode inventoryNode in inventoryNodeList)
                        {
                            if (inventoryNode.ChildNodes.Count > 0)
                            {
                                inventoryQuantity = Convert.ToInt32(inventoryNode.ChildNodes[2].InnerText);
                                lockQuantity      = Convert.ToInt32(inventoryNode.ChildNodes[3].InnerText);

                                sumQuantity     += inventoryQuantity;
                                sumLockQuantity += lockQuantity;
                            }
                        }
                        //sumQuantity += inventoryQuantity;
                        //sumLockQuantity += lockQuantity;
                        inventory = inventory + inventoryQuantity - lockQuantity;
                    }
                }
                pinventory.ProductNo       = productNo;
                pinventory.SumQuantity     = sumQuantity;
                pinventory.SumLockQuantity = sumLockQuantity;
                pinventory.Inventory       = inventory;
            }
            catch (Exception ex)
            {
            }
            return(pinventory);
        }
Esempio n. 2
0
        /// <summary>
        /// 商品列表--查询添加
        /// </summary>
        /// <param name="topicNo"></param>
        /// <param name="categoryNo"></param>
        /// <param name="brandNo"></param>
        /// <param name="productNameOrNo"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public ActionResult AddProduct(string topicNo, int pageindex = 1)
        {
            int    pageSize        = 10;
            string categoryNo1     = Request["CategoryNo1"];
            string categoryNo2     = Request["CategoryNo2"];
            string categoryNo3     = Request["CategoryNo3"];
            string categoryNo4     = Request["CategoryNo4"];
            string brandNo         = Request["BrandNo"];
            string productNoOrName = Request["ProductNameOrNo"];
            string gender          = Request["Gender"];

            if (!string.IsNullOrEmpty(productNoOrName) && productNoOrName.Equals("商品编号/商品名称"))
            {
                productNoOrName = "";
            }
            /////////////////////////分页保留查询数据用///////////////////////////////
            ViewBag.CategoryNo      = categoryNo1 ?? "";
            ViewBag.CategoryNo2     = categoryNo2 ?? "";
            ViewBag.CategoryNo3     = categoryNo3 ?? "";
            ViewBag.CategoryNo4     = categoryNo4 ?? "";
            ViewBag.ProductNameOrNo = productNoOrName ?? "";
            ViewBag.BrandName       = Request.QueryString["BrandName"] ?? "";
            ViewBag.Gender          = gender ?? "";
            ///////////////////////////分页保留查询数据用/////////////////////////////

            string gCategroyNo = categoryNo1;

            if (!string.IsNullOrEmpty(categoryNo2))
            {
                gCategroyNo = categoryNo2;
            }
            if (!string.IsNullOrEmpty(categoryNo3))
            {
                gCategroyNo = categoryNo3;
            }
            if (!string.IsNullOrEmpty(categoryNo4))
            {
                gCategroyNo = categoryNo4;
            }


            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("brandNo", brandNo ?? "");
            dic.Add("productNoOrName", productNoOrName ?? "");
            dic.Add("gender", gender ?? "");
            dic.Add("gCategroyNo", gCategroyNo ?? "");

            SWfsTopicService topicServ = new SWfsTopicService();
            var productList            = topicServ.GetProductList(dic, pageindex, pageSize);

            SWfsProductService productService = new SWfsProductService();
            //ProductInventory pin = new ProductInventory();
            ProductInventoryNew   pin     = new ProductInventoryNew();
            SWfsNewProductService service = new SWfsNewProductService();
            decimal bid = 0;

            foreach (var product in productList.Items)
            {
                //pin = productService.GetInventoryByProductNo(product.ProductNo);
                pin = service.GetInventoryByProductNo(product.ProductNo);
                product.Quantity     = pin.SumQuantity;
                product.LockQuantity = pin.SumLockQuantity;


                bid = productService.GetProductBuyPriceByProductNo(product.ProductNo);

                product.sellBid       = product.SellPrice - bid;
                product.marketBid     = product.MarketPrice - bid;
                product.platinumBid   = product.PlatinumPrice - bid;
                product.diamondBid    = product.DiamondPrice - bid;
                product.limitedBid    = product.LimitedPrice - bid;
                product.limitedVipBid = product.LimitedVipPrice - bid;

                product.selBidRate        = product.SellPrice.Equals(0) ? 100 : Math.Round((product.sellBid / product.SellPrice) * 100, 2);
                product.marketBidRate     = product.MarketPrice.Equals(0) ? 100 : Math.Round((product.marketBid / product.MarketPrice) * 100, 2);             // Convert.ToDecimal(Math.Round((Convert.ToDecimal(marketBid) / Convert.ToDecimal(marketPrice)) * 100, 2)).ToString() + "%";
                product.platinumBidRate   = product.PlatinumPrice.Equals(0) ? 100 : Math.Round((product.platinumBid / product.PlatinumPrice) * 100, 2);       // Convert.ToDecimal(Math.Round((Convert.ToDecimal(platinumBid) / Convert.ToDecimal(platinumPrice)) * 100, 2)).ToString() + "%";
                product.diamondBidRate    = product.DiamondPrice.Equals(0) ? 100 : Math.Round((product.diamondBid / product.DiamondPrice) * 100, 2);          //Convert.ToDecimal(Math.Round((Convert.ToDecimal(diamondBid) / Convert.ToDecimal(diamondPrice)) * 100, 2)).ToString() + "%";
                product.limitedBidRate    = product.LimitedPrice.Equals(0) ? 100 : Math.Round((product.limitedBid / product.LimitedPrice) * 100, 2);          // Convert.ToDecimal(Math.Round((Convert.ToDecimal(limitedBid) / Convert.ToDecimal(limitedPrice)) * 100, 2)).ToString() + "%";
                product.limitedVipBidRate = product.LimitedVipPrice.Equals(0) ? 100 : Math.Round((product.limitedVipBid / product.LimitedVipPrice) * 100, 2); // Convert.ToDecimal(Math.Round((Convert.ToDecimal(limitedVipBid) / Convert.ToDecimal(limitedVipPrice)) * 100, 2)).ToString() + "%";
            }

            //所有的一级分类
            SWfsSubjectService subject = new SWfsSubjectService();

            ViewBag.AllFirstCategory = subject.SelectErpCategoryByParentNo("ROOT");
            //该活动下的一级分类
            //ViewBag.FirstCategory = subject.GetErpCategoryListBySubjectNo(subjectNo);

            ViewBag.Category2 = subject.SelectErpCategoryByParentNo(categoryNo1);
            ViewBag.Category3 = subject.SelectErpCategoryByParentNo(categoryNo2);
            ViewBag.Category4 = subject.SelectErpCategoryByParentNo(categoryNo3);

            ViewBag.TopicNo = topicNo;

            SWfsTopics topicModel = topicServ.GetSWfsTopics(topicNo);

            ViewBag.TopicName = (null != topicModel) ? topicModel.TopicName : "";

            ViewBag.SCategoryNo = gCategroyNo;

            return(View(productList));
        }