Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
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);
            }
        }