/// <summary> /// 查询用户 /// </summary> public string GetUserListData() { var form = Request("form").DeserializeJSONTo <UserQueryEntity>(); var responseData = new ResponseData(); LoggingSessionInfo loggingSessionInfo = null; if (CurrentUserInfo != null) { loggingSessionInfo = CurrentUserInfo; } else { if (string.IsNullOrEmpty(Request("CustomerID"))) { responseData.success = false; responseData.msg = "缺少商户标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else { loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID")); } } var userService = new cUserService(loggingSessionInfo); UserInfo data; string content = string.Empty; string user_code = form.user_code == null ? string.Empty : form.user_code; string user_name = form.user_name == null ? string.Empty : form.user_name; string user_tel = form.user_tel == null ? string.Empty : form.user_tel; string user_status = form.user_status == null ? string.Empty : form.user_status; string para_unit_id = form.unit_id ?? ""; string role_id = form.role_id ?? ""; //int maxRowCount = PageSize; int maxRowCount = Utils.GetIntVal(Request("limit")); int startRowIndex = Utils.GetIntVal(Request("start")); string NameOrPhone = form.NameOrPhone == null ? string.Empty : form.NameOrPhone; string key = string.Empty; if (Request("id") != null && Request("id") != string.Empty) { key = Request("id").ToString().Trim(); } data = userService.SearchUserListByUnitID( //SearchUserListByUnitID user_code, user_name, user_tel, user_status, maxRowCount, startRowIndex, CurrentUserInfo == null?"": CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, role_id, NameOrPhone); var jsonData = new JsonData(); jsonData.totalCount = data.ICount.ToString(); jsonData.data = data.UserInfoList; content = string.Format("{{\"success\":{2},\"msg\":{3},\"totalCount\":{1},\"topics\":{0}}}", data.UserInfoList.ToJSON(), data.ICount , 1, "\"\""); return(content); }
/// <summary> /// 门店内员工排名 /// 排名规则: /// 1.取出打赏金额大于零的员工 /// 2.比较打赏金额,(金额高的往前排) /// 3.金额相同,比较评价等级 (等级高的往前排) /// 4.如果还相同,比较打赏时间(时间靠前,往前排) /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override GetTopRewardListRD ProcessRequest(DTO.Base.APIRequest <GetTopRewardListRP> pRequest) { var rd = new GetTopRewardListRD(); var customerId = CurrentUserInfo.ClientID; var trrBll = new T_RewardRecordBLL(CurrentUserInfo); var userBll = new T_UserBLL(CurrentUserInfo); //获取员工列表(门店内) var userList = userBll.QueryByEntity(new T_UserEntity() { customer_id = customerId }, null); var userService = new cUserService(CurrentUserInfo); CurrentUserInfo.CurrentUserRole.UnitId = string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId) ? "" : CurrentUserInfo.CurrentUserRole.UnitId; var para_unit_id = CurrentUserInfo.CurrentUserRole.UnitId; var maxRowCount = Utils.GetIntVal(Request("limit")); var startRowIndex = Utils.GetIntVal(Request("start")); var rowCount = maxRowCount > 0 ? maxRowCount : 999; //每页行数 var startIndex = startRowIndex > 0 ? startRowIndex : 0; //当前页的起始行数 var userdata = new JIT.CPOS.BS.Entity.User.UserInfo(); if (string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId)) { userdata = userService.SearchUserListByUnitID(string.Empty, string.Empty, string.Empty, string.Empty, rowCount, startIndex, CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, string.Empty, string.Empty); } else { userdata = userService.SearchUserListByUnitID(string.Empty, string.Empty, string.Empty, string.Empty, rowCount, startIndex, CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, string.Empty, string.Empty); } var orderBys = new OrderBy[1]; orderBys[0] = new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Asc }; var trrList = trrBll.QueryByEntity(new T_RewardRecordEntity() { PayStatus = 2, CustomerId = customerId }, orderBys); var oeBll = new ObjectEvaluationBLL(CurrentUserInfo); var oeList = oeBll.QueryByEntity(new ObjectEvaluationEntity() { Type = 4, CustomerID = customerId }, null); var allOE = (from p in oeList.AsEnumerable() group p by p.ObjectID into g select new { g.Key, SumValue = g.Average(p => p.StarLevel) }); var allRewards = (from p in trrList.AsEnumerable() group p by p.RewardedOP into g select new { g.Key, SumValue = g.Sum(p => p.RewardAmount) }).Where(g => g.SumValue > 0).OrderByDescending(g => g.SumValue); var rewardCount = allRewards.ToList().Count; //var top10Rewards = allRewards.Take(10); //金额相同,比较评价等级 (等级高的往前排) rd.RewardList = new List <RewardInfo>(); rd.MyReward = new RewardInfo(); var index = 1; foreach (var item in allRewards) { var tmpRewardInfo = new RewardInfo(); //var userinfo = userList.Where(t => t.user_id == item.Key).ToArray().FirstOrDefault(); var userinfo = userdata.UserInfoList.Where(t => t.User_Id == item.Key).ToArray().FirstOrDefault(); var oeinfo = allOE.Where(t => t.Key == item.Key).ToArray().FirstOrDefault(); if (userinfo != null) { tmpRewardInfo = new RewardInfo() { UserID = userinfo.User_Id, UserName = userinfo.User_Name, UserPhoto = userinfo.imageUrl, StarLevel = oeinfo != null?Convert.ToInt32(oeinfo.SumValue) : 0, Rank = index, RewardIncome = item.SumValue }; rd.RewardList.Add(tmpRewardInfo); if (userinfo.User_Id == pRequest.UserID) { rd.MyReward = tmpRewardInfo; } index++; } } if (string.IsNullOrEmpty(rd.MyReward.UserID))//Top10之外 { //var userinfo = userList.Where(t => t.user_id == pRequest.UserID).ToArray().FirstOrDefault(); var userinfo = userdata.UserInfoList.Where(t => t.User_Id == pRequest.UserID).ToArray().FirstOrDefault(); var oeinfo = allOE.Where(t => t.Key == pRequest.UserID).ToArray().FirstOrDefault(); var myReward = allRewards.Where(t => t.Key == pRequest.UserID).FirstOrDefault(); decimal?myRewardIncome = 0; if (myReward != null) { myRewardIncome = myReward.SumValue != null ? myReward.SumValue : 0; rewardCount = allRewards.Where(g => g.SumValue > myReward.SumValue).ToList().Count; } var myStarLevel = oeinfo != null?Convert.ToInt32(oeinfo.SumValue) : 0; if (userinfo != null) { rd.MyReward = new RewardInfo() { UserID = userinfo.User_Id, UserName = userinfo.User_Name, UserPhoto = userinfo.imageUrl, StarLevel = myStarLevel, Rank = myRewardIncome > 0 ? rewardCount + 1 : 0, RewardIncome = myRewardIncome }; } } return(rd); }