Exemplo n.º 1
0
        private void genBetInfo(InfoBaccarat info)
        {
            BetInfo bet = info.getBetInfo(4); // 庄

            tdZhuangBet.InnerText = bet.bet_count.ToString();
            tdZhuangWin.InnerText = bet.award_count.ToString();

            bet = info.getBetInfo(1); // 闲
            tdXianBet.InnerText = bet.bet_count.ToString();
            tdXianWin.InnerText = bet.award_count.ToString();

            bet = info.getBetInfo(0); // 和
            tdHeBet.InnerText = bet.bet_count.ToString();
            tdHeWin.InnerText = bet.award_count.ToString();

            bet = info.getBetInfo(3); // 庄对
            tdZhuangDuiBet.InnerText = bet.bet_count.ToString();
            tdZhuangDuiWin.InnerText = bet.award_count.ToString();

            bet = info.getBetInfo(2); // 闲对
            tdXianDuiBet.InnerText = bet.bet_count.ToString();
            tdXianDuiWin.InnerText = bet.award_count.ToString();

            // 总和
            tdSumBet.InnerText = info.sumBet().ToString();
            tdSumWin.InnerText = info.sumAward().ToString();
        }
        public void MakeBet([FromBody] BetInfo betInfo)
        {
            var  rouletteIdParameter = Request.RouteValues["rouletteId"] as string;
            bool isValidRouletteId   = int.TryParse(rouletteIdParameter, out int rouletteId);

            if (isValidRouletteId && !string.IsNullOrEmpty(this.UserId))
            {
                this.RouletteFacade.MakeBet(betInfo: betInfo, rouletteId: rouletteId, userId: this.UserId);
                Response.StatusCode = (int)HttpStatusCode.Created;
            }
        }
Exemplo n.º 3
0
        void OnGameResult(GameEvent info)
        {
            Console.WriteLine($"UTC[{DateTime.UtcNow.ToDateTimeString()}] | Type={info.EventType} pars={info.EventParameters}");
            if (RunningBets != null && info.EventType == 1)
            {
                BetInfo binfo = (from b in RunningBets
                                 where info.EventParameters.Contains(b.BetId)
                                 select b).FirstOrDefault();
                if (binfo == null)
                {
                    throw new InvalidOperationException("bet not in cache");
                }

                binfo.Events.Add(info.EventParameters);
            }
        }
Exemplo n.º 4
0
        public bool CreateBetInfo(BetInfoCreate model)
        {
            var entity =
                new BetInfo()
            {
                OwnerId    = _userId,
                Odds       = model.Odds,
                AmountBet  = model.AmountBet,
                ToWin      = (model.Odds > 0) ? (model.AmountBet * model.Odds * 0.01m) : model.AmountBet / (model.Odds * -0.01m),
                CreatedUtc = DateTimeOffset.Now,
                BaseBetId  = model.BaseBetID,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.BetsInfo.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 5
0
        internal void PlaceBets(string userId)
        {
            RunningBets = new List <BetInfo>();

            // {"BoxId":"4E8F0395-7DB5-440F-B434-49217CF9DA89","MinPrice":0.9649558795483333,"MaxPrice":0.9650041204516666,"TimeToGraph":32.0,"TimeLength":6.999999999999992,"Coefficient":1.027643619053309,"BetState":3,"PreviousPrice":{"Instrument":"USDCHF","Bid":0.96499,"Ask":0.96503,"Date":"2017-06-08T04:03:17.673696Z","Time":1496894597673},"CurrentPrice":{"Instrument":"USDCHF","Bid":0.96496,"Ask":0.965,"Date":"2017-06-08T04:03:22.778847Z","Time":1496894602778},"TimeToGraphStamp":"2017-06-08T04:04:42.819815Z","WinStamp":"2017-06-08T04:04:42.819902Z","FinishedStamp":null,"Timestamp":"2017-06-08T04:04:11.208345Z","BetAmount":1.0,"IsWin":true}
            string boxstring = "{{" +
                               "\"Id\":\"{0}\"," +
                               "\"Coefficient\":{1}," +
                               "\"MinPrice\":0.9649558795483333," +
                               "\"MaxPrice\":0.9650041204516666," +
                               "\"TimeToGraph\":4," +
                               "\"TimeLength\":7" +
                               "}}";
            // place 20 bets concurrently
            double coef = 1.027643619053309;

            System.Globalization.CultureInfo CI = new System.Globalization.CultureInfo("en-us");

            for (int i = 0; i < BetCtr; i++)
            {
                Task.Run(() =>
                {
                    string GUID = Guid.NewGuid().ToString().ToLower();
                    BetInfo b   = new BetInfo(GUID);
                    try
                    {
                        string box = string.Format(CI, boxstring, GUID, coef);
                        coef      += 0.02;
                        Console.WriteLine("{0} | {1} | Placing Bet", DateTime.UtcNow.ToTimeString(), GUID);
                        IPlaceBetResult result = _service.PlaceBet(userId, "EURCHF", box, 1);
                        Console.WriteLine("{0} | {1} | Result = {2} ({3})", DateTime.UtcNow.ToTimeString(), GUID, result.BetTimeStamp.ToTimeString(), result.Status);
                        b.Result = result;
                        RunningBets.Add(b);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                });
                Thread.Sleep(10);
            }
        }
Exemplo n.º 6
0
        BetInfo bet(long OpenId, Accounts account, int code)
        {
            var betInfo = new BetInfo()
            {
                AccountId        = account.Id,
                LotteryOpenId    = OpenId,
                ResultType       = (int)Enum_ResultType.Wait,
                CreateTime       = EntitiesTool.GetDateTimeNow(),
                BetNum           = createNum(code),
                BetPlayTypeCode  = code,
                BetTimes         = 1,
                BetUnit          = code == 12 ? 3 : 1,
                BetMoney         = code == 12 ? 6 : 2,
                GetBackPercent   = account.AgentPercent11X5,
                IsGetBackPercent = ckbFandian.Checked,
                MaxBackMoney     = LotteryOpenTool_11x5.LpList()[code - 1].PrizeClass == null?LotteryOpenTool_11x5.LpList()[code - 1].PayBack : LotteryOpenTool_11x5.LpList()[code - 1].PrizeClass.Max(n => n.Value),//根据是否要返点产生中奖金额
            };

            return(betInfo);
        }
        public string SendBetInfo_ZH(string Guid, int LotteryId, bool isWinCancel, List <WS_ZHInfo> ZHInfo)
        {
            if (!isLogin(Guid))
            {
                return(null);
            }
            var l = EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId);

            if (l == null)
            {
                return("无该彩种信息");
            }
            try
            {
                var t     = new List <WS_BetInfo>();
                var accId = GetLoginId(Guid);
                var acc   = AccountDAL.GetAccount(accId);
                var list  = ZHInfo;
                #region 验证下注信息

                var minDec = new decimal(0.2);
                if (list.Exists(n => n.BetMoney < minDec))
                {
                    return("每种玩法的下注金额不能少于" + minDec + "元");
                }
                if (list.Sum(n => n.BetMoney) > acc.AccountBalance)
                {
                    return("余额不足");
                }
                var returnStr = LotteryOpenInfoDAL.IsExistsExpect(LotteryId, ZHInfo[0].Except, EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId).IsPrivate);
                if (returnStr != "")
                {
                    return(returnStr);
                }
                var wBetList = new List <BetInfo>();
                var addNumNo = "ZH" + DateTime.Now.Ticks + random.Next(1000, 10000);
                foreach (var item in list)
                {
                    var betU = Tools.Calculate(l.LotteryType, item.BetPlayTypeCode, item.BetNum, item.ChoicePosition, item.BetUnit);
                    if (betU != item.BetUnit)
                    {
                        return("下单注数验证失败");
                    }
                    if (betU <= 0)
                    {
                        return("下单注数应大于0");
                    }
                    decimal mm = 0;
                    switch (item.BetMoneyMode)
                    {
                    case "元":
                        mm = 2;
                        break;

                    case "角":
                        mm = new decimal(0.2);
                        break;

                    case "分":
                        mm = new decimal(0.02);
                        break;

                    case "厘":
                        mm = new decimal(0.002);
                        break;
                    }
                    if (betU * mm * item.BetTimes != item.BetMoney)
                    {
                        return("下单金额有误");
                    }

                    var betInfo = new BetInfo
                    {
                        AccountId        = acc.Id,
                        ResultType       = (int)Enum_ResultType.Wait,
                        BetNum           = item.BetNum,
                        BetPlayTypeCode  = item.BetPlayTypeCode,
                        BetTimes         = item.BetTimes,
                        BetUnit          = item.BetUnit,
                        BetMoney         = item.BetMoney,
                        ChoicePosition   = item.ChoicePosition,
                        IsGetBackPercent = item.IsGetBackPercent,
                        LotteryId        = LotteryId,
                        LotteryExcept    = item.Except,
                        IsWinCancel      = isWinCancel,//中奖后停止追号
                        //追号单号
                        AddNumNo = addNumNo,
                    };
                    switch (l.LotteryType)
                    {
                    case "ssc":
                        betInfo.GetBackPercent = acc.AgentPercentSSC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "11x5":
                        betInfo.GetBackPercent = acc.AgentPercent11X5;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "dpc":
                        betInfo.GetBackPercent = acc.AgentPercentDPC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;
                    }
                    wBetList.Add(betInfo);
                }
                #endregion
                if (wBetList.Count == 0)
                {
                    return("无有效下注信息");
                }
                var dt = EntitiesTool.GetDateTimeNow(new LotteryAPPEntities());
                wBetList.ForEach(n => n.CreateTime = dt);
                var account = AccountDAL.BalanceChange(acc.Id, wBetList);
                return(account.AccountBalance + "(元)");
            }
            catch (Exception ex)
            {
                return("错误的下注信息" + ex.Message);
            }
        }
        public string SendBetInfo(string Guid, int LotteryId, string Except, List <WS_BetInfo> BetInfo)
        {
            if (!isLogin(Guid))
            {
                return(null);
            }
            var l = EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId);

            if (l == null)
            {
                return("无该彩种信息");
            }
            //if (l.LotteryType == "ssc")
            //{
            //    t.Add(new WS_BetInfo
            //        {
            //            BetMoney = 2,
            //            BetMoneyMode = "元",
            //            BetNum = "0|0|0|0|0",
            //            BetPlayTypeCode = 2,
            //            BetTimes = 1,
            //            BetUnit = 1,
            //            ChoicePosition = "",
            //            IsGetBackPercent = true,
            //        });
            //    t.Add(new WS_BetInfo
            //    {
            //        BetMoney = 6,
            //        BetMoneyMode = "角",
            //        BetNum = "0 1 2|0 1 2",
            //        BetPlayTypeCode = 116,
            //        BetTimes = 1,
            //        BetUnit = 30,
            //        ChoicePosition = "0,1,2,3,4",
            //        IsGetBackPercent = true,
            //    });
            //}
            //if (l.LotteryType == "11x5")
            //{
            //    t.Add(new WS_BetInfo
            //    {
            //        BetMoney = 2,
            //        BetMoneyMode = "元",
            //        BetNum = "04|05|06",
            //        BetPlayTypeCode = 1,
            //        BetTimes = 1,
            //        BetUnit = 1,
            //        ChoicePosition = "",
            //        IsGetBackPercent = false,
            //    });
            //}
            //BetInfo = ObjectToJson(t);//示例[{"BetNum":"0","BetPlayTypeCode":1,"BetUnit":1,"BetTimes":1,"BetMoneyMode":"元","BetMoney":0.0,"ChoicePosition":"","IsGetBackPercent":true}]
            try
            {
                var t     = new List <WS_BetInfo>();
                var accId = GetLoginId(Guid);
                var acc   = AccountDAL.GetAccount(accId);
                //var acc = AccountDAL.GetAccount(2);//jix008
                var list = BetInfo; //JsonToObject(BetInfo, new List<WS_BetInfo>()) as List<WS_BetInfo>;
                #region 验证下注信息
                var returnStr = LotteryOpenInfoDAL.IsExistsExpect(LotteryId, Except, EntitiesTool.GetLotteryDic().Values.FirstOrDefault(n => n.Id == LotteryId).IsPrivate);
                if (returnStr != "")
                {
                    return(returnStr);
                }
                var minDec = new decimal(0.2);
                if (list.Exists(n => n.BetMoney < minDec))
                {
                    return("每种玩法的下注金额不能少于" + minDec + "元");
                }
                if (list.Sum(n => n.BetMoney) > acc.AccountBalance)
                {
                    return("余额不足");
                }
                var wBetList = new List <BetInfo>();
                foreach (var item in list)
                {
                    var betU = Tools.Calculate(l.LotteryType, item.BetPlayTypeCode, item.BetNum, item.ChoicePosition, item.BetUnit);
                    if (betU != item.BetUnit)
                    {
                        return("下单注数验证失败");
                    }
                    if (betU <= 0)
                    {
                        return("下单注数应大于0");
                    }
                    decimal mm = 0;
                    switch (item.BetMoneyMode)
                    {
                    case "元":
                        mm = 2;
                        break;

                    case "角":
                        mm = new decimal(0.2);
                        break;

                    case "分":
                        mm = new decimal(0.02);
                        break;

                    case "厘":
                        mm = new decimal(0.002);
                        break;
                    }
                    if (betU * mm * item.BetTimes != item.BetMoney)
                    {
                        return("下单金额有误");
                    }
                    var betInfo = new BetInfo
                    {
                        AccountId        = acc.Id,
                        ResultType       = (int)Enum_ResultType.Wait,
                        BetNum           = item.BetNum,
                        BetPlayTypeCode  = item.BetPlayTypeCode,
                        BetTimes         = item.BetTimes,
                        BetUnit          = item.BetUnit,
                        BetMoney         = item.BetMoney,
                        ChoicePosition   = item.ChoicePosition,
                        IsGetBackPercent = item.IsGetBackPercent,
                        LotteryId        = LotteryId,
                        LotteryExcept    = Except,
                    };
                    switch (l.LotteryType)
                    {
                    case "ssc":
                        betInfo.GetBackPercent = acc.AgentPercentSSC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryInfo_SSC.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "11x5":
                        betInfo.GetBackPercent = acc.AgentPercent11X5;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_11x5.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;

                    case "dpc":
                        betInfo.GetBackPercent = acc.AgentPercentDPC;
                        betInfo.MaxBackMoney   = (betInfo.IsGetBackPercent ? LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack : AgentCalculateTool.GetAgentBackMoney_SSC(LotteryOpenTool_3D.LpList()[item.BetPlayTypeCode - 1].PayBack, betInfo.GetBackPercent)) * (betInfo.BetMoney / betInfo.BetUnit / 2);
                        break;
                    }
                    wBetList.Add(betInfo);
                }
                #endregion
                if (wBetList.Count == 0)
                {
                    return("无有效下注信息");
                }
                var dt = EntitiesTool.GetDateTimeNow(new LotteryAPPEntities());
                wBetList.ForEach(n => n.CreateTime = dt);
                var account = AccountDAL.BalanceChange(acc.Id, wBetList);
                return(account.AccountBalance + "(元)");
            }
            catch (Exception ex)
            {
                return("错误的下注信息" + ex.Message);
            }
        }
Exemplo n.º 9
0
 protected void AppendLast10(int startCredit, int endCredit, int bet, int win, int luckyWin, int ball_value)
 {
     BetRecord br = new BetRecord();
     br.startCredit = startCredit;
     br.endCredit = endCredit;
     br.bet = bet;
     br.win = win;
     br.luckyWin = luckyWin;
     br.ballValue = ball_value;
     br.bets = new List<BetInfo>();
     foreach (KeyValuePair<string, int> item in betFields)
     {
         BetInfo info = new BetInfo();
         info.betField = item.Key;
         info.betValue = item.Value;
         br.bets.Add(info);
     }
     GameData.GetInstance().betRecords.Add(br);
     while (GameData.GetInstance().betRecords.Count > 10)
     {
         GameData.GetInstance().betRecords.RemoveAt(0);
     }
     GameData.GetInstance().SaveBetRecords();
 }
Exemplo n.º 10
0
    // 最近10场押分记录
    private void ReadBetRecords()
    {
        if (betRecords.Count > 0)
            betRecords.Clear();

        for (int idx = 0; idx < 10; ++idx)
        {
            int startCredit = PlayerPrefs.GetInt("br_startCredit" + idx, -1);
            if (startCredit < 0)
                break;
            BetRecord br = new BetRecord();
            br.startCredit = startCredit;
            br.endCredit = PlayerPrefs.GetInt("br_endCredit" + idx);
            br.bet = PlayerPrefs.GetInt("br_bet" + idx);
            br.win = PlayerPrefs.GetInt("br_win" + idx);
            br.luckyWin = PlayerPrefs.GetInt("br_luckyWin" + idx);
            br.ballValue = PlayerPrefs.GetInt("br_ballValue" + idx);
            br.bets = new List<BetInfo>();
            int numOfbets = PlayerPrefs.GetInt("br_bets" + idx + "_num");
            for (int i = 0; i < numOfbets; ++i)
            {
                string str = PlayerPrefs.GetString("br_bets" + idx + "_field" + i, string.Empty);
                if (string.IsNullOrEmpty(str))
                    break;
                BetInfo betInfo = new BetInfo();
                betInfo.betField = str;
                betInfo.betValue = PlayerPrefs.GetInt("br_bets" + idx + "_value" + i);
                br.bets.Add(betInfo);
            }
            betRecords.Add(br);
        }
    }
Exemplo n.º 11
0
        /// <summary>
        /// 刷新注数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            LotteryInptuNoControl tb = null;

            foreach (var item in ChoiceTabPage.Controls)
            {
                if (item.GetType() == typeof(LotteryInptuNoControl))
                {
                    tb = (LotteryInptuNoControl)item;
                    break;
                }
            }
            if (tb != null)
            {
                var betStr = tb.GetBetNo();
                var bet    = betStr == "" ? 0 : betStr.Split('|').Length;
                lblTotal.Tag  = bet + " " + ChoiceTabPage.Parent.Tag + ChoiceTabPage.Text;
                lblTotal.Text = BetCalculateTool.GetTotalMoney(bet, (int)nudBS.Value, cboDW.SelectedIndex);
                MessageBox.Show("自动剔除不符合规范号码");
            }
            else
            {
                calculate();
            }
            #region  注
            if (lblTotal.Tag == null)
            {
                return;
            }
            var sp = lblTotal.Tag.ToString().Split(' ');
            if (sp[0] == "0")
            {
                return;
            }
            var     lp = LotteryOpenTool_11x5.LpList().FirstOrDefault(n => n.LotteryPlayName == sp[1]);
            BetInfo b  = new BetInfo
            {
                BetPlayTypeCode = lp.BetPlayTypeCode,
                BetTimes        = Convert.ToInt32(nudBS.Value),
                BetUnit         = Convert.ToInt32(sp[0]),
                BetMoney        = Convert.ToDecimal(lblTotal.Text.Substring(lblTotal.Text.IndexOf("¥") + 1, lblTotal.Text.IndexOf("元") - lblTotal.Text.IndexOf("¥") - 1)),
                AccountId       = account.Id,
                CreateTime      = EntitiesTool.GetDateTimeNow(),
                //LotteryOpenId = nextOpen.Id,
                ResultType       = (int)Enum_ResultType.Wait,
                GetBackPercent   = account.AgentPercent11X5,
                IsGetBackPercent = cboFandian.SelectedIndex != 0,
            };
            if (sp[1].Contains("趣味定_"))
            {
                StringBuilder sb = new StringBuilder();
                foreach (var item in txtBetNo.Text.Split(' '))
                {
                    sb.Append(' ' + item[0].ToString());
                }
                b.BetNum = sb.ToString().Trim();
            }
            else
            {
                b.BetNum = txtBetNo.Text;
            }

            b.MaxBackMoney = (b.IsGetBackPercent?AgentCalculateTool.GetAgentBackMoney_11x5(lp.PayBack, account.AgentPercent11X5):lp.PayBack) * (b.BetMoney / b.BetUnit / 2); //根据是否要返点产生中奖金额
            if (string.IsNullOrEmpty(b.BetNum))
            {
                return;
            }
            wBetList.Add(b);
            #endregion
            var row = dgvwBet.Rows[dgvwBet.Rows.Add()];
            row.Cells[0].Value = sp[1];
            row.Cells[1].Value = b.BetNum;
            row.Cells[2].Value = b.BetUnit;
            row.Cells[3].Value = b.BetTimes;
            row.Cells[4].Value = b.BetMoney;
            row.Cells[5].Value = "X";
        }