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); }
protected override GetAggSetoffForSourceByConditionListRD ProcessRequest(DTO.Base.APIRequest <GetAggSetoffForSourceListRP> pRequest) { var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息 var rd = new GetAggSetoffForSourceByConditionListRD(); var parameter = pRequest.Parameters; Agg_SetoffForSourceBLL bll = new Agg_SetoffForSourceBLL(loggingSessionInfo); List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "h.CustomerID", Value = loggingSessionInfo.ClientID }); if (!string.IsNullOrEmpty(parameter.SetoffRoleId)) { complexCondition.Add(new EqualsCondition() { FieldName = "h.SetoffRole", Value = parameter.SetoffRoleId }); } if (!string.IsNullOrEmpty(parameter.unitid)) { complexCondition.Add(new EqualsCondition() { FieldName = "h.UnitId", Value = parameter.unitid }); } if (!string.IsNullOrEmpty(parameter.starttime)) { complexCondition.Add(new DirectCondition("h.DateCode>= '" + parameter.starttime + "' ")); } if (!string.IsNullOrEmpty(parameter.endtime)) { complexCondition.Add(new DirectCondition("h.DateCode<= '" + parameter.endtime + "' ")); } if (String.IsNullOrEmpty(parameter.SortName)) { parameter.SortName = "OrderAmount"; } else { parameter.SortName = "" + parameter.SortName; } if (String.IsNullOrEmpty(parameter.SortOrder)) { parameter.SortOrder = "2"; } OrderBy order = null; if (parameter.SortOrder == "1") { order = new OrderBy() { FieldName = parameter.SortName, Direction = OrderByDirections.Asc }; } else { order = new OrderBy() { FieldName = parameter.SortName, Direction = OrderByDirections.Desc }; } //排序参数 List <OrderBy> lstOrder = new List <OrderBy> { }; lstOrder.Add(order); var tempList = bll.FindAllByPage(complexCondition.ToArray(), lstOrder.ToArray(), parameter.PageSize, parameter.PageIndex); rd.TotalPageCount = tempList.PageCount; rd.TotalCount = tempList.RowCount; rd.aggsetoffforSourcelist = tempList.Entities.Select(m => new AggSetoffForSourceByConditionList() { ID = m.ID.ToString(), PushMessageCount = m.PushMessageCount.ToString(), SetoffRole = bll.GetSetoffRoleNameBySetoffRoleId(Convert.ToInt32(m.SetoffRole.ToString())), ShareCount = m.ShareCount.ToString(), UnitName = m.UnitName, UserName = m.UserName, SetoffCount = m.SetoffCount.ToString(), OrderAmount = m.OrderAmount.ToString() }).ToList(); return(rd); }
/// <summary> /// 根据商户编号、时间、集客角色类型 获取 单条信息 /// </summary> /// <param name="customerid">商户编号</param> /// <param name="createtime">统计时间 2016-5-5</param> /// <param name="tooltype">类型( 员工 = 1, 客服 = 2, 会员 = 3)</param> /// <param name="SetoffRoleToolSourceService"></param> /// <returns></returns> public SetoffSourcesCount GetCountByCustomerIdAndDateCode(string customerid, string createtime, int tooltype, Agg_SetoffForSourceBLL SetoffRoleToolSourceService) { SetoffSourcesCount result = new SetoffSourcesCount(); List <EqualsCondition> lstWhereCondition = new List <EqualsCondition>(); lstWhereCondition.Add(new EqualsCondition() { FieldName = "DateCode", Value = createtime }); lstWhereCondition.Add(new EqualsCondition() { FieldName = "CustomerId", Value = customerid }); lstWhereCondition.Add(new EqualsCondition() { FieldName = "SetoffRole", Value = tooltype }); List <Agg_SetoffForSourceEntity> lst = SetoffRoleToolSourceService.Query(lstWhereCondition.ToArray(), null).ToList(); //按照条件查询 result.PeopleCount = lst.Sum(m => m.SetoffCount); result.ShareNumber = lst.Sum(m => m.ShareCount); return(result); }