/// <summary> /// 实例化一个新的开奖记录 /// </summary> /// <param name="model">开奖记录的数据模型</param> public LotteryExport(Lottery model) { this.Issue = model.Issue; this.TicketId = model.Ticket.Id; this.Ticket = model.Ticket.Name; this.values = string.Join(",", model.Seats.ConvertAll(x => x.Value)); }
/// <summary> /// 获取反奖接口为“任N定位胆”的投注的中奖注数 /// </summary> /// <param name="lottery">开奖记录</param> /// <returns>返回中奖注数</returns> int PositioningBile(Lottery lottery) { int result = lottery.Seats.Count(x => this.Seats.Any(s => s.Name == x.Name && s.ValueList.Contains(x.Value))); return result; }
/// <summary> /// 获取反奖接口为“任N不定位”的投注的中奖注数 /// </summary> /// <param name="lottery">开奖记录</param> /// <returns>返回中奖注数</returns> int DoesNotLocate(Lottery lottery) { List<string> betValues = this.Seats.First().ValueList; if (lottery.Seats.Any(x => betValues.Contains(x.Value))) { return 1; } return 0; }
/// <summary> /// 获取反奖接口为“任N组选”的投注的中奖注数 /// </summary> /// <param name="lottery">开奖记录</param> /// <returns>返回中奖注数</returns> int GroupSelection(Lottery lottery) { List<string> betValues = this.Seats.First().ValueList; string[] seatNames = this.HowToPlay.ValidSeats.Split(new char[] { ',' }); List<string> valuesOfWin = lottery.Seats.Where(x => seatNames.Contains(x.Name) && betValues.Contains(x.Value)) .ToList().ConvertAll(x => x.Value); if (valuesOfWin.Count < this.HowToPlay.CountOfSeatsForWin) { return 0; } List<string> differentValuesOfWin = valuesOfWin.Distinct().ToList(); if (differentValuesOfWin.Count >= this.HowToPlay.LowerCountOfDifferentSeatsForWin && differentValuesOfWin.Count <= this.HowToPlay.CapsCountOfDifferentSeatsForWin) { return 1; } return 0; }
/// <summary> /// 获取反奖接口为“任N直选”的投注的中奖注数 /// </summary> /// <param name="lottery">开奖记录</param> /// <returns>返回中奖注数</returns> int DirectElection(Lottery lottery) { if (this.HowToPlay.Interface != LotteryInterface.任N直选) { throw new Exception("当前投注的玩法的反奖接口不是【任N直选】,请检查操作"); } int result = 0; if (this.HowToPlay.IsDuplex) //复式投注 { if (this.Seats.All(x => lottery.Seats.Any(s => s.Name == x.Name && x.ValueList.Any(v => v == s.Value)))) { result = 1; } } else //单式投注 { string[] seatNames = this.HowToPlay.ValidSeats.Split(new char[] { ',' }); List<string> betValues = this.Seats.First().ValueList; for (int i = 0; i < betValues.Count; i++) { char[] tBettingValues = betValues[i].ToArray(); Dictionary<string, string> tSeats = new Dictionary<string, string>(); for (int j = 0; j < tBettingValues.Count(); j++) { if (this.HowToPlay.Tag.Ticket.CountOfNUm > 10) { string _str = tBettingValues[2 * j].ToString() + tBettingValues[2 * j + 1].ToString(); tSeats.Add(seatNames[j], _str); } else { tSeats.Add(seatNames[j], tBettingValues[j].ToString()); } } if (tSeats.All(t => t.Value == lottery.Seats.First(s => s.Name == t.Key).Value)) { result = 1; break; } } } return result; }
/// <summary> /// 获取中奖注数 /// </summary> /// <param name="lottery">开奖记录</param> /// <returns>返回中奖注数</returns> public int GetNotesOfWin(Lottery lottery) { int result = 0; if (this.HowToPlay.Tag.Ticket.RealName != lottery.Ticket.RealName) { throw new Exception("所传入的开奖记录跟当前投注所对应的彩票不一致"); } switch (this.HowToPlay.Interface) { case LotteryInterface.任N直选: result = DirectElection(lottery); break; case LotteryInterface.任N组选: result = GroupSelection(lottery); break; case LotteryInterface.任N不定位: result = DoesNotLocate(lottery); break; case LotteryInterface.任N定位胆: result = PositioningBile(lottery); break; } return result; }
/// <summary> /// 获取中奖注数 /// </summary> /// <param name="lottery">开奖记录</param> /// <returns>返回中奖注数</returns> public int GetNotesOfWin(Lottery lottery) { if (this.Issue != lottery.Issue) { throw new Exception("所传入的开奖记录跟当前投注所声明的期号不一致"); } return this.Chasing.GetNotesOfWin(lottery); }