Ejemplo n.º 1
0
        /// <summary>
        /// 获取活动信息
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="zoneName"></param>
        /// <returns></returns>
        public CrossActivityInfoResponse GetActivityInfo(Guid managerId, string zoneName)
        {
            CrossActivityInfoResponse response = new CrossActivityInfoResponse();

            response.Data = new CrossActivityInfo();
            try
            {
                if (!IsActivity)
                {
                    response.Data.IsOpen = false;
                    return(response);
                }
                var managerInfo = NbManagerMgr.GetById(managerId, zoneName);
                if (managerInfo == null)
                {
                    return(ResponseHelper.Create <CrossActivityInfoResponse>(MessageCode.NbParameterError));
                }
                var maxCount = CacheFactory.VipdicCache.GetEffectValue(managerInfo.VipLevel,
                                                                       (int)EnumVipEffect.BeThankfulActivity);
                var usedNumber = CrossactivityRecordMgr.GetActivityNumber(managerId, DateTime.Now.Date);
                response.Data.MaxNumber  = maxCount;
                response.Data.UsedNumber = usedNumber;
                response.Data.GoldBar    = _ActivityInfo.GoldBarNumber;
                //response.Data.PrizeList = CacheFactory.TurntableCache.GetAllPrize();
                response.Data.IsOpen        = true;
                response.Data.ActivityEnd   = ShareUtil.GetTimeTick(_ActivityInfo.EndTime);
                response.Data.ActivityStart = ShareUtil.GetTimeTick(_ActivityInfo.StartTime);
                response.Data.IsPrompt      = maxCount > usedNumber;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取跨服活动信息", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 抽奖
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="zoneName"></param>
        /// <returns></returns>
        public CrossActivityPrizeResponse Prize(Guid managerId, string zoneName)
        {
            CrossActivityPrizeResponse response = new CrossActivityPrizeResponse();

            response.Data = new CrossActivityPrize();
            try
            {
                if (!IsActivity)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.CrowdNoData));
                }
                var managerInfo = NbManagerMgr.GetById(managerId, zoneName);
                if (managerInfo == null)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbParameterError));
                }
                var maxCount = CacheFactory.VipdicCache.GetEffectValue(managerInfo.VipLevel,
                                                                       (int)EnumVipEffect.BeThankfulActivity);
                var usedNumber = CrossactivityRecordMgr.GetActivityNumber(managerId, DateTime.Now.Date);
                if (maxCount <= usedNumber)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.DayNumberNot));
                }
                var result = Prize(managerInfo.VipLevel);
                CrossactivityRecordEntity entity = new CrossactivityRecordEntity(0, managerId, zoneName, result.PrizeId,
                                                                                 DateTime.Now);
                ItemPackageFrame package = null;
                int addPoint             = 0;
                int addGoldBar           = 0;
                int itemCode             = 0;
                int itemCount            = 0;
                var messageCode          = AddPrize(result, managerId, zoneName, ref package, ref addPoint, ref addGoldBar, ref itemCode, ref itemCount);
                if (messageCode != MessageCode.Success)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(messageCode));
                }
                if (addPoint > 0)
                {
                    messageCode = PayCore.Instance.AddBonus(managerInfo.Account, addPoint, EnumChargeSourceType.CrossActivity,
                                                            ShareUtil.GenerateComb().ToString(), null, zoneName);
                    if (messageCode != MessageCode.Success)
                    {
                        return(ResponseHelper.Create <CrossActivityPrizeResponse>(messageCode));
                    }
                }
                else if (package != null)
                {
                    if (!package.Save())
                    {
                        return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbUpdateFail));
                    }
                    package.Shadow.Save();
                }
                else if (addGoldBar > 0)
                {
                    var goldBarManager = ScoutingGoldbarMgr.GetById(managerId, zoneName);
                    if (goldBarManager == null)
                    {
                        goldBarManager = new ScoutingGoldbarEntity(managerId, addGoldBar, 0, 0, 0, DateTime.Now,
                                                                   DateTime.Now);
                        if (!ScoutingGoldbarMgr.Insert(goldBarManager, null, zoneName))
                        {
                            return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbUpdateFail));
                        }
                    }
                    else
                    {
                        goldBarManager.GoldBarNumber = goldBarManager.GoldBarNumber + addGoldBar;
                        if (!ScoutingGoldbarMgr.Update(goldBarManager, null, zoneName))
                        {
                            return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbUpdateFail));
                        }
                    }
                }
                try
                {
                    CrossactivityRecordMgr.Insert(entity);
                }
                catch
                {
                }

                response.Data.MaxNumber  = maxCount;
                response.Data.PrizeId    = result.PrizeId;
                response.Data.UsedNumber = usedNumber + 1;
                response.Data.Number     = itemCount;
                response.Data.ItemCode   = itemCode;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("抽奖", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }