/// <summary> /// 商家活动 /// </summary> /// <returns></returns> public ActionResult ActList() { var model = new List <Tuple <string, string, string, DateTime, DateTime, bool, TargetCode> >(); var kanjiaList = IKanJiaService.GetList(x => x.UserID == LoginUser.ID).Select(x => { return(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Kanjia)); }).ToList(); if (kanjiaList != null && kanjiaList.Count > 0) { model.AddRange(kanjiaList); } var pintuanList = IPinTuanService.GetList(x => x.UserID == LoginUser.ID); pintuanList.ForEach(x => { model.Add(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Pintuan)); }); var miaoshaList = IMiaoShaService.GetList(x => x.UserID == LoginUser.ID); miaoshaList.ForEach(x => { model.Add(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Miaosha)); }); var pintuList = IPinTuService.GetList(x => x.UserID == LoginUser.ID); pintuList.ForEach(x => { model.Add(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Pintu)); }); ViewBag.AppId = Params.WeixinAppId; string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret); ViewBag.TimeStamp = WxPayApi.GenerateTimeStamp(); ViewBag.NonceStr = WxPayApi.GenerateNonceStr(); ViewBag.Signature = WxPayApi.GetSignature(Request.Url.ToString().Split('#')[0], cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr); ViewBag.List = model.OrderByDescending(x => x.Item4).ToList(); return(View()); }
/// <summary> /// 用户活动列表 /// </summary> /// <returns></returns> public ActionResult ActList() { //var miaoshasList = IUserActivityService.GetList(x => x.Code == TargetCode.Miaosha); ////var miaoshaIdList=miaoshaList.Select(x => x.TargetID).Distinct().ToList(); //var userIdList = miaoshasList.Select(x => x.JoinUserID).Distinct().ToList(); //var userDic = IUserService.GetDic(x => userIdList.Contains(x.ID)); //miaoshasList.ForEach(x => //{ // if (x.JoinUserID.IsNotNullOrEmpty()&&userDic.ContainsKey(x.JoinUserID)) // { // x.Mobile = userDic[x.JoinUserID].Mobile; // IUserActivityService.Update(x); // } //}); var model = new List <Tuple <string, string, string, string, DateTime?, bool, TargetCode> >(); var actIdList = IUserActivityService.GetList(x => x.JoinUserID == LoginUser.ID && !x.IsDelete && x.IsPrize); var kanjiaIdList = actIdList.Where(x => x.Code == TargetCode.Kanjia && string.IsNullOrEmpty(x.TargetUserID)).Select(x => x.TargetID).Distinct().ToList(); var kanjiaDic = actIdList.Where(x => x.Code == TargetCode.Kanjia && string.IsNullOrEmpty(x.TargetUserID) && !x.IsDelete).ToDictionary(x => x.TargetID); var kanjiaList = IKanJiaService.GetList(x => kanjiaIdList.Contains(x.ID)).Select(x => { if (kanjiaDic.ContainsKey(x.ID)) { var item = kanjiaDic[x.ID]; return(new Tuple <string, string, string, string, DateTime?, bool, TargetCode>(x.Name, x.Picture, x.ID, item.ID, item.UsedTime, item.IsUsedOnLine, TargetCode.Kanjia)); } else { return(null); } }).ToList(); if (kanjiaList != null && kanjiaIdList.Count > 0) { model.AddRange(kanjiaList); } var pintuanIdList = actIdList.Where(x => x.Code == TargetCode.Pintuan).Select(x => x.TargetID).Distinct().ToList(); if (pintuanIdList != null && pintuanIdList.Count > 0) { var pintuanDic = actIdList.Where(x => x.Code == TargetCode.Pintuan).ToDictionary(x => x.TargetID); var pintuanList = IPinTuanService.GetList(x => pintuanIdList.Contains(x.ID)).Select(x => { if (pintuanDic.ContainsKey(x.ID)) { var item = pintuanDic[x.ID]; return(new Tuple <string, string, string, string, DateTime?, bool, TargetCode>(x.Name, x.Picture, x.ID, item.ID, item.UsedTime, item.IsUsedOnLine, TargetCode.Pintuan)); } else { return(null); } }).ToList(); model.AddRange(pintuanList); } var miaoshaIdList = actIdList.Where(x => x.Code == TargetCode.Miaosha).Select(x => x.TargetID).Distinct().ToList(); if (miaoshaIdList != null && miaoshaIdList.Count > 0) { var miaoshaDic = actIdList.Where(x => x.Code == TargetCode.Miaosha).ToDictionary(x => x.TargetID); var miaoshaList = IMiaoShaService.GetList(x => miaoshaIdList.Contains(x.ID)).Select(x => { if (miaoshaDic.ContainsKey(x.ID)) { var item = miaoshaDic[x.ID]; return(new Tuple <string, string, string, string, DateTime?, bool, TargetCode>(x.Name, x.Picture, x.ID, item.ID, item.UsedTime, item.IsUsedOnLine, TargetCode.Miaosha)); } else { return(null); } }).ToList(); model.AddRange(miaoshaList); } var pintuIdList = actIdList.Where(x => x.Code == TargetCode.Pintu).Select(x => x.TargetID).Distinct().ToList(); if (pintuIdList != null && pintuIdList.Count > 0) { var pintuDic = actIdList.Where(x => x.Code == TargetCode.Pintu).ToDictionary(x => x.TargetID); var pintuList = IPinTuService.GetList(x => pintuIdList.Contains(x.ID)).Select(x => { if (pintuDic.ContainsKey(x.ID)) { var item = pintuDic[x.ID]; return(new Tuple <string, string, string, string, DateTime?, bool, TargetCode>(x.Name, x.Picture, x.ID, item.ID, item.UsedTime, item.IsUsedOnLine, TargetCode.Pintu)); } else { return(null); } }).ToList(); model.AddRange(pintuList); } ViewBag.List = model.Where(x => x != null).ToList(); return(View()); }