手机绑定类相关数据库脚本BindAccountByMobile.sql,有需要研究,勿照搬!
脚本内容:
USE WHJHAccountsDB GO SET ANSI_NULLS, QUOTED_IDENTIFIER ON GO Alter PROC GSP_MB_EfficacyBindAccount @dwUserID INT, -- 用户标识 @strAccounts NVARCHAR(31), -- 用户帐号 @strPassword NCHAR(32), -- 用户密码 @strErrorDescribe NVARCHAR(127) OUTPUT -- 输出信息 WITH ENCRYPTION AS -- 属性设置 SET NOCOUNT ON -- 基本信息 -- 执行逻辑 BEGIN --查询用户是否绑定过手机 Declare @UserBindID int Select @UserBindID=UserID from WHJHTreasureDB.dbo.ScorePresentInfo where UserID=@dwUserID IF @UserBindID is not null BEGIN SET @strErrorDescribe=N'您已绑定过手机!' RETURN 999 END -- 首先查找这个账号是否已经被不同的ID 绑定过了 --DECLARE @othUserID INT --SELECT @othUserID=UserID FROM AccountsInfo(NOLOCK) WHERE Accounts=@strAccounts --IF @othUserID IS NOT NULL --BEGIN -- SET @strErrorDescribe=N'此手机号码已被其它账号绑定!' -- RETURN 1 --END -- 查询用户 DECLARE @LogonPass AS NCHAR(32) DECLARE @userAccounts AS NVARCHAR(31) DECLARE @userLastLogonMobile AS NVARCHAR(31) DECLARE @checkCode AS NVARCHAR(10) SELECT @LogonPass=LogonPass, @userAccounts=Accounts, @userLastLogonMobile=LastLogonMobile, @checkCode=checkCode FROM AccountsInfo(NOLOCK) WHERE UserID=@dwUserID -- 密码判断 IF @checkCode IS NULL OR @checkCode<>@strPassword BEGIN SET @strErrorDescribe=N'验证码错误!' RETURN 1 END DECLARE @defaultPhoneNum NVARCHAR(16) SET @defaultPhoneNum=N'0123456789' -- 判断是否已经绑定过了 --IF @userLastLogonMobile IS NOT NULL AND @userLastLogonMobile<>N'' AND @userLastLogonMobile<>@defaultPhoneNum --BEGIN -- SET @strErrorDescribe=N'已经绑定过了!' -- RETURN 1 --END DECLARE @othUserID INT SELECT @othUserID=UserID FROM AccountsInfo(NOLOCK) WHERE Accounts=@strAccounts or LastLogonMobile=@strAccounts IF @othUserID IS NULL BEGIN -- 赠/与/金/币 UPDATE WHJHTreasureDBLink.WHJHTreasureDB.dbo.GameScoreInfo SET Score=Score+300 WHERE UserID=@dwUserID END -- 修改账户信息 UPDATE AccountsInfo SET Accounts=@strAccounts, LastLogonMobile=@strAccounts WHERE UserID=@dwUserID --插入赠送记录 Insert into WHJHTreasureDB.dbo.ScorePresentInfo values (@dwUserID,@strAccounts,300,'绑/定/手/机/赠/送/金/币',GETDATE()) -- -- 设置信息 IF @@ERROR=0 SET @strErrorDescribe=N'恭喜账号绑定成功!' RETURN 0 END RETURN 0 GO
END!!!
发表评论