Пример #1
0
 public ActionResult Add(LotteryCompany model)
 {
     if (!ModelState.IsValid)
     {
         if (Request.IsAjaxRequest())
         {
             JsonResultModel result = new JsonResultModel
             {
                 IsSuccess = false,
                 Message = ModelState.ToErrorString()
             };
             return Json(result);
         }
         else
         {
             return View(model);
         }
     }
     CompanyManager.Add(model, CurrentUser);
     ActionLogger.Log(CurrentUser, CurrentUser, LogResources.AddLotteryCompany, LogResources.GetAddLotteryCompany(model.Name, model.CompanyId));
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Message = Resources.Resource.Success,
             Model = model
         };
         return Json(result);
     }
     else
         return RedirectToAction("Index");
 }
 /// <summary>
 /// 根据公司和日期获取开奖结果.
 /// </summary>
 /// <param name="company">The company.</param>
 /// <param name="date">The date.</param>
 /// <returns></returns>
 public IEnumerable<LotteryRecord> ListRecord(LotteryCompany company, DateTime date)
 {
     string sql = string.Format(@"SELECT LR.* FROM {0} LR
     JOIN {1} LP ON LP.{2}=LR.{3}
     WHERE CONVERT(char(10),LP.{4},120)=CONVERT(char(10),@{4},120) AND LP.{5}=@{5}", LotteryRecord.TABLENAME,
     LotteryPeriod.TABLENAME, LotteryPeriod.PERIODID, LotteryRecord.PERIODID, LotteryPeriod.CREATEDATE, LotteryPeriod.COMPANYID);
     return base.ExecuteList<LotteryRecord>(sql, new SqlParameter(LotteryPeriod.CREATEDATE, date),
         new SqlParameter(LotteryPeriod.COMPANYID, company.CompanyId));
 }
Пример #3
0
 public void Update(LotteryCompany company)
 {
     string sql = string.Format(@"Update {0} SET {1}=@{1},{2}=@{2},{3}=@{3},{4}=@{4},{5}=@{5},{6}=@{6} WHERE {7}=@{7}",
         LotteryCompany.TABLENAME, LotteryCompany.NAME, LotteryCompany.ABBREVIATION, LotteryCompany.TYPEID,
         LotteryCompany.REGION, LotteryCompany.OPENTIME, LotteryCompany.CLOSETIME, LotteryCompany.COMPANYID);
     base.ExecuteNonQuery(sql, new SqlParameter(LotteryCompany.NAME, company.Name),
     new SqlParameter(LotteryCompany.ABBREVIATION, company.Abbreviation),
     new SqlParameter(LotteryCompany.TYPEID, (int)company.CompanyType),
     new SqlParameter(LotteryCompany.REGION, (int)company.Region),
     new SqlParameter(LotteryCompany.OPENTIME, company.OpenTime),
     new SqlParameter(LotteryCompany.CLOSETIME, company.CloseTime),
     new SqlParameter(LotteryCompany.COMPANYID, company.CompanyId));
 }
Пример #4
0
 public void Insert(LotteryCompany company)
 {
     string sql = string.Format(@"Insert into {0} ({1},{2},{3},{4},{5},{6})values(@{1},@{2},@{3},@{4},@{5},@{6})  SELECT SCOPE_IDENTITY()",
         LotteryCompany.TABLENAME, LotteryCompany.NAME, LotteryCompany.ABBREVIATION, LotteryCompany.TYPEID,
         LotteryCompany.REGION, LotteryCompany.OPENTIME, LotteryCompany.CLOSETIME);
     object id = base.ExecuteScalar(sql, new SqlParameter(LotteryCompany.NAME, company.Name),
         new SqlParameter(LotteryCompany.ABBREVIATION, company.Abbreviation),
         new SqlParameter(LotteryCompany.TYPEID, (int)company.CompanyType),
         new SqlParameter(LotteryCompany.REGION, (int)company.Region),
         new SqlParameter(LotteryCompany.OPENTIME, company.OpenTime),
         new SqlParameter(LotteryCompany.CLOSETIME, company.CloseTime));
     company.CompanyId = Convert.ToInt32(id);
 }
Пример #5
0
 public ActionResult Edit(int? Id, LotteryCompany model)
 {
     if (!Id.HasValue) PageNotFound();
     if (!ModelState.IsValid)
     {
         if (Request.IsAjaxRequest())
         {
             JsonResultModel result = new JsonResultModel
             {
                 IsSuccess = false,
                 Message = ModelState.ToErrorString()
             };
             return Json(result);
         }
         else
             return View(model);
     }
     var company = CompanyManager.GetCompany(Id.Value);
     UpdateModel(company);
     CompanyManager.Update(company, CurrentUser);
     ActionLogger.Log(CurrentUser, CurrentUser, LogResources.UpdateLotteryCompany, LogResources.GetUpdateLotteryCompany(company.Name, company.CompanyId));
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Message = Resources.Resource.Success,
             Model = company
         };
         return Json(result);
     }
     else
         return RedirectToAction("Index");
 }
Пример #6
0
 /// <summary>
 /// 获取今日指定号码,玩法,公司的跌水
 /// </summary>
 /// <param name="num">The num.</param>
 /// <param name="gameplaywayId">The gameplayway id.</param>
 /// <param name="company">The company.</param>
 /// <returns></returns>
 public IEnumerable<DropWater> GetTodayNumsDropWater(string num, int gameplaywayId, LotteryCompany company)
 {
     return DaDropWater.ListNumsDropWater(num, gameplaywayId, company, DateTime.Today);
 }
Пример #7
0
 public LotteryResult(LotteryCompany company, IEnumerable<LotteryRecord> records, DateTime periodDate)
 {
     this.Company = company;
     this.Records = records;
     this.PeriodDate = periodDate;
 }
Пример #8
0
 /// <summary>
 /// 列出指定号码的跌水设置.
 /// </summary>
 /// <param name="num">号码.</param>
 /// <param name="gameplaywayId">玩法.</param>
 /// <param name="company">公司.</param>
 /// <param name="date">日期.</param>
 /// <returns></returns>
 public IEnumerable<DropWater> ListNumsDropWater(string num, int gameplaywayId, LotteryCompany company, DateTime date)
 {
     string sql = string.Format(@"select * from {0} dw
     left join {1} dc on dc.{2}=dw.{3}
     where ((dc.{4}=@{4} and dw.{7}=@{7} and CONVERT(char(10),dw.{5},120)=CONVERT(char(10),@{5},120))
     or (dw.{6}=@{6} and dw.{9}=@{9})) and dw.{8}=@{8}", DropWater.TABLENAME, DropInCompany.TABLENAME, DropInCompany.DROPID, DropWater.DROPID,
            DropInCompany.COMPANYID, DropWater.CREATETIME, DropWater.DROPTYPE, DropWater.NUM, DropWater.GAMEPLAYWAYID, DropWater.COMPANYTYPE);
     return base.ExecuteList<DropWater>(sql, new SqlParameter(DropInCompany.COMPANYID, company.CompanyId),
         new SqlParameter(DropWater.CREATETIME, date),
         new SqlParameter(DropWater.DROPTYPE, DropType.Auto),
         new SqlParameter(DropWater.NUM, num),
         new SqlParameter(DropWater.GAMEPLAYWAYID, gameplaywayId),
         new SqlParameter(DropWater.COMPANYTYPE, (int)company.CompanyType));
 }
Пример #9
0
 /// <summary>
 /// 创建下注订单.
 /// </summary>
 /// <param name="num">The num.</param>
 /// <param name="numQuantity">The num quantity.</param>
 /// <param name="commModel">The comm model.</param>
 /// <param name="gamePlayWay">The game play way.</param>
 /// <param name="company">The company.</param>
 /// <param name="wager">The wager.</param>
 /// <returns></returns>
 private BetOrder BuildBetOrder(string num, int numQuantity, Pair<CommissionGroup, IEnumerable<ConcreteCommission>> memberComm, GamePlayWay gamePlayWay,
     LotteryCompany company, decimal wager, User user, bool isCon = false)
 {
     var commValue = memberComm.Value.Find(it => it.CompanyType == company.CompanyType && it.GameType == gamePlayWay.GameType);
     double percentComm = isCon ? commValue.Commission - LotterySystem.Current.AutoElectionCodeCommission : commValue.Commission;
     decimal comm = (decimal)MathHelper.PercentageToDecimal(percentComm, 4);
     decimal turnOver = wager * numQuantity;
     decimal commission = comm * turnOver;
     BetOrder order = new BetOrder
     {
         Num = num,
         GamePlayWayId = gamePlayWay.Id,
         CompanyId = company.CompanyId,
         Amount = wager,
         Odds = commValue.Odds,
         Commission = commission,
         Turnover = turnOver,
         Net = 100 - percentComm,
         NetAmount = turnOver - commission,
         Status = BetStatus.Valid,
         UserId = user.UserId,
         AncestorCommission = BuildAncestorCommission(turnOver, user, gamePlayWay.GameType, company.CompanyType, memberComm.Key.Specie, isCon)
     };
     if (isCon)
     {
         order.DropWater += LotterySystem.Current.AutoElectionCodeCommission;
     }
     return order;
 }
Пример #10
0
        /// <summary>
        /// 创建一个注单并附加到一个Sheet上
        /// </summary>
        /// <param name="orderList">The order list.</param>
        /// <param name="companyType">Type of the company.</param>
        /// <param name="company">The company.</param>
        /// <param name="memberComm">The member comm.</param>
        /// <param name="num">The num.</param>
        /// <param name="wager">The wager.</param>
        /// <param name="user">The user.</param>
        /// <param name="fullArrangementNum">The full arrangement num.</param>
        /// <param name="isCon">if set to <c>true</c> [is con].</param>
        private void AddOrderToDic(IList<BetOrder> orderList, CompanyType companyType, LotteryCompany company, Pair<CommissionGroup, IEnumerable<ConcreteCommission>> memberComm,
            string num, WagerItem wager, User user, IList<long> fullArrangementNum, bool isCon = false)
        {
            List<GamePlayWay> gamePlayWayList = new List<GamePlayWay>();
            var gamePlayWay = LotterySystem.Current.FindGamePlayWay(wager.GamePlayTypeId);     //找到下注的游戏玩法
            var playWay = gamePlayWay.PlayWay;
            if (playWay == PlayWay.HeadAndLast)     //头尾则分解为头,尾两注
            {
                Func<PlayWay, GamePlayWay> findPlayWayFun = (pw) =>
                {
                    return LotterySystem.Current.FindGamePlayWay(gamePlayWay.GameType, pw);
                };
                var headPlayWay = findPlayWayFun(PlayWay.Head);
                var lastPlayWay = findPlayWayFun(PlayWay.Last);
                gamePlayWayList.Add(headPlayWay);
                gamePlayWayList.Add(lastPlayWay);
            }
            else
                gamePlayWayList.Add(gamePlayWay);
            Action<string, int, GamePlayWay> buildOrderToListFunc = (n, q, gpw) =>
            {
                var order = BuildBetOrder(n, q, memberComm, gpw, company, wager.Wager, user, isCon);
                this.BetResult.ExceptTurnover += order.Turnover;
                if (company.IsInBetTime(gpw) && Checker.Check(order, user))
                {
                    orderList.Add(order);
                    this.BetResult.ActualTurnover += order.Turnover;
                    Checker.BeInsertOrderList.Add(order);

                    if (Checker.IsDrop)
                        this.BetResult.DropOrderList.Add(order);
                }
                else
                {
                    this.BetResult.NotAcceptOrderList.Add(order);
                }
            };
            gamePlayWayList.ForEach(x =>
            {
                var counter = NumQuantityCounterFactory.GetFactory.GetCounter(x.GameType, companyType, LotterySystem.Current.GetNumLenSupport(companyType));
                var betNum = counter.GetRealyBetNum(num);
                int numQuantity = CountNumQuantity(betNum, x, companyType); //计算该玩法的号码长度
                if (wager.IsFullPermutation)    //是否全排列下注
                {
                    if (fullArrangementNum == null) //获取号码全排列
                        fullArrangementNum = MathHelper.GetFullArrangement(betNum);
                    fullArrangementNum.ForEach(it => buildOrderToListFunc(it.ToString("D" + betNum.Length), numQuantity, x));
                }
                else
                    buildOrderToListFunc(betNum, numQuantity, x);
            });
        }
Пример #11
0
 private IEnumerable<DropWater> GetMininumDropWater(string num, int gameplaywayId, LotteryCompany company)
 {
     var dropwaterDic = HttpContext.Current.Items[m_MININUMDPDIC] as IDictionary<string, IEnumerable<DropWater>>;
     if (dropwaterDic == null)
     {
         dropwaterDic = new Dictionary<string, IEnumerable<DropWater>>();
         HttpContext.Current.Items[m_MININUMDPDIC] = dropwaterDic;
     }
     string key = string.Format("{0}_{1}_{2}", company.CompanyId, gameplaywayId, num);
     IEnumerable<DropWater> minDropWaters;
     if (!dropwaterDic.TryGetValue(key, out minDropWaters))
     {
         var dropWaters = DwManager.GetTodayNumsDropWater(num, gameplaywayId, company);
         minDropWaters = dropWaters.GroupBy(it => it.Amount).OrderBy(it => it.Key).FirstOrDefault();//最小金额跌水
         dropwaterDic.Add(key, minDropWaters);
     }
     return minDropWaters;
 }
Пример #12
0
 /// <summary>
 /// 根据公司类型和玩法获取默认上限限制
 /// </summary>
 /// <param name="company">The company.</param>
 /// <param name="gameplaywayId">The gameplayway id.</param>
 /// <returns></returns>
 private DefaultUpperLimit GetDefaultUpperLimit(LotteryCompany company, int gameplaywayId)
 {
     IDictionary<string, DefaultUpperLimit> upperlimitDic = HttpContext.Current.Items[m_DEFAULTLIMITDIC] as IDictionary<string, DefaultUpperLimit>;
     if (upperlimitDic == null)
     {
         upperlimitDic = new Dictionary<string, DefaultUpperLimit>();
         HttpContext.Current.Items[m_DEFAULTLIMITDIC] = upperlimitDic;
     }
     string key = string.Format("{0}_{1}", (int)company.CompanyType, gameplaywayId);
     DefaultUpperLimit limit;
     if (!upperlimitDic.TryGetValue(key, out limit))
     {
         limit = DaDefaultLimit.GetDefaultUpperLimit(company.CompanyType, gameplaywayId);
         upperlimitDic.Add(key, limit);
     }
     return limit;
 }
Пример #13
0
 public void Add(LotteryCompany company, User user)
 {
     if (user.Role != Role.Company) throw new NoPermissionException("Add Company", user.ToString());
     DaCompany.Insert(company);
     LotterySystem.ClearAllCompany();
 }
Пример #14
0
 /// <summary>
 /// 获取指定公司支持的号码长度.
 /// </summary>
 /// <param name="company">The company.</param>
 /// <returns></returns>
 public IEnumerable<CompanyTypeSupportNumLen> GetNumLengthByCompany(LotteryCompany company)
 {
     return GetNumLenthByCompanyType(company.CompanyType);
 }
Пример #15
0
 public IEnumerable<CompanyLotteryCycle> GetCycles(LotteryCompany company)
 {
     return DaCompanyCycle.GetCycles(company);
 }
 public LotteryPeriod GetPeriod(LotteryCompany company, DateTime date)
 {
     string sql = string.Format(@"SELECT * FROM {0} WHERE {1}=@{1} AND CONVERT(char(10),{2},120)=CONVERT(char(10),@{2},120)", LotteryPeriod.TABLENAME, LotteryPeriod.COMPANYID, LotteryPeriod.CREATEDATE);
     return base.ExecuteModel<LotteryPeriod>(sql, new SqlParameter(LotteryPeriod.COMPANYID, company.CompanyId),
         new SqlParameter(LotteryPeriod.CREATEDATE, date));
 }
 public IEnumerable<CompanyLotteryCycle> GetCycles(LotteryCompany company)
 {
     string sql = string.Format(@"SELECT * FROM {0} WHERE {1}=@{1}", CompanyLotteryCycle.TABLENAME, CompanyLotteryCycle.COMPANYID);
     return base.ExecuteList<CompanyLotteryCycle>(sql, new SqlParameter(CompanyLotteryCycle.COMPANYID, company.CompanyId));
 }
Пример #18
0
 public IEnumerable<DropWater> GetDropWaterByCondition(string num, LotteryCompany company, int gameplayway, decimal amount, DateTime date)
 {
     string sql = string.Format(@";WITH CTE AS(select  dw.*,dic.CompanyId from tb_DropWater dw
     left join tb_DropInCompany dic on dic.DropId=dw.DropId
     where {1}=@{1} AND {2}=@{2}
     and ((DropType={3} and {5}=@{5}) or (DropType={4} and {0}=@{0} AND {6}=@{6} and CAST({7} as Date)=CAST(@{7} as DATE)))
     )
     select * from CTE", DropWater.NUM, DropWater.GAMEPLAYWAYID, DropWater.AMOUNT, (int)DropType.Auto, (int)DropType.Manual, DropWater.COMPANYTYPE, DropInCompany.COMPANYID, DropWater.CREATETIME);
     return base.ExecuteList<DropWater>(sql, new SqlParameter(DropWater.NUM, num),
         new SqlParameter(DropWater.AMOUNT, amount),
         new SqlParameter(DropWater.GAMEPLAYWAYID, gameplayway),
         new SqlParameter(DropWater.COMPANYTYPE, (int)company.CompanyType),
         new SqlParameter(DropInCompany.COMPANYID, company.CompanyId),
         new SqlParameter(DropWater.CREATETIME, date));
 }