예제 #1
0
        public void ModifyNotice(NoticeInfo noticeInfo)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    NoticeManager manager = new NoticeManager(tran);

                    NoticeEntity entity = manager.GetNotice(noticeInfo.Id);
                    if (entity == null)
                    {
                        throw new ArgumentNullException("通知数据不存在!!");
                    }
                    entity.Name        = noticeInfo.Name;
                    entity.Title       = noticeInfo.Title;
                    entity.IsHasDetail = noticeInfo.IsHasDetail;
                    entity.Message     = noticeInfo.Message;
                    entity.IsForeRed   = noticeInfo.IsForeRed;
                    entity.IsForeBold  = noticeInfo.IsForeBold;
                    entity.StartTime   = noticeInfo.StartTime;
                    entity.EndTime     = noticeInfo.EndTime;
                    entity.IsEnd       = noticeInfo.IsEnd;
                    manager.ModifyNotice(entity);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                throw HandleException("Notice", "Modify", ex);
            }
        }
예제 #2
0
        public void Write(string category, string source, LogType logType, string logMsg, string detail)
        {
            Guid id = Guid.NewGuid();

            LogEntity log = new LogEntity();

            log.Id       = id;
            log.Category = category;
            log.Source   = source;
            log.Type     = (short)logType;
            log.Message  = logMsg;

            LogDetailEntity logDetail = new LogDetailEntity();

            logDetail.Id        = id;
            logDetail.LogDetail = detail;

            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    LogManager manager = new LogManager(tran);
                    manager.AddLog(log);
                    manager.AddLogDetail(logDetail);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                FileLogWriter writer = new FileLogWriter();
                writer.Write(LogCategory.LogWrite, "Write log to database", ex);
                writer.Write(category, source, logType, logMsg, detail);
            }
        }
예제 #3
0
        public void RequestGetMoney(string userId, int bankType, string bankName, string cardNumber, decimal money)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    UserManager  userManager  = new UserManager(tran);
                    MoneyManager moneyManager = new MoneyManager(tran);

                    UserBalanceEntity balance = userManager.GetBalance(userId);
                    if (money > balance.EnableMoney)
                    {
                        throw new FacadeException("余额不足");
                    }
                    MoneyGetDetailEntity moneyGetRequest = new MoneyGetDetailEntity();
                    moneyGetRequest.UserId         = userId;
                    moneyGetRequest.BankType       = bankType;
                    moneyGetRequest.BankName       = bankName;
                    moneyGetRequest.BankCardNumber = cardNumber;
                    moneyGetRequest.RequestMoney   = money;
                    moneyGetRequest.Status         = (int)MoneyGetStatus.Requesting;
                    moneyManager.AddMoneyGetRequest(moneyGetRequest);

                    if (balance.Freeze.HasValue)
                    {
                        balance.Freeze = balance.Freeze.Value + money;
                    }
                    else
                    {
                        balance.Freeze = money;
                    }
                    userManager.ModifyBalance(balance);

                    tran.Commit();
                }
            }
            catch (FacadeException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                HandleException(LogCategory.Money, "申请提款失败!", ex);
                throw new FacadeException("申请提款失败!");
            }
        }
예제 #4
0
        public void ChaseTicket(IList <ChaseAddInfo> chaseList)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    UserManager   userManager   = new UserManager(tran);
                    TicketManager ticketManager = new TicketManager(tran);

                    foreach (ChaseAddInfo chase in chaseList)
                    {
                        ChaseEntity chaseEntity = new ChaseEntity();
                        chaseEntity.TicketId     = chase.TicketId;
                        chaseEntity.GameName     = chase.GameName;
                        chaseEntity.IssuseNumber = chase.IssuseNumber;
                        chaseEntity.Amount       = chase.Amount;
                        chaseEntity.Money        = chase.Money;
                        chaseEntity.UserId       = chase.UserId;
                        chaseEntity.Status       = (int)ChaseStatus.Chasing;
                        ticketManager.AddTicketChase(chaseEntity);

                        UserBalanceEntity balance = userManager.GetBalance(chase.UserId);
                        if (balance == null)
                        {
                            throw new FacadeException("帐户不存在,请先充值!");
                        }
                        decimal balanceMoney = balance.Balance.HasValue ? balance.Balance.Value : 0;
                        decimal freezeMoney  = balance.Freeze.HasValue ? balance.Freeze.Value : 0;
                        decimal enableMoney  = balanceMoney - freezeMoney;
                        if (enableMoney < chase.Money)
                        {
                            throw new FacadeException("帐户余额不足,请先充值!");
                        }
                        // 更新用户余额 - 冻结金额
                        balance.Freeze += chase.Money;
                        userManager.ModifyBalance(balance);
                    }
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                throw HandleException(LogCategory.Ticket, "添加追号失败!", ex);
            }
        }
예제 #5
0
        public void AcceptRequestGetMoney(long id, string operateUserId, string message)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    UserManager  userManager  = new UserManager(tran);
                    MoneyManager moneyManager = new MoneyManager(tran);

                    MoneyGetDetailEntity moneyGetDetail = moneyManager.GetMoneyGetDetailEntity(id);
                    if (moneyGetDetail.Status != (int)MoneyGetStatus.Requesting)
                    {
                        throw new FacadeException("此请求已经被处理!");
                    }
                    UserBalanceEntity balance = userManager.GetBalance(moneyGetDetail.UserId);
                    if (balance.Freeze.Value < moneyGetDetail.RequestMoney)
                    {
                        throw new FacadeException("用户账户发生异常,冻结金额不足!");
                    }

                    moneyGetDetail.Status          = (int)MoneyGetStatus.Accepted;
                    moneyGetDetail.ResponseUserId  = operateUserId;
                    moneyGetDetail.ResponseMoney   = moneyGetDetail.RequestMoney;
                    moneyGetDetail.ResponseMessage = message;
                    moneyManager.ModifyMoneyGetResponseStatus(moneyGetDetail);

                    balance.Freeze  -= moneyGetDetail.RequestMoney;
                    balance.Balance -= moneyGetDetail.RequestMoney;
                    userManager.ModifyBalance(balance);

                    tran.Commit();
                }
            }
            catch (FacadeException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                HandleException(LogCategory.Money, "处理接受提款申请失败!", ex);
                throw new FacadeException("处理接受提款申请失败!");
            }
        }
예제 #6
0
        public BonusNoticeInfo AddBonusNotify(string xml)
        {
            BonusNoticeInfo info = XmlAnalyzer.AnalyseXmlToCommunicationObject <BonusNoticeInfo>(xml);

            try
            {
                BonusEntity bonusEntity = new BonusEntity();
                bonusEntity.GameName      = info._Body._BonusInfo._Issue.GameName;
                bonusEntity.IssuseNumber  = info._Body._BonusInfo._Issue.Number;
                bonusEntity.BonusNumber   = info._Body._BonusInfo.BonusNumber;
                bonusEntity.TotalItems    = info._Body._BonusInfo.TotalItems;
                bonusEntity.TotalMoney    = info._Body._BonusInfo.TotalMoney;
                bonusEntity.NoticeId      = info.Id;
                bonusEntity.IsDistributed = false;
                using (ILHDBTran tran = BeginTran())
                {
                    BonusManager bonusManager = new BonusManager(tran);
                    bonusManager.AddBonus(bonusEntity);
                    List <BonusDetailEntity> bonusDetailList = new List <BonusDetailEntity>();
                    foreach (BonusMappingInfo.BonusItem bonusItem in info._Body._BonusInfo._BonusItemList)
                    {
                        BonusDetailEntity detail = new BonusDetailEntity();
                        detail.TicketId     = bonusItem.TicketId;
                        detail.BonusLevel   = bonusItem.BonusLevel;
                        detail.PlayType     = (int)bonusItem.PlayType;
                        detail.Money        = bonusItem.Money;
                        detail.IsBombBonus  = bonusItem.IsBombBonus;
                        detail.Size         = bonusItem.Size;
                        detail.GameName     = bonusEntity.GameName;
                        detail.IssuseNumber = bonusEntity.IssuseNumber;
                        bonusManager.AddBonusDetail(detail);
                    }
                    tran.Commit();
                }
                return(info);
            }
            catch (Exception ex)
            {
                string errMsg = "添加返奖通知失败!" + xml;
                throw HandleException(LogCategory.Notice, errMsg, ex);
            }
        }
예제 #7
0
        public void Register(UserInfo user, string password)
        {
            LoginEntity loginEntity = new LoginEntity();

            loginEntity.UserId     = user.UserId;
            loginEntity.UserName   = user.UserName;
            loginEntity.IsCanLogin = true;

            UserBaseEntity userBaseEntity = new UserBaseEntity();

            userBaseEntity.UserId     = user.UserId;
            userBaseEntity.RealName   = user.RealName;
            userBaseEntity.Email      = user.Email;
            userBaseEntity.CardType   = user.IdCardType;
            userBaseEntity.CardNumber = user.IdCardNumber;
            userBaseEntity.Mobile     = user.Mobile;

            UserBalanceEntity balanceEntity = new UserBalanceEntity();

            balanceEntity.UserId  = user.UserId;
            balanceEntity.Balance = 0;
            balanceEntity.Freeze  = 0;

            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    UserManager manager = new UserManager(tran);
                    password = EncryptTool.MD5(password);
                    manager.AddLogin(loginEntity, password);
                    manager.AddUserBase(userBaseEntity);
                    manager.AddBalance(balanceEntity);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                string errMsg = "注册新用户失败 - 系统异常,请联系系统管理员!";
                throw HandleException(LogCategory.Register, errMsg, ex);
            }
        }
예제 #8
0
        public void SaveParam(ParamInfo param)
        {
            try
            {
                ParamEntity entity = new ParamEntity();
                entity.Key   = param.Key;
                entity.Value = param.Value;

                using (ILHDBTran tran = BeginTran())
                {
                    ParamManager manager = new ParamManager(tran);
                    manager.DeleteParam(entity);
                    manager.AddParam(entity);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                throw HandleException("Param", "保存系统参数失败 - " + param.Key, ex);
            }
        }
예제 #9
0
        public void Write(string category, string source, Exception exception)
        {
            if (exception == null)
            {
                return;
            }
            Guid id = Guid.NewGuid();

            LogEntity log = new LogEntity();

            log.Id       = id;
            log.Category = category;
            log.Source   = source;
            log.Type     = (short)LogType.Error;
            log.Message  = exception.Message;

            LogDetailEntity logDetail = new LogDetailEntity();

            logDetail.Id        = id;
            logDetail.LogDetail = LogHelper.GetExceptionMessage(exception);

            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    LogManager manager = new LogManager(tran);
                    manager.AddLog(log);
                    manager.AddLogDetail(logDetail);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                FileLogWriter writer = new FileLogWriter();
                writer.Write(LogCategory.LogWrite, "Write log to database", ex);
                writer.Write(category, source, exception);
            }
        }
예제 #10
0
        /// <summary>
        /// 更新投注响应状态
        /// </summary>
        public void UpdateTicketStatus(TicketMappingInfo ticket, UserInfo user, HPResponseInfo response)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    UserManager   userManager   = new UserManager(tran);
                    TicketManager ticketManager = new TicketManager(tran);

                    TicketDetailEntity tmp = ticketManager.GetFreezeTicketDetail(ticket.TicketId, user.UserId);
                    if (tmp == null || tmp.Status != (int)TicketStatus.Requesting)
                    {
                        throw new FacadeException("帐户数据错误,请联系系统管理员!");
                    }
                    UserBalanceEntity balance = userManager.GetBalance(user.UserId);
                    if (balance == null)
                    {
                        throw new FacadeException("帐户不存在,请先充值!");
                    }
                    TicketEntity entity = ticketManager.GetTicket(ticket.TicketId);
                    if (entity == null)
                    {
                        throw new FacadeException("出票数据错误,请联系管理员!");
                    }
                    if (response.Code == "0000")
                    {
                        entity.Status = (int)TicketStatus.Determinate;

                        TicketDetailEntity detail = new TicketDetailEntity();
                        detail.UserId        = user.UserId;
                        detail.TicketId      = ticket.TicketId;
                        detail.BalanceBefore = tmp.BalanceAfter;
                        detail.FreezeBefore  = tmp.FreezeAfter;
                        detail.PayMoney      = tmp.PayMoney;
                        detail.BalanceAfter  = tmp.BalanceAfter - tmp.PayMoney;
                        detail.FreezeAfter   = tmp.FreezeAfter - tmp.PayMoney;
                        detail.Status        = (int)TicketStatus.Determinate;
                        detail.Message       = "落地 - 更新金额并解冻" + tmp.PayMoney;
                        detail.CurrentTime   = DateTime.Now;
                        // 添加彩票购买明细日志记录 - 状态为落地
                        ticketManager.AddTicketDetail(detail);

                        balance.Balance -= tmp.PayMoney;
                        balance.Freeze  -= tmp.PayMoney;
                        userManager.ModifyBalance(balance);
                    }
                    else
                    {
                        entity.Status = (int)TicketStatus.Error;

                        TicketDetailEntity detail = new TicketDetailEntity();
                        detail.UserId        = user.UserId;
                        detail.TicketId      = ticket.TicketId;
                        detail.BalanceBefore = tmp.BalanceAfter;
                        detail.FreezeBefore  = tmp.FreezeAfter;
                        detail.PayMoney      = tmp.PayMoney;
                        detail.BalanceAfter  = tmp.BalanceAfter;
                        detail.FreezeAfter   = tmp.FreezeAfter - tmp.PayMoney;
                        detail.Status        = (int)TicketStatus.Error;
                        detail.Message       = "错误 - " + response.Message + " - 恢复冻结金额" + ticket.Money;
                        detail.CurrentTime   = DateTime.Now;
                        // 添加彩票购买明细日志记录 - 状态为错误
                        ticketManager.AddTicketDetail(detail);

                        balance.Freeze -= tmp.PayMoney;
                        userManager.ModifyBalance(balance);
                    }
                    entity.ResponseCode    = response.Code;
                    entity.ResponseMessage = response.Message;
                    entity.ResponseTime    = DateTime.Now;

                    ticketManager.ModifyTicket(entity);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                throw HandleException(LogCategory.Ticket, "更新投注状态失败! - " + ex.Message, ex, ticket, response);
            }
        }
예제 #11
0
        /// <summary>
        /// 投注购票
        /// </summary>
        public void BuyTicket(TicketMappingInfo ticket, UserInfo user)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    UserManager   userManager   = new UserManager(tran);
                    TicketManager ticketManager = new TicketManager(tran);

                    UserBalanceEntity balance = userManager.GetBalance(user.UserId);
                    if (balance == null)
                    {
                        throw new FacadeException("帐户不存在,请先充值!");
                    }
                    decimal balanceMoney = balance.Balance.HasValue ? balance.Balance.Value : 0;
                    decimal freezeMoney  = balance.Freeze.HasValue ? balance.Freeze.Value : 0;
                    decimal enableMoney  = balanceMoney - freezeMoney;
                    if (enableMoney < ticket.Money)
                    {
                        throw new FacadeException("帐户余额不足,请先充值!");
                    }

                    TicketDetailEntity detail = new TicketDetailEntity();
                    detail.UserId        = user.UserId;
                    detail.TicketId      = ticket.TicketId;
                    detail.BalanceBefore = balanceMoney;
                    detail.FreezeBefore  = freezeMoney;
                    detail.PayMoney      = ticket.Money;
                    detail.BalanceAfter  = balanceMoney;
                    detail.FreezeAfter   = freezeMoney + ticket.Money;
                    detail.Status        = (int)TicketStatus.Requesting;
                    detail.Message       = "投注 - 冻结金额" + ticket.Money;
                    detail.CurrentTime   = DateTime.Now;
                    // 添加彩票购买明细日志记录 - 状态为请求中
                    ticketManager.AddTicketDetail(detail);
                    // 更新用户余额 - 冻结金额
                    balance.Freeze += ticket.Money;
                    userManager.ModifyBalance(balance);

                    TicketEntity entity = new TicketEntity();
                    entity.TicketId     = ticket.TicketId;
                    entity.BuyType      = (int)ticket.BuyType;
                    entity.Amount       = ticket.Amount;
                    entity.Money        = ticket.Money;
                    entity.UserId       = user.UserId;
                    entity.GameName     = ticket.IssueInfo.GameName;
                    entity.IssuseNumber = ticket.IssueInfo.Number;
                    entity.Status       = (int)TicketStatus.Requesting;
                    entity.RequestTime  = DateTime.Now;
                    ticketManager.AddTicket(entity);
                    foreach (string code in ticket.AnteCodes)
                    {
                        TicketAnteCodeEntity anteCode = new TicketAnteCodeEntity();
                        anteCode.TicketId = ticket.TicketId;
                        anteCode.AnteCode = code;
                        ticketManager.AddAnteCode(anteCode);
                    }
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                throw HandleException(LogCategory.Ticket, "投注购票失败!", ex, ticket, user);
            }
        }
예제 #12
0
        public void DistributeBonus(string gameName, string issueNumber)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    BonusManager bonusManger = new BonusManager(tran);
                    UserManager  userManager = new UserManager(tran);

                    BonusEntity bonusEntity = bonusManger.GetBonus(gameName, issueNumber);
                    if (bonusEntity == null)
                    {
                        throw new Exception("要分派的奖期信息不存在 - " + gameName + ":" + issueNumber);
                    }
                    if (bonusEntity.IsDistributed)
                    {
                        throw new Exception("此奖期已经派奖 - " + gameName + ":" + issueNumber);
                    }
                    IList <BonusDetailEntity> bonusDetailList = bonusManger.GetBonusDetailList(gameName, issueNumber);
                    TicketManager             ticketManager   = new TicketManager(tran);
                    foreach (BonusDetailEntity bonusDetail in bonusDetailList)
                    {
                        TicketEntity ticket = ticketManager.GetTicket(bonusDetail.TicketId);
                        if (ticket != null)
                        {
                            BonusDistributeEntity bonusDistribute = new BonusDistributeEntity();
                            bonusDistribute.TicketId     = bonusDetail.TicketId;
                            bonusDistribute.BonusLevel   = bonusDetail.BonusLevel;
                            bonusDistribute.UserId       = ticket.UserId;
                            bonusDistribute.GameName     = bonusDetail.GameName;
                            bonusDistribute.IssuseNumber = bonusDetail.IssuseNumber;
                            bonusDistribute.PlayType     = bonusDetail.PlayType;
                            bonusDistribute.IsBombBonus  = bonusDetail.IsBombBonus;
                            bonusDistribute.BonusSize    = bonusDetail.Size;
                            bonusDistribute.Money        = bonusDetail.Money;

                            bonusManger.AddBonusDistribute(bonusDistribute);

                            UserBalanceEntity balanceEntity = userManager.GetBalance(ticket.UserId);
                            if (balanceEntity == null)
                            {
                                throw new Exception("异常 - 彩民的账户不存在 - " + ticket.UserId);
                            }
                            if (!balanceEntity.Balance.HasValue)
                            {
                                throw new Exception("异常 - 彩民的账户为空 - " + ticket.UserId);
                            }
                            balanceEntity.Balance += bonusDetail.Money;
                            userManager.ModifyBalance(balanceEntity);
                        }
                    }
                    bonusEntity.IsDistributed = true;
                    bonusManger.ModifyBonusDistrbite(bonusEntity);

                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                string errMsg = "派奖失败 - " + gameName + ":" + issueNumber;
                throw HandleException(LogCategory.Distribute, errMsg, ex);
            }
        }