Advertisement
vitas13

MuProcCOnnectMem

Sep 29th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. USE [MuOnline]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[WZ_CONNECT_MEMB] Script Date: 06/14/2018 20:33:25 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8.  
  9.  
  10. --
  11. -- Definition for stored procedure WZ_CONNECT_MEMB :
  12. --
  13.  
  14. ALTER PROCEDURE [dbo].[WZ_CONNECT_MEMB]
  15. @memb___id varchar(10),
  16. @ServerName varchar(50),
  17. @IP varchar(20)
  18. AS
  19. Begin
  20. set nocount on
  21. Declare @find_id varchar(10)
  22. Declare @ConnectStat tinyint
  23. Declare @disconnect_time varchar(20)
  24. Declare @vip_till_time varchar(20)
  25. Declare @vip_ends_at varchar(20)
  26. Set @find_id = 'NOT'
  27. Set @disconnect_time = 'NOT'
  28. Set @vip_till_time = 'NOT'
  29. Set @vip_ends_at = 'NOT'
  30. Set @ConnectStat = 1 -- ?? ?? ? 1 = ??, 0 = ??X
  31.  
  32. select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id
  33. where I.memb___id = @memb___id
  34.  
  35. if( @find_id = 'NOT' )
  36. begin
  37. insert into MEMB_STAT (memb___id,ConnectStat,ServerName,IP,ConnectTM, DisConnectTM)
  38. values(@memb___id, @ConnectStat, @ServerName, @IP, getdate(), getdate())
  39. end
  40. else
  41. update MEMB_STAT set ConnectStat = @ConnectStat,
  42. ServerName = @ServerName,IP = @IP,
  43. ConnectTM = getdate()
  44. where memb___id = @memb___id
  45. select @disconnect_time = DisConnectTM from MEMB_STAT where memb___id = @memb___id
  46. if ( @disconnect_time != 'NOT' )
  47. begin
  48. SELECT @vip_till_time = DATEADD(mi, (DATEDIFF(mi, @disconnect_time, getdate()) / 10), getdate())
  49. SELECT @vip_ends_at = AccountExpireDate FROM MEMB_INFO WHERE memb___id = @memb___id
  50. if ((DATEDIFF(mi, @disconnect_time, getdate()) / 15) > 5)
  51. begin
  52. if (DATEDIFF(mi, @vip_till_time, @vip_ends_at) > 0)
  53. begin
  54. SELECT @vip_till_time = DATEADD(mi, (DATEDIFF(mi, @disconnect_time, getdate()) / 10), @vip_ends_at)
  55. UPDATE MEMB_INFO SET AccountLevel = 1,AccountExpireDate = @vip_till_time WHERE memb___id = @memb___id
  56. end
  57. else
  58. UPDATE MEMB_INFO SET AccountLevel = 1,AccountExpireDate = @vip_till_time WHERE memb___id = @memb___id
  59. end
  60. end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement