Ejemplo n.º 1
0
        private OrderDailyInfo GetSourcePriceModel(IDataReader read)
        {
            OrderDailyInfo odInfo = new OrderDailyInfo();

            odInfo.Source      = read["Source"].ToInt();
            odInfo.PayQuan     = read["PayQuan"].ToInt();
            odInfo.PayAmount   = read["PayAmount"].ToDecimal();
            odInfo.OrderQuan   = read["OrderQuan"].ToInt();
            odInfo.OrderAmount = read["OrderAmount"].ToDecimal();
            return(odInfo);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  查询对比值
        /// </summary>
        /// <param name="typeID">类型: 0:当天 1:昨天 2:7天 3:30天 4:自定义时间 5:90天</param>
        /// <returns></returns>
        public JsonResult GetDataContrast(string startTime, string endTime, int typeID = 2)
        {
            //同比:由时间控制
            //环比:开始时间 对比的数据是上一个月数据,被对比的数据,是由时间提供,本月数据不作对比


            //设定时间
            var result = new JsonResultObject();
            IList <DataContrastInfo> dcInfoList = new List <DataContrastInfo>();

            //当前时间
            DateTime sTime = DateTime.Now;
            DateTime eTime = DateTime.Now;

            GetTime(startTime, endTime, typeID, ref sTime, ref eTime);

            //同比时间
            DateTime anSTime = sTime.AddYears(-1);
            DateTime anETime = eTime.AddYears(-1);

            //被环比的时间
            DateTime adjStime = sTime.AddDays(-1);
            DateTime adjEtime = eTime.AddDays(-1);


            TimeSpan ts = sTime - DateTime.Parse(eTime.ToShortDateString());

            adjStime = adjStime.Add(ts);
            adjEtime = adjEtime.Add(ts);

            //同比数据
            OperationResult <IList <OrderDailyInfo> > anInfo =
                OrderDailyBLL.Instance.OrderDaily_GetSUMAll(anSTime, anETime);

            //环比数据
            OperationResult <IList <OrderDailyInfo> > adjInfo =
                OrderDailyBLL.Instance.OrderDaily_GetSUMAll(adjStime, adjEtime);

            //获取本年同比数据
            OperationResult <IList <OrderDailyInfo> > currentAnInfo =
                OrderDailyBLL.Instance.OrderDaily_GetSUMAll(sTime, eTime);

            if (anInfo.ResultType != OperationResultType.Success ||
                adjInfo.ResultType != OperationResultType.Success ||
                currentAnInfo.ResultType != OperationResultType.Success)
            {
                result.status = false;
                result.msg    = "展示异常,数据库连接异常!";
                return(Json(result));
            }
            IList <OrderDailyInfo> cInfoList = currentAnInfo.AppendData;

            for (int i = 0; i < cInfoList.Count; i++)
            {
                OrderDailyInfo   cInfo  = cInfoList[i];
                DataContrastInfo dcInfo = new DataContrastInfo();
                dcInfo.Source      = cInfo.Source;
                dcInfo.SourceName  = Enum.GetName(typeof(OrderSource), dcInfo.Source);
                dcInfo.OrderAmount = cInfo.OrderAmount;
                dcInfo.OrderQuan   = cInfo.OrderQuan;
                dcInfo.PayQuan     = cInfo.PayQuan;
                dcInfo.NoPayQuan   = cInfo.OrderQuan - cInfo.PayQuan;
                dcInfoList.Add(dcInfo);
            }

            foreach (var cInfo in dcInfoList)
            {
                foreach (var aInfo in anInfo.AppendData)
                {
                    //同比值
                    if (cInfo.Source == aInfo.Source)
                    {
                        cInfo.AnOrderAmount = GetPercent(cInfo.OrderAmount, aInfo.OrderAmount);                             //总订单额
                        cInfo.AnOrderQuan   = GetPercent(cInfo.OrderQuan, aInfo.OrderQuan);                                 //总订单数
                        cInfo.AnPayQuan     = GetPercent(cInfo.PayQuan, aInfo.PayQuan);                                     //支付订单
                        cInfo.AnNoPayQuan   = GetPercent(cInfo.OrderQuan - cInfo.PayQuan, aInfo.OrderQuan - aInfo.PayQuan); //未支付订单量
                    }
                }
                foreach (var adInfo in adjInfo.AppendData)
                {
                    //环比值
                    if (cInfo.Source == adInfo.Source)
                    {
                        cInfo.AdjOrderAmount = GetPercent(cInfo.OrderAmount, adInfo.OrderAmount);                              //总订单额
                        cInfo.AdjOrderQuan   = GetPercent(cInfo.OrderQuan, adInfo.OrderQuan);                                  //总订单数
                        cInfo.AdjPayQuan     = GetPercent(cInfo.PayQuan, adInfo.PayQuan);                                      //支付订单
                        cInfo.AdjNoPayQuan   = GetPercent(cInfo.OrderQuan - cInfo.PayQuan, adInfo.OrderQuan - adInfo.PayQuan); //未支付订单量
                    }
                }
            }
            result.data   = JsonHelper.ConvertToJson(dcInfoList);
            result.msg    = null;
            result.status = true;
            return(Json(result));
        }