Пример #1
0
        /// <summary>
        /// 处理库存信息
        /// </summary>
        /// <param name="saleGoodsViews"></param>
        /// <param name="stockId"></param>
        /// <returns></returns>
        public async Task <List <SaleGoodsView> > HandleQty(List <SaleGoodsView> saleGoodsViews, long stockId)
        {
            if (saleGoodsViews == null || !saleGoodsViews.Any())
            {
                return(saleGoodsViews);
            }
            var goodsIds = saleGoodsViews.Select(p => p.GoodsId).ToList();
            var qtys     = await _goodsBll.GetStStockQtyView(goodsIds, stockId);

            saleGoodsViews.ForEach(p =>
            {
                var qtyView = qtys.FirstOrDefault(j => j.GoodsId == p.GoodsId);
                if (qtyView != null)
                {
                    p.Qty = qtyView.Qty;
                }
            });
            return(saleGoodsViews);
        }
Пример #2
0
        /// <summary>
        /// 分页获取商品信息
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ResponsePagingBase> ProcessAction(HttpContext httpContext, GetGoodsPagingRequest request)
        {
            if (!HandleRequest(httpContext, request))
            {
                return(ResponsePagingBase.Success(new List <OpGoodsView>(), 0));
            }
            var result = await _openDataBll.GetGoodsPaging(request);

            if (result == null || result.Item2 == 0)
            {
                return(ResponsePagingBase.Success(new List <OpGoodsView>(), 0));
            }
            var goods            = result.Item1.ToList();
            var goodsIds         = new List <long>();
            var goodsCategoryIds = new List <long>();
            var stockIds         = new List <long>();
            var areaIds          = new List <long>();
            var unitIds          = new List <long>();
            var brandIds         = new List <long>();

            foreach (var g in goods)
            {
                goodsIds.Add(g.GoodsId);
                stockIds.Add(g.StockId);
                areaIds.Add(g.Province);
                areaIds.Add(g.City);
                areaIds.Add(g.District);
                areaIds.Add(g.Street);
                unitIds.Add(g.BaseUnitId);
                goodsCategoryIds.Add(g.GoodsCategoryId);
                brandIds.Add(g.BrandId);
            }
            var areas = await _areaBll.GetArea(areaIds.Distinct().ToList());

            var goodsCategorys = await _goodsBll.GetGoodsCategory(goodsCategoryIds.Distinct().ToList());

            var units = await _goodsBll.GetUnits(unitIds.Distinct().ToList());

            var stockQtys = await _goodsBll.GetStStockQtyView(goodsIds, stockIds);

            var brands = await _goodsBll.GetGoodsBrands(brandIds.Distinct().ToList());

            var opGoodsView = goods.Select(p => new OpGoodsView()
            {
                Province           = ComLib.GetAreaName(p.Province, areas),
                City               = ComLib.GetAreaName(p.City, areas),
                District           = ComLib.GetAreaName(p.District, areas),
                Street             = ComLib.GetAreaName(p.Street, areas),
                Comment            = p.Comment,
                Contents           = p.Contents,
                DosageForms        = p.DosageForms,
                GoodsCategoryName  = ComLib.GetCategoryName(p.GoodsCategoryId, goodsCategorys),
                GoodsCode          = p.GoodsCode,
                GoodsIngredient    = p.GoodsIngredient,
                GoodsName          = p.GoodsName,
                GoodsOrigin        = p.GoodsOrigin,
                GoodsProduct       = p.GoodsProduct,
                GoodsRestrictive   = p.GoodsRestrictive,
                GoodsShortName     = p.GoodsShortName,
                GoodsSpec          = p.GoodsSpec,
                RegistrationHolder = p.RegistrationHolder,
                RegistrationNumber = p.RegistrationNumber,
                ShopName           = p.ShopName,
                RepertoryUnit      = ComLib.GetUnitNmae(p.BaseUnitId, units),
                RepertoryQty       = ComLib.GetRepertoryQty(p.GoodsId, p.StockId, stockQtys),
                GoodsBrand         = ComLib.GetBrand(p.BrandId, brands)
            });

            return(ResponsePagingBase.Success(opGoodsView, result.Item2));
        }