public int AddPrizeRecord(PrizeRecordInfo model) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("insert into Vshop_PrizeRecord("); stringBuilder.Append("ActivityID,PrizeTime,UserID,PrizeName,Prizelevel,IsPrize)"); stringBuilder.Append(" values ("); stringBuilder.Append("@ActivityID,@PrizeTime,@UserID,@PrizeName,@Prizelevel,@IsPrize)"); stringBuilder.Append(";select @@IDENTITY"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(stringBuilder.ToString()); this.database.AddInParameter(sqlStringCommand, "ActivityID", DbType.Int32, model.ActivityID); this.database.AddInParameter(sqlStringCommand, "PrizeTime", DbType.DateTime, model.PrizeTime); this.database.AddInParameter(sqlStringCommand, "UserID", DbType.Int32, model.UserID); this.database.AddInParameter(sqlStringCommand, "PrizeName", DbType.String, model.PrizeName); this.database.AddInParameter(sqlStringCommand, "Prizelevel", DbType.String, model.Prizelevel); this.database.AddInParameter(sqlStringCommand, "IsPrize", DbType.Boolean, model.IsPrize); object obj = this.database.ExecuteScalar(sqlStringCommand); int num; int result; if (!int.TryParse(obj.ToString(), out num)) { result = 0; } else { result = num; } return(result); }
protected override void AttachChildControls() { int num; int.TryParse(HttpContext.Current.Request.QueryString.Get("activityid"), out num); if (VshopBrowser.GetUserPrizeRecord(num) == null) { this.Context.Response.Redirect(this.Context.Request.Url.ToString().ToLower().Replace("winningresults.aspx?activityid=", "signup.aspx?id=")); this.Context.Response.End(); } PrizeRecordInfo userPrizeRecord = VshopBrowser.GetUserPrizeRecord(num); this.litPrizeLevel = (Literal)this.FindControl("litPrizeLevel"); if (userPrizeRecord != null) { this.litPrizeLevel.Text = userPrizeRecord.Prizelevel; } MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { this.txtName = (HtmlInputText)this.FindControl("txtName"); this.txtPhone = (HtmlInputText)this.FindControl("txtPhone"); this.txtName.Value = currentMember.RealName; this.txtPhone.Value = currentMember.CellPhone; } PageTitle.AddSiteNameTitle("中奖记录"); }
public int AddPrizeRecord(PrizeRecordInfo model) { int num; StringBuilder builder = new StringBuilder(); builder.Append("insert into Vshop_PrizeRecord("); builder.Append("ActivityID,PrizeTime,UserID,RealName,CellPhone,PrizeName,Prizelevel,IsPrize)"); builder.Append(" values ("); builder.Append("@ActivityID,@PrizeTime,@UserID,@RealName,@CellPhone,@PrizeName,@Prizelevel,@IsPrize)"); builder.Append(";select @@IDENTITY"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "ActivityID", DbType.Int32, model.ActivityID); this.database.AddInParameter(sqlStringCommand, "PrizeTime", DbType.DateTime, model.PrizeTime); this.database.AddInParameter(sqlStringCommand, "UserID", DbType.Int32, model.UserID); this.database.AddInParameter(sqlStringCommand, "RealName", DbType.String, model.RealName); this.database.AddInParameter(sqlStringCommand, "CellPhone", DbType.String, model.CellPhone); this.database.AddInParameter(sqlStringCommand, "PrizeName", DbType.String, model.PrizeName); this.database.AddInParameter(sqlStringCommand, "Prizelevel", DbType.String, model.Prizelevel); this.database.AddInParameter(sqlStringCommand, "IsPrize", DbType.Boolean, model.IsPrize); if (!int.TryParse(this.database.ExecuteScalar(sqlStringCommand).ToString(), out num)) { return(0); } return(num); }
public void UpdatePrizeRecord(PrizeRecordInfo model) { using (var conn = new SqlConnection(connectString)) { string sql = "UPDATE [PrizeRecord] SET RealName=@RealName, CellPhone=@CellPhone,[Company]=@Company WHERE ActivityID=@ActivityID AND UserID=@UserID AND IsPrize = 1 AND CellPhone IS NULL AND RealName IS NULL And Company IS NULL"; conn.Execute(sql, model); } }
public bool UpdatePrizeRecordPrize(PrizeRecordInfo model) { string query = "UPDATE Vshop_PrizeRecord SET IsPrize=@IsPrize WHERE RecordId=@RecordId"; DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query); this.database.AddInParameter(sqlStringCommand, "RecordId", DbType.Int32, model.RecordId); this.database.AddInParameter(sqlStringCommand, "IsPrize", DbType.Int32, model.IsPrize); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public static bool UpdatePrizeRecord(int activityId, int userId, string realName, string cellPhone) { PrizeRecordDao prizeRecordDao = new PrizeRecordDao(); PrizeRecordInfo userPrizeRecord = prizeRecordDao.GetUserPrizeRecord(activityId, HiContext.Current.UserId); userPrizeRecord.UserID = userId; userPrizeRecord.RealName = realName; userPrizeRecord.CellPhone = cellPhone; return prizeRecordDao.UpdatePrizeRecord(userPrizeRecord); }
public int Add(PrizeRecordInfo entity) { using (var conn = new SqlConnection(connectString)) { string sql = @"INSERT INTO [PrizeRecord](ActivityID,PrizeTime,UserID,PrizeName,Prizelevel,IsPrize,RealName,Company,CellPhone) VALUES(@ActivityID,@PrizeTime,@UserID,@PrizeName,@Prizelevel,@IsPrize,@RealName,@Company,@CellPhone); select SCOPE_IDENTITY()"; return(conn.Query <int>(sql, entity).Single()); } }
public bool UpdatePrizeRecord(PrizeRecordInfo model) { string query = "UPDATE Vshop_PrizeRecord SET RealName=@RealName, CellPhone=@CellPhone WHERE ActivityID=@ActivityID AND UserId=@UserId AND IsPrize = 1 AND CellPhone IS NULL AND RealName IS NULL"; DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query); this.database.AddInParameter(sqlStringCommand, "ActivityID", DbType.Int32, model.ActivityID); this.database.AddInParameter(sqlStringCommand, "UserID", DbType.Int32, model.UserID); this.database.AddInParameter(sqlStringCommand, "RealName", DbType.String, model.RealName); this.database.AddInParameter(sqlStringCommand, "CellPhone", DbType.String, model.CellPhone); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public static bool UpdatePrizeRecord(int activityId, int userId, string realName, string cellPhone) { PrizeRecordDao dao = new PrizeRecordDao(); PrizeRecordInfo userPrizeRecord = dao.GetUserPrizeRecord(activityId); if (userPrizeRecord == null) { return(false); } userPrizeRecord.UserID = userId; userPrizeRecord.RealName = realName; userPrizeRecord.CellPhone = cellPhone; return(dao.UpdatePrizeRecord(userPrizeRecord)); }
public PrizeRecordInfo LastPrizeRecord(int activityId, int userId) { PrizeRecordInfo result = new PrizeRecordInfo(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("select top 1 * from Vshop_PrizeRecord where ActivityId=@ActivityId and UserID=@UserID ORDER BY RecordId desc"); DbCommand sqlStringCommand = base.database.GetSqlStringCommand(stringBuilder.ToString()); base.database.AddInParameter(sqlStringCommand, "ActivityId", DbType.Int32, activityId); base.database.AddInParameter(sqlStringCommand, "UserID", DbType.Int32, userId); using (IDataReader objReader = base.database.ExecuteReader(sqlStringCommand)) { result = DataHelper.ReaderToModel <PrizeRecordInfo>(objReader); } return(result); }
protected override void AttachChildControls() { int activityid = default(int); int.TryParse(HttpContext.Current.Request.QueryString.Get("activityid"), out activityid); PrizeRecordInfo userPrizeRecord = VshopBrowser.GetUserPrizeRecord(activityid); this.litPrizeLevel = (Literal)this.FindControl("litPrizeLevel"); if (userPrizeRecord != null) { this.litPrizeLevel.Text = userPrizeRecord.Prizelevel; } MemberInfo user = HiContext.Current.User; if (user.UserId != 0) { this.txtName = (HtmlInputText)this.FindControl("txtName"); this.txtPhone = (HtmlInputText)this.FindControl("txtPhone"); this.txtName.Value = user.RealName; this.txtPhone.Value = user.CellPhone; } PageTitle.AddSiteNameTitle("中奖记录"); }
public static bool UpdatePrizeRecordPrize(PrizeRecordInfo model) { return(new PrizeRecordDao().UpdatePrizeRecordPrize(model)); }
public static int AddPrizeRecord(PrizeRecordInfo model) { return(new PrizeRecordDao().AddPrizeRecord(model)); }
public static void UpdatePrizeRecord(PrizeRecordInfo entity) { dal.UpdatePrizeRecord(entity); }
/// <summary> /// 大转盘抽奖 /// </summary> private void GetPrize() { Response.ContentType = "application/json"; //当前用户 UserInfo theUser = UserBLL.Read(base.UserId); int result = 1; if (int.TryParse(Request["activityid"], out result) && result > 0 && theUser.Id > 0) {// 如果参数 activityid有效才执行抽奖 LotteryActivityInfo lotteryActivity = LotteryActivityBLL.Read(result); if (lotteryActivity != null) { lotteryActivity.PrizeSettingList = JsonConvert.DeserializeObject <List <PrizeSetting> >(lotteryActivity.PrizeSetting); } int userPrizeCount = PrizeRecordBLL.GetUserPrizeCountToday(result, theUser.Id);//获取该用户当天抽奖次数 //if (MemberProcessor.GetCurrentMember() == null) //{ // MemberInfo member = new MemberInfo(); // string generateId = Globals.GetGenerateId(); // member.GradeId = MemberProcessor.GetDefaultMemberGrade(); // member.UserName = ""; // member.OpenId = ""; // member.CreateDate = DateTime.Now; // member.SessionId = generateId; // member.SessionEndTime = DateTime.Now; // MemberProcessor.CreateMember(member); // member = MemberProcessor.GetMember(generateId); // HttpCookie cookie = new HttpCookie("Vshop-Member") // { // Value = member.UserId.ToString(), // Expires = DateTime.Now.AddYears(10) // }; // HttpContext.Current.Response.Cookies.Add(cookie); //} StringBuilder builder = new StringBuilder(); builder.Append("{"); int maxNumOfLottery = lotteryActivity.MaxNum; //分享增加一次投资机会 //if (theUser.HasShared == 1) //{ // maxNumOfLottery++; //} if ((DateTime.Now.Date < lotteryActivity.StartTime.Date) || (DateTime.Now.Date > lotteryActivity.EndTime.Date)) { builder.Append("\"No\":\"-3\""); builder.Append("}"); Response.Write(builder.ToString()); } else if (userPrizeCount >= maxNumOfLottery) { builder.Append("\"No\":\"-1\""); builder.Append("}"); Response.Write(builder.ToString()); } else { List <PrizeRecordInfo> prizeList = PrizeRecordBLL.SearchList(new PrizeRecordSearchInfo { ActivityID = result, IsPrize = 1, }); int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; int num7Count = 0; int num8Count = 0; bool hasPrized = false; if ((prizeList != null) && (prizeList.Count > 0)) { num3 = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "一等奖"); num4 = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "二等奖"); num5 = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "三等奖"); } //prizeList = PrizeRecordBLL.GetPrizeList(result, theUser.Id); ////百分百中奖无须判断是否有获奖 //if ((prizeList != null) && (prizeList.Count > 0)) //{ // //foreach (PrizeRecordInfo prizeRecord in prizeList) // //{ // // if (prizeRecord.Prizelevel != "六等奖") // // { // hasPrized = true; // //break; // // } // //} //} if (hasPrized)//如果已中奖则不能再参与抽奖 { builder.Append("\"No\":\"-2\""); builder.Append("}"); Response.Write(builder.ToString()); } else { PrizeRecordInfo model = new PrizeRecordInfo { PrizeTime = new DateTime?(DateTime.Now), UserID = theUser.Id, UserName = theUser.UserName, ActivityName = lotteryActivity.ActivityName, ActivityID = result, RealName = Request["RealName"], Company = Request["Company"], CellPhone = Request["CellPhone"], IsPrize = (int)BoolType.True }; List <PrizeSetting> prizeSettingList = lotteryActivity.PrizeSettingList; decimal num9 = prizeSettingList[0].Probability * 100M; decimal num10 = num9 + prizeSettingList[1].Probability * 100M; decimal num11 = num10 + prizeSettingList[2].Probability * 100M; int num15 = new Random(Guid.NewGuid().GetHashCode()).Next(1, 0x2711); #region //抽奖 if (prizeSettingList.Count > 3) //如果开启了4-8等奖 { decimal num12 = num11 + prizeSettingList[3].Probability * 100M; decimal num13 = num12 + prizeSettingList[4].Probability * 100M; decimal num14 = num13 + prizeSettingList[5].Probability * 100M; decimal num7Rate = num14 + prizeSettingList[6].Probability * 100M; decimal num8Rate = num7Rate + prizeSettingList[7].Probability * 100M; num6 = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "四等奖"); num7 = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "五等奖"); num8 = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "六等奖"); num7Count = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "七等奖"); num8Count = prizeList.Count <PrizeRecordInfo>(a => a.Prizelevel == "八等奖"); if (prizeList.Count >= (prizeSettingList[0].PrizeNum + prizeSettingList[1].PrizeNum + prizeSettingList[2].PrizeNum + prizeSettingList[3].PrizeNum + prizeSettingList[4].PrizeNum + prizeSettingList[5].PrizeNum + prizeSettingList[6].PrizeNum + prizeSettingList[7].PrizeNum))//如果奖品已经抽完 { model.IsPrize = (int)BoolType.False; builder.Append("\"No\":\"-4\""); } else if ((num15 <= num9) && (prizeSettingList[0].PrizeNum > num3)) { builder.Append("\"No\":\"1\",\"Prizelevel\":\"" + prizeSettingList[0].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[0].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[0].PrizeName + "\""); model.Prizelevel = "一等奖"; model.PrizeName = prizeSettingList[0].PrizeName; } else if ((num15 > num9) && (num15 <= num10) && (prizeSettingList[1].PrizeNum > num4)) { builder.Append("\"No\":\"2\",\"Prizelevel\":\"" + prizeSettingList[1].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[1].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[1].PrizeName + "\""); model.Prizelevel = "二等奖"; model.PrizeName = prizeSettingList[1].PrizeName; } else if ((num15 > num10) && (num15 <= num11) && (prizeSettingList[2].PrizeNum > num5)) { builder.Append("\"No\":\"3\",\"Prizelevel\":\"" + prizeSettingList[2].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[2].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[2].PrizeName + "\""); model.Prizelevel = "三等奖"; model.PrizeName = prizeSettingList[2].PrizeName; } else if ((num15 > num11) && (num15 <= num12) && (prizeSettingList[3].PrizeNum > num6)) { builder.Append("\"No\":\"4\",\"Prizelevel\":\"" + prizeSettingList[3].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[3].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[3].PrizeName + "\""); model.Prizelevel = "四等奖"; model.PrizeName = prizeSettingList[3].PrizeName; } else if ((num15 > num12) && (num15 <= num13) && (prizeSettingList[4].PrizeNum > num7)) { builder.Append("\"No\":\"5\",\"Prizelevel\":\"" + prizeSettingList[4].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[4].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[4].PrizeName + "\""); model.Prizelevel = "五等奖"; model.PrizeName = prizeSettingList[4].PrizeName; } else if ((num15 > num13) && (num15 <= num14) && (prizeSettingList[5].PrizeNum > num8)) { builder.Append("\"No\":\"6\",\"Prizelevel\":\"" + prizeSettingList[5].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[5].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[5].PrizeName + "\""); model.Prizelevel = "六等奖"; model.PrizeName = prizeSettingList[5].PrizeName; } else if ((num15 > num14) && (num15 <= num7Rate) && (prizeSettingList[6].PrizeNum > num7Count)) { //if (lotteryActivity.ActivityId == 6) //{ // model.IsPrize = false; // builder.Append("\"No\":\"0\""); //} //else //{ builder.Append("\"No\":\"7\",\"Prizelevel\":\"" + prizeSettingList[6].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[6].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[6].PrizeName + "\""); model.Prizelevel = "七等奖"; model.PrizeName = prizeSettingList[6].PrizeName; //} } else if ((num15 > num7Rate) && (num15 <= num8Rate) && (prizeSettingList[7].PrizeNum > num8Count)) { //if (lotteryActivity.ActivityId == 6) //{ // model.IsPrize = false; // builder.Append("\"No\":\"0\""); //} //else //{ builder.Append("\"No\":\"8\",\"Prizelevel\":\"" + prizeSettingList[7].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[7].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[7].PrizeName + "\""); model.Prizelevel = "八等奖"; model.PrizeName = prizeSettingList[7].PrizeName; //} } else { model.IsPrize = (int)BoolType.False; builder.Append("\"No\":\"0\""); } } else { //如果只开启了1-3等奖 if (prizeList.Count >= (prizeSettingList[0].PrizeNum + prizeSettingList[1].PrizeNum + prizeSettingList[2].PrizeNum)) //如果奖品已经抽完 { model.IsPrize = (int)BoolType.False; builder.Append("\"No\":\"-4\""); } else if ((num15 < num9) && (prizeSettingList[0].PrizeNum > num3)) { builder.Append("\"No\":\"1\",\"Prizelevel\":\"" + prizeSettingList[0].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[0].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[0].PrizeName + "\""); model.Prizelevel = "一等奖"; model.PrizeName = prizeSettingList[0].PrizeName; } else if ((num15 < num10) && (prizeSettingList[1].PrizeNum > num4)) { builder.Append("\"No\":\"2\",\"Prizelevel\":\"" + prizeSettingList[1].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[1].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[1].PrizeName + "\""); model.Prizelevel = "二等奖"; model.PrizeName = prizeSettingList[1].PrizeName; } else if ((num15 < num11) && (prizeSettingList[2].PrizeNum > num5)) { builder.Append("\"No\":\"3\",\"Prizelevel\":\"" + prizeSettingList[2].PrizeLevel + "\",\"PrizeTitle\":\"" + prizeSettingList[2].PrizeTitle + "\",\"PrizeName\":\"" + prizeSettingList[2].PrizeName + "\""); model.Prizelevel = "三等奖"; model.PrizeName = prizeSettingList[2].PrizeName; } else { model.IsPrize = (int)BoolType.False; builder.Append("\"No\":\"0\""); } } #endregion builder.Append("}"); if (Request["activitytype"] != "scratch") { if (model.IsPrize == (int)BoolType.True) { int addNum = PrizeRecordBLL.Add(model);//插入抽奖纪录 if (addNum <= 0) { builder.Clear().Append("\"No\":\"0\""); } #region 发送短信 if (model.ActivityID == 5) { string sendMobile = Request["cellPhone"]; if (sendMobile != string.Empty) { string sendStr = string.Empty; switch (model.Prizelevel) { case "一等奖": sendStr = prizeSettingList[0].PrizeTitle; break; case "二等奖": sendStr = prizeSettingList[1].PrizeTitle; break; case "三等奖": sendStr = prizeSettingList[2].PrizeTitle; break; case "四等奖": sendStr = prizeSettingList[3].PrizeTitle; break; case "五等奖": sendStr = prizeSettingList[4].PrizeTitle; break; case "六等奖": sendStr = prizeSettingList[5].PrizeTitle; break; case "七等奖": sendStr = prizeSettingList[6].PrizeTitle; break; case "八等奖": sendStr = prizeSettingList[7].PrizeTitle; break; } //SendSms(sendMobile, sendStr);//发送短信 } } #endregion } } Response.Clear(); Response.Write(builder.ToString()); Response.End(); } } } }
public static int AddPrizeRecord(PrizeRecordInfo model) { return (int)new PrizeRecordDao().Add(model, null); }
public static bool UpdatePrizeRecord(PrizeRecordInfo model) { return new PrizeRecordDao().UpdatePrizeRecord(model); }
public static int Add(PrizeRecordInfo entity) { return(dal.Add(entity)); }