private KFBoCaoHistoryData InsertHistoryData() { KFBoCaoHistoryData HistoryData = new KFBoCaoHistoryData(); HistoryData.DataPeriods = this.OpenData.DataPeriods; HistoryData.RoleID = -1; HistoryData.ZoneID = -1; HistoryData.ServerID = -1; HistoryData.RoleName = "占位"; HistoryData.BuyNum = -1; HistoryData.WinMoney = -1L; KFBoCaiDbManager.InsertLotteryHistory(this.BoCaiType, HistoryData); return(HistoryData); }
public override void Thread() { try { lock (this.mutex) { if (this.Stage != BoCaiStageEnum.Stage_Init && !this.UpToDBOpenData.WinInfo.Equals(this.OpenData.WinInfo) && this.OpenData.DataPeriods > 1L) { this.SetUpToDBOpenData(); if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData)) { this.UpToDBOpenData.WinInfo = ""; } else { this.InsertHistoryData(); } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } if (BoCaiStageEnum.Stage_Open == this.Stage) { try { List <KFBoCaoHistoryData> History = new List <KFBoCaoHistoryData>(); lock (this.mutex) { int Value = 0; List <int> openVal = new List <int>(); for (int i = 0; i < 3; i++) { int num = Global.GetRandomNumber(1, 7); openVal.Add(num); Value += num; } this.OpenData.strWinNum = KFBoCaiDbManager.ListInt2String(openVal); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_caidaxiao_猜大小]猜大小 {0},winNum={1}", this.OpenData.DataPeriods, this.OpenData.strWinNum), null, true); if (Value > 3 && Value < 11) { Value = 1; } else if (Value >= 11 && Value < 18) { Value = 3; } else { Value = 2; } if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData)) { LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小] 猜大小 开始计算中奖了 KFBoCaiDbManager.InserOpenLottery(data) false", null, true); return; } double Rate = this.CompensateRate((DiceValueEnum)Value); foreach (List <KFBuyBocaiData> BuyDataList in this.RoleBuyDict.Values) { foreach (KFBuyBocaiData BuyData in BuyDataList) { if (Value == Convert.ToInt32(BuyData.BuyValue)) { History.Add(new KFBoCaoHistoryData { DataPeriods = this.OpenData.DataPeriods, RoleID = BuyData.RoleID, ZoneID = BuyData.ZoneID, ServerID = BuyData.ServerID, RoleName = BuyData.RoleName, BuyNum = BuyData.BuyNum, WinMoney = (long)((int)(Rate * (double)BuyData.BuyNum)) }); } } } } if (History.Count > 5) { History.Sort(new Comparison <KFBoCaoHistoryData>(KFBoCaiCaiDaXiao.SortHistory)); } History = History.GetRange(0, Math.Min(5, History.Count)); foreach (KFBoCaoHistoryData item in History) { if (!KFBoCaiDbManager.InsertLotteryHistory(this.BoCaiType, item)) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_caidaxiao_猜大小]猜大小插入中奖历史 false DataPeriods ={0}", item.DataPeriods), null, true); } } if (History.Count < 1) { History.Add(this.InsertHistoryData()); } this.addHistory(History); base.SetOpenHistory(this.GetOpenLottery()); this.Stage = BoCaiStageEnum.Stage_End; base.KFSendPeriodsData(); base.KFSendStageData(); } catch (Exception ex) { this.Stage = BoCaiStageEnum.Stage_End; LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true); } } }
public override void Thread() { try { lock (this.mutex) { if (BoCaiStageEnum.Stage_Ready < this.Stage && this.UpToDBOpenData.AllBalance != this.OpenData.AllBalance && this.OpenData.DataPeriods > 1L) { this.SetUpToDBOpenData(); if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData)) { this.UpToDBOpenData.AllBalance = 0L; } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜数字]{0}", ex.ToString()), null, true); } if (BoCaiStageEnum.Stage_Open == this.Stage) { try { List <int> value = new List <int>(); int no3Num = 0; if ((long)this.Config.ChuFaBiZhong <= this.OpenData.AllBalance && this.RoleBuyDict.Count > 0) { int index = Global.GetRandomNumber(0, this.RoleBuyDict.Count); List <string> keyList = this.RoleBuyDict.Keys.ToList <string>(); List <KFBuyBocaiData> buyList = this.RoleBuyDict[keyList[index]]; index = Global.GetRandomNumber(0, buyList.Count); KFBoCaiDbManager.String2ListInt(buyList[index].BuyValue, out value); } else { while (value.Count < 5) { value.Add(Global.GetRandomNumber(0, 10)); } } int no1Num; int no2Num; List <KFBoCaoHistoryData> Hsitory; this.GetWinRoleNum(value, out no1Num, out no2Num, out no3Num, out Hsitory); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字]猜数1等奖人数={0},二等奖={1},3等奖={2}", no1Num, no2Num, no3Num), null, true); long No1Money = 0L; long No2Money = 0L; long No3Money = 0L; lock (this.mutex) { long no1Win = (long)((double)this.OpenData.AllBalance * this.Config.AnNiuList[0].Percent); long no2Win = (long)((double)this.OpenData.AllBalance * this.Config.AnNiuList[1].Percent); long no3Win = (long)((double)this.OpenData.AllBalance * this.Config.AnNiuList[2].Percent); this.OpenData.SurplusBalance = this.OpenData.AllBalance; if (no1Num > 0) { this.OpenData.SurplusBalance -= no1Win; No1Money = no1Win / (long)no1Num; } if (no2Num > 0) { this.OpenData.SurplusBalance -= no2Win; No2Money = no2Win / (long)no2Num; } if (no3Num > 0) { this.OpenData.SurplusBalance -= no3Win; No3Money = no3Win / (long)no3Num; } this.OpenData.WinInfo = string.Format("{0},{1},{2}", No1Money, No2Money, No3Money); this.OpenData.strWinNum = KFBoCaiDbManager.ListInt2String(value); if (!KFBoCaiDbManager.InserOpenLottery(this.OpenData)) { LogManager.WriteLog(LogTypes.Error, "[ljl_CaiShuZi_猜数字]开始计算中奖了 KFBoCaiDbManager.InserOpenLottery(data) false", null, true); this.OpenData.SurplusBalance = 0L; this.OpenData.WinInfo = ""; this.OpenData.strWinNum = ""; return; } this.BoCaiWinHistoryList.Clear(); this.BoCaiWinHistoryList.AddRange(Hsitory); base.SetOpenHistory(this.GetOpenLottery()); this.Stage = BoCaiStageEnum.Stage_End; } foreach (KFBoCaoHistoryData item in Hsitory) { if (1 == item.WinNo) { item.WinMoney = (long)item.BuyNum * No1Money; } else if (2 == item.WinNo) { item.WinMoney = (long)item.BuyNum * No2Money; } else if (3 == item.WinNo) { item.WinMoney = (long)item.BuyNum * No3Money; } if (!KFBoCaiDbManager.InsertLotteryHistory(this.BoCaiType, item)) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_CaiShuZi_猜数字]插入中奖历史 false DataPeriods ={0}, name={1},id={2},WinNo={3},WinMoney={4}", new object[] { item.DataPeriods, item.RoleName, item.RoleID, item.WinNo, item.WinMoney }), null, true); } } if (!KFBoCaiDbManager.DelTableData("t_bocai_lottery_history", string.Format("DataPeriods < {0}", this.OpenData.DataPeriods))) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_CaiShuZi_猜数字] DelTableData t_bocai_lottery_history false DataPeriods ={0}", this.OpenData.DataPeriods), null, true); } base.KFSendPeriodsData(); base.KFSendStageData(); } catch (Exception ex) { this.Stage = BoCaiStageEnum.Stage_End; LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_CaiShuZi_猜数字]{0}", ex.ToString()), null, true); } } }