<%




Class PayResult

	Public wanjia 	'游戏ID
	Public cash  	'冲值金额
	Public ip    	'服务器IP
	Public post 	'通讯端口
	Public Qpay_keys   '通讯密钥
	Public TruePrice    '实际支付的金额	

	
	'设置支付成功
	Public Sub PayOK(resultnum)

		set Rs=GrateRs("select * from [mobile1] Where Num='"&resultnum&"'",3)
		  If Rs.eof Then
		     response.Write("订单不存在！")
		     response.End()
		  end if

		set rsu = GrateRs("select * from member where username='"&rs("username")&"'",3)

		if TruePrice="" or isnull(TruePrice) then  TruePrice = Rs("Price")



		    
			
			'元宝奖励/////////////////////////////////////////////////

			Dim Prs,jiangli
			'set prs=GrateRs("Select * From L_jiangli where UserID in(Select id From member Where username='"&Rs("username")&"') and QuID="&cint(Rs("wooolid"))&" and psortID="&Rs("port"),1)


			set prs=GrateRs("Select * From L_jiangli where UserID in(Select id From member Where username='"&Rs("username")&"') and QuID="&cint(Rs("wooolid"))&" and psortID=(select fenzu from H_Plist where id="&Rs("port")&") ",1)
			If not (prs.Eof and prs.Bof) Then
			    If prs("jiangli")>0 Then
			        jiangli = prs("jiangli")
			     Else
		             jiangli = 0
				 End if
			else
			     jiangli = 0
			end if




		  SQL = "Select * From H_rmbname order by id"
		  Set Res3 = Server.CreateObject("ADODB.Recordset")
		  Res3.Open SQL,Conn,1,2
		  Do While Not Res3.Eof


				set prs = GrateRs("Select * From L_rmbjiangli where UserID="&rsu("id")&" and QuID="&cint(Rs("wooolid"))&" and psortID="&Res3("id"),1)
				If not (prs.Eof and prs.Bof) Then
					if int(Res3("rmb")) <= int(TruePrice) then rmbjiangli = prs("jiangli")
				end if
				prs.close
		  Res3.Movenext
		  Loop

		if rmbjiangli="" or isnull(rmbjiangli) then  rmbjiangli = 0



			paymoney = TruePrice * (1 + jiangli/100 + rmbjiangli/100)
			paymoney = Round(paymoney,2)



           '元宝奖励结束///////////////////////////////////////////////////////////

			postkey = Rs("password")
			username = Rs("number")
			codenum = Rs("wooolid")
			
			set Rsq=GrateRs("select * from [L_woool] Where id="&codenum,1)
		    		if not Rsq.eof then
			   	bili = rsq("yuanbao")
				svrip=rsq("ip")
				svrport=rsq("post")
			end if
							 
							
			


					set urs = GrateRs("select * from member where username='"&Rs("upline")&"' ",1)

					set prc = GrateRs("select * from H_plist where ID="&Rs("port"),1)

					IF urs("hy")=0  then
						Rate = prc("Percentage")
					elseif urs("hy")=1  then
						Rate = prc("Percentage1")
					elseif urs("hy")=2  then
						Rate = prc("Percentage2")
					elseif urs("hy")=3  then
						Rate = prc("Percentage3")
					elseif urs("hy")=4  then
						Rate = prc("Percentage4")
					end if


				fencheng=TruePrice*(Rate/100)
				jifen=int(TruePrice/10)


		
		
			set Res=GrateRs("select * from mobile Where Num='"&resultnum&"'",3)
			if not Res.eof then
			'response.Write("支付成功")
			'response.Write("订单重复！")
			'response.End()
		        else
			'保存订单
			Res.addnew
			Res("num")=resultnum
			Res("regDate") = Date()
			Res("regTime") = Time()	
			Res("chkDate") = Date() + 30		
			Res("number") = Rs("number")
			Res("ip") = Rs("ip")
			Res("state") = 1
			Res("Price") = TruePrice
			Res("fencheng") = fencheng
			Res("jifen") = jifen
			Res("password") = Rs("password")
			Res("serviceurl") = Rs("serviceurl")
			Res("upline") = Rs("username")
			Res("username") = Rs("username")
			Res("Pname")=Rs("Pname")
			Res("port")=Rs("port")
			Res("prov")=Rs("prov")
			Res("ebank")=Rs("ebank")
			Res("tuiguang")=Rs("tuiguang")
			Res("wooolid")=Rs("wooolid")
			Res("usercode")=Rs("usercode")
			Res("usercode2")=Rs("usercode2")
			Res.Update
			Res.Close

		        end if 



					   
			set Rss=GrateRs("select * from [MirMoUrl1] where num='"&resultnum&"'",3)
			if not Rss.eof then
			'response.Write("支付成功")
			'response.Write("订单重复！")
			'response.End()
			else
			rss.addnew
			rss("num") = resultnum
			rss("codenum") = codenum
			rss("username") = username
			rss("postkey") = postkey
			rss("give")=1'1为显示日志 
			rss("paymoney") = paymoney*bili
			rss("money") = TruePrice
			rss("svrport") = svrport
			rss("svrip") = svrip
			rss.update
			rss.close



				set Rsl=GrateRs("select * from [logo] ",3)
				Rsl.addnew
				Rsl("userid") = rsu("id")
				Rsl("username") = username
				Rsl("num") = resultnum
				Rsl("money") = rsu("moneyTotal")-rsu("removeMoney")
				Rsl("money1")=fencheng
				Rsl("money2") = rsu("moneyTotal")-rsu("removeMoney")+fencheng
				Rsl("leixing") = Rs("Pname")
				Rsl("time") = now()
				Rsl("miaoshu") = "账号"&username&"通过"&Rs("Pname")&"支付"&fencheng&"元,订单成功处理!"
				Rsl("tast") = 1
				Rsl.update
				Rsl.close


			rsu("moneyTotal")=rsu("moneyTotal")+fencheng
			rsu("jifen")=rsu("jifen")+jifen
			rsu.update
			rsu.Close


			end if   



	End Sub
	
End Class
%>