Пример #1
0
        public void BettingSport_AfterTranCommit(string userId, Sports_BetingInfo bettingOrder, string schemeId)
        {
            // 更新最新动态,忽略异常,异常只记录日志
            var desc = string.Format("代购了 {0}第{1}期¥{2:N0} 投注方案", GetGameName(bettingOrder.GameCode, bettingOrder.GameType), bettingOrder.IssuseNumber, bettingOrder.TotalMoney);

            UsefullHelper.TryDoAction(() => UpdateProfileDynamic(userId, schemeId, bettingOrder.GameCode, bettingOrder.IssuseNumber, bettingOrder.TotalMoney, "代购"));
            // 更新统计数据
            UsefullHelper.TryDoAction(() => UpdateProfileDataReport(userId, 1, null, null, null));
            //普通用户推广
            UsefullHelper.TryDoAction(() => UpdateSporeadUserData(userId, bettingOrder.GameCode, bettingOrder.TotalMoney));
            //分享推广活动 用户购彩了 送红包 只送一次
            //UsefullHelper.TryDoAction(() => FirstLotteryGiveRedBag(userId));
        }
Пример #2
0
        public CommonActionResult Sports_Betting(Sports_BetingInfo info, string password, decimal redBagMoney, string userid)
        {
            try
            {
                //检查彩种是否暂停销售
                KaSon.FrameWork.ORM.Helper.BusinessHelper.CheckGameEnable(info.GameCode.ToUpper());
                BettingHelper.CheckGameCodeAndType(info.GameCode, info.GameType);
                // 验证用户身份及权限
                //var userId = GameBizAuthBusiness.ValidateUserAuthentication(userToken);

                //栓查是否实名
                //if (!BusinessHelper.IsUserValidateRealName(userId))
                //    throw new LogicException("未实名认证用户不能购买彩票");

                CheckJCRepeatBetting(userid, info);
                //检查投注内容,并获取投注注数
                var totalCount = BusinessHelper.CheckBetCode(userid, info.GameCode.ToUpper(), info.GameType.ToUpper(), info.SchemeSource, info.PlayType, info.Amount, info.TotalMoney, info.AnteCodeList);
                //检查投注的比赛,并获取最早结束时间
                var stopTime = RedisMatchBusiness.CheckGeneralBettingMatch(info.GameCode.ToUpper(), info.GameType.ToUpper(), info.PlayType, info.AnteCodeList, info.IssuseNumber, info.BettingCategory);

                string schemeId = string.Empty;
                //lock (UsefullHelper.moneyLocker)
                //{
                schemeId = new Sports_Business().SportsBetting(info, userid, password, "Bet", totalCount, stopTime, redBagMoney);
                //}
                //! 执行扩展功能代码 - 提交事务后
                BusinessHelper.ExecPlugin <IBettingSport_AfterTranCommit>(new object[] { userid, info, schemeId });

                return(new CommonActionResult
                {
                    IsSuccess = true,
                    ReturnValue = schemeId + "|" + info.TotalMoney,
                    Message = "足彩投注成功",
                });
            }
            //catch (AggregateException ex)
            //{
            //    throw new AggregateException(ex.Message);
            //}
            catch (LogicException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception("订单投注异常,请重试 ", ex);
            }
        }
Пример #3
0
        /// <summary>
        /// 足彩投注,用户保存的订单
        /// </summary>
        public CommonActionResult SaveOrderSportsBettingByResult(Sports_BetingInfo info, string userid)
        {
            // 验证用户身份及权限
            //var userId = GameBizAuthBusiness.ValidateUserAuthentication(userToken);

            try
            {
                //栓查是否实名
                //if (!BusinessHelper.IsUserValidateRealName(userId))
                //    throw new LogicException("未实名认证用户不能购买彩票");

                CheckDisableGame(info.GameCode, info.GameType);
                BettingHelper.CheckGameCodeAndType(info.GameCode, info.GameType);

                // 检查订单基本信息
                BettingHelper.CheckSchemeOrder(info);

                string schemeId = new Sports_Business().SaveOrderSportsBetting(info, userid);

                //! 执行扩展功能代码 - 提交事务后
                BusinessHelper.ExecPlugin <IBettingSport_AfterTranCommit>(new object[] { userid, info, schemeId });

                return(new CommonActionResult
                {
                    IsSuccess = true,
                    ReturnValue = schemeId + "|" + info.TotalMoney,
                    Message = "保存订单成功",
                });
            }
            catch (LogicException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception("保存订单异常,请重试 ", ex);
            }
        }
Пример #4
0
 public Task <CommonActionResult> Login(Sports_BetingInfo info, string password, decimal redBagMoney, string userid)
 {
     throw new NotImplementedException();
 }
Пример #5
0
 /// <summary>
 /// 检查竞彩订单频繁投注
 /// </summary>
 private void CheckJCRepeatBetting(string currUserId, Sports_BetingInfo info, bool isYouHua = false)
 {
     try
     {
         if (!_sportsBettingListInfo.ContainsKey(currUserId))
         {
             info.CurrentBetTime = DateTime.Now;
             _sportsBettingListInfo.TryAdd(currUserId, info);
             return;
         }
     }
     catch (Exception)
     {
     }
     lock (_sportsBettingListInfo)
     {
         try
         {
             Sports_BetingInfo value = _sportsBettingListInfo[currUserId];
             if (isYouHua)//奖金优化
             {
                 //不重复
                 if (!info.Equals(value))
                 {
                     _sportsBettingListInfo.TryRemove(currUserId, out value);
                     info.CurrentBetTime = DateTime.Now;
                     _sportsBettingListInfo.TryAdd(currUserId, info);
                     return;
                 }
                 //重复投注
                 if (value.Amount == info.Amount && value.GameCode.ToUpper() == info.GameCode.ToUpper() && value.PlayType == info.PlayType && value.TotalMoney == info.TotalMoney && value.Attach == info.Attach)
                 {
                     info.IsRepeat = true;
                 }
                 //重复投注
                 if (info.IsRepeat)
                 {
                     var timeSpan = DateTime.Now - value.CurrentBetTime;
                     if (timeSpan.TotalSeconds > 5)
                     {
                         //大于间隔时间
                         _sportsBettingListInfo.TryRemove(currUserId, out value);
                         info.CurrentBetTime = DateTime.Now;
                         _sportsBettingListInfo.TryAdd(currUserId, info);
                         return;
                     }
                     else
                     {
                         throw new LogicException("Repeat");
                     }
                 }
             }
             else
             {
                 //不重复
                 if (!info.Equals(value))
                 {
                     _sportsBettingListInfo.TryRemove(currUserId, out value);
                     info.CurrentBetTime = DateTime.Now;
                     _sportsBettingListInfo.TryAdd(currUserId, info);
                     return;
                 }
                 //重复投注
                 if (value.Amount == info.Amount && value.GameCode.ToUpper() == info.GameCode.ToUpper() && value.PlayType == info.PlayType && value.TotalMoney == info.TotalMoney)
                 {
                     info.IsRepeat = true;
                 }
                 //重复投注
                 if (info.IsRepeat)
                 {
                     var timeSpan = DateTime.Now - value.CurrentBetTime;
                     if (timeSpan.TotalSeconds > 5)
                     {
                         //大于间隔时间
                         _sportsBettingListInfo.TryRemove(currUserId, out value);
                         info.CurrentBetTime = DateTime.Now;
                         _sportsBettingListInfo.TryAdd(currUserId, info);
                         return;
                     }
                     else
                     {
                         throw new LogicException("Repeat");
                     }
                 }
             }
         }
         catch
         {
             _sportsBettingListInfo.Clear();
             return;
         }
     }
 }
Пример #6
0
        /// <summary>
        /// 保存用户未投注订单
        /// </summary>
        public string SaveOrderSportsBetting(Sports_BetingInfo info, string userId)
        {
            string schemeId = string.Empty;

            info.GameCode = info.GameCode.ToUpper();
            info.GameType = info.GameType.ToUpper();
            var gameCode = info.GameCode;

            schemeId = BettingHelper.GetSportsBettingSchemeId(gameCode);
            var sportsManager = new Sports_Manager();
            //验证比赛是否还可以投注
            var stopTime = CheckGeneralBettingMatch(sportsManager, gameCode, info.GameType, info.PlayType, info.AnteCodeList, info.IssuseNumber);
            // 检查订单金额是否匹配
            var betCount    = CheckBettingOrderMoney(info.AnteCodeList, gameCode, info.GameType, info.PlayType, info.Amount, info.TotalMoney, stopTime, false, userId);
            var userManager = new UserBalanceManager();
            var user        = userManager.LoadUserRegister(userId);

            //开启事务
            using (DB)
            {
                //biz.BeginTran();
                DB.Begin();
                try
                {
                    AddRunningOrderAndOrderDetail(schemeId, info.BettingCategory, info.GameCode, info.GameType, info.PlayType, true, info.IssuseNumber, info.Amount, betCount, info.TotalMatchCount, info.TotalMoney, stopTime,
                                                  info.SchemeSource, info.Security, SchemeType.SaveScheme, false, true, user.UserId, user.AgentId, info.CurrentBetTime, info.ActivityType, info.Attach, false, 0M, ProgressStatus.Waitting, TicketStatus.Waitting);
                    foreach (var item in info.AnteCodeList)
                    {
                        //sportsManager.AddSports_AnteCode(new C_Sports_AnteCode
                        //{
                        //    SchemeId = schemeId,
                        //    AnteCode = item.AnteCode,
                        //    BonusStatus = (int)BonusStatus.Waitting,
                        //    CreateTime = DateTime.Now,
                        //    GameCode = gameCode,
                        //    GameType = string.IsNullOrEmpty(item.GameType) ? info.GameType.ToUpper() : item.GameType.ToUpper(),
                        //    IsDan = item.IsDan,
                        //    IssuseNumber = info.IssuseNumber,
                        //    MatchId = item.MatchId,
                        //    PlayType = info.PlayType,
                        //    Odds = string.Empty,
                        //});
                        var c_entity = new C_Sports_AnteCode
                        {
                            SchemeId     = schemeId,
                            AnteCode     = item.AnteCode,
                            BonusStatus  = (int)BonusStatus.Waitting,
                            CreateTime   = DateTime.Now,
                            GameCode     = gameCode,
                            GameType     = string.IsNullOrEmpty(item.GameType) ? info.GameType.ToUpper() : item.GameType.ToUpper(),
                            IsDan        = item.IsDan,
                            IssuseNumber = info.IssuseNumber,
                            MatchId      = item.MatchId,
                            PlayType     = info.PlayType,
                            Odds         = string.Empty,
                        };

                        DB.GetDal <C_Sports_AnteCode>().Add(c_entity);
                    }
                    //C_UserSaveOrder
                    var C_UserSaveOrderEntity = new C_UserSaveOrder
                    {
                        SchemeId              = schemeId,
                        UserId                = userId,
                        GameCode              = info.GameCode,
                        GameType              = info.GameType,
                        PlayType              = info.PlayType,
                        SchemeType            = (int)SchemeType.SaveScheme,
                        SchemeSource          = (int)info.SchemeSource,
                        SchemeBettingCategory = (int)info.BettingCategory,
                        ProgressStatus        = (int)ProgressStatus.Waitting,
                        IssuseNumber          = info.IssuseNumber,
                        Amount                = info.Amount,
                        BetCount              = betCount,
                        TotalMoney            = info.TotalMoney,
                        StopTime              = stopTime,
                        CreateTime            = DateTime.Now,
                        StrStopTime           = stopTime.AddMinutes(-5).ToString("yyyyMMddHHmm"),
                    };
                    //用户的订单保存
                    //sportsManager.AddUserSaveOrder(new C_UserSaveOrder
                    //{
                    //    SchemeId = schemeId,
                    //    UserId = userId,
                    //    GameCode = info.GameCode,
                    //    GameType = info.GameType,
                    //    PlayType = info.PlayType,
                    //    SchemeType = SchemeType.SaveScheme,
                    //    SchemeSource = info.SchemeSource,
                    //    SchemeBettingCategory = info.BettingCategory,
                    //    ProgressStatus = ProgressStatus.Waitting,
                    //    IssuseNumber = info.IssuseNumber,
                    //    Amount = info.Amount,
                    //    BetCount = betCount,
                    //    TotalMoney = info.TotalMoney,
                    //    StopTime = stopTime,
                    //    CreateTime = DateTime.Now,
                    //    StrStopTime = stopTime.AddMinutes(-5).ToString("yyyyMMddHHmm"),
                    //});

                    DB.Commit();
                }
                catch (Exception EX)
                {
                    DB.Rollback();
                    throw EX;
                }
            }
            return(schemeId);
        }