/// <summary> /// 取得排行记录 /// </summary> /// <param name="p_pageIndex">当前页</param> /// <param name="p_pageSize">分页大小</param> /// <param name="p_recordCount">返回总记录数</param> /// <param name="strWhere">查询条件</param> /// <returns>IList HcPay</returns> public IList <BCW.Model.Game.HcPay> GetHcPaysTop(int p_pageIndex, int p_pageSize, string strWhere, out int p_recordCount) { IList <BCW.Model.Game.HcPay> listHcPayTop = new List <BCW.Model.Game.HcPay>(); // 计算记录数 string countString = "SELECT COUNT(DISTINCT UsID) FROM tb_HcPay where " + strWhere + ""; p_recordCount = Convert.ToInt32(SqlHelper.GetSingle(countString)); if (p_recordCount > 50) { p_recordCount = 50; } if (p_recordCount > 0) { int pageCount = BasePage.CalcPageCount(p_recordCount, p_pageSize, ref p_pageIndex); } else { return(listHcPayTop); } // 取出相关记录 string queryString = ""; queryString = "SELECT Top 50 UsID,sum(WinCent-PayCents) as WinCents FROM tb_HcPay where " + strWhere + " group by UsID Order by sum(WinCent-PayCents) desc"; using (SqlDataReader reader = SqlHelper.ExecuteReader(queryString)) { int stratIndex = (p_pageIndex - 1) * p_pageSize; int endIndex = p_pageIndex * p_pageSize; int k = 0; while (reader.Read()) { if (k >= stratIndex && k < endIndex) { BCW.Model.Game.HcPay objHcPay = new BCW.Model.Game.HcPay(); objHcPay.UsID = reader.GetInt32(0); objHcPay.WinCent = reader.GetInt64(1); listHcPayTop.Add(objHcPay); } if (k == endIndex) { break; } k++; } } return(listHcPayTop); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(BCW.Model.Game.HcPay model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_HcPay set "); strSql.Append("Types=@Types,"); strSql.Append("CID=@CID,"); strSql.Append("UsID=@UsID,"); strSql.Append("UsName=@UsName,"); strSql.Append("Vote=@Vote,"); strSql.Append("PayCent=@PayCent,"); strSql.Append("Result=@Result,"); strSql.Append("State=@State,"); strSql.Append("WinCent=@WinCent,"); strSql.Append("BzType=@BzType,"); strSql.Append("AddTime=@AddTime,"); strSql.Append("IsSpier=@IsSpier"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@Types", SqlDbType.Int, 4), new SqlParameter("@CID", SqlDbType.Int, 4), new SqlParameter("@UsID", SqlDbType.Int, 4), new SqlParameter("@UsName", SqlDbType.NVarChar, 50), new SqlParameter("@Vote", SqlDbType.NVarChar, 200), new SqlParameter("@PayCent", SqlDbType.BigInt, 8), new SqlParameter("@Result", SqlDbType.NVarChar, 50), new SqlParameter("@State", SqlDbType.TinyInt, 1), new SqlParameter("@WinCent", SqlDbType.BigInt, 8), new SqlParameter("@BzType", SqlDbType.TinyInt, 1), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@IsSpier", SqlDbType.TinyInt, 1) }; parameters[0].Value = model.id; parameters[1].Value = model.Types; parameters[2].Value = model.CID; parameters[3].Value = model.UsID; parameters[4].Value = model.UsName; parameters[5].Value = model.Vote; parameters[6].Value = model.PayCent; parameters[7].Value = model.Result; parameters[8].Value = model.State; parameters[9].Value = model.WinCent; parameters[10].Value = model.BzType; parameters[11].Value = model.AddTime; parameters[12].Value = model.IsSpier; SqlHelper.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BCW.Model.Game.HcPay model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_HcPay("); strSql.Append("Types,CID,UsID,UsName,Vote,PayCent,PayCents,Result,State,WinCent,BzType,AddTime,IsSpier)"); strSql.Append(" values ("); strSql.Append("@Types,@CID,@UsID,@UsName,@Vote,@PayCent,@PayCents,@Result,@State,@WinCent,@BzType,@AddTime,@IsSpier)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Types", SqlDbType.Int, 4), new SqlParameter("@CID", SqlDbType.Int, 4), new SqlParameter("@UsID", SqlDbType.Int, 4), new SqlParameter("@UsName", SqlDbType.NVarChar, 50), new SqlParameter("@Vote", SqlDbType.NVarChar, 200), new SqlParameter("@PayCent", SqlDbType.BigInt, 8), new SqlParameter("@PayCents", SqlDbType.BigInt, 8), new SqlParameter("@Result", SqlDbType.NVarChar, 50), new SqlParameter("@State", SqlDbType.TinyInt, 1), new SqlParameter("@WinCent", SqlDbType.BigInt, 8), new SqlParameter("@BzType", SqlDbType.TinyInt, 1), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@IsSpier", SqlDbType.TinyInt, 1) }; parameters[0].Value = model.Types; parameters[1].Value = model.CID; parameters[2].Value = model.UsID; parameters[3].Value = model.UsName; parameters[4].Value = model.Vote; parameters[5].Value = model.PayCent; parameters[6].Value = model.PayCents; parameters[7].Value = model.Result; parameters[8].Value = model.State; parameters[9].Value = model.WinCent; parameters[10].Value = model.BzType; parameters[11].Value = model.AddTime; parameters[12].Value = model.IsSpier; object obj = SqlHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 取得每页记录 /// </summary> /// <param name="p_pageIndex">当前页</param> /// <param name="p_pageSize">分页大小</param> /// <param name="p_recordCount">返回总记录数</param> /// <param name="strWhere">查询条件</param> /// <returns>IList HcPay</returns> public IList <BCW.Model.Game.HcPay> GetHcPays(int p_pageIndex, int p_pageSize, string strWhere, out int p_recordCount) { IList <BCW.Model.Game.HcPay> listHcPays = new List <BCW.Model.Game.HcPay>(); string sTable = "tb_HcPay"; string sPkey = "id"; string sField = "id,Types,CID,UsID,UsName,Vote,PayCent,Result,State,WinCent,BzType,AddTime,IsSpier"; string sCondition = strWhere; string sOrder = "ID Desc"; int iSCounts = 0; using (SqlDataReader reader = SqlHelper.RunProcedureMe(sTable, sPkey, sField, p_pageIndex, p_pageSize, sCondition, sOrder, iSCounts, out p_recordCount)) { //计算总页数 if (p_recordCount > 0) { int pageCount = BasePage.CalcPageCount(p_recordCount, p_pageSize, ref p_pageIndex); } else { return(listHcPays); } while (reader.Read()) { BCW.Model.Game.HcPay objHcPay = new BCW.Model.Game.HcPay(); objHcPay.id = reader.GetInt32(0); objHcPay.Types = reader.GetInt32(1); objHcPay.CID = reader.GetInt32(2); objHcPay.UsID = reader.GetInt32(3); objHcPay.UsName = reader.GetString(4); objHcPay.Vote = reader.GetString(5); objHcPay.PayCent = reader.GetInt64(6); objHcPay.Result = reader.GetString(7); objHcPay.State = reader.GetByte(8); objHcPay.WinCent = reader.GetInt64(9); objHcPay.BzType = reader.GetByte(10); objHcPay.AddTime = reader.GetDateTime(11); objHcPay.IsSpier = reader.GetByte(12); listHcPays.Add(objHcPay); } } return(listHcPays); }
/// <summary> /// 得到一个对象实体 /// </summary> public BCW.Model.Game.HcPay GetHcPay(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,Types,CID,UsID,UsName,Vote,PayCent,Result,State,WinCent,BzType,AddTime,IsSpier from tb_HcPay "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; BCW.Model.Game.HcPay model = new BCW.Model.Game.HcPay(); using (SqlDataReader reader = SqlHelper.ExecuteReader(strSql.ToString(), parameters)) { if (reader.HasRows) { reader.Read(); model.id = reader.GetInt32(0); model.Types = reader.GetInt32(1); model.CID = reader.GetInt32(2); model.UsID = reader.GetInt32(3); model.UsName = reader.GetString(4); model.Vote = reader.GetString(5); model.PayCent = reader.GetInt64(6); model.Result = reader.GetString(7); model.State = reader.GetByte(8); model.WinCent = reader.GetInt64(9); model.BzType = reader.GetByte(10); model.AddTime = reader.GetDateTime(11); model.IsSpier = reader.GetByte(12); return(model); } else { return(null); } } }
//机器人购买 private void PlayHc1_Robot() { //得到随机的UsID int meid = GetUsID(); if (meid == 0) { Response.Write("随机机器人ID出错.error1<br/>"); Response.End(); } if (!new BCW.BLL.User().ExistsID(meid)) { Response.Write("随机机器人ID不存在.error1<br/>"); Response.End(); } //得到随机的类型 int num1 = GetPtype(); //得到随机投注的酷币 long Price = GetPayCent(); //xml限定每个机器人购买次数 int buycou = 0; try { buycou = Convert.ToInt32(ub.GetSub("hc1ROBOTBUY", xmlPath)); } catch { buycou = 0; } long Gold = new BCW.BLL.User().GetGold(meid); #region 判断机器人币够不够投注 if (Gold < Price || Gold < 0) { Response.Write("<b>机器人" + meid + "币不够!请换一个机器人或者给该机器人充值 </b><br />"); } else { #region 机器人投注 int dnu = 0; string dsb = DateTime.Now.ToString("yyMMdd"); dnu = int.Parse(dsb + "001"); string where1 = string.Empty; where1 = "ORDER BY ID DESC"; //最后一期 DataSet ds = new BCW.BLL.Game.HcList().GetList("top 1 id", "State=0 order by EndTime desc"); int maxid = Convert.ToInt32(ds.Tables[0].Rows[0][0]); BCW.Model.Game.HcList modelbuy1 = new BCW.BLL.Game.HcList().GetHcList(maxid); BCW.Model.Game.HcPay modelbuy = new BCW.Model.Game.HcPay(); int count = new BCW.BLL.Game.HcList().GetcountRebot(meid); if ((count < buycou) || (buycou == 0)) { #region 大小单双投注 if (num1 == 5)//1大2小/3单/4双 { int a11 = int.Parse(Get_DXSD()); modelbuy.Types = 5; if (a11 == 1) { modelbuy.Vote = "大"; } else if (a11 == 2) { modelbuy.Vote = "小"; } else if (a11 == 3) { modelbuy.Vote = "单"; } else { modelbuy.Vote = "双"; } } #endregion //选号玩法 else if (num1 == 1) { modelbuy.Types = 1; Random a3 = new Random(); int a33 = a3.Next(1, 37); modelbuy.Vote = Convert.ToString(a33); } //生肖玩法 else if (num1 == 2) { modelbuy.Types = 2; Random a4 = new Random(); int a44 = a4.Next(1, 13); switch (a44) { case 1: modelbuy.Vote = "鼠"; break; case 2: modelbuy.Vote = "牛"; break; case 3: modelbuy.Vote = "虎"; break; case 4: modelbuy.Vote = "兔"; break; case 5: modelbuy.Vote = "龙"; break; case 6: modelbuy.Vote = "蛇"; break; case 7: modelbuy.Vote = "马"; break; case 8: modelbuy.Vote = "羊"; break; case 9: modelbuy.Vote = "猴"; break; case 10: modelbuy.Vote = "鸡"; break; case 11: modelbuy.Vote = "狗"; break; case 12: modelbuy.Vote = "猪"; break; } } //方位玩法 else if (num1 == 3) { modelbuy.Types = 3; Random a5 = new Random(); int a55 = a5.Next(1, 5); switch (a55) { case 1: modelbuy.Vote = "东"; break; case 2: modelbuy.Vote = "南"; break; case 3: modelbuy.Vote = "西"; break; case 4: modelbuy.Vote = "北"; break; } } else if (num1 == 4)//四季玩法 { modelbuy.Types = 4; Random a6 = new Random(); int a66 = a6.Next(1, 5); switch (a66) { case 1: modelbuy.Vote = "春"; break; case 2: modelbuy.Vote = "夏"; break; case 3: modelbuy.Vote = "秋"; break; case 4: modelbuy.Vote = "东"; break; } } //六肖中奖 else if (num1 == 6) { modelbuy.Types = 6; int a66 = 0; //随机生成6个生肖 string rand = ""; while (a66 < 6) { rand += GetRandomNum1()[a66]; rand += ","; a66++; } modelbuy.Vote = rand; } //尾数大小 else if (num1 == 7) { modelbuy.Types = 7; Random a7 = new Random(); int a77 = a7.Next(0, 2); switch (a77) { case 0: modelbuy.Vote = "大"; break; case 1: modelbuy.Vote = "小"; break; } } //尾数单双 else if (num1 == 8) { modelbuy.Types = 8; Random a8 = new Random(); int a88 = a8.Next(0, 2); switch (a88) { case 0: modelbuy.Vote = "单"; break; case 1: modelbuy.Vote = "双"; break; } } //家禽0野兽1 else if (num1 == 9) { modelbuy.Types = 9; Random a9 = new Random(); int a99 = a9.Next(0, 2); switch (a99) { case 0: modelbuy.Vote = "家禽"; break; case 1: modelbuy.Vote = "野兽"; break; } } modelbuy.UsID = meid; //用户id modelbuy.AddTime = DateTime.Now; //投注时间 modelbuy.State = 0; //未开奖 modelbuy.WinCent = 0; //获得多少酷币 modelbuy.IsSpier = 1; modelbuy.BzType = 0; modelbuy.Result = ""; //开奖结果 modelbuy.PayCent = Price; //每注投多少钱 modelbuy.PayCents = Price; //总投了多少钱 modelbuy.CID = modelbuy1.CID; //最新投注期数 long gold = new BCW.BLL.User().GetGold(meid); long prices = Convert.ToInt64(Price); string mename = new BCW.BLL.User().GetUsName(meid); modelbuy.UsName = mename;//用户名字 if (gold < prices) { //更新消费记录 BCW.Model.Goldlog modelx = new BCW.Model.Goldlog(); modelx.BbTag = 3; modelx.PUrl = Utils.getPageUrl();//操作的文件名 modelx.UsId = meid; modelx.UsName = mename; modelx.AcGold = prices; modelx.AfterGold = gold + prices;//更新后的币数 modelx.AcText = "系统机器人自动操作"; modelx.AddTime = DateTime.Now; new BCW.BLL.Goldlog().Add(modelx); BCW.Data.SqlHelper.ExecuteSql("Update tb_User set iGold=iGold+(" + prices + ") where id=" + meid + ""); } new BCW.BLL.User().UpdateiGold(meid, mename, -prices, 1001);//新快3----更新排行榜与扣钱 new BCW.BLL.Game.HcPay().Add(modelbuy); new BCW.BLL.User().UpdateiGold(meid, mename, -prices, "好彩1" + modelbuy1.CID + "期投注消费"); new BCW.BLL.Game.HcList().Update1(modelbuy1.CID, prices, 1); //更新下注总额和下注额 ChanageOnline(meid); //邵广林 增加机器人在线时长 //动态 string wText = "[url=/bbs/uinfo.aspx?uid=" + meid + "]" + mename + "[/url]在[url=/bbs/game/hc1.aspx]" + GameName + "[/url]下注**" + ub.Get("SiteBz") + ""; //" + prices + " new BCW.BLL.Action().Add(1001, 1, meid, "", wText); } #endregion } #endregion }