public void BindGrid(int paramPageIndex, int paramPageSize, string sortExpression, string sortDirection) { int No = 1; var PlatformId = int.Parse(this.ddlPlatform.SelectedValue); var NickId = int.Parse(this.ddlNick.SelectedValue); var BeginDate = this.txtBeginDate.SelectedDate; var EndDate = this.txtEndDate.SelectedDate; var CustomerId = this.ddlCustomerService.SelectedValue; var NoTurnoverType = this.ddlNoTurnoverType.SelectedValue; var FollowCount = int.Parse(this.ddlFollowCount.SelectedValue); var Shift = this.ddlShift.SelectedValue; var xMNickList = base.XMNickService.GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 0); List <int?> a = new List <int?> { }; if (NickId == -2) { foreach (var list in xMNickList) { a.Add(list.nick_id); } } var NoDeallist = base.XMConsultationService.GetDataAnalysisNoDealList(PlatformId, NickId, BeginDate, EndDate, int.Parse(CustomerId), a, NoTurnoverType, FollowCount, int.Parse(Shift)); List <XMDataAnalysy> List = new List <XMDataAnalysy>(); List <XMDataAnalysy> ALL = new List <XMDataAnalysy>(); var Group_NoTurnoverType = NoDeallist.GroupBy(x => new { x.NoTurnoverType }); foreach (var Info in Group_NoTurnoverType) { int no = 1; int NoTurnoverTypeTotal = 0; XMDataAnalysy record = new XMDataAnalysy(); var InfoList = Info.ToList <XMDataAnalysy>(); record.ID = No; record.NoTurnoverType = InfoList[0].NoTurnoverType; No++; var group = InfoList.GroupBy(x => new { x.PlatformTypeId, x.NickId, x.CreatorID, x.DateReason }); foreach (var data in group) { var info = data.ToList <XMDataAnalysy>(); XMDataAnalysy one = new XMDataAnalysy(); one.ID = no; one.PlatformTypeId = info[0].PlatformTypeId; one.NickId = info[0].NickId; one.CreatorID = info[0].CreatorID; one.NoTurnoverTypeCount = info.Count; one.NoTurnoverType = info[0].NoTurnoverType; one.FollowCount = (int)info[0].XMConsultationDetails; one.DateReason = info[0].DateReason; ALL.Add(one); no++; record.DetailTab = record.DetailTab + "<tr><td>" + one.ID.ToString() + "</td><td>" + one.PlatformType + "</td><td>" + one.NickName + "</td><td>" + one.CreateName.FullName + "</td><td>" + one.DateReason + "</td></tr>"; NoTurnoverTypeTotal = NoTurnoverTypeTotal + one.NoTurnoverTypeCount; } record.NoTurnoverTypeCount = NoTurnoverTypeTotal; List.Add(record); } xmConsultationTotal = List; xmConsultationAll = ALL; var pageList = new PagedList <XMDataAnalysy>(List, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvQuestion, pageList, paramPageSize + 1); }
public void BindGrid(int paramPageIndex, int paramPageSize, string sortExpression, string sortDirection) { int No = 1; var PlatformId = int.Parse(this.ddlPlatform.SelectedValue); var NickId = int.Parse(this.ddlNick.SelectedValue); var BeginDate = this.txtBeginDate.SelectedDate; var EndDate = this.txtEndDate.SelectedDate; var CustomerId = this.ddlCustomerService.SelectedValue; var Shift = this.ddlShift.SelectedValue; var xMNickList = base.XMNickService.GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 0); List <int?> a = new List <int?> { }; if (NickId == -2) { foreach (var list in xMNickList) { a.Add(list.nick_id); } } var Consultationlist = base.XMConsultationService.GetDataAnalysisList(PlatformId, NickId, BeginDate, EndDate, int.Parse(CustomerId), a, int.Parse(Shift)); List <XMDataAnalysy> List = new List <XMDataAnalysy>(); List <XMDataAnalysy> ALL = new List <XMDataAnalysy>(); var Group_CreatorID = Consultationlist.GroupBy(x => new { x.CreatorID }); foreach (var Info in Group_CreatorID) { int no = 1; int Total_Consultation = 0; int Total_Deal = 0; int Total_DealPeople = 0; decimal Total_DealTotal = 0; XMDataAnalysy record = new XMDataAnalysy(); var InfoList = Info.ToList <XMConsultation>(); record.ID = No; record.CreatorID = InfoList[0].CreatorID; No++; var group = InfoList.GroupBy(x => new { x.PlatformTypeId, x.NickId }); foreach (var data in group) { var info = data.ToList <XMConsultation>(); int DealCount = 0; decimal DealTotal = 0; List <string> CustomerIDList = new List <string>(); XMDataAnalysy one = new XMDataAnalysy(); one.ID = no; one.PlatformTypeId = info[0].PlatformTypeId; one.NickId = info[0].NickId; one.CreatorID = info[0].CreatorID; //one.ReceptionDate = info[0].ReceptionDate; one.ConsultationCount = info.Count; foreach (var z in info) { if (z.IsOrder != null && (bool)z.IsOrder) { DealCount++; //var order = base.XMOrderInfoService.GetXMOrderByOrderCode(z.OrderCode); List <string> OrderCodeList = new List <string>();//防止同一订单号多条数据,报错 OrderCodeList.Add(z.OrderCode); var orderCodeList = base.XMOrderInfoService.GetXMOrderInfoByOrderCodeList(OrderCodeList); if (orderCodeList != null && orderCodeList.Count > 0) { DealTotal = DealTotal + (decimal)orderCodeList[0].PayPrice; } if (CustomerIDList.IndexOf(z.CustomerID) == -1) { CustomerIDList.Add(z.CustomerID); } } } one.DealCount = DealCount; one.DealPeopleCount = CustomerIDList.Count; one.ConversionRate = Math.Round(decimal.Parse(DealCount.ToString()) / decimal.Parse(info.Count.ToString()), 4); one.DealTotal = DealTotal; ALL.Add(one); no++; record.DetailTab = record.DetailTab + "<tr><td>" + one.ID.ToString() + "</td><td>" + one.PlatformType + "</td><td>" + one.NickName + "</td><td>" + one.ConsultationCount.ToString() + "</td><td>" + one.DealCount + "</td><td>" + one.DealPeopleCount + "</td><td>" + Math.Round(one.ConversionRate * 100, 2).ToString() + "%" + "</td><td>" + one.DealTotal.ToString() + "</td></tr>"; Total_Consultation = Total_Consultation + one.ConsultationCount; Total_Deal = Total_Deal + one.DealCount; Total_DealPeople = Total_DealPeople + one.DealPeopleCount; Total_DealTotal = Total_DealTotal + one.DealTotal; } record.ConsultationCount = Total_Consultation; record.DealCount = Total_Deal; record.DealPeopleCount = Total_DealPeople; record.ConversionRate = Math.Round(decimal.Parse(Total_Deal.ToString()) / decimal.Parse(Total_Consultation.ToString()), 4); record.DealTotal = Total_DealTotal; List.Add(record); } xmConsultationTotal = List; xmConsultationAll = ALL; var pageList = new PagedList <XMDataAnalysy>(List, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvQuestion, pageList, paramPageSize + 1); }
public void BindGrid(int paramPageIndex, int paramPageSize, string sortExpression, string sortDirection) { int No = 1; var PlatformId = int.Parse(this.ddlPlatform.SelectedValue); var NickId = int.Parse(this.ddlNick.SelectedValue); var BeginDate = this.txtBeginDate.SelectedDate; var EndDate = this.txtEndDate.SelectedDate; //var CustomerId = this.ddlCustomerService.SelectedValue; var ApplicationType = this.ddlApplicationType.SelectedValue; var xMNickList = base.XMNickService.GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 0); List <int?> a = new List <int?> { }; if (NickId == -2) { foreach (var list in xMNickList) { a.Add(list.nick_id); } } var Questionlist = base.XMApplicationService.GetDataAnalysisList(PlatformId, NickId, BeginDate, EndDate, -1, a, int.Parse(ApplicationType)); List <XMDataAnalysy> List = new List <XMDataAnalysy>(); List <XMDataAnalysy> ALL = new List <XMDataAnalysy>(); var Group_CreatorID = Questionlist.GroupBy(x => new { x.ApplicationType }); foreach (var Info in Group_CreatorID) { int no = 1; int DealTotal = 0; XMDataAnalysy record = new XMDataAnalysy(); var InfoList = Info.ToList <XMApplication>(); record.ID = No; record.ApplicationType = (int)InfoList[0].ApplicationType; No++; var group = InfoList.GroupBy(x => new { x.PlatformTypeId, x.NickId }); foreach (var data in group) { var info = data.ToList <XMApplication>(); List <string> CustomerIDList = new List <string>(); XMDataAnalysy one = new XMDataAnalysy(); one.ID = no; one.PlatformTypeId = info[0].PlatformTypeId; one.NickId = info[0].NickId; one.CreatorID = info[0].CreateID; one.ApplicationType = (int)info[0].ApplicationType; one.DealCount = info.Count; int count = base.XMApplicationService.GetNickCount(Questionlist, (int)info[0].PlatformTypeId, (int)info[0].NickId); one.TotalRate = Math.Round(decimal.Parse(info.Count.ToString()) / decimal.Parse(count.ToString()), 4); string rate = (Math.Round(one.TotalRate * 100, 2)).ToString() + "%"; ALL.Add(one); no++; record.DetailTab = record.DetailTab + "<tr><td>" + one.ID.ToString() + "</td><td>" + one.PlatformType + "</td><td>" + one.NickName + "</td><td>" + one.DealCount + "</td><td>" + rate + "</td></tr>"; DealTotal = DealTotal + one.DealCount; } record.DealCount = DealTotal; List.Add(record); } xmConsultationTotal = List; xmConsultationAll = ALL; var pageList = new PagedList <XMDataAnalysy>(List, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvQuestion, pageList, paramPageSize + 1); }
public void BindGrid(int paramPageIndex, int paramPageSize, string sortExpression, string sortDirection) { int No = 1; var PlatformId = int.Parse(this.ddlPlatform.SelectedValue); var NickId = int.Parse(this.ddlNick.SelectedValue); var BeginDate = this.txtBeginDate.SelectedDate; var EndDate = this.txtEndDate.SelectedDate; var CustomerId = this.ddlCustomerService.SelectedValue; var QuestionType = this.ddlQuestionType.SelectedValue; var QuestionLevel = this.ddlQuestionLevel.SelectedValue; List <int?> questionTypeIDs = new List <int?>(); //子节点集合 if (Convert.ToInt16(QuestionType) > 0) { var questionType = base.XMQuestionCategoryService.GetXMQuestionCategoryById(int.Parse(QuestionType)); if (questionType != null) { //查询该父节点下子节点列表 var childQuestion = base.XMQuestionCategoryService.GetXMQuestionCategoryByParentID(questionType.Id); if (childQuestion != null && childQuestion.Count() > 0) { foreach (XMQuestionCategory str in childQuestion) { questionTypeIDs.Add(str.Id); } } } } var xMNickList = base.XMNickService.GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 0); List <int?> a = new List <int?> { }; if (NickId == -2) { foreach (var list in xMNickList) { a.Add(list.nick_id); } } //查出对应问题列表 (问题类型为子节点类型) //var Questionlist = base.XMQuestionService.GetDataAnalysisList(PlatformId, NickId, BeginDate, EndDate, int.Parse(CustomerId), a, int.Parse(QuestionType), int.Parse(QuestionLevel)); var Questionlist = base.XMQuestionService.GetQuestionAnalysisList(PlatformId, NickId, BeginDate, EndDate, int.Parse(CustomerId), a, questionTypeIDs, int.Parse(QuestionLevel)); List <XMDataAnalysy> List = new List <XMDataAnalysy>(); List <XMDataAnalysy> ALL = new List <XMDataAnalysy>(); var Group_CreatorID = Questionlist.GroupBy(x => new { x.CreatorID }); foreach (var Info in Group_CreatorID) { int no = 1; //int DealTotal = 0; //int ProcessingCount = 0; decimal TimeTotal = 0; int TimeCount = 0; XMDataAnalysy record = new XMDataAnalysy(); var InfoList = Info.ToList <XMDataAnalysy>(); record.ID = No; record.CreatorID = InfoList[0].CreatorID; No++; if (int.Parse(ddlQuestionType.SelectedValue) > 0) { var group = InfoList.GroupBy(x => new { x.PlatformTypeId, x.NickId, x.QuestionLevel }); foreach (var data in group) { var info = data.ToList <XMDataAnalysy>(); List <string> CustomerIDList = new List <string>(); XMDataAnalysy one = new XMDataAnalysy(); one.ID = no; one.PlatformTypeId = info[0].PlatformTypeId; one.NickId = info[0].NickId; one.CreatorID = info[0].CreatorID; one.QuestionType = info[0].QuestionType; one.QuestionLevel = info[0].QuestionLevel; one.DealCount = info.Count; ALL.Add(one); no++; string QuestionLevelName = one.QuestionLevelName == null ? "" : one.QuestionLevelName.CodeName; string QuestionTypeName = one.QuestionTypeName == null ? "" : one.QuestionTypeName.CodeName; record.DetailTab = record.DetailTab + "<tr><td>" + one.ID.ToString() + "</td><td>" + one.PlatformType + "</td><td>" + one.NickName + "</td><td>" + one.ParentQuestionTypeName + "</td><td>" + QuestionLevelName + "</td><td>" + one.DealCount + "</td></tr>"; //DealTotal = DealTotal + one.DealCount; } } else//选择所有 { var group = InfoList.GroupBy(x => new { x.PlatformTypeId, x.NickId, x.ParentQuestionType, x.QuestionLevel }); List <XMDataAnalysy> List2 = new List <XMDataAnalysy>(); foreach (var data in group) { string categoryName = string.Empty; var info = data.ToList <XMDataAnalysy>(); XMDataAnalysy one = new XMDataAnalysy(); one.ID = no; one.PlatformTypeId = info[0].PlatformTypeId; one.NickId = info[0].NickId; one.CreatorID = info[0].CreatorID; one.QuestionType = info[0].QuestionType; one.QuestionLevel = info[0].QuestionLevel; one.DealCount = info.Count; ALL.Add(one); no++; string QuestionLevelName = one.QuestionLevelName == null ? "" : one.QuestionLevelName.CodeName; string QuestionTypeName = info[0].QuestionCategoryName; var f = base.XMQuestionCategoryService.GetXMQuestionCategoryById(info[0].ParentQuestionType); if (f != null) { categoryName = f.CategoryName; } record.DetailTab = record.DetailTab + "<tr><td>" + one.ID.ToString() + "</td><td>" + one.PlatformType + "</td><td>" + one.NickName + "</td><td>" + categoryName + "</td><td>" + QuestionLevelName + "</td><td>" + one.DealCount + "</td></tr>"; //DealTotal = DealTotal + one.DealCount; } } record.DealCount = 0; //数量 record.ProcessingCount = 0; //处理中数量 record.CompleteRate = 0; //完成率 record.OrderAmount = 0; //订单金额 List <int> questionIdList = InfoList.Select(x => x.QuestionID).Distinct().ToList(); var QuestionList = base.XMQuestionService.GetQuestionsListByIDs(questionIdList); if (QuestionList != null && QuestionList.Count > 0) { record.DealCount = QuestionList.Count; var processingCount = QuestionList.Where(x => x.Status == (int)QuestionStatusEnum.Deal || x.Status == (int)QuestionStatusEnum.Submit); if (processingCount != null && processingCount.Count() > 0) { record.ProcessingCount = processingCount.Count(); } var completeCount = QuestionList.Where(x => x.Status == (int)QuestionStatusEnum.Complete); if (completeCount != null && completeCount.Count() > 0) { record.CompleteCount = completeCount.Count(); record.CompleteRate = Math.Round(decimal.Parse(completeCount.Count().ToString()) / decimal.Parse(record.DealCount.ToString()), 4); List <string> orderCodeList = completeCount.Select(x => x.OrderNO).Distinct().ToList(); var OrderList = base.XMOrderInfoService.GetXMOrderInfoByOrderCodeList(orderCodeList); if (OrderList != null && OrderList.Count > 0) { record.OrderAmount = (decimal)OrderList.Sum(x => x.PayPrice); } } } //处理中问题数量 foreach (var data in InfoList) { //if (data.Status == (int)QuestionStatusEnum.Deal) //{ // ProcessingCount++; //} if (data.Status == (int)QuestionStatusEnum.Complete) { if (!data.IsReturns) { TimeCount++; TimeSpan ts = (TimeSpan)(data.LastModifyTime - data.OrdersTime); TimeTotal += (decimal)ts.TotalHours; } } } //record.ProcessingCount = ProcessingCount; if (TimeCount > 0) { record.TimeEfficiency = Math.Round((TimeTotal / TimeCount), 2); } else { record.TimeEfficiency = 0; } //int CompleteCount = base.XMQuestionService.GetCompleteCount(Questionlist, (int)InfoList[0].CreatorID, "Complete"); //record.CompleteRate = Math.Round(decimal.Parse(CompleteCount.ToString()) / decimal.Parse(DealTotal.ToString()), 4); int ReturnCount = base.XMQuestionService.GetCompleteCount(Questionlist, (int)InfoList[0].CreatorID, "ReturnCount"); int ReturnTotal = base.XMQuestionService.GetCompleteCount(Questionlist, (int)InfoList[0].CreatorID, "ReturnTotal"); //实际退货数量 record.RealReturnCount = ReturnCount; record.ReturnTotal = ReturnTotal; //申请退货问题数量 record.ApplicationReturnCount = ReturnTotal; if (ReturnTotal != 0) { record.ReturnRate = Math.Round(decimal.Parse((ReturnTotal - ReturnCount).ToString()) / decimal.Parse(ReturnTotal.ToString()), 4); } else { record.ReturnRate = 0; } List.Add(record); } xmConsultationTotal = List; xmConsultationAll = ALL; var pageList = new PagedList <XMDataAnalysy>(List, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvQuestion, pageList, paramPageSize + 1); }
public void BindGrid(int paramPageIndex, int paramPageSize, string sortExpression, string sortDirection) { int No = 1; var BeginDate = this.txtBeginDate.SelectedDate; var EndDate = this.txtEndDate.SelectedDate; var QuestionType = this.ddlQuestionType.SelectedValue; List <int?> questionTypeIDs = new List <int?>(); //子节点集合 if (Convert.ToInt16(QuestionType) > 0) { var questionType = base.XMQuestionCategoryService.GetXMQuestionCategoryById(int.Parse(QuestionType)); if (questionType != null) { //查询该父节点下子节点列表 var childQuestion = base.XMQuestionCategoryService.GetXMQuestionCategoryByParentID(questionType.Id); if (childQuestion != null && childQuestion.Count() > 0) { foreach (XMQuestionCategory str in childQuestion) { questionTypeIDs.Add(str.Id); } } } } List <XMDataAnalysy> List = new List <XMDataAnalysy>(); List <XMDataAnalysy> ALL = new List <XMDataAnalysy>(); //选择问题类型了 if (int.Parse(QuestionType) > 0) { //获取选定问题类型信息 var f = base.XMQuestionCategoryService.GetXMQuestionCategoryById(int.Parse(QuestionType)); if (f != null) { XMDataAnalysy record = new XMDataAnalysy(); int no = 1; int total = 0; record.ID = No; record.QuestionType = f.Id; record.ParentQuestionTypeName = f.CategoryName; //查询该父节点下的所有子节点 var cCategoryList = base.XMQuestionCategoryService.GetXMQuestionCategoryPrarentList(f.Id); //该节点下所有子节点 if (cCategoryList != null) { int sum = getPCategoryCount(f.Id, BeginDate, EndDate); foreach (var t in cCategoryList) { XMDataAnalysy one = new XMDataAnalysy(); var xMProjectId = Convert.ToInt32(this.ddXMProject.SelectedValue); int nickID = -1; int.TryParse(this.ddlNick.SelectedValue, out nickID); string nickids = ""; if (nickID == 99) //某个项目店铺权限,选择有权限的店铺 { var nickList = base.XMOrderInfoAPIService.GetXMNickListSS("", Convert.ToInt32(true), xMProjectId, HozestERPContext.Current.User.CustomerID, 0); for (int i = 0; i < nickList.Count; i++) { nickids = nickids + nickList[i].nick_id + ","; } if (nickids.Length > 0) { nickids = nickids.Substring(0, nickids.Length - 1); } } else { nickids = nickID.ToString(); } var info = base.XMQuestionDetailService.GetQuestionDetailsByParm(xMProjectId, nickids, BeginDate, EndDate, t.Id); if (info != null && info.Count() > 0) { total += info.Count(); one.ID = no; one.NickId = nickID; one.QuestionType = info[0].QuestionTypeID; int count = info.Count(); one.TotalRate = sum != 0 ? Math.Round(count / decimal.Parse(sum.ToString()), 4) : 0; string rate = (Math.Round(one.TotalRate * 100, 2)).ToString() + "%"; one.DealCount = info.Count; ALL.Add(one); no++; record.DetailTab = record.DetailTab + "<tr><td>" + one.ID.ToString() + "</td><td>" + info[0].QuestionCategoryType + "</td><td>" + one.DealCount + "</td><td>" + rate + "</td></tr>"; } } } record.DealCount = total; List.Add(record); } } else //所有 { var pCategoryList = base.XMQuestionCategoryService.GetXMQuestionCategoryByParentID(0); //查询所有父节点 //遍历父节点 foreach (var q in pCategoryList) { XMDataAnalysy record = new XMDataAnalysy(); int no = 1; int total = 0; record.ID = No; record.QuestionType = q.Id; record.ParentQuestionTypeName = q.CategoryName; No++; //查询该父节点下的所有子节点 var cCategoryList = base.XMQuestionCategoryService.GetXMQuestionCategoryPrarentList(q.Id); //该节点下所有子节点 if (cCategoryList != null) { int sum = getPCategoryCount(q.Id, BeginDate, EndDate); foreach (var t in cCategoryList) { XMDataAnalysy one = new XMDataAnalysy(); var xMProjectId = Convert.ToInt32(this.ddXMProject.SelectedValue); int nickID = -1; int.TryParse(this.ddlNick.SelectedValue, out nickID); string nickids = ""; if (nickID == 99) //某个项目店铺权限,选择有权限的店铺 { var nickList = base.XMOrderInfoAPIService.GetXMNickListSS("", Convert.ToInt32(true), xMProjectId, HozestERPContext.Current.User.CustomerID, 0); for (int i = 0; i < nickList.Count; i++) { nickids = nickids + nickList[i].nick_id + ","; } if (nickids.Length > 0) { nickids = nickids.Substring(0, nickids.Length - 1); } } else { nickids = nickID.ToString(); } var info = base.XMQuestionDetailService.GetQuestionDetailsByParm(xMProjectId, nickids, BeginDate, EndDate, t.Id); if (info != null && info.Count() > 0) { total += info.Count(); one.ID = no; one.NickId = nickID; one.QuestionType = info[0].QuestionTypeID; int count = info.Count(); one.TotalRate = sum != 0 ? Math.Round(count / decimal.Parse(sum.ToString()), 4) : 0; string rate = (Math.Round(one.TotalRate * 100, 2)).ToString() + "%"; one.DealCount = info.Count; ALL.Add(one); no++; record.DetailTab = record.DetailTab + "<tr><td>" + one.ID.ToString() + "</td><td>" + info[0].QuestionCategoryType + "</td><td>" + one.DealCount + "</td><td>" + rate + "</td></tr>"; } } } record.DealCount = total; List.Add(record); } } xmConsultationTotal = List; xmConsultationAll = ALL; var pageList = new PagedList <XMDataAnalysy>(List, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvQuestion, pageList, paramPageSize + 1); }