public bool SendWinItem(OpenLottery data, BuyBoCai2SDB buyItem) { try { buyItem.IsSend = true; string[] files = data.WinInfo.Split(new char[] { ',' }); List <int> winList; BoCaiHelper.String2ListInt(data.strWinNum, out winList); int No1Win = Convert.ToInt32(files[0]); int No2Win = Convert.ToInt32(files[1]); int No3Win = Convert.ToInt32(files[2]); List <int> selfBuy; BoCaiHelper.String2ListInt(buyItem.strBuyValue, out selfBuy); if (selfBuy.Count != winList.Count) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl_博彩]selfBuy.Count != winList.Count DataPeriods={0}, type={1}, roleid={2}", data.DataPeriods, data.BocaiType, buyItem.m_RoleID), null, true); return(false); } int sameNum = 0; for (int i = 0; i < selfBuy.Count; i++) { if (selfBuy[i] == winList[i]) { sameNum++; } } int No = 0; int WinNum = 0; if (sameNum == 5) { No = 1; WinNum = No1Win * buyItem.BuyNum; } else if (sameNum == 4) { No = 2; WinNum = No2Win * buyItem.BuyNum; } else if (sameNum == 3) { No = 3; WinNum = No3Win * buyItem.BuyNum; } string strLog = string.Format("猜数字id={6},name={7}, {0}期开奖{1}赢得{2},自己购买{3},{4}注,info={5}", new object[] { data.DataPeriods, data.strWinNum, WinNum, buyItem.strBuyValue, buyItem.BuyNum, data.WinInfo, buyItem.m_RoleID, buyItem.m_RoleName }); if (WinNum < 1) { buyItem.IsWin = false; BoCaiBuy2DBList.getInstance().AddData(buyItem, -1, true); return(true); } buyItem.IsWin = true; BoCaiBuy2DBList.getInstance().AddData(buyItem, -1, false); if (!"True".Equals(Global.Send2DB <BuyBoCai2SDB>(2082, buyItem, 0))) { LogManager.WriteLog(LogTypes.Warning, string.Format("[ljl_博彩]更新数据库标志失败,不发奖励,没关系 会自动处理旧数据{0}", strLog), null, true); return(false); } string strTitle = "猜数字"; string strIntro = string.Format("恭喜您在{0}期猜数字玩法中,中{2}等奖,获得欢乐代币{1},系统将邮件的形式将您获取的欢乐代币返还与你。", buyItem.DataPeriods, WinNum, No); List <GoodsData> goodsData = new List <GoodsData> { HuanLeDaiBiManager.GetInstance().GetHuanLeDaiBi(WinNum) }; return(this.SendMail(buyItem, goodsData, strTitle, strIntro, WinNum, true)); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true); } return(false); }
private void BuyCaiShuzi(GameClient client, int BuyNum, string strBuyVal, ref BuyBoCaiResult mgsData) { try { List <int> buyList; BoCaiHelper.String2ListInt(strBuyVal, out buyList); if (buyList.Count != 5 || BuyNum < 1) { mgsData.Info = 2; LogManager.WriteLog(LogTypes.Warning, string.Format("[ljl_博彩] BuyCaiShuzi 购买内容 {0}, BuyNum={1} ", strBuyVal, BuyNum), null, true); } else { for (int i = 0; i < buyList.Count; i++) { if (buyList[i] > 9 || buyList[i] < 0) { mgsData.Info = 2; return; } } if (!BoCaiCaiShuZi.GetInstance().IsCanBuy()) { mgsData.Info = 7; } else { ReturnValue <bool> msgData = TcpCall.KFBoCaiManager.IsCanBuy(2, strBuyVal, BuyNum, BoCaiCaiShuZi.GetInstance().GetDataPeriods()); if (!msgData.IsReturn) { mgsData.Info = 8; } else if (!msgData.Value) { mgsData.Info = 5; } else { int XiaoHaoDaiBi = BoCaiCaiShuZi.GetInstance().GetXiaoHaoDaiBi(); if (XiaoHaoDaiBi < 1) { mgsData.Info = 3; LogManager.WriteLog(LogTypes.Error, "[ljl_博彩]XiaoHaoDaiBi /GuDingLeiXing<1", null, true); } else { int useItemNum = BuyNum * XiaoHaoDaiBi; if (!HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, useItemNum)) { mgsData.Info = 4; } else { int allNum = BuyNum; BuyBoCai2SDB DbData = BoCaiCaiShuZi.GetInstance().BuyBocai(client, BuyNum, strBuyVal, ref allNum); if (null == DbData) { mgsData.Info = 8; BoCaiCaiShuZi.GetInstance().BuyBocai(client, -BuyNum, strBuyVal, ref allNum); LogManager.WriteLog(LogTypes.Error, "[ljl_博彩]BoCaiCaiShuZi.GetInstance().BuyBocai err", null, true); } else if (!HuanLeDaiBiManager.GetInstance().UseHuanledaibi(client, useItemNum)) { mgsData.Info = 4; } else { ReturnValue <bool> msgData2 = TcpCall.KFBoCaiManager.BuyBoCai(new KFBuyBocaiData { BocaiType = 2, RoleID = DbData.m_RoleID, RoleName = DbData.m_RoleName, ZoneID = DbData.ZoneID, ServerID = DbData.ServerId, BuyNum = DbData.BuyNum, BuyValue = DbData.strBuyValue }); if (!msgData2.IsReturn) { mgsData.Info = 8; } else if (!msgData2.Value) { GameManager.logDBCmdMgr.AddMessageLog(-1, "欢乐代币", "购买失败扣物品成功中心2次通信", client.ClientData.RoleName, client.ClientData.RoleName, "减少", useItemNum, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, ""); mgsData.Info = 5; } else { DbData.BuyNum = allNum; BoCaiBuy2DBList.getInstance().AddData(DbData, useItemNum, true); BoCaiCaiShuZi.GetInstance().CopyBuyList(out mgsData.ItemList, DbData.m_RoleID); } } } } } } } } catch (Exception ex) { mgsData.Info = 100; LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true); } }