/// <summary> /// 更新一条数据 /// </summary> public void Update(BCW.JQC.Model.JQC_Jackpot model) { dal.Update(model); }
//机器人购买 private void Play_jqcRobot() { int meid = GetUsID();//得到随机的UsID if (!new BCW.BLL.User().ExistsID(meid)) { Response.Write("随机机器人ID不存在.error1<br/>"); Response.End(); } if (meid > 0) { //随机延时 System.Threading.Thread.Sleep(R(1, 11) * 1000); int beilv = GetPayCent(); //得到随机投注的倍率 int buycou = Convert.ToInt32(ub.GetSub("ROBOTBUY", xmlPath)); //xml限定每个机器人购买次数 int zhuPrice = Convert.ToInt32(ub.GetSub("zhuPrice", xmlPath)); //每注酷币 long Price = zhuPrice * beilv; //随机得到投注号码 string votenum = string.Empty; int[] a = new int[] { 0, 1, 2, 3 }; string s = string.Empty; Random ran = new Random(); for (int j = 0; j < 8; j++) { s = a[ran.Next(0, 4)].ToString(); if (j == 7) { votenum += s; } else { votenum += s + "#"; } } string where1 = "where phase!='' and Sale_Start < getdate() and Sale_End > getdate() order by newid()";//查询数据库可以下注的随机一期 BCW.JQC.Model.JQC_Internet model = new BCW.JQC.BLL.JQC_Internet().GetJQC_Internet_model(where1); if (model.phase > 0) { BCW.JQC.Model.JQC_Bet modelBuy = new BCW.JQC.Model.JQC_Bet(); //计数出该机器人投注的次数是否大于xml限定次数 int count = new BCW.JQC.BLL.JQC_Bet().GetRecordCount(" UsID=" + meid + " and Lottery_issue='" + model.phase + "'"); if ((count < buycou) || (buycou == 0)) { modelBuy.Lottery_issue = model.phase; modelBuy.UsID = meid; modelBuy.Input_Time = DateTime.Now; modelBuy.State = 0; modelBuy.isRobot = 1; modelBuy.Zhu = 1; modelBuy.Zhu_money = zhuPrice; modelBuy.GetMoney = 0; modelBuy.VoteRate = beilv; modelBuy.PutGold = Price; modelBuy.VoteNum = votenum; long gold = new BCW.BLL.User().GetGold(meid); long prices = Price; string mename = new BCW.BLL.User().GetUsName(meid); if (gold < prices) { //更新消费记录 BCW.Model.Goldlog modelx = new BCW.Model.Goldlog(); modelx.BbTag = 3; modelx.Types = 0; 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 + ""); } long xPrices = Utils.ParseInt64(ub.GetSub("BigPrice", xmlPath)); if (xPrices > 0) { long oPrices = 0; DataSet ds = new BCW.JQC.BLL.JQC_Bet().GetList("PutGold", "UsID=" + meid + " and Lottery_issue='" + model.phase + "'"); DataTable dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { int drs = int.Parse(dr[0].ToString()); oPrices = oPrices + drs; } if (oPrices + prices > xPrices) { Response.End(); } } int id = new BCW.JQC.BLL.JQC_Bet().Add(modelBuy); new BCW.BLL.User().UpdateiGold(meid, mename, -prices, "进球彩第" + model.phase + "期投注消费-标识ID" + id + ""); //更新奖池 BCW.JQC.Model.JQC_Jackpot jack = new BCW.JQC.Model.JQC_Jackpot(); jack.UsID = meid; jack.InPrize = Price; jack.OutPrize = 0; //jack.Jackpot = Price + new BCW.JQC.BLL.JQC_Jackpot().GetGold();//实时奖池 jack.Jackpot = Price + new BCW.JQC.BLL.JQC_Jackpot().GetGold_phase(model.phase); jack.AddTime = DateTime.Now; jack.phase = model.phase; jack.type = 0;//玩家下注 jack.BetID = id; new BCW.JQC.BLL.JQC_Jackpot().Add(jack); new BCW.BLL.User().UpdateTime(meid, 5); //更新会员在线时长 //动态 string wText = "[url=/bbs/uinfo.aspx?uid=" + meid + "]" + new BCW.BLL.User().GetUsName(meid) + "[/url]在[url=/bbs/game/jqc.aspx]" + GameName + "[/url]第" + model.phase + "期下注" + Price + "" + ub.Get("SiteBz") + ""; new BCW.BLL.Action().Add(1014, id, meid, "", wText); } } Response.Write("ok1"); } else { Response.Write("error1.机器人为空."); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BCW.JQC.Model.JQC_Jackpot model) { return(dal.Add(model)); }
//开始返彩 public void Open_price(string phase) { //如果这个期号前面有未开奖的期号,就算这期有开奖号码,都不开奖,内线提示10086 //查询是否有开奖为空的期号 if (new BCW.JQC.BLL.JQC_Internet().Exists_wei(int.Parse(phase))) { DataSet ds = new BCW.BLL.Guest().GetList("*", "Content LIKE '%进球彩%' AND ToId=52784 AND ToName='森林仔555' AND DateDiff(dd,AddTime,getdate())=0"); if (ds == null && ds.Tables[0].Rows.Count <= 0) { new BCW.BLL.Guest().Add(1, 52784, "森林仔555", "注意:进球彩在第" + phase + "期前存在未开奖期号,请马上去后台检查开奖."); } DataSet ds1 = new BCW.BLL.Guest().GetList("*", "Content LIKE '%进球彩%' AND ToId=10086 AND ToName='客服10086' AND DateDiff(dd,AddTime,getdate())=0"); if (ds1 == null && ds1.Tables[0].Rows.Count <= 0) { new BCW.BLL.Guest().Add(1, 10086, "客服10086", "注意:进球彩在第" + phase + "期前存在未开奖期号,请马上去后台检查开奖."); } Response.Write("<br/>在" + phase + "期前存在未开奖期号,请马上检查开奖.ok1<br/>"); } else { #region string where = string.Empty; where = "where phase='" + phase + "'"; BCW.JQC.Model.JQC_Internet model = new BCW.JQC.BLL.JQC_Internet().GetJQC_Internet_model(where); string Result = model.Result; Response.Write("<br/>等待开奖期号:[" + model.phase + "]ok1<br/>"); if (Result != "")//如果开奖号码为空,则不返奖 { //取出当前期的奖池金额 long get_jiangchi_kou = new BCW.JQC.BLL.JQC_Jackpot().GetGold_phase((int.Parse(phase))); #region 判断系统是否有投入和开奖是否够币 //如果奖池大于400w,则判断是否有系统投入,若有,则先扣除系统投入,再拿去派奖和扣税 if (get_jiangchi_kou > jiangchi_guding) { //通过比较type=4、InPrize次数和OutPrize次数对比 if (new BCW.JQC.BLL.JQC_Jackpot().Getxitong_toujin() > new BCW.JQC.BLL.JQC_Jackpot().Getxitong_huishou()) { BCW.JQC.Model.JQC_Jackpot bb = new BCW.JQC.Model.JQC_Jackpot(); bb.AddTime = DateTime.Now; bb.BetID = 0; bb.InPrize = 0; bb.Jackpot = get_jiangchi_kou - jiangchi; bb.OutPrize = jiangchi; bb.phase = (int.Parse(phase)); //开奖的那期 bb.type = 4; //系统 bb.UsID = 10086; new BCW.JQC.BLL.JQC_Jackpot().Add(bb); } } //判断该期最后的奖池是否大于最低的200w,如果是,则增加200w if (get_jiangchi_kou < jianchi_zuidi) { BCW.JQC.Model.JQC_Jackpot aa = new BCW.JQC.Model.JQC_Jackpot(); aa.AddTime = DateTime.Now; aa.BetID = 0; aa.InPrize = jiangchi; aa.Jackpot = jiangchi + get_jiangchi_kou; aa.OutPrize = 0; aa.phase = (int.Parse(phase)); //开奖的那期 aa.type = 4; //系统 aa.UsID = 10086; new BCW.JQC.BLL.JQC_Jackpot().Add(aa); } #endregion //取出当前期的奖池金额——系统增加或扣除后 long get_jiangchi = new BCW.JQC.BLL.JQC_Jackpot().GetGold_phase((int.Parse(phase))); //把金额存到相应的期号 new BCW.JQC.BLL.JQC_Internet().Update_Result("nowprize='" + get_jiangchi + "'", "phase='" + phase + "'"); //系统没收的金额并奖池减少 long moshou = Convert.ToInt64(get_jiangchi * huishou * 0.01); BCW.JQC.Model.JQC_Jackpot aa1 = new BCW.JQC.Model.JQC_Jackpot(); aa1.AddTime = DateTime.Now; aa1.BetID = 0; aa1.InPrize = 0; aa1.Jackpot = get_jiangchi - moshou; aa1.OutPrize = moshou; aa1.phase = (int.Parse(phase)); aa1.type = 3;//系统扣税10% aa1.UsID = 10086; new BCW.JQC.BLL.JQC_Jackpot().Add(aa1); //检查投注表是否存在没开奖数据 //if (new BCW.JQC.BLL.JQC_Bet().Exists_num(model.phase)) { //得到每个奖的金额 long z4 = Convert.ToInt64(get_jiangchi * jqcFour * 0.01); long z3 = Convert.ToInt64(get_jiangchi * jqcThree * 0.01); long z2 = Convert.ToInt64(get_jiangchi * jqcTwo * 0.01); long z1 = Convert.ToInt64(get_jiangchi * jqcOne * 0.01); DataSet ds = new BCW.JQC.BLL.JQC_Bet().GetList("*", " State=0 and Lottery_issue='" + model.phase + "'"); if (ds != null && ds.Tables[0].Rows.Count > 0) { int count = 0; string[] resultnum = Result.Split(','); //中奖判断 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //投注数据 int ID = int.Parse(ds.Tables[0].Rows[i]["ID"].ToString()); int UsID = int.Parse(ds.Tables[0].Rows[i]["UsID"].ToString()); string Lottery_issue = ds.Tables[0].Rows[i]["Lottery_issue"].ToString(); int State = int.Parse(ds.Tables[0].Rows[i]["State"].ToString()); long Zhu_money = Int64.Parse(ds.Tables[0].Rows[i]["Zhu_money"].ToString()); long PutGold = Int64.Parse(ds.Tables[0].Rows[i]["PutGold"].ToString()); long GetMoney = Int64.Parse(ds.Tables[0].Rows[i]["GetMoney"].ToString()); int VoteRate = int.Parse(ds.Tables[0].Rows[i]["VoteRate"].ToString());//投注倍率 DateTime Input_Time = Convert.ToDateTime(ds.Tables[0].Rows[i]["Input_Time"]); int isRobot = int.Parse(ds.Tables[0].Rows[i]["isRobot"].ToString()); string Vote = ds.Tables[0].Rows[i]["VoteNum"].ToString(); //投注号码 int VoteNum = int.Parse(ds.Tables[0].Rows[i]["Zhu"].ToString()); //投注注数 if (VoteNum == 1) //单注 { #region 单式中奖算法 string[] votenum = Vote.Split('#'); if (Vote != "" && Result != "") { for (int k = 0; k < 8; k++) { string aa = votenum[k]; string bb = resultnum[k]; if (True(aa, bb)) { count++; } } } #endregion #region 单式中奖更新数据库 if (count == 5)//4等奖----State=4 { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize4=1", "ID='" + ID + "'"); new BCW.JQC.BLL.JQC_Bet().Update_win(ID, 1); //0未开1中2不中3已领4过期 } else if (count == 6) //3等奖----State=3 { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize3=1", "ID='" + ID + "'"); new BCW.JQC.BLL.JQC_Bet().Update_win(ID, 1); } else if (count == 7)//2等奖----State=2 { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize2=1", "ID='" + ID + "'"); new BCW.JQC.BLL.JQC_Bet().Update_win(ID, 1); } else if (count == 8)//1等奖----State=1 { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize1=1", "ID='" + ID + "'"); new BCW.JQC.BLL.JQC_Bet().Update_win(ID, 1); } else//不中奖 { new BCW.JQC.BLL.JQC_Bet().Update_win(ID, 2); } count = 0; #endregion } else//复式 { #region 式中奖算法 int num1 = 0; int num2 = 0; int num3 = 0; int num4 = 0; string[] buyvote = Vote.Split('#'); string[] vote1 = buyvote[0].Split(','); string[] vote2 = buyvote[1].Split(','); string[] vote3 = buyvote[2].Split(','); string[] vote4 = buyvote[3].Split(','); string[] vote5 = buyvote[4].Split(','); string[] vote6 = buyvote[5].Split(','); string[] vote7 = buyvote[6].Split(','); string[] vote8 = buyvote[7].Split(','); List <string[]> list = new List <string[]>(); list.Add(vote1); list.Add(vote2); list.Add(vote3); list.Add(vote4); list.Add(vote5); list.Add(vote6); list.Add(vote7); list.Add(vote8); string[] totalResult; string[] Finalresult = Result.Split(','); totalResult = bianli(list);//得到投注数据 for (int iresult = 0; iresult < totalResult.Length; iresult++) { //builder.Append(totalResult[iresult].Replace("#", ",") + "<br/>"); string[] results = totalResult[iresult].Split('#'); for (int j = 0; j < results.Length; j++) { if (results[j].Equals(Finalresult[j])) { count++;//遍历开奖数据是否相同,相同则count+1 } } if (count == 5)//如果count出现的次数等于5,证明是四等奖 { num4++; } if (count == 6)//如果count出现的次数等于6,证明是三等奖 { num3++; } if (count == 7)//如果count出现的次数等于7,证明是二等奖 { num2++; } if (count == 8)//如果count出现的次数等于8,证明是一等奖 { num1 = 1; } count = 0; } #endregion #region 单式中奖更新数据库 //更新各中几等奖 if (num1 > 0) { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize1=1", "ID='" + ID + "'"); } if (num2 > 0) { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize2=" + num2 + "", "ID='" + ID + "'"); } if (num3 > 0) { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize3=" + num3 + "", "ID='" + ID + "'"); } if (num4 > 0) { new BCW.JQC.BLL.JQC_Bet().update_GetMoney("Prize4=" + num4 + "", "ID='" + ID + "'"); } //更新中奖状态 if (num1 == 0 && num2 == 0 && num3 == 0 && num4 == 0) { new BCW.JQC.BLL.JQC_Bet().Update_win(ID, 2); } else { new BCW.JQC.BLL.JQC_Bet().Update_win(ID, 1); } #endregion } } } //计算当期各等奖总注数 int q4 = new BCW.JQC.BLL.JQC_Bet().count_renshu(model.phase, "Prize4"); int q3 = new BCW.JQC.BLL.JQC_Bet().count_renshu(model.phase, "Prize3"); int q2 = new BCW.JQC.BLL.JQC_Bet().count_renshu(model.phase, "Prize2"); int q1 = new BCW.JQC.BLL.JQC_Bet().count_renshu(model.phase, "Prize1"); //得到每注金额 long z_price4, z_price3, z_price2, z_price1 = 0; if (q1 != 0) { z_price1 = z1 / q1; } else { z_price1 = z1; } if (q2 != 0) { z_price2 = z2 / q2; } else { z_price2 = z2; } if (q3 != 0) { z_price3 = z3 / q3; } else { z_price3 = z3; } if (q4 != 0) { z_price4 = z4 / q4; } else { z_price4 = z4; } string ai = q1 + "," + q2 + "," + q3 + "," + q4; string aii = z_price1 + "," + z_price2 + "," + z_price3 + "," + z_price4; //把中奖注数和每注金额存到数据库对应的那期 new BCW.JQC.BLL.JQC_Internet().Update_Result("zhu='" + ai + "',zhu_money='" + aii + "'", "phase='" + phase + "'"); //派奖 DataSet ds1 = new BCW.JQC.BLL.JQC_Bet().GetList("*", " State>0 and Lottery_issue='" + model.phase + "'"); for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) { int ID = int.Parse(ds1.Tables[0].Rows[i]["ID"].ToString()); int UsID = int.Parse(ds1.Tables[0].Rows[i]["UsID"].ToString()); int VoteRate = int.Parse(ds1.Tables[0].Rows[i]["VoteRate"].ToString());//投注倍率 int isRobot = int.Parse(ds1.Tables[0].Rows[i]["isRobot"].ToString()); int Prize1 = int.Parse(ds1.Tables[0].Rows[i]["Prize1"].ToString()); int Prize2 = int.Parse(ds1.Tables[0].Rows[i]["Prize2"].ToString()); int Prize3 = int.Parse(ds1.Tables[0].Rows[i]["Prize3"].ToString()); int Prize4 = int.Parse(ds1.Tables[0].Rows[i]["Prize4"].ToString()); long qian = 0; //奖池减少 BCW.JQC.Model.JQC_Jackpot bb = new BCW.JQC.Model.JQC_Jackpot(); bb.AddTime = DateTime.Now; bb.BetID = ID; bb.InPrize = 0; bb.phase = int.Parse(phase); bb.type = 1; bb.UsID = UsID; if (Prize1 > 0 || Prize2 > 0 || Prize3 > 0 || Prize4 > 0) { qian = z_price4 * VoteRate * Prize4 + z_price3 * VoteRate * Prize3 + z_price2 * VoteRate * Prize2 + z_price1 * VoteRate * Prize1; new BCW.JQC.BLL.JQC_Bet().update_GetMoney("GetMoney='" + qian + "'", "ID=" + ID + ""); //奖池 bb.Jackpot = new BCW.JQC.BLL.JQC_Jackpot().GetGold_phase(int.Parse(phase)) - qian; bb.OutPrize = qian; new BCW.JQC.BLL.JQC_Jackpot().Add(bb); if (isRobot == 0) { new BCW.BLL.Guest().Add(1, UsID, new BCW.BLL.User().GetUsName(UsID), "恭喜您在" + GameName + "第" + model.phase + "期获得了" + qian + "" + ub.Get("SiteBz") + "[url=/bbs/game/jqc.aspx?act=case]马上兑奖[/url]"); } string wText = "[url=/bbs/uinfo.aspx?uid=" + UsID + "]" + new BCW.BLL.User().GetUsName(UsID) + "[/url]在[url=/bbs/game/jqc.aspx]" + GameName + "[/url]《" + model.phase + "期》获得了" + qian + "" + ub.Get("SiteBz") + ""; new BCW.BLL.Action().Add(1014, ID, UsID, "", wText); System.Threading.Thread.Sleep(5); } } System.Threading.Thread.Sleep(5); //把剩余的奖池,加到下一期去,该期奖池清空 BCW.JQC.Model.JQC_Jackpot aa3 = new BCW.JQC.Model.JQC_Jackpot(); aa3.AddTime = DateTime.Now; aa3.BetID = 0; aa3.InPrize = 0; aa3.Jackpot = 0; aa3.OutPrize = get_jiangchi - moshou - new BCW.JQC.BLL.JQC_Bet().Get_paijiang(int.Parse(phase)); aa3.phase = (int.Parse(phase)); aa3.type = 5;//5是系统滚存 aa3.UsID = 10086; new BCW.JQC.BLL.JQC_Jackpot().Add(aa3); BCW.JQC.Model.JQC_Jackpot aa2 = new BCW.JQC.Model.JQC_Jackpot(); aa2.AddTime = DateTime.Now; aa2.BetID = 0; aa2.InPrize = get_jiangchi - moshou - new BCW.JQC.BLL.JQC_Bet().Get_paijiang(int.Parse(phase)); aa2.Jackpot = new BCW.JQC.BLL.JQC_Jackpot().GetGold_phase((int.Parse(phase) + 1)) + get_jiangchi - moshou - new BCW.JQC.BLL.JQC_Bet().Get_paijiang(int.Parse(phase)); aa2.OutPrize = 0; aa2.phase = (int.Parse(phase) + 1); aa2.type = 5;//5是系统滚存 aa2.UsID = 10086; new BCW.JQC.BLL.JQC_Jackpot().Add(aa2); //滚存后,判断下一期是否够200w,如果不够则加200w //查询滚存后的那期奖池 if (new BCW.JQC.BLL.JQC_Jackpot().GetGold_phase((int.Parse(phase) + 1)) < jianchi_zuidi) { BCW.JQC.Model.JQC_Jackpot aa = new BCW.JQC.Model.JQC_Jackpot(); aa.AddTime = DateTime.Now; aa.BetID = 0; aa.InPrize = jiangchi; aa.Jackpot = jiangchi + new BCW.JQC.BLL.JQC_Jackpot().GetGold_phase((int.Parse(phase) + 1)); aa.OutPrize = 0; aa.phase = (int.Parse(phase) + 1); aa.type = 4;//系统 aa.UsID = 10086; new BCW.JQC.BLL.JQC_Jackpot().Add(aa); } } } #endregion } }