public void BindGrid(int paramPageIndex, int paramPageSize)//type为1时表示执行导出操作 { try { //退款状态 List <string> RefundStatus = new List <string>(); RefundStatus.Add("TRADE_CLOSED"); //天猫 RefundStatus.Add("TRADE_CANCELED"); //京东 RefundStatus.Add("STATUS_97"); //唯品会 RefundStatus.Add("ORDER_CANCEL"); //一号店 RefundStatus.Add("已取消"); //亚马逊 RefundStatus.Add("40"); //苏宁易购 //开始日期 string beginDate = this.ddlBeginDate.Value.ToString(); //结束日期 string endDate = this.ddlEndDate.Value.ToString(); if (string.IsNullOrEmpty(beginDate) || string.IsNullOrEmpty(endDate)) { if (string.IsNullOrEmpty(beginDate) && string.IsNullOrEmpty(endDate)) { return; } else { base.ShowMessage("请先选择开始日期与结束日期!"); return; } } DateTime begin = DateTime.Parse(beginDate); DateTime end = DateTime.Parse(endDate).AddDays(1); if (begin >= end) { base.ShowMessage("开始日期不能大于结束日期,请重新选择!"); return; } //组别 int groupId = int.Parse(this.ddlGroupID.SelectedValue); //姓名 string Name = this.ddlName.Text.ToString(); //级别 int RankID = int.Parse(this.ddlRank.SelectedValue); //客服部DepCode string DepCode = "QC1403-1,QC1403-2,QC1506-1"; //根据条件查询客服信息 var xMProjectList = base.CustomerInfoService.GetCustomerInfoPreList(groupId, "", DepCode, ""); //根据排名,求排名奖金系数 //分页 //var xMProjectPageList = new PagedList<XMPreSalesSalary>(xMProjectList, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); var codePlatformTypeList = base.CodeService.GetCodeListInfoByCodeTypeID(182, false);//获取平台信息 int JingDongID = 0; int TianMaoID = 0; for (int i = 0; i < codePlatformTypeList.Count; i++) { if (codePlatformTypeList[i].CodeName == "京东") { JingDongID = codePlatformTypeList[i].CodeID; } if (codePlatformTypeList[i].CodeName == "天猫") { TianMaoID = codePlatformTypeList[i].CodeID; } } for (int i = 0; i < xMProjectList.Count; i++) { //DateTime begin = DateTime.Parse(beginDate); //DateTime end = DateTime.Parse(endDate).AddDays(1); //客服ID int CustomerID = (int)xMProjectList[i].CustomerID; //旺旺号 var WangNoPreList = base.XMWangNoService.GetWangNoPreList(CustomerID, begin, end, RefundStatus); List <string> wangNoList = new List <string>(); List <XMPreSalesSalary> WangNoList = new List <XMPreSalesSalary>(); decimal TotalMoney = 0;//销售总金额 for (int j = 0; j < WangNoPreList.Count; j++) { if (wangNoList.IndexOf(WangNoPreList[j].WangNo) == -1) { wangNoList.Add(WangNoPreList[j].WangNo); XMPreSalesSalary info = new XMPreSalesSalary(); info.PlatformTypeId = WangNoPreList[j].PlatformTypeId; info.WangNo = WangNoPreList[j].WangNo; WangNoList.Add(info); } } for (int j = 0; j < WangNoPreList.Count; j++) { int index = wangNoList.IndexOf(WangNoPreList[j].WangNo); if (WangNoList[index].TotalMoney == null) { WangNoList[index].TotalMoney = (decimal)0; } if (WangNoPreList[j].PayPrice == null) { WangNoPreList[j].PayPrice = (decimal)0; } WangNoList[index].TotalMoney = WangNoList[index].TotalMoney + WangNoPreList[j].PayPrice;//旺旺号对应实际销售 TotalMoney = TotalMoney + (decimal)WangNoList[index].TotalMoney; } xMProjectList[i].TotalMoney = TotalMoney; decimal JingMao = 0; //京东天猫总销售额 decimal OtherPerformance = 0; //第三方平台总销售额 for (int j = 0; j < WangNoList.Count; j++) { if (WangNoList[j].PlatformTypeId == JingDongID || WangNoList[j].PlatformTypeId == TianMaoID) { JingMao = JingMao + (decimal)WangNoList[j].TotalMoney; } else { OtherPerformance = OtherPerformance + (decimal)WangNoList[j].TotalMoney; } } xMProjectList[i].JingMao = JingMao; xMProjectList[i].OtherPerformance = OtherPerformance; } for (int i = 0; i < xMProjectList.Count; i++) { //DateTime begin = DateTime.Parse(beginDate); //DateTime end = DateTime.Parse(endDate); //客服ID int CustomerID = (int)xMProjectList[i].CustomerID; //旺旺号 var WangNoPreList = base.XMWangNoService.GetWangNoPreList(CustomerID, begin, end, RefundStatus); var TotalClickFarming = base.XMWangNoService.GetTotalClickFarmingList(CustomerID, begin, end, RefundStatus); var TotalRefund = base.XMWangNoService.GetTotalRefundList(CustomerID, begin, end, RefundStatus); decimal totalClickFarming = 0; decimal totalRefund = 0; for (int z = 0; z < TotalClickFarming.Count; z++) { totalClickFarming = totalClickFarming + (decimal)TotalClickFarming[z].PayPrice; } xMProjectList[i].TotalClickFarming = totalClickFarming; for (int z = 0; z < TotalRefund.Count; z++) { totalRefund = totalRefund + (decimal)TotalRefund[z].PayPrice; } xMProjectList[i].TotalRefund = totalRefund; List <string> wangNoList = new List <string>(); List <XMPreSalesSalary> WangNoList = new List <XMPreSalesSalary>(); for (int j = 0; j < WangNoPreList.Count; j++) { if (wangNoList.IndexOf(WangNoPreList[j].WangNo) == -1) { wangNoList.Add(WangNoPreList[j].WangNo); XMPreSalesSalary info = new XMPreSalesSalary(); info.PlatformTypeId = WangNoPreList[j].PlatformTypeId; info.WangNo = WangNoPreList[j].WangNo; WangNoList.Add(info); } } for (int j = 0; j < WangNoPreList.Count; j++) { int index = wangNoList.IndexOf(WangNoPreList[j].WangNo); if (WangNoList[index].TotalMoney == null) { WangNoList[index].TotalMoney = (decimal)0; } if (WangNoPreList[j].PayPrice == null) { WangNoPreList[j].PayPrice = (decimal)0; } WangNoList[index].TotalMoney = WangNoList[index].TotalMoney + WangNoPreList[j].PayPrice;//旺旺号对应实际销售 } int GroupID = (int)xMProjectList[i].GroupID; var xMPreList = base.CustomerInfoService.GetSortPreList(xMProjectList, GroupID); if (xMProjectList[i].RankName == "组长" || xMProjectList[i].RankName == "主管") { xMProjectList[i].RankCoefficient = (decimal)0.007; } else if (xMPreList.Count > 0 && xMPreList[0].CustomerID == xMProjectList[i].CustomerID) { xMProjectList[i].RankCoefficient = (decimal)0.008; } else if (xMPreList.Count > 1 && xMPreList[1].CustomerID == xMProjectList[i].CustomerID) { xMProjectList[i].RankCoefficient = (decimal)0.007; } else if (xMPreList.Count > 2 && xMPreList[2].CustomerID == xMProjectList[i].CustomerID) { xMProjectList[i].RankCoefficient = (decimal)0.006; } else { xMProjectList[i].RankCoefficient = (decimal)0.005; } xMProjectList[i].TotalMoney = xMProjectList[i].JingMao + xMProjectList[i].OtherPerformance; xMProjectList[i].TotalCommission = xMProjectList[i].RankCoefficient * xMProjectList[i].JingMao + (decimal)0.001 * xMProjectList[i].OtherPerformance;//总提成 if (xMProjectList[i].BasicSalary == null) { xMProjectList[i].BasicSalary = 0; } xMProjectList[i].Total = xMProjectList[i].TotalCommission + xMProjectList[i].BasicSalary; string tabWangNo = ""; List <XMPreSalesSalary> ExportList = new List <XMPreSalesSalary>(); for (int j = 0; j < WangNoList.Count; j++) { if (WangNoList[j].PlatformTypeId == JingDongID || WangNoList[j].PlatformTypeId == TianMaoID) { WangNoList[j].RankCoefficient = xMProjectList[i].RankCoefficient; } else { WangNoList[j].RankCoefficient = (decimal)0.001; } if (type == 0) { //排名系数百分比显示 string Coefficient = ((float)(WangNoList[j].RankCoefficient) * 100).ToString() + "%"; tabWangNo = tabWangNo + "<tr><td style='text-align:center;'>" + WangNoList[j].WangNo + "</td>" + "<td style='text-align:left;'>" + WangNoList[j].TotalMoney + "</td>" + "<td style='text-align:left;'>" + WangNoList[j].RankCoefficient * WangNoList[j].TotalMoney + "</td>" + "<td style='text-align:left;'>" + Coefficient + "</td></tr>"; } else if (type == 1) { XMPreSalesSalary list = new XMPreSalesSalary(); list.WangNo = WangNoList[j].WangNo; //旺旺号 list.TotalMoney = WangNoList[j].TotalMoney; //实际销售额 list.Commission = WangNoList[j].RankCoefficient * WangNoList[j].TotalMoney; //提成 list.RankCoefficient = WangNoList[j].RankCoefficient; //排名系数 ExportList.Add(list); } } xMProjectList[i].tabWangNoList = ExportList; xMProjectList[i].tabWangNo = tabWangNo; } if (!string.IsNullOrEmpty(Name) || RankID != -1) { var xMPreNameList = base.CustomerInfoService.GetSortPreNameList(xMProjectList, Name, RankID); if (type == 1) { ExportXMPreSalesSalaryList = xMPreNameList; return; } var xMProjectPageNameList = new PagedList <XMPreSalesSalary>(xMPreNameList, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.grdvClients, xMProjectPageNameList, paramPageSize + 1); return; } if (type == 1) { ExportXMPreSalesSalaryList = xMProjectList; return; } var xMProjectPageList = new PagedList <XMPreSalesSalary>(xMProjectList, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.grdvClients, xMProjectPageList, paramPageSize + 1); } catch (Exception ex) { base.ShowMessage("查询出错!"); } }
/// <summary> /// 得到月售后数据 /// </summary> public XMAfterSalesDataAll GetAfterSalesData(XMPreSalesSalary user, string Month) { string[] year_month = Month.Split('-'); DateTime begin = DateTime.Parse(Month + "-01"); DateTime end = DateTime.Parse(Month + "-" + (DateTime.DaysInMonth(int.Parse(year_month[0]), int.Parse(year_month[1]))).ToString()); XMAfterSalesDataAll one = new XMAfterSalesDataAll(); one.CustomerID = (int)user.CustomerID; one.CustomerName = user.Name; one.GroupID = (int)user.GroupID; one.GroupName = user.Group; List <QuestionDetailed_Result> PersonalWorkload = base.XMAfterSalesDataService.GetXMAfterSalesDataByPersonalWorkload(begin, end, one.CustomerID); one.PersonalWorkload = PersonalWorkload.Count; List <QuestionDetailed_Result> DemandReturnCount = PersonalWorkload.Where(p => p.IsReturns == true).ToList(); one.DemandReturn = DemandReturnCount.Count; int ReturnID = 0; var codelist = base.CodeService.GetCodeListAll(); if (codelist != null) { foreach (CodeList item in codelist) { if (item.CodeName == "退货") { ReturnID = item.CodeID; break; } } } List <QuestionDetailed_Result> ActualReturnCount = PersonalWorkload.Where(p => p.ResultsId == ReturnID).ToList(); one.ActualReturn = ActualReturnCount.Count(); if (one.DemandReturn != 0) { one.ReturnRate = (Math.Round((Convert.ToDouble(one.DemandReturn - one.ActualReturn) * 100 / Convert.ToDouble(one.DemandReturn)), 2)).ToString() + " %"; } else { one.ReturnRate = "0 %"; } string date = begin.Year.ToString() + "-" + begin.Month.ToString().PadLeft(2, '0'); XMAfterSalesData data = base.XMAfterSalesDataService.GetXMAfterSalesDataInfoByMonth(Month, one.CustomerID); if (data != null) { one.ID = data.ID; one.ErrorCount = data.ErrorCount.ToString().Trim(); one.TMIndex = Math.Round((decimal)data.TMIndex, 2) + "%"; one.DSRScore = data.DSRScore.ToString().Trim(); one.ResponseTime = data.ResponseTime.ToString().Trim(); one.JDResponseTime = data.JDResponseTime.ToString().Trim(); one.JDCustomerService = data.JDCustomerService.ToString().Trim(); one.CustomerComplaints = data.CustomerComplaints.ToString().Trim(); one.EvaluationPoints = data.EvaluationPoints.ToString().Trim(); one.ExistXMAfterSalesData = true; } else { one.ID = 0; one.ErrorCount = ""; one.TMIndex = ""; one.DSRScore = ""; one.ResponseTime = ""; one.JDResponseTime = ""; one.JDCustomerService = ""; one.CustomerComplaints = ""; one.EvaluationPoints = ""; one.ExistXMAfterSalesData = false; } return(one); }