Example #1
0
        public int TelCodeVerify(int serverID, int czoneID, int croleID, int telCode)
        {
            if (!IsAgent(serverID))
            {
                return((int)ESpreadState.EServer);
            }

            KFSpreadKey        ckey       = KFSpreadKey.Get(czoneID, croleID);
            KFSpreadVerifyData verifyData = null;

            if (!_spreadVerifyDataDic.TryGetValue(ckey, out verifyData))
            {
                return((int)ESpreadState.EVerifyNo);
            }

            //推广员
            KFSpreadData pData = GetSpreadData(verifyData.PZoneID, verifyData.PRoleID);

            if (pData == null)
            {
                return((int)ESpreadState.EVerifyCodeWrong);
            }
            pData.UpdateLogtime();

            if (verifyData.TelCode != telCode)
            {
                return((int)ESpreadState.ETelCodeWrong);
            }

            if (DateTime.Now.AddSeconds(-TEL_CODE_OUT_TIME) > verifyData.TelTime)
            {
                return((int)ESpreadState.ETelCodeOutTime);
            }

            //验证成功加数据库
            bool result = SpreadPersistence.Instance.DBSpreadRoleAdd(
                verifyData.PZoneID, verifyData.PRoleID, verifyData.CUserID, verifyData.CZoneID, verifyData.CRoleID, verifyData.Tel, verifyData.IsVip, verifyData.IsLevel);

            if (!result)
            {
                return((int)ESpreadState.Fail);
            }

            //推广员
            lock (pData)
            {
                pData.CountLevel += verifyData.IsLevel;
                pData.CountVip   += verifyData.IsVip;
                pData.CountRole  += 1;

                if (pData.ServerID > 0)
                {
                    NotifySpreadData(pData);
                }
            }

            _spreadVerifyDataDic.TryRemove(ckey, out verifyData);
            return((int)ESpreadState.Success);
        }
Example #2
0
        public int TelCodeVerify(int serverID, int czoneID, int croleID, int telCode)
        {
            int result;

            if (!this.IsAgent(serverID))
            {
                result = -5;
            }
            else
            {
                KFSpreadKey        ckey       = KFSpreadKey.Get(czoneID, croleID);
                KFSpreadVerifyData verifyData = null;
                if (!this._spreadVerifyDataDic.TryGetValue(ckey, out verifyData))
                {
                    result = -10;
                }
                else
                {
                    KFSpreadData pData = this.GetSpreadData(verifyData.PZoneID, verifyData.PRoleID);
                    if (pData == null)
                    {
                        result = -14;
                    }
                    else
                    {
                        pData.UpdateLogtime();
                        if (verifyData.TelCode != telCode)
                        {
                            result = -34;
                        }
                        else if (TimeUtil.NowDateTime().AddSeconds(-90.0) > verifyData.TelTime)
                        {
                            result = -35;
                        }
                        else if (!SpreadPersistence.Instance.DBSpreadRoleAdd(verifyData.PZoneID, verifyData.PRoleID, verifyData.CUserID, verifyData.CZoneID, verifyData.CRoleID, verifyData.Tel, verifyData.IsVip, verifyData.IsLevel))
                        {
                            result = -1;
                        }
                        else
                        {
                            lock (pData)
                            {
                                pData.CountLevel += verifyData.IsLevel;
                                pData.CountVip   += verifyData.IsVip;
                                pData.CountRole++;
                                if (pData.ServerID > 0)
                                {
                                    this.NotifySpreadData(pData);
                                }
                            }
                            this._spreadVerifyDataDic.TryRemove(ckey, out verifyData);
                            result = 1;
                        }
                    }
                }
            }
            return(result);
        }
Example #3
0
        public int TelCodeGet(int cserverID, int czoneID, int croleID, string tel)
        {
            int result;

            if (!this.IsAgent(cserverID))
            {
                result = -5;
            }
            else
            {
                KFSpreadKey        ckey       = KFSpreadKey.Get(czoneID, croleID);
                KFSpreadVerifyData verifyData = null;
                if (!this._spreadVerifyDataDic.TryGetValue(ckey, out verifyData))
                {
                    result = -10;
                }
                else
                {
                    bool isTelBind = SpreadPersistence.Instance.DBSpreadTelBind(tel);
                    if (isTelBind)
                    {
                        result = -32;
                    }
                    else
                    {
                        KFSpreadTelTotal totalData = this.GetTelTotalData(tel, true);
                        if (totalData.IsStop)
                        {
                            result = -36;
                        }
                        else
                        {
                            KFSpreadRoleTotal roleTotalData = this.GetRoleTotalData(cserverID, czoneID, croleID, true);
                            if (roleTotalData.IsStop)
                            {
                                result = -16;
                            }
                            else
                            {
                                verifyData.Tel     = tel;
                                verifyData.TelCode = this.GetTelCodeRandom();
                                verifyData.TelTime = TimeUtil.NowDateTime();
                                if (!SpreadPersistence.Instance.DBSpreadTelCodeAdd(verifyData.PZoneID, verifyData.PRoleID, czoneID, croleID, tel, verifyData.TelCode))
                                {
                                    result = -33;
                                }
                                else
                                {
                                    result = 1;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Example #4
0
        public int CheckVerifyCode(int cserverID, string cuserID, int czoneID, int croleID, int pzoneID, int proleID, int isVip, int isLevel)
        {
            if (!IsAgent(cserverID))
            {
                return((int)ESpreadState.EServer);
            }

            //推广员
            KFSpreadData pData = GetSpreadData(pzoneID, proleID);

            if (pData == null)
            {
                return((int)ESpreadState.EVerifyCodeWrong);
            }

            //已验证
            bool isVerify = SpreadPersistence.Instance.DBSpreadVeruftCheck(czoneID, croleID, cuserID);

            if (isVerify)
            {
                return((int)ESpreadState.EVerifyCodeHave);
            }

            //角色验证统计
            KFSpreadRoleTotal roleTotalData = GetRoleTotalData(cserverID, czoneID, croleID);

            if (roleTotalData.IsStop)
            {
                return((int)ESpreadState.EVerifyMore);
            }

            //验证信息
            KFSpreadKey        ckey       = KFSpreadKey.Get(czoneID, croleID);
            KFSpreadVerifyData verifyData = null;

            _spreadVerifyDataDic.TryRemove(ckey, out verifyData);

            verifyData = new KFSpreadVerifyData()
            {
                CUserID   = cuserID,
                CServerID = cserverID,
                CZoneID   = czoneID,
                CRoleID   = croleID,

                PZoneID = pzoneID,
                PRoleID = proleID,
                IsVip   = isVip,
                IsLevel = isLevel,
            };

            _spreadVerifyDataDic.TryAdd(ckey, verifyData);

            return((int)ESpreadState.Success);
        }
Example #5
0
        public int CheckVerifyCode(int cserverID, string cuserID, int czoneID, int croleID, int pzoneID, int proleID, int isVip, int isLevel)
        {
            int result;

            if (!this.IsAgent(cserverID))
            {
                result = -5;
            }
            else
            {
                KFSpreadData pData = this.GetSpreadData(pzoneID, proleID);
                if (pData == null)
                {
                    result = -14;
                }
                else
                {
                    bool isVerify = SpreadPersistence.Instance.DBSpreadVeruftCheck(czoneID, croleID, cuserID);
                    if (isVerify)
                    {
                        result = -12;
                    }
                    else
                    {
                        KFSpreadRoleTotal roleTotalData = this.GetRoleTotalData(cserverID, czoneID, croleID, false);
                        if (roleTotalData.IsStop)
                        {
                            result = -16;
                        }
                        else
                        {
                            KFSpreadKey        ckey       = KFSpreadKey.Get(czoneID, croleID);
                            KFSpreadVerifyData verifyData = null;
                            this._spreadVerifyDataDic.TryRemove(ckey, out verifyData);
                            verifyData = new KFSpreadVerifyData
                            {
                                CUserID   = cuserID,
                                CServerID = cserverID,
                                CZoneID   = czoneID,
                                CRoleID   = croleID,
                                PZoneID   = pzoneID,
                                PRoleID   = proleID,
                                IsVip     = isVip,
                                IsLevel   = isLevel
                            };
                            this._spreadVerifyDataDic.TryAdd(ckey, verifyData);
                            result = 1;
                        }
                    }
                }
            }
            return(result);
        }
Example #6
0
        public int TelCodeGet(int cserverID, int czoneID, int croleID, string tel)
        {
            if (!IsAgent(cserverID))
            {
                return((int)ESpreadState.EServer);
            }

            KFSpreadKey        ckey       = KFSpreadKey.Get(czoneID, croleID);
            KFSpreadVerifyData verifyData = null;

            if (!_spreadVerifyDataDic.TryGetValue(ckey, out verifyData))
            {
                return((int)ESpreadState.EVerifyNo);
            }

            //手机号绑定
            bool isTelBind = SpreadPersistence.Instance.DBSpreadTelBind(tel);

            if (isTelBind)
            {
                return((int)ESpreadState.ETelBind);
            }

            //手机验证统计
            KFSpreadTelTotal totalData = GetTelTotalData(tel, true);

            if (totalData.IsStop)
            {
                return((int)ESpreadState.ETelMore);
            }

            //角色验证统计
            KFSpreadRoleTotal roleTotalData = GetRoleTotalData(cserverID, czoneID, croleID, true);

            if (roleTotalData.IsStop)
            {
                return((int)ESpreadState.EVerifyMore);
            }

            verifyData.Tel     = tel;
            verifyData.TelCode = GetTelCodeRandom();
            verifyData.TelTime = DateTime.Now;

            bool result = SpreadPersistence.Instance.DBSpreadTelCodeAdd(verifyData.PZoneID, verifyData.PRoleID, czoneID, croleID, tel, verifyData.TelCode);

            if (!result)
            {
                return((int)ESpreadState.ETelCodeGet);
            }

            return((int)ESpreadState.Success);
        }