public int AddPrizeRecord(PrizeRecordInfo model) { int num; StringBuilder builder = new StringBuilder(); builder.Append("insert into Vshop_PrizeRecord("); builder.Append("ActivityID,PrizeTime,UserID,PrizeName,Prizelevel,IsPrize)"); builder.Append(" values ("); builder.Append("@ActivityID,@PrizeTime,@UserID,@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, "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; }
private void GetPrize(HttpContext context) { context.Response.ContentType = "application/json"; int result = 1; int.TryParse(context.Request["activityid"], out result); LotteryActivityInfo lotteryActivity = VshopBrowser.GetLotteryActivity(result); int userPrizeCount = VshopBrowser.GetUserPrizeCount(result); 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("{"); if (userPrizeCount >= lotteryActivity.MaxNum) { builder.Append("\"No\":\"-1\""); builder.Append("}"); context.Response.Write(builder.ToString()); } else if ((DateTime.Now < lotteryActivity.StartTime) || (DateTime.Now > lotteryActivity.EndTime)) { builder.Append("\"No\":\"-3\""); builder.Append("}"); context.Response.Write(builder.ToString()); } else { PrizeQuery page = new PrizeQuery { ActivityId = result }; List<PrizeRecordInfo> prizeList = VshopBrowser.GetPrizeList(page); int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; 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 == "三等奖"); } PrizeRecordInfo model = new PrizeRecordInfo { PrizeTime = new DateTime?(DateTime.Now), UserID = Globals.GetCurrentMemberUserId(), ActivityName = lotteryActivity.ActivityName, ActivityID = result, IsPrize = true }; List<PrizeSetting> prizeSettingList = lotteryActivity.PrizeSettingList; decimal num9 = prizeSettingList[0].Probability * 100M; decimal num10 = prizeSettingList[1].Probability * 100M; decimal num11 = prizeSettingList[2].Probability * 100M; int num15 = new Random(Guid.NewGuid().GetHashCode()).Next(1, 0x2711); if (prizeSettingList.Count > 3) { decimal num12 = prizeSettingList[3].Probability * 100M; decimal num13 = prizeSettingList[4].Probability * 100M; decimal num14 = prizeSettingList[5].Probability * 100M; num6 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "四等奖"); num7 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "五等奖"); num8 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "六等奖"); if ((num15 < num9) && (prizeSettingList[0].PrizeNum > num3)) { builder.Append("\"No\":\"9\""); model.Prizelevel = "一等奖"; model.PrizeName = prizeSettingList[0].PrizeName; } else if ((num15 < num10) && (prizeSettingList[1].PrizeNum > num4)) { builder.Append("\"No\":\"11\""); model.Prizelevel = "二等奖"; model.PrizeName = prizeSettingList[1].PrizeName; } else if ((num15 < num11) && (prizeSettingList[2].PrizeNum > num5)) { builder.Append("\"No\":\"1\""); model.Prizelevel = "三等奖"; model.PrizeName = prizeSettingList[2].PrizeName; } else if ((num15 < num12) && (prizeSettingList[3].PrizeNum > num6)) { builder.Append("\"No\":\"3\""); model.Prizelevel = "四等奖"; model.PrizeName = prizeSettingList[3].PrizeName; } else if ((num15 < num13) && (prizeSettingList[4].PrizeNum > num7)) { builder.Append("\"No\":\"5\""); model.Prizelevel = "五等奖"; model.PrizeName = prizeSettingList[4].PrizeName; } else if ((num15 < num14) && (prizeSettingList[5].PrizeNum > num8)) { builder.Append("\"No\":\"7\""); model.Prizelevel = "六等奖"; model.PrizeName = prizeSettingList[5].PrizeName; } else { model.IsPrize = false; builder.Append("\"No\":\"0\""); } } else if ((num15 < num9) && (prizeSettingList[0].PrizeNum > num3)) { builder.Append("\"No\":\"9\""); model.Prizelevel = "一等奖"; model.PrizeName = prizeSettingList[0].PrizeName; } else if ((num15 < num10) && (prizeSettingList[1].PrizeNum > num4)) { builder.Append("\"No\":\"11\""); model.Prizelevel = "二等奖"; model.PrizeName = prizeSettingList[1].PrizeName; } else if ((num15 < num11) && (prizeSettingList[2].PrizeNum > num5)) { builder.Append("\"No\":\"1\""); model.Prizelevel = "三等奖"; model.PrizeName = prizeSettingList[2].PrizeName; } else { model.IsPrize = false; builder.Append("\"No\":\"0\""); } builder.Append("}"); if (context.Request["activitytype"] != "scratch") { VshopBrowser.AddPrizeRecord(model); } context.Response.Write(builder.ToString()); } }
private void AddUserPrize(HttpContext context) { context.Response.ContentType = "application/json"; int result = 1; int.TryParse(context.Request["activityid"], out result); string str = context.Request["prize"]; LotteryActivityInfo lotteryActivity = VshopBrowser.GetLotteryActivity(result); PrizeRecordInfo model = new PrizeRecordInfo { PrizeTime = new DateTime?(DateTime.Now), UserID = Globals.GetCurrentMemberUserId(), ActivityName = lotteryActivity.ActivityName, ActivityID = result, Prizelevel = str }; switch (str) { case "一等奖": model.PrizeName = lotteryActivity.PrizeSettingList[0].PrizeName; model.IsPrize = true; break; case "二等奖": model.PrizeName = model.PrizeName = lotteryActivity.PrizeSettingList[1].PrizeName; model.IsPrize = true; break; case "三等奖": model.PrizeName = lotteryActivity.PrizeSettingList[2].PrizeName; model.IsPrize = true; break; case "四等奖": model.PrizeName = lotteryActivity.PrizeSettingList[3].PrizeName; model.IsPrize = true; break; case "五等奖": model.PrizeName = lotteryActivity.PrizeSettingList[4].PrizeName; model.IsPrize = true; break; case "六等奖": model.PrizeName = lotteryActivity.PrizeSettingList[5].PrizeName; model.IsPrize = true; break; default: model.IsPrize = false; break; } VshopBrowser.AddPrizeRecord(model); StringBuilder builder = new StringBuilder(); builder.Append("{"); builder.Append("\"Status\":\"OK\""); builder.Append("}"); context.Response.Write(builder); }
private void AddSignUp(HttpContext context) { context.Response.ContentType = "application/json"; int activityid = Convert.ToInt32(context.Request["id"]); string str = Convert.ToString(context.Request["code"]); LotteryTicketInfo lotteryTicket = VshopBrowser.GetLotteryTicket(activityid); if (!string.IsNullOrEmpty(lotteryTicket.InvitationCode) && (lotteryTicket.InvitationCode != str)) { context.Response.Write("{\"success\":false, \"msg\":\"邀请码不正确\"}"); } else if (lotteryTicket.EndTime < DateTime.Now) { context.Response.Write("{\"success\":false, \"msg\":\"活动已结束\"}"); } else if (lotteryTicket.OpenTime < DateTime.Now) { context.Response.Write("{\"success\":false, \"msg\":\"报名已结束\"}"); } else if (VshopBrowser.GetUserPrizeRecord(activityid) == null) { PrizeRecordInfo model = new PrizeRecordInfo { ActivityID = activityid }; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); model.UserID = currentMember.UserId; model.UserName = currentMember.UserName; model.IsPrize = true; model.Prizelevel = "已报名"; model.PrizeTime = new DateTime?(DateTime.Now); VshopBrowser.AddPrizeRecord(model); context.Response.Write("{\"success\":true, \"msg\":\"报名成功\"}"); } else { context.Response.Write("{\"success\":false, \"msg\":\"你已经报名了,请不要重复报名!\"}"); } }
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 int AddPrizeRecord(PrizeRecordInfo model) { return new PrizeRecordDao().AddPrizeRecord(model); }
public static bool UpdatePrizeRecord(PrizeRecordInfo model) { return new PrizeRecordDao().UpdatePrizeRecord(model); }