Exemplo n.º 1
0
        static void AddManagerData(Guid managerId, int prizeExp, int prizeCoin, int prizeSophisticate,
                                   EnumCoinChargeSourceType coinSourceType, string coinOrderId)
        {
            NbManagerEntity homeManager = ManagerCore.Instance.GetManager(managerId);

            ManagerUtil.AddManagerData(homeManager, prizeExp, prizeCoin, prizeSophisticate, coinSourceType, coinOrderId);
            ManagerUtil.SaveManagerData(homeManager);
            ManagerUtil.SaveManagerAfter(homeManager, true);
        }
Exemplo n.º 2
0
 public MessageCode AddManagerData(Guid managerId, int prizeExp, int prizeCoin, int prizeSophisticate)
 {
     try
     {
         NbManagerEntity homeManager = ManagerCore.Instance.GetManager(managerId);
         ManagerUtil.AddManagerData(homeManager, prizeExp, prizeCoin, prizeSophisticate, EnumCoinChargeSourceType.AdminAdd, "");
         ManagerUtil.SaveManagerData(homeManager);
         ManagerUtil.SaveManagerAfter(homeManager, true);
         return(MessageCode.Success);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("AdminCore:AddManagerData", ex);
         return(MessageCode.Exception);
     }
 }
Exemplo n.º 3
0
        public NBManagerInfoResponse Levelup(Guid managerId)
        {
            var manager    = ManagerCore.Instance.GetManager(managerId);
            var levelupExp = CacheFactory.ManagerDataCache.GetExp(manager.Level);

            if (levelupExp > 0)
            {
                levelupExp = levelupExp - manager.EXP + 1;
                ManagerUtil.AddManagerData(manager, levelupExp, 0, 0, EnumCoinChargeSourceType.None, "");
                if (ManagerUtil.SaveManagerData(manager))
                {
                    ManagerUtil.SaveManagerAfter(manager);
                    return(ManagerCore.Instance.GetManagerInfo(managerId, false));
                }
                else
                {
                    return(ResponseHelper.Create <NBManagerInfoResponse>(MessageCode.NbUpdateFail));
                }
            }
            else
            {
                return(ResponseHelper.Create <NBManagerInfoResponse>(MessageCode.NbManagerLevelOver));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 领取竞猜正确活动奖励
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="step"></param>
        /// <returns></returns>
        public EuropeGambleMatchResponse DrawPrize(Guid managerId, int step)
        {
            EuropeGambleMatchResponse response = new EuropeGambleMatchResponse();

            response.Data = new EuropeGambleMatch();
            try
            {
                var manager = ManagerCore.Instance.GetManager(managerId);
                if (manager == null)
                {
                    response.Code = (int)MessageCode.MissManager;
                    return(response);
                }
                var info      = GetMyGambleInfo(managerId);
                var prizeList = info.PrizeRecord.Split(',');
                if (prizeList.Length < step || prizeList[step - 1] == "0")
                {
                    response.Code = (int)MessageCode.TourNoPassPrize;
                    return(response);
                }
                if (prizeList[step - 1] == "2")
                {
                    response.Code = (int)MessageCode.NbPrizeRepeat;
                    return(response);
                }
                var prizeConfig = EuropeConfig.Instance.GetPrize(step);
                if (prizeConfig.Count <= 0)
                {
                    response.Code = (int)MessageCode.ActivityNoConfigPrize;
                    return(response);
                }
                ItemPackageFrame package = null;

                prizeList[step - 1] = "2";
                info.PrizeRecord    = String.Join(",", prizeList);
                info.UpdateTime     = DateTime.Now;
                int addPoint = 0;
                int addCoin  = 0;
                foreach (var prize in prizeConfig)
                {
                    switch (prize.PrizeType)
                    {
                    case 1:
                        addPoint += prize.PrizeCount;
                        break;

                    case 2:
                        addCoin += prize.PrizeCount;
                        break;

                    case 3:
                        if (package == null)
                        {
                            package = ItemCore.Instance.GetPackage(managerId,
                                                                   Entity.Enums.Shadow.EnumTransactionType.EuropeConfig);
                            if (package == null)
                            {
                                return(ResponseHelper.Create <EuropeGambleMatchResponse>(MessageCode.NbNoPackage));
                            }
                        }
                        package.AddItems(prize.PrizeCode, prize.PrizeCount);
                        break;
                    }
                }
                if (addCoin > 0)
                {
                    ManagerUtil.AddManagerData(manager, 0, addCoin, 0, EnumCoinChargeSourceType.Eruope,
                                               ShareUtil.GenerateComb().ToString());
                }

                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var code = MessageCode.FailUpdate;
                    do
                    {
                        if (addPoint > 0)
                        {
                            code = PayCore.Instance.AddBonus(managerId, addPoint, EnumChargeSourceType.Europe,
                                                             ShareUtil.GenerateComb().ToString(), transactionManager.TransactionObject);
                            if (code != MessageCode.Success)
                            {
                                break;
                            }
                        }
                        if (addCoin > 0)
                        {
                            if (!ManagerUtil.SaveManagerData(manager, null, transactionManager.TransactionObject))
                            {
                                break;
                            }
                        }
                        if (package != null)
                        {
                            if (!package.Save(transactionManager.TransactionObject))
                            {
                                break;
                            }
                            package.Shadow.Save();
                        }
                        if (!EuropeGambleMgr.Update(info, transactionManager.TransactionObject))
                        {
                            break;
                        }
                        code = MessageCode.Success;
                    } while (false);

                    if (code != MessageCode.Success)
                    {
                        transactionManager.Rollback();
                        response.Code = (int)MessageCode.GamblePayError;
                        return(response);
                    }
                    transactionManager.Commit();
                    response.Data.Point = PayCore.Instance.GetPoint(managerId);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("领取竞猜正确活动奖励", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }