/// <summary> /// 获取我的竞猜列表 /// </summary> /// <param name="managerId"></param> /// <returns></returns> public GetMyEuropeGambleResponse GetMyGamble(Guid managerId) { GetMyEuropeGambleResponse response = new GetMyEuropeGambleResponse(); try { var managerList = EuropeGamblerecordMgr.GambleRecord(managerId); response.Data = new GetMyEuropeGamble(); foreach (var item in managerList) { var match = EuropeConfig.Instance.GetOneMatch(item.MatchId); if (match != null) { item.HomeName = match.HomeName; item.AwayName = match.AwayName; item.TimeTick = ShareUtil.GetTimeTick(item.RowTime); } } response.Data.GambleList = managerList; } catch (Exception ex) { SystemlogMgr.Error("获取我的竞猜列表", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }
/// <summary> /// 竞猜比赛 /// </summary> /// <param name="managerId"></param> /// <param name="matchId"></param> /// <param name="gambleType"></param> /// <param name="pointType"></param> /// <returns></returns> public EuropeGambleMatchResponse GambleMatch(Guid managerId, int matchId, int gambleType, int pointType) { EuropeGambleMatchResponse response = new EuropeGambleMatchResponse(); try { DateTime date = DateTime.Now; var manager = ManagerCore.Instance.GetManager(managerId); if (manager == null) { response.Code = (int)MessageCode.MissManager; return(response); } var match = EuropeConfig.Instance.GetOneMatch(matchId); if (match == null) { response.Code = (int)MessageCode.NotHaveMatch; return(response); } if (match.States != (int)EnumEuropeStatus.Gamble || match.MatchTime < date)//不可以竞猜 { response.Code = (int)MessageCode.HaveGambleTime; return(response); } var gambleRecord = EuropeGamblerecordMgr.GambleRecord(managerId, matchId); if (gambleRecord != null)//已经竞猜过 { response.Code = (int)MessageCode.HaveGamble; return(response); } var pointConfig = EuropeConfig.Instance.GetGamblePoint(pointType); if (pointConfig == null || pointConfig.VipLevel > manager.VipLevel)//竞猜点卷有误 { response.Code = (int)MessageCode.PointConfigNotHave; return(response); } var managerPoint = PayCore.Instance.GetPoint(managerId); if (managerPoint < pointConfig.Point)//钻石不足 { response.Code = (int)MessageCode.NbPointShortage; return(response); } gambleRecord = new EuropeGamblerecordEntity(0, managerId, matchId, gambleType, pointConfig.Point, 0, false, false, date, date); using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault())) { transactionManager.BeginTransaction(); MessageCode code = MessageCode.FailUpdate; do { if (!EuropeGamblerecordMgr.Insert(gambleRecord, transactionManager.TransactionObject)) { break; } code = PayCore.Instance.GambleTrueMatch(managerId, pointConfig.Point, ShareUtil.GenerateComb().ToString(), transactionManager.TransactionObject); } while (false); if (code != MessageCode.Success) { transactionManager.Rollback(); response.Code = (int)code; return(response); } transactionManager.Commit(); response.Data = new EuropeGambleMatch(); response.Data.Point = managerPoint - pointConfig.Point; } } catch (Exception ex) { SystemlogMgr.Error("欧洲杯竞猜", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }
/// <summary> /// 获取比赛列表 /// </summary> /// <param name="managerId"></param> /// <param name="matchDate">比赛日期</param> /// <returns></returns> public GetEuropeMatchListResponse GetMatchList(Guid managerId, DateTime matchDate, int isDefault) { GetEuropeMatchListResponse response = new GetEuropeMatchListResponse(); try { DateTime date = DateTime.Now; var list = EuropeConfig.Instance.GetMatchDay(matchDate); List <EuropeMatchEntity> matchList = new List <EuropeMatchEntity>(); if (isDefault == 1) { var notMatchList = list.FindAll(r => r.MatchTime > date); for (int i = 0; i < 5; i++) { if (notMatchList.Count > 0) { break; } matchDate = matchDate.AddDays(1); notMatchList = EuropeConfig.Instance.GetMatchDay(matchDate); } matchList.AddRange(notMatchList); } else { matchList.AddRange(list); } var gambleRecord = EuropeGamblerecordMgr.GambleRecord(managerId); List <EuropeMatchEntity> resultList = new List <EuropeMatchEntity>(); foreach (var item in matchList) { var entity = new EuropeMatchEntity(); entity.AwayGoals = item.AwayGoals; entity.AwayLogo = item.AwayLogo; entity.AwayName = item.AwayName; entity.HomeGoals = item.HomeGoals; entity.HomeLogo = item.HomeLogo; entity.HomeName = item.HomeName; entity.IsAlreadyGamble = false; entity.MatchDate = item.MatchDate; entity.MatchId = item.MatchId; entity.MatchTimeTick = item.MatchTimeTick; entity.ResultType = item.ResultType; entity.States = item.States; if (gambleRecord.Exists(r => r.MatchId == item.MatchId)) { entity.IsAlreadyGamble = true; } resultList.Add(entity); } response.Data = new GetEuropeMatchList(); response.Data.MatchList = resultList; response.Data.MatchDateTick = ShareUtil.GetTimeTick(matchDate); } catch (Exception ex) { SystemlogMgr.Error("获取欧洲杯比赛列表", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }