public ResponseModel <List <RiceDateDetailDTO> > GetMyJoinRiceDate([FromUri] int UserId, int Page_Index = 1, int Page_Size = 20) { var result = new ResponseModel <List <RiceDateDetailDTO> >(); result.error_code = Result.SUCCESS; int totalCount = 0; var data = new List <RiceDateDetailDTO>(); if (UserId <= 0) { result.error_code = Result.ERROR; result.message = "用户Id不合法"; } var riceDateUserList = _riceDateUserService.GetByUserId(UserId, Page_Index, Page_Size, out totalCount); if (riceDateUserList != null && riceDateUserList.Count > 0) { foreach (var item in riceDateUserList) { int riceDateStatus = 0; var riceDateList = _riceDateUserService.GetByRiceDateId(item.RiceDateId); var feedBack = _riceDateFeedbackService.GetByUserIdAndRiceDateId(UserId, item.RiceDateId); if (riceDateList != null && riceDateList.Count > 0) { int count = riceDateList.Where(c => c.ApplyStatus == (int)EnumHelp.RiceDateApplyStatus.申请通过).ToList().Count; if (feedBack != null) { riceDateStatus = (int)EnumHelp.RiceDateStatus.被投诉; } else if (item.ApplyStatus == (int)EnumHelp.RiceDateApplyStatus.申请中 && item.RiceDate.BeginDate >= System.DateTime.Now) { riceDateStatus = (int)EnumHelp.RiceDateStatus.等待确认; } else if (count >= item.RiceDate.UserCount) { riceDateStatus = (int)EnumHelp.RiceDateStatus.快用餐; } } int age = 0; if (item.RiceDate.User.BirthDay != null) { var BirthDay = DateTime.Parse(item.RiceDate.User.BirthDay.ToString()); age = System.DateTime.Now.Year - BirthDay.Year; } data.Add(new RiceDateDetailDTO() { BusinessName = item.RiceDate.BusinessName, Address = item.RiceDate.Address, BeginDate = item.RiceDate.BeginDate, UseCount = item.RiceDate.UserCount, Zone = item.RiceDate.Zone, Sex = item.RiceDate.Sex, Age = item.RiceDate.Age, Taste = item.RiceDate.Taste, UserImage = item.RiceDate.User == null ? "" : (item.RiceDate.User.BaseImage.Source + item.RiceDate.User.BaseImage.Path), PayWay = item.RiceDate.PayWay, Usex = item.RiceDate.User.Sex == null ? 0 : int.Parse(item.RiceDate.User.Sex.ToString()), Uage = age, RiceDateStatu = riceDateStatus }); } } result.total_count = totalCount; result.data = data; return(result); }
public ResponseModel <RiceDateDetailDTO> GetRiceDateDetail([FromUri] int UserId, int RiceDateId) { var result = new ResponseModel <RiceDateDetailDTO>(); var data = new RiceDateDetailDTO(); result.error_code = Result.SUCCESS; if (RiceDateId <= 0) { result.error_code = Result.ERROR; result.message = "约饭信息ID无效"; return(result); } var riceDate = _riceDateService.GetById(RiceDateId); if (riceDate.IsDelete == (int)EnumHelp.IsDeleteEnum.效 && riceDate.Status == (int)EnumHelp.EnabledEnum.效) { data.Address = riceDate.Address; data.Age = riceDate.Age; data.BeginDate = riceDate.BeginDate; data.BusinessName = riceDate.BusinessName; data.NickName = riceDate.User != null ? riceDate.User.NickName : ""; data.PayWay = riceDate.PayWay; data.Remark = riceDate.Remark; data.RiceDateId = riceDate.RiceDateId; data.Sex = riceDate.Sex; data.Taste = riceDate.Taste; data.UserImage = riceDate.User == null ? "" : (riceDate.User.BaseImage == null ? "" : riceDate.User.BaseImage.Source + riceDate.User.BaseImage.Path); data.Zone = riceDate.Zone; data.UseCount = riceDate.UserCount; var riceDateUserList = _riceDateUserService.GetByUserId(riceDate.UserId); data.DateCount = riceDateUserList.Count; string[] ids = riceDate.BaseImageIds.Split(',').ToArray(); int[] output = Array.ConvertAll <string, int>(ids, delegate(string s) { return(int.Parse(s)); }); var baseImageList = _baseImageService.GetByIds(output); List <string> imageList = new List <string>(); if (baseImageList != null && baseImageList.Count > 0) { foreach (var item in baseImageList) { imageList.Add(item == null ? "" : item.Source + item.Path); } } data.ImagePath = imageList; ///投诉 var riceDateFeedbacklist = _riceDateFeedbackService.GetByUserId(riceDate.UserId); var complainList = new List <ComplainDetail>(); if (riceDateFeedbacklist != null && riceDateFeedbacklist.Count > 0) { data.ComplainCount = riceDateFeedbacklist.Count; foreach (var item in riceDateFeedbacklist) { complainList.Add(new ComplainDetail() { NickName = item.User == null ? "" : item.User.NickName, Content = item.Content }); } } data.ComplainDetailList = complainList; //是否已经报名 var riceDateUser = _riceDateUserService.GetByUserIdAndRiceDateId(UserId, RiceDateId); if (riceDateUser != null) { data.IsDate = 1; } if (riceDate.BeginDate >= System.DateTime.Now && riceDateUser.ApplyStatus == (int)EnumHelp.RiceDateApplyStatus.申请通过) { data.IsComplain = 1; } int age = 0; if (riceDate.User.BirthDay != null) { var BirthDay = DateTime.Parse(riceDate.User.BirthDay.ToString()); age = System.DateTime.Now.Year - BirthDay.Year; } data.Uage = age; data.Usex = string.IsNullOrWhiteSpace(riceDate.User.Sex.ToString()) ? 0 : int.Parse(riceDate.User.Sex.ToString()); } else { result.error_code = Result.ERROR; result.message = "约饭信息无效"; } result.data = data; return(result); }