Esempio n. 1
0
        /// <summary>
        /// 分页获取商品信息
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ResponsePagingBase> ProcessAction(HttpContext httpContext, GetPurchaseBackPagingRequest request)
        {
            if (!HandleRequest(httpContext, request))
            {
                return(ResponsePagingBase.Success(new List <OpBackReceiptDetail>(), 0));
            }
            var result = await _openDataBll.GetBackReceiptDetail(request);

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

            foreach (var g in inReceipt)
            {
                areaIds.Add(g.Province);
                areaIds.Add(g.City);
                areaIds.Add(g.District);
                areaIds.Add(g.Street);
                unitIds.Add(g.UnitId);
                goodsCategoryIds.Add(g.GoodsCategoryId);
                brandIds.Add(g.BrandId);
                supplierIds.Add(g.BackOfferId);
            }
            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 brands = await _goodsBll.GetGoodsBrands(brandIds.Distinct().ToList());

            var suppliers = await _baseSupplierBll.GetBaseSupplier(supplierIds.Distinct().ToList());

            var opReceiptDetail = inReceipt.Select(p => new OpBackReceiptDetail()
            {
                Province          = ComLib.GetAreaName(p.Province, areas),
                City              = ComLib.GetAreaName(p.City, areas),
                District          = ComLib.GetAreaName(p.District, areas),
                Street            = ComLib.GetAreaName(p.Street, areas),
                GoodsCategoryName = ComLib.GetCategoryName(p.GoodsCategoryId, goodsCategorys),
                GoodsName         = p.GoodsName,
                GoodsSpec         = p.GoodsSpec,
                ShopName          = p.ShopName,
                GoodsBrand        = ComLib.GetBrand(p.BrandId, brands),
                BackCode          = p.BackCode,
                BackDate          = p.BackDate.ToDateTimeFromTimeStamp(),
                Qty          = p.Qty,
                SupplierName = ComLib.GetSupplierName(p.BackOfferId, suppliers),
                UnitName     = ComLib.GetUnitNmae(p.UnitId, units)
            });

            return(ResponsePagingBase.Success(opReceiptDetail, result.Item2));
        }
Esempio n. 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));
        }
        /// <summary>
        /// 分页获取商品信息
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ResponsePagingBase> ProcessAction(HttpContext httpContext, GetSaleGoodsBackPagingRequest request)
        {
            if (!HandleRequest(httpContext, request))
            {
                return(ResponsePagingBase.Success(new List <OpRetailDetail>(), 0));
            }
            var result = await _openDataBll.GetRetailBackDetail(request);

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

            foreach (var g in retailBack)
            {
                areaIds.Add(g.Province);
                areaIds.Add(g.City);
                areaIds.Add(g.District);
                areaIds.Add(g.Street);
                unitIds.Add(g.UnitId);
                goodsCategoryIds.Add(g.GoodsCategoryId);
                brandIds.Add(g.BrandId);
                retailId.Add(g.RetailBackId);
            }
            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 brands = await _goodsBll.GetGoodsBrands(brandIds.Distinct().ToList());

            var customers = await _retailCustomerBll.GetRetailCustomer(retailId.Distinct().ToList());

            var opRetailDetail = retailBack.Select(p =>
            {
                var customer = customers.FirstOrDefault(g => g.RetailId == p.RetailBackId);
                return(new OpRetailBackDetail()
                {
                    Province = ComLib.GetAreaName(p.Province, areas),
                    City = ComLib.GetAreaName(p.City, areas),
                    District = ComLib.GetAreaName(p.District, areas),
                    Street = ComLib.GetAreaName(p.Street, areas),
                    GoodsCategoryName = ComLib.GetCategoryName(p.GoodsCategoryId, goodsCategorys),
                    GoodsName = p.GoodsName,
                    GoodsSpec = p.GoodsSpec,
                    ShopName = p.ShopName,
                    GoodsBrand = ComLib.GetBrand(p.BrandId, brands),
                    BackBillCode = p.BillCode,
                    BackBillDate = p.BillDate.ToDateTimeFromTimeStamp(),
                    Qty = p.Qty,
                    UnitName = ComLib.GetUnitNmae(p.UnitId, units),
                    ReturnerIdentification = customer?.Identification,
                    ReturnerName = customer?.RetailCustomerName,
                    ReturnerTel = customer?.RetailCustomerTel
                });
            });

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