Ejemplo n.º 1
0
        /// <summary>
        /// 记录ghost下注信息
        /// </summary>
        /// <param name="ghostBetInfo">ghost下注对象</param>
        /// <returns>下注是否成功</returns>
        public bool AddGhostBetInfo(GhostBet ghostBetInfo)
        {
            bool flag = false;
            MySqlParameter[] parms = new MySqlParameter[]{
                                                     new MySqlParameter("@ghostId",ghostBetInfo.Ghost.ghostId),
                                                     new MySqlParameter("@matchId", ghostBetInfo.MatchId),
                                                     new MySqlParameter("@leagueName", ghostBetInfo.LeagueName),
                                                     new MySqlParameter("@betCoverage", ghostBetInfo.BetCoverage),
                                                     new MySqlParameter("@betType", ghostBetInfo.BetType),
                                                     new MySqlParameter("@homeName",ghostBetInfo.HomeName),
                                                     new MySqlParameter("@awayName", ghostBetInfo.AwayName),
                                                     new MySqlParameter("@transTime", ghostBetInfo.betTime),
                                                     new MySqlParameter("@matchType", ghostBetInfo.MatchType),
                                                     new MySqlParameter("@seletecedMatch", ghostBetInfo.SelectedMatch),
                                                     new MySqlParameter("@sportType",ghostBetInfo.SportType),
                                                     new MySqlParameter("@HDP", ghostBetInfo.HDP),
                                                     new MySqlParameter("@odds", ghostBetInfo.Odds),
                                                     new MySqlParameter("@oddsType", ghostBetInfo.OddsType),
                                                     new MySqlParameter("@amount", ghostBetInfo.Amount),
                                                     new MySqlParameter("@status", ghostBetInfo.Status),
                                                     new MySqlParameter("@win", ghostBetInfo.WinValue),
                                                     new MySqlParameter("@isOutstanding", ghostBetInfo.IsOutstanding),
                                                     new MySqlParameter("@accountingDate", ghostBetInfo.AccountingDate)
            };

            try
            {
                if (DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "AddNewGhostBetInfo", parms) != 0)
                {
                    flag = true;
                }
            }
            catch
            {
                throw;
            }

            return flag;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据下注类型计算相关类型盈利
        /// </summary>
        /// <param name="type"></param>
        /// <param name="homeSoore"></param>
        /// <param name="awayScore"></param>
        /// <param name="playerBet"></param>
        private double InvokeComputeByBetType(string type, double homeScore, double awayScore, GhostBet playerBet)
        {
            double win = 0;
            switch (type)
            {
                case ConstUtil.HDP:
                    win = ComputeHDP(homeScore, awayScore, playerBet);
                    break;

                case ConstUtil.OU:
                    win = ComputeOverUnder(homeScore, awayScore, playerBet);
                    break;

                case ConstUtil.HOME_DRAW_AWAY:
                    win = Compute1X2(homeScore, awayScore, playerBet);
                    break;

                default:
                    win = ComputeOverUnder(homeScore, awayScore, playerBet);
                    break;
            }
            return win;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 计算玩家下注盈利
        /// </summary>
        /// <param name="matchResult">赛事结果</param>
        /// <param name="playerBets">玩家下注的赛事列表</param>
        private void ComputePlayerBetWin(MatchResult matchResult, GhostBet playerBet)
        {
            // 主队得分
                double homeScore = 0;
                // 客队得分
                double awayScore = 0;

                // 判定FT/HT下注
                if (ConstUtil.BET_FT == playerBet.BetCoverage)
                {
                    homeScore = matchResult.get_FTHomeScore();
                    awayScore = matchResult.get_FTAwayScore();
                }
                else
                {
                    homeScore = matchResult.get_HalfHomeScore();
                    awayScore = matchResult.get_HalfAwayScore();
                }

                // 玩家盈利
                double win = InvokeComputeByBetType(playerBet.BetType,homeScore,awayScore,playerBet);

                playerBet.WinValue = win;
                playerBet.AccountingDate = DateTime.Now.ToShortDateString();
                string result = "HT: " + matchResult.get_HalfHomeScore() + " - " + matchResult.get_HalfAwayScore() + "<br/>" +
                                "FT: " + matchResult.get_FTHomeScore() + " - " + matchResult.get_FTAwayScore();
                if (win > 0)
                {
                    playerBet.Status = "&nbsp;&nbsp;Won<br/>" + result;
                }
                else if (win == 0)
                {
                    playerBet.Status = "&nbsp;&nbsp;Draw<br/>" + result;
                }
                else
                {
                    playerBet.Status = "&nbsp;&nbsp;Lose<br/>" + result;
                }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 大小盘盈利计算方法
        /// </summary>
        /// <returns></returns>
        private double ComputeOverUnder(double homeScore, double awayScore, GhostBet playerBet)
        {
            double win = 0;
            double totalScore = homeScore + awayScore;
            bool condition = false;

            if (totalScore == playerBet.HDP)
            {
                return win;
            }

            // 判断玩家over/under
            if (ConstUtil.SELECT_OVER == playerBet.SelectedMatch) // 大盘
            {
                 condition = (totalScore > playerBet.HDP) ? true : false;
            }
            else
            {
                condition = (totalScore < playerBet.HDP) ? true : false;
            }

            win = ComputeBetWin(condition, playerBet);
            if (Math.Abs(totalScore - playerBet.HDP) == 0.25)
            {
                win /= 2;
            };
            return win;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 让球盈利计算方法
        /// </summary>
        /// <returns></returns>
        private double ComputeHDP(double homeScore, double awayScore, GhostBet playerBet)
        {
            double win = 0;
            double moreScore = 0;
            double result = 0;

            // 判定玩家选择的比赛
            if (playerBet.HomeName == playerBet.SelectedMatch) // 主场
            {
                moreScore = homeScore - awayScore;
            }
            else if(playerBet.AwayName == playerBet.SelectedMatch)// 客场赢
            {
                moreScore = awayScore - homeScore;
            }

            result = moreScore + playerBet.HDP;
            // 判定输赢
            if (result != 0)
            {
                win = ComputeBetWin(result, playerBet);
            }
            return win;
        }
Ejemplo n.º 6
0
        private double ComputeBetWin(bool condition, GhostBet playerBet)
        {
            double win = 0;
            // 判定输赢
            if (condition)
            {
                if (playerBet.Odds > 0)
                {
                    win = playerBet.Amount * playerBet.Odds;
                    if (playerBet.Odds > 1)
                    {
                        win -= playerBet.Amount;
                    }
                }
                else
                {
                    // odds为-时,盈利值为下注值
                    win = playerBet.Amount;
                }
            }
            else
            {
                if (playerBet.Odds > 0)
                {
                    win = -playerBet.Amount;
                }
                else
                {
                    win = playerBet.Amount * playerBet.Odds;
                }
            }

            return win;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 计算下注盈利值
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="playerBet"></param>
        /// <returns></returns>
        private double ComputeBetWin(double condition, GhostBet playerBet)
        {
            double win = 0;
            if (condition > 0)
            {
                if (playerBet.Odds > 0)
                {
                    win = playerBet.Amount * playerBet.Odds;
                    if (playerBet.Odds > 1)
                    {
                        win -= playerBet.Amount;
                    }
                }
                else
                {
                    // odds为-时,盈利值为下注值
                    win = playerBet.Amount;
                }
            }
            else if (condition < 0)
            {
                if (playerBet.Odds > 0)
                {
                    win = -playerBet.Amount;
                }
                else
                {
                    win = playerBet.Amount * playerBet.Odds;
                }
            }

            if (Math.Abs(condition) <= 0.25)
            {
                win /= 2;
            }

            return win;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 1X2盈利计算方法
        /// </summary>
        /// <returns></returns>
        private double Compute1X2(double homeScore, double awayScore, GhostBet playerBet)
        {
            double win = 0;
            bool condition = false;

            if (playerBet.SelectedMatch.Contains(ConstUtil.SELECT_1)) // home win
            {
                condition = (homeScore > awayScore) ? true : false;
            }
            else if (playerBet.SelectedMatch.ToLower().Contains(ConstUtil.SELECT_X.ToLower()))
            {
                condition = (homeScore == awayScore) ? true : false;
            }
            else if (playerBet.SelectedMatch.Contains(ConstUtil.SELECT_2))
            {
                condition = (homeScore < awayScore) ? true : false;
            }

            win = ComputeBetWin(condition, playerBet);
            return win;
        }
Ejemplo n.º 9
0
        public bool UpdateGhostBetWin(GhostBet playerBetInfo)
        {
            bool flag = false;
            MySqlParameter[] parms = new MySqlParameter[]{
                                                     new MySqlParameter("@_betId",playerBetInfo.Id),
                                                     new MySqlParameter("@_win",playerBetInfo.WinValue),
                                                     new MySqlParameter("@_accountingDate", playerBetInfo.AccountingDate),
                                                     new MySqlParameter("@_status", playerBetInfo.Status)
            };
            try
            {
                if (DBHelper.ExecuteNonQuery(connectStr, CommandType.StoredProcedure, "UpdateGhostBetInfoWin", parms) != 0)
                {
                    flag = true;
                }
            }
            catch
            {
                throw;
            }

            return flag;
        }
Ejemplo n.º 10
0
        public List<GhostBet> GetGhostBetsByMatchId(string homeName, string awayName, string matchDate)
        {
            List<GhostBet> ghostBets = null;

            try
            {
                matchDate = FormateMatchDate(matchDate);
                MySqlParameter[] parms = new MySqlParameter[]{
                                                     new MySqlParameter("@_homeName",homeName),
                                                     new MySqlParameter("@_awayName",awayName),
                                                     new MySqlParameter("@_matchDate",matchDate)

               };

                ghostBets = new List<GhostBet>();
                DataSet ds = DBHelper.ExecuteDataset(connectStr, CommandType.StoredProcedure, "getGhostBetInfoByMatchDate", parms);
                if (null != ds)
                {
                    DataTable dt = ds.Tables[0];
                    if (null != dt && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            GhostBet playerBet = new GhostBet();
                            playerBet.Id = System.Convert.ToInt32(dt.Rows[i]["betId"]);
                            playerBet.LeagueName = dt.Rows[i]["leagueName"].ToString();
                            playerBet.HomeName = dt.Rows[i]["homeName"].ToString();
                            playerBet.AwayName = dt.Rows[i]["awayName"].ToString();
                            playerBet.BetCoverage = dt.Rows[i]["betCoverage"].ToString();
                            playerBet.BetType = dt.Rows[i]["betType"].ToString();
                            playerBet.SelectedMatch = dt.Rows[i]["seletecedMatch"].ToString();
                            playerBet.Odds = System.Convert.ToDouble(dt.Rows[i]["odds"]);
                            playerBet.Amount = System.Convert.ToInt32(dt.Rows[i]["amount"]);
                            playerBet.HDP = System.Convert.ToDouble(dt.Rows[i]["HDP"]);
                            int ghostId = System.Convert.ToInt32(dt.Rows[i]["ghostId"]);
                            playerBet.Ghost = new Ghost(ghostId);
                            ghostBets.Add(playerBet);
                        }
                    }
                }

            }
            catch
            {
                throw;
            }

            return ghostBets;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 更新Ghost盈利
        /// </summary>
        /// <param name="playerBet"></param>
        /// <returns></returns>
        public static bool UpdateGhostBet(GhostBet ghostBet)
        {
            bool isSuccess = false;
            try
            {
                // 创建下注数据访问对象
                BetService betService = new BetService();
                isSuccess = betService.UpdateGhostBetWin(ghostBet);
            }
            catch (Exception e)
            {

                throw;
            }

            return isSuccess;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 保存Ghost下注信息
        /// </summary>
        /// <param name="matchBetNew">新的下注</param>
        /// <returns>保存是否成功</returns>
        public static bool SaveGhostBetInfo(MatchBetNew matchBetNew)
        {
            bool isSuccess = false;
            try
            {
                // 创建gosht下注对象
                GhostBet ghostBet = new GhostBet();
                Ghost ghost = GetGhostByGhostName(matchBetNew.get_MemberName(), matchBetNew.get_Company());
                ghostBet.Ghost = ghost;
                ghostBet.MatchId = matchBetNew.getMatchID();
                ghostBet.LeagueName = matchBetNew.get_League();
                ghostBet.SelectedMatch = matchBetNew.get_SelectedMatch();
                ghostBet.MatchType = matchBetNew.get_MatchType();
                ghostBet.HomeName = matchBetNew.get_HomeName();
                ghostBet.AwayName = matchBetNew.get_AwayName();
                ghostBet.betTime = matchBetNew.get_BetDate();
                ghostBet.BetCoverage = System.Convert.ToString(matchBetNew.get_BetCoverage());
                ghostBet.BetType = System.Convert.ToString(matchBetNew.get_BetType());
                ghostBet.Status = System.Convert.ToString(matchBetNew.get_RunningStatus()) + "<br/>" + matchBetNew.get_IPAddress();
                ghostBet.SportType = System.Convert.ToString(matchBetNew.get_SportType());
                if (string.IsNullOrEmpty(matchBetNew.HDPValue))
                {
                    matchBetNew.HDPValue = "0.0";
                }
                ghostBet.HDP = float.Parse(matchBetNew.HDPValue);
                ghostBet.Odds = (float)matchBetNew.get_Odds();
                ghostBet.Amount = int.Parse(matchBetNew.get_BetAmount());
                ghostBet.WinValue = 0;
                ghostBet.IsOutstanding = true;

                // 创建下注数据访问对象
                BetService ghostBetService = new BetService();
                isSuccess = ghostBetService.AddGhostBetInfo(ghostBet);
            }
            catch (Exception e)
            {

            }

            return isSuccess;
        }