public static List <CboItem> GetLotteryItems() { if (LotteryItems == null) { LotteryItems = new List <CboItem>(); LotteryItems.Add(new CboItem { Id = 0, Name = "全部" }); foreach (var item in EntitiesTool.GetLotteryDic()) { LotteryItems.Add(new CboItem { Id = item.Value.Id, Name = item.Value.LotteryName }); } } return(LotteryItems); }
public Accounts BalanceChange(int AccountId, List <BetInfo> BList) { using (e = new LotteryAPPEntities()) { var dt = EntitiesTool.GetDateTimeNow(e); var account = e.Accounts.FirstOrDefault(n => n.Id == AccountId); using (var tran = new TransactionScope()) { foreach (var BetInfo in BList) { e.BetInfo.Add(BetInfo); e.SaveChanges(); #region 添加业务单 var ab = new AccountBusiness { AccountId = BetInfo.AccountId, BusinessTypeId = (int)Enum_AccountBusinessType.Bet, CreateTime = dt, EventId = BetInfo.Id, PayBefore = account.AccountBalance, PayOut = BetInfo.BetMoney, PayAfter = account.AccountBalance - BetInfo.BetMoney, }; e.AccountBusiness.Add(ab);//投注业务单 account.AccountBalance = ab.PayAfter; #region 返点 if (false) //若不是追号则给返点 { var pList = GetAllParentAccount(AccountId, e); //上级名单(含自己) if (BetInfo.IsGetBackPercent) //如果要返点 { ab = new AccountBusiness { AccountId = BetInfo.AccountId, BusinessTypeId = (int)Enum_AccountBusinessType.BackPercent, CreateTime = dt, EventId = BetInfo.Id, PayBefore = account.AccountBalance, PayIn = (BetInfo.BetMoney * BetInfo.GetBackPercent / 100), }; ab.PayAfter = account.AccountBalance + ab.PayIn.Value; account.AccountBalance = ab.PayAfter; e.AccountBusiness.Add(ab);//返点业务单 } #region 单个玩法投注>0.2元,上级产生返点(固定等级差返点) if (BetInfo.BetMoney >= new decimal(0.2) && pList.Count > 1) { for (int i = 1; i < pList.Count; i++) { var payIn = EntitiesTool.GetLotteryDic().FirstOrDefault(n => n.Value.Id == BetInfo.LotteryId).Value.LotteryType == "11x5" ? BetInfo.BetMoney * (pList[i].AgentPercent11X5 - pList[i - 1].AgentPercent11X5) / 100 : BetInfo.BetMoney * (pList[i].AgentPercentSSC - pList[i - 1].AgentPercentSSC) / 100; ab = new AccountBusiness { AccountId = pList[i].Id, BusinessTypeId = (int)Enum_AccountBusinessType.BackPercent, CreateTime = dt, EventId = BetInfo.Id, PayBefore = pList[i].AccountBalance, PayIn = payIn, }; ab.PayAfter = pList[i].AccountBalance + ab.PayIn.Value; pList[i].AccountBalance = ab.PayAfter; e.AccountBusiness.Add(ab);//返点业务单 } } #endregion } #endregion #endregion e.SaveChanges(); } tran.Complete(); } return(account); } }