public async Task UpdateMatchAsync(LotterySportsMatch match)
 {
     await _lotterySportsMatchRepository.UpdateAsync(match);
 }
        public async Task <(LotteryMerchanteOrder order, TimeSpan?delay)> CreateAsync(string lvpOrderId, long?lvpUserId, string lvpVenderId, int lotteryId, int lotteryPlayId, int?issueNumber, string investCode, bool investType, short investCount, byte investTimes, int investAmount)
        {
            string   id = _identityGenerater.Generate().ToString();
            DateTime expectedBonusTime = DateTime.Now;
            DateTime currentTime       = DateTime.Now;
            TimeSpan?delayTime         = null;

            if (issueNumber.HasValue && issueNumber != 0)
            {
                var phaseNumber = await _lotteryPhaseRepository.FirstOrDefaultAsync(predicate => predicate.LotteryId == lotteryId && predicate.IssueNumber == issueNumber);

                expectedBonusTime = phaseNumber.EndTime;
                if (lotteryId < 100)
                {
                    expectedBonusTime = expectedBonusTime.AddHours(1.5);

                    /*低频数字彩票0点到12点不销售*/
                    if (currentTime.Hour < 9)
                    {
                        delayTime = currentTime.Date.AddHours(9) - currentTime;
                    }
                }
                else
                {
                    /* 高频彩票期后30秒开始投注出票*/
                    if (phaseNumber.StartTime > currentTime)
                    {
                        delayTime = (phaseNumber.StartTime - currentTime).Add(TimeSpan.FromSeconds(30));
                    }
                }
            }
            else
            {
                string[] investMatches = investCode.Split(new string[] { "^" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in investMatches)
                {
                    string[] items   = item.Split('|');
                    long     matchId = long.Parse($"{ items[0] }{ items[1] }{ items[2]}");

                    LotterySportsMatch lotterySportsMatch = await _lotterySportsMatchRepository.FirstOrDefaultAsync(matchId);

                    if (expectedBonusTime < lotterySportsMatch.StartTime)
                    {
                        expectedBonusTime = lotterySportsMatch.StartTime;
                    }
                }
                expectedBonusTime = expectedBonusTime.AddHours(3);
                /* 竞彩周日,周一 1点到9点,不销售,其他时间0点到9点不销售*/
                if (currentTime.Hour < 9)
                {
                    if ((currentTime.DayOfWeek == DayOfWeek.Sunday || currentTime.DayOfWeek == DayOfWeek.Monday) && currentTime.Hour > 1)
                    {
                        delayTime = currentTime.Date.AddHours(9) - currentTime;
                    }
                    else
                    {
                        delayTime = currentTime.Date.AddHours(9) - currentTime;
                    }
                }
            }

            var order = await _orderingReoository.InsertAsync(new LotteryMerchanteOrder
            {
                Id                = id,
                LvpOrderId        = lvpOrderId,
                LotteryBuyerId    = 619,
                LvpUserId         = lvpUserId,
                LvpVenderId       = lvpVenderId,
                LotteryId         = lotteryId,
                LotteryPlayId     = lotteryPlayId,
                IssueNumber       = issueNumber,
                InvestCode        = investCode,
                InvestType        = investType,
                InvestCount       = investCount,
                InvestTimes       = investTimes,
                InvestAmount      = investAmount,
                ExpectedBonusTime = expectedBonusTime,
                Status            = (int)OrderStatus.Succeed,
                CreationTime      = DateTime.Now
            });

            return(order, delayTime);
        }
 public async Task CreateMatchAsync(LotterySportsMatch match)
 {
     await _lotterySportsMatchRepository.InsertAsync(match);
 }