<!--#include file="inc/payconn.asp"-->
<!--#include file="buy/func.asp"-->
<!--#include file="buy/fun.asp"-->
<!--#include file="inc/out.asp"-->
<%

mobile = YeSqlStr(ClearSQL(Request.form("mobile")),3)
codepassword = YeSqlStr(ClearSQL(Request.form("password")),3)
ka_type=Request("ka_type")




	If ka_type<>""  Then
		If (InStr(ka_type,"|")>0) Then
		setlen = Split(ka_type,"|")
		ka_type=setlen(0)
		ka_type1=setlen(1)
		End if
	End If





if ka_type<>"" then p=pr(""&ka_type&"")

userid = ClearSQL(Request.form("userid"))
If userid = "" Then
	Call WriteErr("提示，商户ID出现错误！","1")
End If

wooolID = ClearSQL(Request.form("wooolID"))
If wooolID = "" Then
	Call WriteErr("提示，游戏分区出现错误！","1")
End If

username=YeSqlStr((request.Form("username")),3)
If UserName = "" Then
	Call WriteErr("提示，要充值的玩家帐号不能为空！","1")
End If
if p="" or isnull(p) then p=trim(request("price"))
'if p="" or isnull(p) then p=trim(ClearSQL(request.form("price")))
Price = p

PayID = ClearSQL(Request.form("PayID"))
If PayID = "" Then
	Call WriteErr("缺少参数！","1")
End If
If IsNumeric(Price)=0 Then
	Call WriteErr("请选择正确的金额！","1")
End If
If Price<5 Then
	Call WriteErr("单笔金额必须大于5元！","1")
End If
If Price>10000 Then
	Call WriteErr("单笔金额最大为10000元！","1")
End If
t = Request("stype")
if t="" then
	t="未知"
end if


shouji = YeSqlStr(ClearSQL(Request.form("shouji")),3)

If shouji <> "" Then
If len(shouji) <> 11 Then shouji=""
end if

Call ConnectionDatabase()

	If mobile<>""  Then

	SQL = "Select *  From [mobile1] Where usercode = '"&mobile&"' and stat = 1 order by id desc"
	Set Resk = Server.CreateObject("ADODB.Recordset")
	Resk.Open SQL,Conn,1,1
	If not (resk.Eof and resk.Bof) Then
	session("wid") = ClearSQL(Request.form("wooolID"))
	Call WriteErr("在本次提交之前,此卡已经支付成功！","1")	
	end if


	SQL = "Select *  From [mobile1] Where usercode = '"&mobile&"' and stat2 = 1 order by id desc"
	Set Resk = Server.CreateObject("ADODB.Recordset")
	Resk.Open SQL,Conn,1,1
	If not (resk.Eof and resk.Bof) Then
	session("wid") = ClearSQL(Request.form("wooolID"))
	Call WriteErr("在本次提交之前,此卡已经支付成功！","1")
	end if


	SQL = "Select *  From [mobile1] Where usercode = '"&mobile&"' and des = '等待处理' order by id desc"
	Set Resk = Server.CreateObject("ADODB.Recordset")
	Resk.Open SQL,Conn,1,1
	If not (resk.Eof and resk.Bof) Then
	session("wid") = ClearSQL(Request.form("wooolID"))
	Call WriteErr("此卡正在处理，不要重复提交.请稍后查询状态！","1")
	end if


	End If




	Dim prs
	Set prs = Conn.Execute("Select * From [H_Plist] Where ID="&Cint(PayID))
	if prs.Eof Then
		Call WriteErr("找不到支付方式！","1")
	Else
		psort = prs("psort")
		t = prs("wangguan")	
		if t="BANK"	 then psort="BANK"
		if t="tenpayBANK" then psort="tenpayBANK"
               Pname=prs("Pname")
		state = prs("state")
		setlen2 = prs("setlen")
		if ka_type1="" then ka_type1=prs("Pname")

		If state<>"0"  Then
			Call WriteErr("你选择的支付方式，接口升级，暂时维护！","1")
		End If

	End If


	If setlen2<>"" and not isNull(setlen2) Then
		setlen = Split(setlen2,"|")
		kal=setlen(0)
		mml=setlen(1)
		kal2=len(mobile)
		mml2=len(codepassword)

		If int(kal2) <> int(kal) Then
			Call WriteErr("卡号位数不对！","1")
		End If


		If int(mml2) <> int(mml) Then
			Call WriteErr("卡密码位数不对！","1")
		End If
	End If

	
	ComeIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
	If ComeIp = "" Then ComeIp = Request.ServerVariables("HTTP_Cdn-Src-Ip")
	If ComeIp = "" Then ComeIp = Request.ServerVariables("REMOTE_ADDR")

	'randomize timer
	'kk=int(100000*rnd)
	'Num = wooolID&Year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&kk&Price


	randomize timer
	kk=int(9*rnd)
	kk1=int(9*rnd)
	kk2=int(9*rnd)
	kk3=int(9*rnd)
	y=Year(now)
	m=month(now)
	if m<10 then m="0"&m
	d=day(now)
	if d<10 then d="0"&d
	h=hour(now)
	if h<10 then h="0"&h
	m2=minute(now)
	if m2<10 then m2="0"&m2
	s=second(now)
	if s<10 then s="0"&s
	num=y&m&d&h&m2&s&kk&kk1&kk2&kk3

	SQL = "Select L_woool.*,member.username,member.tuiguang From [L_woool] left join [member] on L_woool.UserID = member.id Where L_woool.ID=" & wooolID
	Set Rs = server.CreateObject("ADODB.Recordset")
	Rs.Open sql,conn,1,1
	if not Rs.Eof Then
		UPUserName = Rs("username")
		tuiguang = Rs("tuiguang")
		serviceurl = Rs("IP")&":"&Rs("post")
		wkey = Rs("wkey")
	end if

	
	Dim Res


	SQL = "Select * From [mobile1] Where ID is null"
	Set Res = Server.CreateObject("ADODB.Recordset")
	Res.Open SQL,Conn,1,3
	Res.Addnew
	
	Res("Num") = Num
	Res("Time") = Now
	Res("date") = Date()
	Res("UserName") = UPUserName
	Res("upline") = UPUserName
	Res("Price") = Price
	Res("number") = UserName
	Res("eBank") = psort
	Res("password") = wkey
	if wooolID<>"" then Res("wooolID") = wooolID
	Res("tuiguang") = tuiguang
	Res("serviceurl")=serviceurl
	Res("ip") = ComeIp
	Res("prov")=t
	Res("Pname")=ka_type1
	Res("port")=Cint(PayID)
	Res("usercode") = mobile
	Res("usercode2") = codepassword
	Res("des") = "未付"
	Res("shouji") = shouji
	Res.update
	Res.Close
	Set Res = nothing

	
	Session("L_PayPrice") = Price
	Session("L_Num") = Num
	Session("wooolID") = wooolID
	Session("L_Name") = UserName
	
	Select Case psort
		Case "15173":
			GoUrl = "/Pay/15173/?PayID="&PayID&"&ka_number="&mobile&"&ka_password="&codepassword&"&ka_type="&ka_type&"&Price="&Price&"&num="&num

		Case "51ka":		    
		if t="51bank" then
			GoUrl = "/Pay/51ka_bank/Send_51KA.asp?PayID="&PayID&"&ka_type="&ka_type&"&Price="&Price&"&num="&num
			response.Redirect GoUrl
			response.End()
		else
		ka_type=replace(ka_type,"51","")
			GoUrl = "/Pay/51ka/Send_51KA.asp?PayID="&PayID&"&ka_type="&ka_type&"&cardNo="&mobile&"&cardPwd="&codepassword&"&Price="&Price&"&num="&num
			'response.Redirect GoUrl
			'response.End()
		end if
		Case "46ka":		    
		ka_type=replace(ka_type,"46ka","")
			GoUrl = "/Pay/46ka/Send_46KA.asp?PayID="&PayID&"&ka_type="&ka_type&"&cardNo="&mobile&"&cardPwd="&codepassword&"&Price="&Price&"&num="&num


			'Response.Write GoUrl
			'response.End()


			'response.Redirect GoUrl
			'response.End()
		Case "70card":		    
			GoUrl = "/Pay/70card/Send_70card.asp?PayID="&PayID&"&ka_type="&ka_type&"&cardNo="&mobile&"&cardPwd="&codepassword&"&Price="&Price&"&num="&num
			'response.Redirect GoUrl
			'response.End()
		Case "ebao":
			GoUrl = "/Pay/ebao/?PayID="&PayID&"&cardNo="&mobile&"&cardPwd="&codepassword&"&Price="&Price&"&num="&num
			'response.Redirect GoUrl
			'response.End()			
		Case "kbpay"
		if t="kbbank" then
			GoUrl = "/Pay/kbpay_bank/send.asp?PayID="&PayID&"&GetStr_wg="&ka_type&""
			response.Redirect GoUrl
			response.End()
		else
		ka_type=replace(ka_type,"kb","")
			GoUrl = "/Pay/kbpay_card/send.asp?PayID="&PayID&"&ka_type="&ka_type&"&cardNo="&mobile&"&cardPwd="&codepassword&"&Price="&Price&"&num="&num
		end if
		Case "95588"
		if t="95588bank" then
			GoUrl = "/Pay/95588_bank/send.asp?PayID="&PayID&"&GetStr_wg="&ka_type&""
			response.Redirect GoUrl
			response.End()
		else
			GoUrl = "/Pay/95588_card/send.asp?PayID="&PayID&"&ka_type="&ka_type&"&cardNo="&mobile&"&cardPwd="&codepassword&"&Price="&Price&"&num="&num
		end if

		Case "BANK":
			GoUrl = "/pay/ebao_bank/?PayID="&PayID&"&GetStr_wg="&ka_type&""
			response.Redirect GoUrl
			response.End()		
		Case "alipay":
			GoUrl = "/Pay/alipay/?dingdan="&Num&"&myprice="&Price&"&UserName="&UserName&""
			response.Redirect GoUrl
			response.End()
		Case "tenpayBANK":
			GoUrl = "/Pay/tenpay_bank/?dingdan="&Num&"&myprice="&Price&"&UserName="&UserName&"&GetStr_wg="&ka_type&""
			response.Redirect GoUrl
			response.End()
		Case "tenpay":
			GoUrl = "/Pay/tenpay/?dingdan="&Num&"&myprice="&Price&"&UserName="&UserName&""
			response.Redirect GoUrl
			response.End()
		End Select


	PostUrl="http://"&Request.ServerVariables("HTTP_HOST")&""&gourl




	Rvalue=xmlGet(PostUrl)

	'Rvalue=GetBody(PostUrl)
	'Rvalue=Bytes2bStr(Rvalue)

			'Response.Write GoUrl
			'Response.Write PostUrl
			'Response.Write Rvalue
			'response.End()

    session("stat")=Rvalue
    session("num")=num
    session("uid") = ClearSQL(Request.form("userid"))
    session("wid") = ClearSQL(Request.form("wooolID"))

	session("ka_type_2")=ka_type
	'session("ka_type_2")=price

	'response.Redirect "Result.asp?num="&num


if Rvalue<>"" and Rvalue="OK" then

	conn.Execute("update mobile1  SET des = '等待处理' where num='"&num&"' ")

	else

if Rvalue="您的卡号密码已支付！" then Rvalue="此卡号与密码错误次数超限！或您的卡号密码已支付！"
if Rvalue="您的选择的支付方式，接口升级，预计时间30分钟!" then Rvalue="您的选择的支付方式，接口升级，请稍后再试!"
if Rvalue="" then Rvalue="提交失败,请联系在线客服!"

	conn.Execute("update mobile1  SET des = '"&Rvalue&"' where num='"&num&"' ")

	Call WriteErr(Rvalue,"3")
End If

response.Redirect "listpka.asp"


call DBConnEnd
%>