public ResultInfo ExchangePointPacket(UserInfo userinfo) { string source = "CampEvents_ExchangePointPacket"; ResultInfo resultinfo = new ResultInfo() { Result = ErrorCode.PacketFailed, IsNotice = false, PacketName = "" }; int CampId = ctx.UserCampLogs.Where(p => p.AreaId == userinfo.AreaId && p.UserId == userinfo.UserId && p.AvatarId == userinfo.AvatarId).Select(p => p.CampId).SingleOrDefault(); if (CampId == default(int)) { resultinfo.Result = ErrorCode.NoCampFailed; return(resultinfo); } int TotalPoints = ctx.Wallets.Where(p => p.AreaId == userinfo.AreaId && p.UserId == userinfo.UserId && p.AvatarId == userinfo.AvatarId).Sum(p => (int?)p.DailyGetPoints).GetValueOrDefault(); //阵营不同个人积分奖励不同 //PointPacketConfig packetlist = ctx.PointPacketConfigs.Where(p => p.CampId == CampId && p.NeedPoints <= TotalPoints && p.ShowId == userinfo.ExchangeID).SingleOrDefault(); //阵营不同个人积分奖励相同 PointPacketConfig packetlist = ctx.PointPacketConfigs.Where(p => p.NeedPoints <= TotalPoints && p.ShowId == userinfo.ExchangeID).SingleOrDefault(); if (packetlist == null) { resultinfo.Result = ErrorCode.NoPoints; return(resultinfo); } bool IsExistRecord = ctx.PointPacketExchangeLogs.Any(p => p.AreaId == userinfo.AreaId && p.UserId == userinfo.UserId && p.AvatarId == userinfo.AvatarId && p.PointPacketConfigId == packetlist.ConfigId); if (IsExistRecord) { resultinfo.Result = ErrorCode.RepeatedFailed; return(resultinfo); } PointPacketExchangeLog exchangelog = new PointPacketExchangeLog() { UserId = userinfo.UserId, AreaId = userinfo.AreaId, AvatarId = userinfo.AvatarId, AvatarName = userinfo.AvatarName, Sex = userinfo.Sex, LoginName = userinfo.LoginName, CurrentPoints = TotalPoints, PointPacketConfigId = packetlist.ConfigId }; ctx.PointPacketExchangeLogs.Add(exchangelog); PacketQueue packetqueue = new PacketQueue() { UserId = userinfo.UserId, AreaId = userinfo.AreaId, AvatarId = userinfo.AvatarId, Sex = userinfo.Sex, PacketId = packetlist.PacketId, Source = source, FromId = exchangelog.Id }; ctx.PacketQueues.Add(packetqueue); int rs = ctx.SaveChanges(); if (rs == 2) { resultinfo.Result = ErrorCode.Succuess; resultinfo.IsNotice = packetlist.IsNotice; resultinfo.PacketName = packetlist.PacketName; } return(resultinfo); }
/// <summary> /// 列表 /// </summary> /// <param name="searchSort">用来搜索的实例</param> /// <returns></returns> public ActionResult PointPacketExchangeLogList(DataPage dp, PointPacketExchangeLog model) { model.CreateTime = defaultDate; List <PointPacketExchangeLog> lists = new List <PointPacketExchangeLog>(); if (Request["btnExportExcel"] == null)//导出Excel { lists = CampEventsBll.GetPointPacketExchangeLogList(ref dp, model); GetDataPage(dp); } else { dp.PageSize = 0; lists = CampEventsBll.GetPointPacketExchangeLogList(ref dp, model); string fileName = "nothing"; if (lists.Count() > 0) { fileName = "PointPacketExchangeLogList" + lists.Count() + "_Item"; } Dictionary <string, Func <PointPacketExchangeLog, string> > showFields = new Dictionary <string, Func <PointPacketExchangeLog, string> >(); showFields.Add("Id", z => "'" + z.Id.ToString()); showFields.Add("UserId", z => "'" + z.UserId.ToString()); showFields.Add("LoginName", z => "'" + z.LoginName.ToString()); showFields.Add("AreaId", z => "'" + z.AreaId.ToString()); showFields.Add("AvatarId", z => "'" + z.AvatarId.ToString()); showFields.Add("AvatarName", z => "'" + z.AvatarName.ToString()); showFields.Add("Sex", z => "'" + z.Sex.ToString()); showFields.Add("PointPacketConfigId", z => "'" + z.PointPacketConfigId.ToString()); showFields.Add("CurrentPoints", z => "'" + z.CurrentPoints.ToString()); showFields.Add("CreateTime", z => "'" + z.CreateTime.ToString()); ObjectUtil.Common.ExcelHelper2 <PointPacketExchangeLog> elh = new ObjectUtil.Common.ExcelHelper2 <PointPacketExchangeLog>(lists, null, showFields); elh.FileWebSaveAs(Response, fileName); } //记录日志 Log(string.Format("查看[PointPacketExchangeLog]列表页面 搜索数据:{0}", model.ToString())); return(View(lists)); }
public List <PointPacketExchangeLog> GetPointPacketExchangeLogList(ref DataPage dp, PointPacketExchangeLog searchPointPacketExchangeLog) { Expression <Func <PointPacketExchangeLog, bool> > exp = CreateDydaminWhereAndExpression <PointPacketExchangeLog>(searchPointPacketExchangeLog); List <PointPacketExchangeLog> list = GetEntityQueryList(ref dp, exp, p => p.Id); List <PointPacketExchangeLog> resultlist = list.Select(p => new PointPacketExchangeLog { PointPacketConfigId = p.PointPacketConfigId, UserId = p.UserId, AreaId = p.AreaId, AvatarId = p.AvatarId, AvatarName = p.AvatarName, CreateTime = p.CreateTime, LoginName = p.LoginName, Sex = p.Sex, Id = p.Id, CurrentPoints = p.CurrentPoints }).ToList <PointPacketExchangeLog>(); return(resultlist); }
public List <PointPacketExchangeLog> GetPointPacketExchangeLogList(ref DataPage dp, PointPacketExchangeLog searchPointPacketExchangeLog) { return(_dal.GetPointPacketExchangeLogList(ref dp, searchPointPacketExchangeLog)); }
public List <PointPacketExchangeLog> GetPointPacketExchangeLogList(ref DataPage dp, PointPacketExchangeLog searchPointPacketExchangeLog) { _admin = new CampEventsAdminService.CampEventsAdminServiceClient(); List <PointPacketExchangeLog> lists = new List <PointPacketExchangeLog>(); try { lists = _admin.GetPointPacketExchangeLogList(ref dp, searchPointPacketExchangeLog); _admin.Close(); return(lists); } catch (Exception ex) { _admin.CloseCatch(ex, "GetPointPacketExchangeLogList failed"); return(lists); } }