Example #1
0
        /// <summary>
        /// 获取中奖概率
        /// </summary>
        /// <param name="id"></param>
        /// <param name="awardId"></param>
        /// <returns></returns>
        public double GetCount(long id, long awardId)
        {
            var   item        = WeiActivityApplication.GetActivityModel(id);
            var   proportions = 0.0;//抽取完成的概率总和
            float sum         = 0;
            List <WeiActivityAwardModel> listModel = item.awards;
            var model = listModel.Where(p => p.Id == awardId).ToList();

            foreach (var t in item.awards)
            {
                bool falg = WeiActivityApplication.GetWinNumberByAward(id, t.Id); //查询当前奖等是否有剩余数量
                if (!falg)                                                        //无剩余数量
                {
                    proportions += t.proportion;
                    continue;
                }
                if (t.awardLevel < model[0].awardLevel)
                {
                    sum += t.proportion;
                }
            }

            var isOver = WeiActivityApplication.GetWinNumberByAward(id, awardId);//是否还有奖品

            if (!isOver)
            {
                return(0);
            }
            else
            {
                return(proportions + sum + model[0].proportion);
            }
        }