Exemple #1
0
        protected override GetAggSetoffForSourceListRD ProcessRequest(APIRequest <GetAggSetoffForSourceListRP> pRequest)
        {
            #region 设置参数 获取数据源
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息

            var rd = new GetAggSetoffForSourceListRD();

            int    Days       = 7;
            int    type       = pRequest.Parameters.type;
            string customerid = loggingSessionInfo.ClientID;
            if (type == 2)
            {
                Days = 30;
            }                             //typeId(1=近7天,2=近30天)
            DateTime currentTime = DateTime.Now.AddDays(-6);

            Agg_SetoffForSourceBLL SetoffRoleToolSourceService = new Agg_SetoffForSourceBLL(loggingSessionInfo);

            List <int> setoffrolelst = new List <int>()
            {
                1, 2, 3
            };
            #endregion

            #region 柱状图
            for (int i = 0; i < 5; i++)               //获取前五天柱状图 柱状图 永远是5天。
            {
                currentTime = currentTime.AddDays(1); //当前时间的累积
                SetOffSourcesDate _model = new SetOffSourcesDate();
                _model.datetime = currentTime.ToString("yyyy-MM-dd");
                // 3个类别所以循环三次分别统计该商户某一天的某一个类别下面的集客人数和分享人数
                foreach (var item in setoffrolelst)  //     员工 = 1, 客服 = 2, 会员 = 3
                {
                    var basemodel = GetCountByCustomerIdAndDateCode(customerid, _model.datetime, item, SetoffRoleToolSourceService);
                    SetOffSourcesContent content = new SetOffSourcesContent();
                    content.PeopleCount  = basemodel.PeopleCount;
                    content.ShareCount   = basemodel.ShareNumber;
                    content.SetoffRoleId = item;
                    _model.RoleContent.Add(content);
                }
                rd.lst.Add(_model);
            }
            #endregion

            //根据类型 和商户编号 来获取数据 {分页就可以了}
            #region 统计上面方块基础数据
            //3 个角色 一个角色有好几天的 信息 总计  记住是前 7天而不是前 7条数据
            foreach (var item in setoffrolelst) //员工 = 1, 客服 = 2, 会员 = 3
            {
                string begintime     = DateTime.Now.AddDays(-Days).ToString("yyyy-MM-dd");
                string endtime       = DateTime.Now.ToString("yyyy-MM-dd");
                string prevbegintime = DateTime.Now.AddDays(-2 * Days).ToString("yyyy-MM-dd");

                var modles = SetoffRoleToolSourceService.GetSetofSourcesListByCustomerId(customerid, item, begintime, endtime);
                SetoffSourcesCount currentmodel = ConvertToEntity(modles);
                var oldmodels = SetoffRoleToolSourceService.GetSetofSourcesListByCustomerId(customerid, item, prevbegintime, begintime);
                SetoffSourcesCount oldmodel = ConvertToEntity(oldmodels);
                int?DiffCount = currentmodel.PeopleCount - oldmodel.PeopleCount;
                rd.roletoolsources.Add(new SetOffRoleSources(item, currentmodel.ShareNumber, currentmodel.PeopleCount, DiffCount));
            }
            #endregion

            #region 统计总数据
            //统计总数
            rd.ShareTotal     = rd.roletoolsources.Sum(m => m.ShareCount);  //分享总数
            rd.TotalSetOff    = rd.roletoolsources.Sum(m => m.SetoffCount); //集客总数
            rd.AddTotalSetOff = rd.roletoolsources.Sum(m => m.DiffCount);   //新增集客人数
            #endregion
            return(rd);
        }