/// <summary>
        /// 获取默认显示的库存信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private async Task <ResponsePagingBase> GetStatisticsStockShopDefault(GetStatisticsStockShopPageRequest request)
        {
            Tuple <IEnumerable <DbStatisticsStockViewShop>, int> statisticsStockShopView = null;

            switch (_appTicket.DataLimitType)
            {
            case (int)DataLimitTypeEnum.All:
                var province = await _areaBll.GetProvince();

                statisticsStockShopView = await _reportBll.GetStatisticsStockShop(request, string.Join(',', province.Select(p => p.AreaId)), AreaLevelEnum.Province);

                break;

            case (int)DataLimitTypeEnum.Area:
                if (!string.IsNullOrEmpty(_appTicket.DataLimitArea))
                {
                    var areaInfo = await ComLib.GetGetAreaStatisticsAreaId(_areaBll, _appTicket.DataLimitArea);

                    statisticsStockShopView = await _reportBll.GetStatisticsStockShop(request, areaInfo.Item1, areaInfo.Item2);
                }
                break;

            case (int)DataLimitTypeEnum.Shop:
                if (!string.IsNullOrEmpty(_appTicket.DataLimitShop))
                {
                    statisticsStockShopView = await _reportBll.GetStatisticsStockShopByShop(request, _appTicket.DataLimitShop);
                }
                break;
            }
            var result = await GetStatisticsStockShopView(statisticsStockShopView, request.Type);

            var recordCount = statisticsStockShopView == null ? 0 : statisticsStockShopView.Item2;

            return(ResponsePagingBase.Success(result, recordCount));
        }
Exemplo n.º 2
0
 public async Task <ResponsePagingBase> GetStatisticsStockShopPage([FromBody] GetStatisticsStockShopPageRequest request)
 {
     try
     {
         var action = new GetStatisticsStockShopPageAction(_areaBll, _reportBll);
         return(await action.ProcessAction(this.HttpContext, request));
     }
     catch (Exception ex)
     {
         Log.Error(request, ex, this.GetType());
         return(new ResponsePagingBase().GetResponseCodeError());
     }
 }
        /// <summary>
        /// 通过区域级别获取库存信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private async Task <ResponsePagingBase> GetStatisticsStockShopLevel(GetStatisticsStockShopPageRequest request)
        {
            if (_appTicket.DataLimitType == (int)DataLimitTypeEnum.Area && _appTicket.DataLimitArea.IndexOf(request.AreaId.ToString()) < 0)
            {
                return(new ResponsePagingBase().GetResponseError(StatusCode.DataForbidden, "数据无权访问"));
            }
            var         newLevel = string.Empty;
            List <Area> areas    = null;

            switch (request.Level)
            {
            case AreaLevelEnum.Province:
                //获取市
                newLevel = AreaLevelEnum.City;
                areas    = await _areaBll.GetCity(request.AreaId);

                break;

            case AreaLevelEnum.City:
                //获取县、区
                newLevel = AreaLevelEnum.District;
                areas    = await _areaBll.GetDistrict(request.AreaId);

                break;

            case AreaLevelEnum.District:
                //获取乡镇
                newLevel = AreaLevelEnum.Street;
                areas    = await _areaBll.GetStreet(request.AreaId);

                break;
            }
            if (areas == null || !areas.Any())
            {
                return(ResponsePagingBase.Success(GetEmptyData(), 0));
            }
            var statisticsRetail = await _reportBll.GetStatisticsStockShop(request, string.Join(',', areas.Select(p => p.AreaId)), newLevel);

            var result = await GetStatisticsStockShopView(statisticsRetail, request.Type);

            var recordCount = statisticsRetail == null ? 0 : statisticsRetail.Item2;

            return(ResponsePagingBase.Success(result, recordCount));
        }
 /// <summary>
 /// 区域门店库存看板
 /// </summary>
 /// <param name="httpContext"></param>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <ResponsePagingBase> ProcessAction(HttpContext httpContext, GetStatisticsStockShopPageRequest request)
 {
     _appTicket = AppTicket.GetAppTicket(httpContext);
     if (request.AreaId == 0 || _appTicket.DataLimitType == (int)DataLimitTypeEnum.Shop)
     {
         return(await GetStatisticsStockShopDefault(request));
     }
     return(await GetStatisticsStockShopLevel(request));
 }