Пример #1
0
        TurntableInfo GetTurntableInfo(TurntableFrame turntable)
        {
            TurntableInfo data             = new TurntableInfo();
            var           turntableManager = turntable.TurntableManagerEntity;

            data.DayProduceLuckyCoin = turntableManager.DayProduceLuckyCoin;
            data.FreeOfChargeNumber  = turntableManager.GiveLuckyCoin;
            data.LuckyCoin           = turntableManager.LuckyCoin;
            data.TurntableType       = turntableManager.TurntableType;
            data.NextResetPoint      = turntable.GetResetPoint();
            data.ItemList            = turntable.GetTurntableList();
            data.StartTimeTick       = ShareUtil.GetTimeTick(startTime);
            data.EndTimeTick         = ShareUtil.GetTimeTick(endTime);
            return(data);
        }
Пример #2
0
        /// <summary>
        /// 重置转盘
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public TurntableResetResponse ResetTurntable(Guid managerId)
        {
            TurntableResetResponse response = new TurntableResetResponse();

            response.Data = new TurntableReset();
            try
            {
                var turntable = new TurntableFrame(managerId);
                if (turntable == null)
                {
                    return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.NbParameterError));
                }
                if (!turntable.TurnTableDic.ItemList.Exists(r => !r.IsEffective)) //不需要重置
                {
                    return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.TurntableNotReset));
                }
                int consumePoint = turntable.GetResetPoint(turntable.TurntableManagerEntity.TurntableType);
                if (consumePoint == 0)
                {
                    return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.NbParameterError));
                }
                var point = PayCore.Instance.GetPoint(managerId);
                if (point < consumePoint)//钻石不足
                {
                    return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.NbPointShortage));
                }
                //重置
                turntable.Reset(turntable.TurntableManagerEntity.TurntableType);
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main)))
                {
                    transactionManager.BeginTransaction();
                    MessageCode messageCode = MessageCode.NbUpdateFail;
                    do
                    {
                        messageCode = PayCore.Instance.GambleConsume(managerId, consumePoint, ShareUtil.GenerateComb(), EnumConsumeSourceType.Turntable, transactionManager.TransactionObject);
                        if (messageCode != MessageCode.Success)
                        {
                            break;
                        }
                        if (!turntable.Save(transactionManager.TransactionObject))
                        {
                            messageCode = MessageCode.NbUpdateFail;
                            break;
                        }
                        messageCode = MessageCode.Success;
                    } while (false);
                    if (messageCode == MessageCode.Success)
                    {
                        transactionManager.Commit();
                    }
                    else
                    {
                        transactionManager.Rollback();
                        return(ResponseHelper.Create <TurntableResetResponse>((int)messageCode));
                    }
                }
                response.Data.TurntableInfo = GetTurntableInfo(turntable);
                response.Data.Point         = point - consumePoint;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("重置转盘", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }