// 投输赢 // GET: /Casino/SingleChoice/id public ActionResult SingleChoice(Guid id) { var model = new SingleChoiceDto(); var gambler = _repo.Query <Gambler>(x => x.UserID == AcnID).FirstOrDefault(); model.MyCash = gambler?.Cash ?? 0f; // 判断玩家是否有单注限制 var leagueGuid = _repo.Single <Match>(id)?.LeagueGuid; if (leagueGuid.HasValue) { model.BetLimit = GamblerDW.GetGamblerBetLimit(AcnID, leagueGuid.Value); } else { model.BetLimit = model.MyCash; } model.Match = MatchDto.Single(id); model.MatchGuid = id; return(View(model)); }
public void Execute(object state) { var logInfo = new LogInfo { MethodInstance = MethodBase.GetCurrentMethod(), ThreadInstance = Thread.CurrentThread }; try { _log.Info("Scheduler Start: (AutoUpdateMonthlyRank)", logInfo); IRepository repo = new Repository(); var iDay = DateTime.Today; var firstBetDate = repo.Single <Bet>(1).BetTime; while (!(iDay.Year <= firstBetDate.Year && iDay.Month < firstBetDate.Month)) { var winner = GamblerDW.GetTopGamblerMonthly(iDay, RankType.Winner); var loser = GamblerDW.GetTopGamblerMonthly(iDay, RankType.Loser); var rper = GamblerDW.GetTopGamblerMonthly(iDay, RankType.RP); if (winner != null && loser != null) { var day = iDay; var rank = repo.Query <Rank>(x => x.RankYear == day.Year && x.RankMonth == day.Month).FirstOrDefault(); if (rank != null) { //update rank.Init(winner, loser, rper); repo.Update(rank); } else { //insert var instance = new Rank { RankYear = day.Year, RankMonth = day.Month }; instance.Init(winner, loser, rper); repo.Insert(instance); } } iDay = iDay.AddMonths(-1); } _log.Info("Scheduler End: (AutoUpdateMonthlyRank)", logInfo); } catch (Exception ex) { _log.Warn(ex, logInfo); } }
public ActionResult Contest() { var model = new ContestDto(); var league = League.Cache.Load(ConfigGlobal_AcnCasino.DefaultLeagueID); if (league != null) { var list = GamblerDW.All(league.ID); if (list != null && list.Count > 0) { // 进入最终名次排行榜的标准(评选要求)同时满足以下3个条件: //1、赛季中必须投注博采币次数达到5个单场及以上(反复多次投注同一场比赛只能算是1次); //2、赛季中参与累计投注量达到5,000菠菜币及以上; //3、赛季中并且获得RP+3及以上,即猜对本赛季3场以上的比赛比分。 if (!ConfigGlobal_AcnCasino.ContestLimitIgnore) { list = list.FindAll(g => g.MatchBet >= ConfigGlobal_AcnCasino.ContestCondition[0] && g.TotalBet >= ConfigGlobal_AcnCasino.ContestCondition[1] && g.RPBonus >= ConfigGlobal_AcnCasino.ContestCondition[2]); } var tbs = ConfigGlobal_AcnCasino.TotalBetStandard; var listUpper = list.FindAll(g => g.TotalBet >= tbs); var listLower = list.FindAll(g => g.TotalBet < tbs); if (listUpper.Count > 0) { listUpper = GamblerDW.SortRank(listUpper); } if (listLower.Count > 0) { listLower = GamblerDW.SortRank(listLower); } model.UpperGamblers = listUpper.Take(6); model.LowerGamblers = listLower.Take(6); } model.RankCondition = ConfigGlobal_AcnCasino.ContestCondition; model.ContestLeague = league; } return(View(model)); }
public void AutoUpdateMonthlyRank_Test() { try { IRepository repo = new Repository(); var iDay = DateTime.Today; var firstBetDate = repo.Single <Bet>(1).BetTime; while (!(iDay.Year <= firstBetDate.Year && iDay.Month < firstBetDate.Month)) { var winner = GamblerDW.GetTopGamblerMonthly(iDay, RankType.Winner); var loser = GamblerDW.GetTopGamblerMonthly(iDay, RankType.Loser); var rper = GamblerDW.GetTopGamblerMonthly(iDay, RankType.RP); if (winner != null && loser != null) { var day = iDay; var rank = repo.Query <Rank>(x => x.RankYear == day.Year && x.RankMonth == day.Month).FirstOrDefault(); if (rank != null) { //update rank.Init(winner, loser, rper); repo.Update(rank); } else { //insert var instance = new Rank { RankYear = day.Year, RankMonth = day.Month }; instance.Init(winner, loser, rper); repo.Insert(instance); } } iDay = iDay.AddMonths(-1); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
public ActionResult SingleChoice(SingleChoiceDto model) { var id = model.MatchGuid; var leagueGuid = _repo.Single <Match>(id)?.LeagueGuid; if (ModelState.IsValid) { try { //Gambler in Lower could not bet above the SingleBetLimit of DefaultLeague (Contest) if (leagueGuid != null && leagueGuid.Equals(ConfigGlobal_AcnCasino.DefaultLeagueID)) { var g = GamblerDW.Single(AcnID, leagueGuid.Value); // 如果没有投过注,或投注量小于标准,判断是否在下半赛区 if (g == null || g.TotalBet < ConfigGlobal_AcnCasino.TotalBetStandard) { var singleBetLimit = ConfigGlobal_AcnCasino.SingleBetLimit; double?alreadyMatchBet = null; // 获取单场比赛当前用户投注总额 var item = _repo.Query <CasinoItem>(x => x.MatchGuid == id && x.ItemType == CasinoType.SingleChoice).FirstOrDefault(); var myBets = _repo.Query <Bet>(x => x.CasinoItemGuid == item.ID && x.UserID == AcnID); if (myBets.Count > 0) { alreadyMatchBet = myBets.Sum(x => x.BetAmount); } // 已投注量+本次投注量不可超过单场比赛限额 if (singleBetLimit > 0 && (alreadyMatchBet ?? 0) + model.BetAmount > singleBetLimit) { throw new Exception($"下半赛区每个玩家单场投注总量不能超过{singleBetLimit.ToString("N0")}博彩币"); } } } //if (model.BetAmount > ConfigGlobal_AcnCasino.SingleBetLimit) //{ throw new Exception($"移动版单场不能超过{ConfigGlobal_AcnCasino.SingleBetLimit.ToString("f0")}博彩币"); } var bet = new Bet { UserID = AcnID, UserName = User.Identity.Name, BetAmount = model.BetAmount }; bet.Place(id, model.SelectedOption); //投注成功 TempData["DataUrl"] = $"data-url=/Casino/GameBet/{id}"; return(RedirectToAction("GameBet", new { id })); } catch (Exception ex) { ModelState.AddModelError("Warn", ex.Message); } } else { ModelState.AddModelError("Warn", "请正确填写投注单"); } var gambler = _repo.Query <Gambler>(x => x.UserID == AcnID).FirstOrDefault(); model.MyCash = gambler?.Cash ?? 0f; if (leagueGuid.HasValue) { model.BetLimit = GamblerDW.GetGamblerBetLimit(AcnID, leagueGuid.Value); } else { model.BetLimit = model.MyCash; } model.Match = MatchDto.Single(model.MatchGuid); return(View(model)); }