public HttpResponseMessage GetNoteListJson(string queryJson) { var watch = CommonHelper.TimerStart(); var loginid = queryJson.ToJObject()["loginid"].ToString(); var datas = employ_notebll.GetList(queryJson); var user = userBLL.GetEntity(loginid); var lstuid = new List <string>(); if (loginid == null) { return(new HttpResponseMessage { Content = new StringContent("超时,请重新登录。", Encoding.GetEncoding("UTF-8"), "application/json") }); } HttpResponseMessage ut = new HttpResponseMessage { Content = new StringContent(datas.ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; ////不是经理时,只能看到自己的数据 if (!string.IsNullOrEmpty(user.ManagerId)) { lstuid = CommonMethod.GetUserList(loginid); if (lstuid == null) { return(new HttpResponseMessage { Content = new StringContent("当前用户ID不存在", Encoding.GetEncoding("UTF-8"), "application/json") }); } var data = datas.Where(p => lstuid.Contains(p.UserId)); ut = new HttpResponseMessage { Content = new StringContent(data.ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; } return(ut); }
public HttpResponseMessage CheckLoginJson(string username, string password) { try { RoleBLL roleBLL = new RoleBLL(); DepartmentBLL departmentBLL = new DepartmentBLL(); OrganizeBLL organizeBLL = new OrganizeBLL(); UserBLL userBLL = new UserBLL(); byte[] sor = Encoding.UTF8.GetBytes(password); MD5 md5 = MD5.Create(); byte[] result = md5.ComputeHash(sor); StringBuilder strbul = new StringBuilder(40); for (int i = 0; i < result.Length; i++) { strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位 } password = strbul.ToString(); UserEntity userEntity = new UserBLL().CheckLogin(username, password); if (userEntity == null) { return(new HttpResponseMessage { Content = new StringContent("查询失败", Encoding.GetEncoding("UTF-8"), "application/json") }); } UserUrlModel userurlmodel = new UserUrlModel(); EntityToEntity(userurlmodel, userEntity); OrganizeEntity orgent = organizeBLL.GetEntity(userEntity.OrganizeId); if (string.IsNullOrEmpty(orgent.ParentId) || orgent.ParentId == "0") { userurlmodel.IsTopOrg = true; } //var orgnizedata = organizeBLL.GetList().ToList(); //List<OrganizeEntity> lstOrg = new List<OrganizeEntity>(); Operator operators = new Operator(); //foreach (OrganizeEntity org in orgnizedata) //{ // if (org.ManagerId == userurlmodel.UserId) // { // // operators.LstOrganizeId.Add(org.OrganizeId); //登录用户作为负责人的公司 // lstOrg=(Reorg(orgnizedata, org.OrganizeId));//登录用户作为负责人的公司及下属 // } //} //operators.LstOrganizeId = new List<string>(); //foreach (OrganizeEntity org in lstOrg) //{ // operators.LstOrganizeId.Add(org.OrganizeId); //} //var departmentdata = departmentBLL.GetList().ToList(); //List<DepartmentEntity> lstDep = new List<DepartmentEntity>(); //foreach (DepartmentEntity dep in departmentdata) //{ // if (dep.DepartmentId == userurlmodel.DepartmentId) // { // userurlmodel.DepartmentName = dep.FullName; // } // if (dep.ManagerId == userurlmodel.UserId) // { // // operators.LstOrganizeId.Add(dep.DepartmentId);//登录用户作为负责人的部门 // lstDep=(Redep(departmentdata, dep.DepartmentId));//登录用户作为负责人的部门及下属 // } //} //operators.LstDepartmentId = new List<string>(); //foreach (DepartmentEntity dep in lstDep) //{ // operators.LstDepartmentId.Add(dep.DepartmentId); //} //var userdata = userBLL.GetList().ToList(); //List<UserEntity> lstUser = new List<UserEntity>(); //foreach (UserEntity usr in userdata) //{ // if (usr.ManagerId == userurlmodel.UserId) // { // //operators.LstStaffId.Add(usr.UserId);//登录用户上级主管的用户 // lstUser=(Reusr(userdata, userurlmodel.UserId));//登录用户作为负责人的部门及下属 // } //} //operators.LstStaffId = new List<string>(); //foreach (UserEntity usr in lstUser) //{ // operators.LstStaffId.Add(usr.UserId); //} ////var depuser1 = new List<string>(); ////var depuser2 = new List<UserEntity>(); ////var depuser3 = new List<UserEntity>(); //if (operators.LstOrganizeId.Count > 0) //{//获取公司及下属公司人员 // var depuser1 = userdata.FindAll(a => operators.LstOrganizeId.Contains(a.OrganizeId.ToString())) ; // foreach(var ent in depuser1) // { // operators.LstStaffId.Add(ent.UserId); // } //} //if (operators.LstDepartmentId.Count > 0) //{//获取部门及下属部门人员 // var depuser2 = userdata.FindAll(a => operators.LstDepartmentId.Contains(a.DepartmentId.ToString())) ; // foreach (var ent in depuser2) // { // operators.LstStaffId.Add(ent.UserId); // } //} //if (operators.LstStaffId.Count > 0) //{////获取人员及下属人员 // var depuser3 = userdata.FindAll(a => operators.LstStaffId.Contains(a.UserId.ToString())) ; // foreach (var ent in depuser3) // { // operators.LstStaffId.Add(ent.UserId); // } //} operators.UserId = userEntity.UserId; operators.UserName = userEntity.RealName; operators.Token = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); operators.LogTime = DateTime.Now; OperatorProvider.Provider.AddCurrent(operators); var roledata = roleBLL.GetList(); foreach (RoleEntity dep in roledata) { if (dep.RoleId == userEntity.RoleId) { userurlmodel.RoleName = dep.FullName; userurlmodel.RoleCode = dep.EnCode; } } CommonMethod.cache.Remove(userEntity.UserId + "organize"); CommonMethod.cache.Remove(userEntity.UserId + "user"); CommonMethod.GetUserList(userEntity.UserId); CommonMethod.GetOrgnizeList(userEntity.UserId); JavaScriptSerializer serializer = new JavaScriptSerializer(); string str = serializer.Serialize(userurlmodel); HttpResponseMessage ut = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") }; return(ut); } catch (Exception ex) { return(new HttpResponseMessage { Content = new StringContent(ex.Message, Encoding.GetEncoding("UTF-8"), "application/json") }); } }
public HttpResponseMessage GetFlowDetailListJson(string queryJson) { string userid = queryJson.ToJObject()["loginid"].ToString(); string flowname = queryJson.ToJObject()["FlowName"].ToString(); var datas = base_flowbll.GetDetailListApi(queryJson); var user = userBLL.GetEntity(userid); var lstuid = new List <string>(); if (flowname == "进店") { flowname = "路过"; } if (userid == null) { return(new HttpResponseMessage { Content = new StringContent("超时,请重新登录。", Encoding.GetEncoding("UTF-8"), "application/json") }); } HttpResponseMessage ut = new HttpResponseMessage { Content = new StringContent(datas.ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; ////不是经理时,只能看到自己的数据 if (!string.IsNullOrEmpty(user.ManagerId)) { lstuid = CommonMethod.GetUserList(userid); if (lstuid == null) { return(new HttpResponseMessage { Content = new StringContent("当前用户ID不存在", Encoding.GetEncoding("UTF-8"), "application/json") }); } var datat = datas.Where(p => lstuid.Contains(p.CreateUserId) && p.FlowName == flowname); var data = datat.GroupBy(t => t.FlowName) .Select(g => new { FlowCount = g.Sum(t => Convert.ToInt32(t.FlowCount)), OrganizeName = Convert.ToString(g.First().OrganizeName), FlowName = Convert.ToString(g.First().FlowName) }); ut = new HttpResponseMessage { Content = new StringContent(data.ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; } else { var datat = datas.Where(p => p.FlowName == flowname); var data = datat.GroupBy(t => new { t.FlowName, t.OrganizeName }) .Select(g => new { FlowCount = g.Sum(t => Convert.ToInt32(t.FlowCount)), OrganizeName = Convert.ToString(g.First().OrganizeName), FlowName = Convert.ToString(g.First().FlowName) }); ut = new HttpResponseMessage { Content = new StringContent(data.ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; } return(ut); }
public HttpResponseMessage GetSalesJson(string queryJson) { var watch = CommonHelper.TimerStart(); var datas = reportbll.GetList(queryJson); var queryParam = queryJson.ToJObject(); var loginid = queryJson.ToJObject()["UserId"].ToString(); var orderparam = Convert.ToString(queryJson.ToJObject()["OrderParam"]); var user = userBLL.GetEntity(loginid); var lstuserMainCom = userBLL.GetList(); var orgnizedata = organizeBLL.GetList().ToList(); //if (Convert.ToString(queryParam["RptSellerType"]) == "1") //{ try { ////不是经理时,只能看到自己的数据 if (!string.IsNullOrEmpty(user.ManagerId)) { // orgnizedata.Where(p => p.OrganizeId == ""); var lstuid = CommonMethod.GetUserList(Convert.ToString(queryParam["UserId"])); var lstorg = CommonMethod.GetOrgnizeList(Convert.ToString(queryParam["UserId"])); //if (Convert.ToString(queryParam["RptSellerType"]) == "2") //门店 //{ // lstuid = CommonMethod.GetOrgnizeList(Convert.ToString(queryParam["UserId"])); //} if (lstuid == null) { return(new HttpResponseMessage { Content = new StringContent("当前用户ID不存在", Encoding.GetEncoding("UTF-8"), "application/json") }); } if (!lstorg.Contains("207fa1a9-160c-4943-a89b-8fa4db0547ce")) { if (Convert.ToString(queryParam["RptSellerType"]) != "2") //门店\ { var lstuserMainC = lstuserMainCom.Where(p => p.OrganizeId != "207fa1a9-160c-4943-a89b-8fa4db0547ce").Select(p => p.UserId).ToList(); datas = datas.Where(p => lstuserMainC.Contains(p.SellerId)); } else { datas = datas.Where(p => p.SellerId != "207fa1a9-160c-4943-a89b-8fa4db0547ce"); } } } var data = datas; data = datas.OrderByDescending(n => n.Accounts).ToList(); if (!string.IsNullOrEmpty(orderparam)) { switch (orderparam) { case "1": //金额 data = datas.OrderByDescending(n => n.Accounts).ToList(); break; case "2": //开单数 data = datas.OrderByDescending(n => n.OrderCount).ToList(); break; case "3": //回款 data = datas.OrderByDescending(n => n.Subscription).ToList(); break; } } //} int ranval = 1; decimal preaccount = -10; decimal?orderaccount = 0; foreach (OrderReportModel obj in data) { orderaccount = obj.Accounts; if (!string.IsNullOrEmpty(orderparam)) { switch (orderparam) { case "1": //金额 orderaccount = obj.Accounts; break; case "2": //开单数 orderaccount = obj.OrderCount; break; case "3": //回款 orderaccount = obj.Subscription; break; } } if (preaccount == Convert.ToDecimal(orderaccount)) { obj.RankingValue = ranval - 1; } else { obj.RankingValue = ranval; ranval = ranval + 1; } preaccount = Convert.ToDecimal(orderaccount); } HttpResponseMessage ut = new HttpResponseMessage { Content = new StringContent(data.ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; return(ut); } catch { HttpResponseMessage ut = new HttpResponseMessage { Content = new StringContent(new List <string>().ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; return(ut); } }