public IDictionary<BetSheet, IList<BetOrder>> BuildOrder(User user, LotterySpecies specie, IEnumerable<AutoBetItem> betList, IDictionary<string, object> parameters) { this._betResult = new BetResult(); BetResult returnResult = new Models.BetResult(); var todayLotteryCompany = TodayLotteryCompany.Instance.GetTodayCompany(); //获取今日开奖公司 var memberComm = CommManager.GetMemberCommissionInSession(user, specie); //获取会员的佣金 IDictionary<BetSheet, IList<BetOrder>> betSheetDic = new Dictionary<BetSheet, IList<BetOrder>>(); IDictionary<BetSheet, IList<BetOrder>> resultDic = new Dictionary<BetSheet, IList<BetOrder>>(); foreach (var betOrder in betList) { int[] nums; switch (betOrder.BetType) { case AutoBetType.TwelveZodiac: nums = LotterySystem.Current.TwelveZodiac; break; case AutoBetType.EvenEven: nums = LotterySystem.Current.EvenEven; break; case AutoBetType.EvenOdd: nums = LotterySystem.Current.EvenOdd; break; case AutoBetType.OddEven: nums = LotterySystem.Current.OddEven; break; case AutoBetType.OddOdd: nums = LotterySystem.Current.OddOdd; break; case AutoBetType.Small: nums = LotterySystem.Current.Small; break; case AutoBetType.Big: nums = LotterySystem.Current.Big; break; default: throw new InvalidDataException("不可到达,数据异常!"); } var sheet = BuildAutoElectionCodeOrder(user, specie, betOrder.CompanyList, betOrder.WagerList, nums); betSheetDic.AddRange(sheet); returnResult.Append(this.BetResult); List<BetOrder> orderList = new List<BetOrder>(); foreach (var item in betSheetDic) orderList.AddRange(item.Value); StringBuilder companySb = new StringBuilder(); foreach (var companyId in betOrder.CompanyList) { var company = todayLotteryCompany.Find(it => it.CompanyId == companyId); if (company == null) throw new InvalidDataException("CompanyId:" + companyId); companySb.AppendFormat("{0} ", company.Abbreviation); } BetSheet orderSheet = new BetSheet { Num = betOrder.BetType.ToString(), Turnover = orderList.Sum(it => it.Turnover), NetAmount = orderList.Sum(it => it.NetAmount), Commission = orderList.Sum(it => it.Commission), UserId = user.UserId, Status = BetStatus.Valid, IPAddress = IPHelper.IPAddress, BetCompany = companySb.ToString(), BetAmount = JoinSheetBetAmount(sheet.Keys) }; resultDic.Add(orderSheet, orderList); betSheetDic.Clear(); } this._betResult = returnResult; return resultDic; }
public void Insert(BetSheet sheet) { string sql = string.Format(@"INSERT INTO {0} ({1},{2},{3},{4},{5},{6}) VALUES (@{1},@{2},@{3},@{4},@{5},@{6}) SELECT SCOPE_IDENTITY()", BetSheet.TABLENAME, BetSheet.USERID, BetSheet.NUM, BetSheet.STATUS, BetSheet.IPADDRESS, BetSheet.BETCOMPANY, BetSheet.BETAMOUNT); object id = base.ExecuteScalar(sql, new SqlParameter(BetSheet.USERID, sheet.UserId), new SqlParameter(BetSheet.NUM, sheet.Num), new SqlParameter(BetSheet.STATUS, (int)sheet.Status), new SqlParameter(BetSheet.IPADDRESS, sheet.IPAddress), new SqlParameter(BetSheet.BETCOMPANY, sheet.BetCompany), new SqlParameter(BetSheet.BETAMOUNT, sheet.BetAmount)); sheet.SheetId = Convert.ToInt32(id); }