/// <summary> /// 宝单分享 /// </summary> public void ComplateTicket(string userId, string schemeId, decimal totalMoney, decimal totalErrorMoney) { try { if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(schemeId)) { return; } var orderManager = new Sports_Manager(); var sd_Manager = new TotalSingleTreasureManager(); var manager = new BDFXManager(); var orderRunning = orderManager.QuerySports_Order_Running(schemeId); if (orderRunning == null) { return; } if (orderRunning.SchemeType == (int)SchemeType.SingleTreasure) { var saveOrderEntity = orderManager.QuerySaveOrder(schemeId); if (saveOrderEntity == null) { return; } var BDFXOrderEntity = sd_Manager.QueryTotalSingleTreasureBySchemeId(schemeId); var anteCodeList = orderManager.QuerySportsAnteCodeBySchemeId(schemeId); DateTime firstMatchStopTime = new DateTime(); DateTime lastMatchStopTime = new DateTime(); if (orderRunning.GameCode.ToUpper() == "JCZQ") { var matchIdArray = (from l in anteCodeList select l.MatchId).Distinct().ToArray(); var matchList = orderManager.QueryJCZQSaleMatchCount(matchIdArray); firstMatchStopTime = matchList.Min(s => s.FSStopBettingTime); lastMatchStopTime = matchList.Max(s => s.FSStopBettingTime); } if (BDFXOrderEntity == null || string.IsNullOrEmpty(BDFXOrderEntity.UserId))//晒单 { var epectedBonusMoney = 0M; var ticketList = orderManager.QueryTicketList(schemeId); if (ticketList != null && ticketList.Count > 0) { foreach (var item in ticketList) { var minMoney = 0M; var maxMoney = 0M; var playCount = 0; if (!string.IsNullOrEmpty(item.PlayType)) { var tempArray = item.PlayType.Replace("P", "").Split('_'); if (tempArray.Length >= 2) { playCount = Convert.ToInt32(tempArray[1]); } } if (string.IsNullOrEmpty(item.PlayType) || playCount <= 1) { var winMoneyList = string.IsNullOrEmpty(item.BetContent) || string.IsNullOrEmpty(item.LocOdds) ? null : Common.Utilities.UsefullHelper.GetTicketMinMoneyOrMaxMoney(item.BetContent, item.LocOdds, out minMoney, out maxMoney); } else { Common.Utilities.UsefullHelper.GetTicketMinMoneyOrMaxMoney_MN(item.PlayType.Replace("P", ""), item.BetContent, item.LocOdds, out minMoney, out maxMoney); } epectedBonusMoney += maxMoney; } } epectedBonusMoney = Convert.ToDecimal(epectedBonusMoney.ToString("N2")); var expectedReturnRate = 0M; if (orderRunning.TotalMoney > 0) { expectedReturnRate = epectedBonusMoney / orderRunning.TotalMoney; expectedReturnRate = Math.Truncate(expectedReturnRate * 100) / 100M; } BDFXOrderEntity = new C_TotalSingleTreasure(); BDFXOrderEntity.Commission = saveOrderEntity.BDFXCommission; BDFXOrderEntity.CreateTime = DateTime.Now; BDFXOrderEntity.CurrentBetMoney = orderRunning.TotalMoney; BDFXOrderEntity.ExpectedBonusMoney = epectedBonusMoney; BDFXOrderEntity.ExpectedReturnRate = expectedReturnRate; BDFXOrderEntity.FirstMatchStopTime = firstMatchStopTime; BDFXOrderEntity.IsBonus = false; BDFXOrderEntity.IsComplate = false; BDFXOrderEntity.LastMatchStopTime = lastMatchStopTime.AddMinutes(120); BDFXOrderEntity.TotalBuyCount = 0; BDFXOrderEntity.TotalBuyMoney = 0; BDFXOrderEntity.TotalBonusMoney = 0; BDFXOrderEntity.ProfitRate = 0; BDFXOrderEntity.SchemeId = orderRunning.SchemeId; BDFXOrderEntity.TotalCommissionMoney = 0; BDFXOrderEntity.UserId = orderRunning.UserId; BDFXOrderEntity.SingleTreasureDeclaration = saveOrderEntity.SingleTreasureDeclaration; BDFXOrderEntity.Security = orderRunning.Security; sd_Manager.AddTotalSingleTreasure(BDFXOrderEntity); } var singleTreasureAttentionSummary = manager.QuerySingleTreasureAttentionSummaryByUserId(orderRunning.UserId); if (singleTreasureAttentionSummary == null || string.IsNullOrEmpty(singleTreasureAttentionSummary.UserId))//初始化关注统计表 { C_SingleTreasure_AttentionSummary entity = new C_SingleTreasure_AttentionSummary(); entity.UserId = orderRunning.UserId; entity.BeConcernedUserCount = 0; entity.ConcernedUserCount = 0; entity.SingleTreasureCount += 1; entity.UpdateTime = DateTime.Now; manager.AddSingleTreasureAttentionSummary(entity); } else { singleTreasureAttentionSummary.SingleTreasureCount += 1; manager.UpdateSingleTreasureAttentionSummary(singleTreasureAttentionSummary); } } else if (orderRunning.SchemeType == (int)SchemeType.SingleCopy)//抄单 { var recordSingleCopyEntity = sd_Manager.QueryBDFXRecordSingleCopyBySchemeId(schemeId); if (recordSingleCopyEntity != null) { var bdEntity = sd_Manager.QueryTotalSingleTreasureBySchemeId(recordSingleCopyEntity.BDXFSchemeId); if (bdEntity != null) { bdEntity.TotalBuyCount += 1; bdEntity.TotalBuyMoney += totalMoney; sd_Manager.UpdateTotalSingleTreasure(bdEntity); } } } } catch { } }