public void Run() { var pkService = new PKService(); var bonusService = new PKBonusService(); var betService = new BetService(); var pks = pkService.GetNotBonusPKs(); foreach (var pk in pks) { if (pk != null && !string.IsNullOrEmpty(pk.Ranks)) { // 生成奖金 if (!pk.IsBonused) { // 更新 奖金生成标志, 防止多次计算 pkService.UpdateIsBonused(pk.PKId, true); // 生成奖金 bonusService.GenerateBonus(pk); var msg = string.Format("Generate Bonus - PKId : {0} - Time : {1}", pk.PKId, DateTime.Now.ToString(DateFormatConst.yMd_Hms)); _logger.Info(msg); } } } // 更新Bet表已结算标志 betService.UpdateSettlementDone(); }
public void Run() { var pkService = new PKService(); var bonusService = new PKBonusService(); var betService = new BetService(); //var pk = pkService.GetCurrentPK(); var pks = pkService.GetNotCalculatePKs(); foreach (var pk in pks) { if (pk != null && string.IsNullOrEmpty(pk.Ranks)) { var now = DateTime.Now; if (now >= pk.BeginTime.AddSeconds(pk.OpeningSeconds))// 封盘 { // 计算名次 var rankList = betService.CalculateRanks(pk.PKId); var ranks = string.Join(",", rankList); pk.Ranks = ranks; var success = pkService.UpdateRanks(pk.PKId, ranks); if (success) { var msg = string.Format("Calculate Ranks - PKId : {0} - Ranks : {1} - Time : {2}", pk.PKId, ranks, now.ToString(DateFormatConst.yMd_Hms)); _logger.Info(msg); } else { var msg = string.Format("Calculate Ranks Failed, 已经生成过Ranks - PKId : {0} - Ranks : {1} - Time : {2}", pk.PKId, ranks, now.ToString(DateFormatConst.yMd_Hms)); _logger.Info(msg); } } } } // 更新Bet表已结算标志 betService.UpdateSettlementDone(); }