Ejemplo n.º 1
0
        public object Do_GetOnlineShopData(BaseApi baseApi)
        {
            GetOnlineShopDataParam getOnlineShopDataParam = JsonConvert.DeserializeObject <GetOnlineShopDataParam>(baseApi.param.ToString());

            if (getOnlineShopDataParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }

            OnlineData onlineData = Utils.GetCache <OnlineData>(getOnlineShopDataParam);

            if (onlineData == null)
            {
                string       shopId       = getOnlineShopDataParam.shopId;
                DashboardDao dashboardDao = new DashboardDao();
                Shops        shops        = dashboardDao.OnlineGetShops();

                PartSales partSales = new PartSales
                {
                    dailyAverage = dashboardDao.OnlineGetDailyAverage(shopId),
                    partSalesDay = dashboardDao.OnlineGetPartSalesDay(shopId),
                    monthGroups  = dashboardDao.OnlineGetMonthGroups(shopId)
                };

                Proportion proportion = new Proportion
                {
                    proportionLegend = dashboardDao.OnlineGetProportionLegend(),
                    proportionValues = dashboardDao.OnlineGetProportionValues()
                };

                SalesTrendData salesTrendData = new SalesTrendData
                {
                    list = dashboardDao.OnlineGetSalesTrendList(shopId)
                };

                OrderTrendData orderTrendData = new OrderTrendData
                {
                    list = dashboardDao.OnlineGetOrderTrendList(shopId)
                };

                BestSellerGoodsData bestSellerGoodsData = new BestSellerGoodsData
                {
                    list = dashboardDao.OnlineGetBestSellerGoodsList(shopId)
                };

                LowSellerGoodsData lowSellerGoodsData = new LowSellerGoodsData
                {
                    list = dashboardDao.OnlineGetLowSellerGoodsList(shopId)
                };

                AccountsReceivableTRateData accountsReceivableTRateData = new AccountsReceivableTRateData
                {
                    list = dashboardDao.OnlineGetAccountsReceivableTRateList(shopId)
                };

                onlineData = new OnlineData
                {
                    accountsReceivableTRateData = accountsReceivableTRateData,
                    bestSellerGoodsData         = bestSellerGoodsData,
                    lowSellerGoodsData          = lowSellerGoodsData,
                    orderTrendData = orderTrendData,
                    partSales      = partSales,
                    proportion     = proportion,
                    salesTrendData = salesTrendData,
                    shops          = shops
                };
                onlineData.Unique = getOnlineShopDataParam.GetUnique();
                Utils.SetCache(onlineData, 0, 1, 0);
            }

            return(onlineData);
        }