Ejemplo n.º 1
0
 public MessageCode SaveInvitePrize(NbManagerEntity manager, FriendinvitePrizerecordEntity record, ItemPackageFrame package, DbTransaction trans, int coin, string account)
 {
     if (manager != null)
     {
         if (!ManagerUtil.SaveManagerData(manager, null, trans))
         {
             return(MessageCode.NbUpdateFailPackage);
         }
     }
     if (coin > 0)
     {
         var mess = ManagerCore.Instance.AddCoin(manager, coin, EnumCoinChargeSourceType.FriendInvite, Guid.NewGuid().ToString(), trans);
         if (mess != MessageCode.Success)
         {
             return(mess);
         }
     }
     if (!FriendinvitePrizerecordMgr.Insert(record, trans))
     {
         return(MessageCode.NbUpdateFailPackage);
     }
     if (!package.Save(trans))
     {
         return(MessageCode.NbUpdateFailPackage);
     }
     package.Shadow.Save();
     return(MessageCode.Success);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 领取好友成长奖励
        /// </summary>
        /// <param name="account"></param>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public GrowUpPrizeResponse GrowUpPrize(string account, Guid managerId)
        {
            GrowUpPrizeResponse response = new GrowUpPrizeResponse();

            response.Data = new GrowUpPrize();
            try
            {
                var manager = ManagerCore.Instance.GetManager(managerId);
                if (manager == null)
                {
                    return(ResponseHelper.Create <GrowUpPrizeResponse>((int)MessageCode.AdMissManager));
                }
                var list = GetFrindInviteList(account);
                if (list == null)
                {
                    return(ResponseHelper.Create <GrowUpPrizeResponse>((int)MessageCode.ActiveNotPrize));
                }
                FriendinvitePrizerecordEntity record = new FriendinvitePrizerecordEntity();
                int mayPrize = 0;
                foreach (var item in list)
                {
                    record.PrizeInfo += item.ByAccount + ",";
                    mayPrize         += item.MayPrize;
                }
                record.PrizeInfo = record.PrizeInfo.Substring(0, record.PrizeInfo.Length - 1);
                if (mayPrize <= 0)
                {
                    return(ResponseHelper.Create <GrowUpPrizeResponse>((int)MessageCode.ActiveNotPrize));
                }
                record.Account     = account;
                record.UpdateTime  = DateTime.Now;
                record.PrizeType   = 1;
                record.PrizeString = mayPrize.ToString();

                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var messCode = PayCore.Instance.AddBonus(managerId, mayPrize, EnumChargeSourceType.FriendInvite,
                                                             ShareUtil.CreateSequential().ToString(), transactionManager.TransactionObject);
                    if (messCode != MessageCode.Success)
                    {
                        transactionManager.Rollback();
                        return(ResponseHelper.Create <GrowUpPrizeResponse>((int)messCode));
                    }
                    if (!FriendinviteMgr.SavePrize(account, transactionManager.TransactionObject))
                    {
                        transactionManager.Rollback();
                        return(ResponseHelper.Create <GrowUpPrizeResponse>((int)MessageCode.NbParameterError));
                    }
                    if (!FriendinvitePrizerecordMgr.Insert(record, transactionManager.TransactionObject))
                    {
                        transactionManager.Rollback();
                        return(ResponseHelper.Create <GrowUpPrizeResponse>((int)MessageCode.NbParameterError));
                    }
                    transactionManager.Commit();
                    response.Data.Point    = mayPrize;
                    response.Data.SumPoint = PayCore.Instance.GetPoint(managerId);;
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("领取好友邀请奖励", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }