<!--#include file="../inc/Bll.asp"-->
<!--#include file="../inc/Constant.asp"-->
<!--#include file="../inc/Md5.asp"-->
<!--#include file="../inc/App.asp"-->

<%
Auto_Login2()

if Request.QueryString("ac")="uproompay" then 
	dim RGuid,RGunick,GiftID,GiftNum,StoreMoney,GiftPrice,GiftSumParice,GiftName,Rid,StoreMoney2,IsLive
	if Request.QueryString("guid")="" then REND
	if not IsNumeric(Request.QueryString("guid")) then REND
	RGuid=Request.QueryString("guid")
	if Request.QueryString("rid")="" then REND
	if not IsNumeric(Request.QueryString("rid")) then REND
	Rid=Request.QueryString("rid")
	if Session(Session_UserID_Arg)="" then RW "var PayRe=""alert('操作超时请重新登录！')"";":Rend
	GiftPrice = Clng(GetRoomInfo(Rid,"i_Sys_Room_Pay"))
	RS_End
	
	'判断是否正在直播
	RS=DB_CONN.EXECUTE("select a.*,isnull(DateDiff(n,a.[i_User_ForUpdateTime],getdate()),100) as IsLive from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where b.[i_Sys_Room_ID]="&Rid)
	IsLive = Clng(RS("IsLive"))
	if IsLive>1 then Rend
	
	RS_End
	StoreMoney = Clng(GUInfo("i_User_Money"))
	RS_End
	GiftSumParice = Clng(GiftPrice)
	if StoreMoney<GiftSumParice then RW "var PayRe=""alert('余额不足，请充值！')"";":Rend
	RS_End
	RS.Open "select * from [i_User_Info] where [i_User_ID]="&Session(Session_UserID_Arg), DB_CONN , 1 , 3
		RS("i_User_Money")=StoreMoney-GiftSumParice
		RS("i_User_PayNum")=Clng(RS("i_User_PayNum"))+GiftSumParice
		RS.Update()
	RS_End
	RecordConsume GiftSumParice,0,"在（"&Rid&"）房间定时扣费，支出"&Trim(Cstr(GiftSumParice)),Session(Session_UserID_Arg)
	RS_End
	StoreMoney2 = Clng(tGUInfo(RGuid,"i_User_Money"))
	RS_End
	RS.Open "select * from [i_User_Info] where [i_User_ID]="&RGuid, DB_CONN , 1 , 3
		RS("i_User_Money")=StoreMoney2+GiftSumParice
		RS("i_User_IncomeNum")=Clng(RS("i_User_IncomeNum"))+GiftSumParice
		RS.Update()
	RS_End
	RecordConsume 0,GiftSumParice,"用户 "&Session(Session_UserNickName_Arg)&" 定时收费，收入"&GiftSumParice,RGuid
	RS_End
	RW "var PayRe=true;var MoneyNumRe="&Clng(GUInfo("i_User_Money"))&";"
	RS_End
	Rend
end if


'获取用户收入等级信息
function GetRoomInfo(roomid,f)
	dim t_Rs
	set t_Rs = DB_CONN.EXECUTE("select * from [i_Sys_Room] where [i_Sys_Room_ID]="&roomid)
	GetRoomInfo=t_Rs(f)
end function
%>