开奖结果为5位数:
万、千、百、十、个
五星购买的时候必须至少每个位选择一个数进行组合,若每个位数对上计算中奖;那么我们必须先定义好复式的格式,如下:
万千百十个
开奖结果:1,2,3,4,5
对数据进行组合:
BetDetail的BetContent属性为投注内容,
BetContent="1,2,3,4,5";
1 /// <summary> 2 /// 根据投注内容得到所有的组合情况 3 /// </summary> 4 /// <returns></returns> 5 private List<string> GetAllBets(BasicModel.LotteryBasic.BetDetail item) 6 { 7 if (null == item || string.IsNullOrEmpty(item.BetContent)) 8 return null; 9 else 10 { 11 var bets = item.BetContent.Split(','); 12 if (bets.Count() != 5) 13 { 14 return null; 15 } 16 else 17 { 18 var list = new List<string>(); 19 var wan = bets[0].Select(m => Convert.ToInt32(m.ToString())).ToList(); 20 var qian = bets[1].Select(m => Convert.ToInt32(m.ToString())).ToList(); 21 var bai = bets[2].Select(m => Convert.ToInt32(m.ToString())).ToList(); 22 var shi = bets[3].Select(m => Convert.ToInt32(m.ToString())).ToList(); 23 var ge = bets[4].Select(m => Convert.ToInt32(m.ToString())).ToList(); 24 list = (from w in wan 25 from q in qian 26 from b in bai 27 from s in shi 28 from g in ge 29 select string.Format("{0}{1}{2}{3}{4}", w, q, b, s, g)).ToList(); 30 return list; 31 } 32 } 33 }
执行GetAllBets获取组合的结果,然后对结果进行比对,若与开奖结果的每个位置比对成功,那么久算中奖:
1 var list = GetAllBets(item); 2 var result = list.Find(m => m == openResult.Replace(",", "")); 3 if (result != null) 4 { 5 item.IsMatch = true; 6 decimal stepAmt = 0; 7 item.WinMoney = TotalWinMoney(item, GetBaseAmt(item, ref stepAmt), stepAmt, 1); 8 }
若有不明白的请私信我或加群:542620409一起讨论