在线时间发钱存储过程修改

IF EXISTS ( SELECT memb___id FROM MEMB_STAT WITH (READUNCOMMITTED)
WHERE memb___id = @uid )
Begin
UPDATE MEMB_STAT
SET DisConnectTM = (getdate()), connectstat = 0 WHERE memb___id = @uid


--根据在线时间发money
IF EXISTS ( SELECT UserID FROM LOG_UserLogin WITH (READUNCOMMITTED) WHERE UserID = @uid and logoutTM is null)
Begin
declare @ntm datetime
declare @otm int
declare @mny int
set @ntm=getdate()
select @otm=datediff(minute,LoginTM,@ntm) from LOG_UserLogin where UserID = @uid and logoutTM is null
set @mny=@otm*50000
--发钱到仓库
update warehouse set [money]=(case when [money">2000000000-@mny>[money] then [money]+@mny else 2000000000 end)
where accountid=@uid
--写入到登录详细记录
UPDATE LOG_UserLogin
SET LogoutTM = @ntm,OnlineSec=@otm,GiveMoney=@mny
WHERE UserID = @uid and logoutTM is null
--生成积分
declare @ll int
,@jf int
,@jfbl int
,@ctm int
set @jfbl=1 --设置积分兑换比例 1/X
select @ctm=CountTime,@ll=LastCount from ExtIdData where accountid=@uid
--写入扩展用户ID数据
if @ctm is not null begin
set @jf=cast((@ctm+@otm-@ll)/@jfbl as int)
update ExtIdData set counttime=counttime+@otm,lastlogin=getdate()
,HaveCents=HaveCents+@jf,LastCount=@ll+@jf*@jfbl
where accountid=@uid
end else begin
set @jf=cast(@otm/@jfbl as int)
insert into ExtIdData (accountid,counttime,lastlogin,LastCount,HaveCents)
values (@uid,@otm,getdate(),@jf*@jfbl,@jf)
end
End
End

 

本文出自 7j45 > 奇迹一条龙