<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.MemberCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<%
Dim KSCls
Set KSCls = New User_Recharge
KSCls.HSK_Run()
Set KSCls = Nothing

Class User_Recharge
		Private KS,KSUser
		Private AlipayAccount
		Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSUser = New UserCls
		  AlipayAccount = "az@mm2006.com"   			'你的支付宝收款账号，请把此账号修改为你的再使用。
		End Sub
		
		Private Sub Class_Terminate()
		 Set KS=Nothing
		 Set KSUser=Nothing
		End Sub
		%>
		<!--#include file="../HSK_Cls/UserFunction.asp"-->
		<%
		Public Sub LoadMain()
		IF Cbool(KSUser.UserLoginChecked)=false Then
		  GCls.ComeUrl = "/User/User_Transfer.asp"
		  Response.Write "<script>top.location.href='Login';</script>"
		  Exit Sub
		End If
		Call KSUser.Head()
		Call KSUser.InnerLocation("支付宝自动充值")
		Response.Write "<div  class=""tabs"">"
		Response.Write " <ul>"
		Response.Write " <li class='select'><a href=""User_Transfer.asp"" style='color:red;'>支付宝自动充值</a></li>"
		Response.Write " <li><a href=""User_PayOnline.asp"">在线支付充值</a></li>"
		Response.Write " <li><a href=""user_recharge.asp"">充值卡充值</a></li>"
		Response.Write " <li><a href=""User_Card.asp"" style='color:red;'>购买点卡</a></li>"
		If Mid(KS.Setting(170),1,1)="1" or Mid(KS.Setting(170),2,1)="1" Then
		Response.Write " <li><a href=""user_exchange.asp?Action=Point"">兑换" & KS.Setting(45) & "</a></li>"
		End If
		If Mid(KS.Setting(170),3,1)="1" or Mid(KS.Setting(170),4,1)="1" Then
		Response.Write " <li><a href=""user_exchange.asp?Action=Edays"">兑换有效期</a></li>"
		End If
		If Mid(KS.Setting(170),5,1)="1" Then
		Response.Write " <li><a href=""user_exchange.asp?Action=Money"">兑换资金</a></li>"
		End If
		Response.Write "</ul>"
		Response.Write "</div>"
		Select Case KS.S("Action")
		 Case "SaveAlipPayCZ"
		    Call DoSaveAlipPayCZ()
		 Case "Del"
		 	Call DoDel()
	     Case Else
		    Call DOMainList()
		End Select
		End Sub
		
		Sub DoMainList()
	    %>
	   <script>
	   function CheckCZ(){
		   if (document.getElementById("CZMoney").value == "" || document.getElementById("CZMoney").value <= 0){
			   alert('请输入大于0的整数，谢谢！');
			   document.getElementById("CZMoney").focus();
			   return false;
			   }
          var form = document.getElementById("JumpForm");
          form.action="https://shenghuo.alipay.com/send/payment/fill.htm";
          form.payAmount.value = document.getElementById("CZMoney").value;
          form.title.value = "充值:" + document.getElementById("UserName").value;
          form.submit();
		  }
		   
		function Confirm()
		 {
		  if (document.myform.TradeNo.value=="")
		  {
		   alert('请输入支付宝交易号!')
		   document.myform.TradeNo.focus();
		   return false;
		  }
		  if (document.myform.TradeNo.value.length<16)
		  {
		   alert('您输入的支付宝交易号长度不对，标准交易号为16位或28位!')
		   document.myform.TradeNo.focus();
		   return false;
		  }
		  if (document.myform.Money.value=="")
		  {
		   alert('请输入支付的金额!')
		   document.myform.Money.focus();
		   return false;
		  }
		  if (document.myform.Money.value<=0)
		  {
		   alert('支付的金额必需是大于0')
		   document.myform.Money.focus();
		   return false;
		  }
		  if (document.myform.Verifycode.value=="")
		  {
		   alert('请输入验证码！')
		   document.myform.Verifycode.focus();
		   return false;
		  }
		  return true;
		  }
		  
		function openPrdUrl(url, obj) {
		var isIe=(document.all)?true:false;
			if (isIe) {
				try {
					window.open(url);
				} catch (e) {
					try {
						alert('对不起，可能你使用了遨游浏览器，弹出的网址无法打开，请再一次点击');
						obj.onclick = function() { window.open(url); }
					} catch (ex) { }
				}
			} else if (prompt('请你使用 Ctrl+C 复制到剪贴板', url)) {
				alert("您已经成功复制了网址，请粘贴到浏览器的地址栏，然后打开");
			}
			return false;
		}
	   </script>
       <form name="JumpForm" id="JumpForm" action="" target="_blank" Method="post">
       <input id=_tosheet type=hidden value="true" name="_tosheet">
       <input id=optEmail type=hidden value="<%=AlipayAccount%>" name="optEmail">
       <input id=payAmount type=hidden value="0" name="payAmount">
       <input id=title type=hidden value="" name="title">
       </form>
		  <table class=border cellSpacing=1 cellPadding=2 width="100%" align=center border=0>
          <!-- 
			<tr>
			  <td colSpan=2 class=chargetitle height=22> 财付通转账充值</td>
			</tr>
            <tr class=tdbg>
              <td height=100 align=right width=186><a href="javascript:void(0)" target="_blank" onclick="openPrdUrl('https://www.tenpay.com/')" title="点击打开财付通连接"><img src="/style/images/tenpay2.gif" border="0" /></a>&nbsp; &nbsp; </td>
              <td align=left><p>请使用财付通向&ldquo;<strong>亲朋好友付款</strong>&rdquo;的即时到账交易进行转账！<strong>(免手续费)</strong><br />
              付款时备注填写：您在平台的用户名（必填）<br />
              请转完款后，联系充值客服确认并入款，QQ：484xxxxx <a href='tencent://message/?uin=4842xxxxx'><img width='25' height='17' border='0' src='http://wpa.qq.com/pa?p=1:4842xxxxx:17' alt='点击联系充值客服' align="absmiddle" /></a></p>
              <p style="color:#F63"><strong>财付通账号：4422xxxxx  &nbsp; （最少10元起充）</strong></p></td>
            </tr>
            -->
			<tr>
			  <td colSpan=2 class=chargetitle height=22> 账号余额信息</td>
			</tr>
			<tr class=tdbg>
			  <td colSpan=2 align=center height=50>用户名：<span style="color:#FF5500"><%=KSUser.UserName%></span> &nbsp; &nbsp; 账户余额：<span style="color:#FF5500"><%=KS.GetN(KSUser.GetUserInfo("Money"),2)%></span> 元 &nbsp;&nbsp; 发布点：<span style="color:#FF5500"><%=KS.GetN(KSUser.GetUserInfo("Point"),2)%></span> <%=KS.Setting(46)%> &nbsp;&nbsp; 收藏点：<span style="color:#FF5500"><%=KS.GetN(KSUser.GetUserInfo("KS_CollectPoint"),3)%></span> 点 &nbsp;&nbsp; 流量点：<span style="color:#FF5500"><%=KS.GetN(KSUser.GetUserInfo("KS_FlowPoint"),4)%></span> 点</td>
			</tr>
			<tr>
			  <td colSpan=2 class=chargetitle height=22> <font color="#FF0000">支付宝自动充值 （免手续费推荐）</font></td>
			</tr>
			<tr class=tdbg>
           	  <td height=100 align=center width=187><a href="javascript:void(0)" onclick="openPrdUrl('https://www.alipay.com/')" title="点击打开支付宝连接"><img src="/style/images/alipay2.gif" border="0" /></a></td>
              <td width="1199" align=left><p>1、在下框输入要充值的金额数目(只能是整数，例：100)，然后点击&ldquo;确认充值&rdquo;按钮跳到支付宝网站。<br />
2、在支付宝网站页面中完成支付，再到支付宝网站顶部的&ldquo;消费记录&rdquo;，找到刚支付完成的&ldquo;交易号&rdquo;，复制交易号的数字，类似&ldquo;201107280249XXXX&rdquo;<br />
<font color="#FF0000">3、将交易号和充值金额输入到下面的支付宝支付信息下框中并提交，系统会在1分钟左右自动充值完成。</font></p>
                <p style="color:#F63; font-size:16px; font-weight:bold;">收款支付宝账户：<span id="AlipayAccount"><%=AlipayAccount%></span></p>
              <table width="100%" border="0">
                <tr>
                  <td align="right">&nbsp;</td>
                  <td align="left"><input type="hidden" name="UserName" id="UserName" value="<%=KSUser.UserName%>" readonly="readonly" /></td>
                </tr>
                <tr>
                  <td width="11%" align="right">充值金额：</td>
                  <td width="89%" align="left"><input name="CZMoney" id="CZMoney" type="text" class="textbox" size="25" maxlength="8" onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')" onblur="this.value=this.value.replace(/\D/g,'')" /></td>
                </tr>
                <tr>
                  <td align="right">&nbsp;</td>
                  <td align="left" height=30><input class="button" id="Chongzhi" type="button" value="确定充值"  name="Chongzhi" onclick="CheckCZ()" /></td>
                </tr>
              </table>
              <br />
              </td>
			</tr>
            <tr>
			  <td colSpan=2 class=chargetitle height=22> 填写支付宝支付信息</td>
			</tr>
			<FORM name=myform action="User_Transfer.asp" method="post">
			<tr class=tdbg>
           	  <td height=30 align=right width=187>交易号：&nbsp; </td>
              <td align=left><p>
                <input name="TradeNo" id="TradeNo" type="text" class="textbox" size="25" maxlength="30" onKeyUp="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')" onblur="this.value=this.value.replace(/\D/g,'')" />
              </p></td>
			</tr>
			<tr class=tdbg>
           	  <td height=30 align=right width=187>充值金额：&nbsp; </td>
              <td align=left><p>
                <input name="Money" id="Money" type="text" class="textbox" size="25" maxlength="8" onKeyUp="this.value=this.value.replace(/[^0123456789.]/g,'')"  onafterpaste="this.value=this.value.replace(/[^0123456789.]/g,'')" onblur="this.value=this.value.replace(/[^0123456789.]/g,'')" />
              </p></td>
			</tr>
			<tr class=tdbg>
           	  <td height=30 align=right width=187>验证码：&nbsp; </td>
              <td align=left><input type="text" maxlength="6" name="Verifycode" id="Verifycode" onFocus="this.value='';" class="textbox" style="width:80px;" autocomplete="off" />&nbsp; <img align="absmiddle" src="../plus/verifycode.asp" onClick='this.src="../plus/verifycode.asp?n="+ Math.random();'></td>
			</tr>
			<tr class=tdbg>
			  <td align=left height=30></td>
			  <td align=left height=30><Input id=Action type=hidden value="SaveAlipPayCZ" name="Action"> 
				<Input class="button" id=Submit type=submit value="确定提交" onClick="return(Confirm())" name=Submit></td>
			</tr>
		 	</FORM>
		  </table>
        
		<%   Dim RS: Set RS=Server.CreateObject("ADODB.RECORDSET")
             RS.Open "Select * From AutoCZ Where UserName = '" & KSUser.UserName & "' And DateDiff(" & DataPart_D & ",AddDate," & SQLNowString & ") < 3 And Status < 3 Order By ID Desc",Conn,1,1
             If Not RS.Eof Then
		%>
        <br />
        <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="border">
            <tr class=titlename align=middle>
              <td nowrap width=70 height="25">序号</td>
              <td nowrap width=160>交易号</td>
              <td nowrap width=110>充值金额</td>
              <td nowrap width=160>提交时间</td>
              <td nowrap width=100>状态</td>
              <td nowrap>操作</td>
            </tr>
			<%   Dim i: i = 1
                 Do While Not(RS.Eof) %>
                <tr class=tdbg onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
                  <td class="splittd" align="center"><%=i%></td>
                  <td class="splittd" align="center"><%=RS("TradeNo")%></td>
                  <td class="splittd" align="center"><%=RS("Money")%> 元</td>
                  <td class="splittd" align="center"><%=RS("AddDate")%></td>
                  <td class="splittd" align="center"><%
				  If RS("Status")=0 Then
				  		KS.Echo "<span style=""color:green"">等待充值</span>"
				  ElseIf RS("Status")=1 Then
				  		KS.Echo "充值成功"
				  ElseIf RS("Status")=2 Then
				  		KS.Echo "<span style=""color:red"">充值失败</span>"
				  End If
				  %></td>
                  <td class="splittd" align="center"><%If RS("Status")=0 Then%><a href="?Action=Del&ID=<%=RS("ID")%>" onClick="return confirm('您确定要删除吗？')">删除</a><%End If%>&nbsp;</td>
              	</tr>
            <%	 RS.MoveNext
                 i = i + 1
                 loop
			%>
            <tr>
			  <td colSpan=6 height=40> &nbsp; 提示：只显示3天之内提交的充值记录</td>
			</tr>
        </table>
        <%
             End If
             RS.Close
	         Set RS=Nothing

	   End Sub
		
	   Sub DoDel()
	   		Dim ID: ID = KS.ChkClng(KS.S("ID"))
			If ID = 0 Then Call KS.AlertHistory("提交参数有误！",-1)
			If Not Conn.Execute ("SELECT ID FROM AutoCZ Where UserName = '" & KSUser.UserName & "' And Status = 0 And ID = " & ID).Eof Then
				Conn.Execute ("DELETE FROM AutoCZ Where UserName = '" & KSUser.UserName & "' And Status = 0 And ID = " & ID)
				Call KS.AlertHintScript("删除成功！")
			Else
				Call KS.AlertHistory("抱歉！系统已受理了，不可再删除！",-1)
			End If
			Exit Sub
	   End Sub
	   
	   
	   Sub DoSaveAlipPayCZ()
			Dim TradeNo: TradeNo=Left(Trim(KS.S("TradeNo")),30)
			Dim Money:Money=Left(Trim(KS.S("Money")),8)
			If TradeNo="" Or Money="" Then 
				Call KS.AlertHistory("请输入支付宝的交易号或支付金额！",-1)
				Exit Sub
			end if
			If Len(TradeNo) < 16 Then 
				Call KS.AlertHistory("您输入的支付宝交易号长度不对，标准交易号为16位或28位!",-1)
				Exit Sub
			end if
			If Not IsNumeric(Money) Then
				Call KS.AlertHistory("支付的金额输入有误！",-1)
				Exit Sub
			End if
			If Round(Money,2) <= 0 Then
				Call KS.AlertHistory("支付的金额必需是大于0",-1)
				Exit Sub
			End if
			IF Trim(KS.S("Verifycode")) <> Trim(Session("Verifycode")) Then
				Call KS.AlertHistory("验证码有误，请重新输入！",-1)
				Exit Sub
			End IF
			If KS.ChkClng(Session("AutoCZ")) >= 6 Then Call KS.Alert("系统检测到你有恶意或频繁提交行为，达到一定条件系统自动封锁账号处理。","") 
			Dim RS: Set Rs = Server.CreateObject("ADODB.Recordset")
			Rs.Open "SELECT * FROM AutoCZ WHERE TradeNo = '" & TradeNo & "'", Conn, 1, 3
			If Not Rs.EOF Then
				If Rs.RecordCount >= 2 then
					Rs.Close: Set Rs = Nothing
					Call KS.AlertHistory("抱歉！系统限制同一交易号不能提交超过2条！\n\n如果您是不小心填错金额，请联系客服核实处理！谢谢！",-1)
					KS.Die ""
				ElseIf Rs("Status") = 0 Then
					Rs.Close: Set Rs = Nothing
					Call KS.AlertHistory("该交易号已经存在，请不要重复提交！谢谢！",-1)
					KS.Die ""
				ElseIf Rs("Status") = 1 Then
					Rs.Close: Set Rs = Nothing
					Call KS.AlertHistory("该交易号已经充值成功，请不要重复提交！谢谢！",-1)
					KS.Die ""
				ElseIf Rs("Status") = 3 Then
					Rs.Close: Set Rs = Nothing
					Call KS.AlertHistory("该交易号系统已禁止充值，请不要恶意提交！谢谢！",-1)
					KS.Die ""
				End IF
			End If
			'不存在相同交易号的 和 第一次充值失败(Status=2)的允许再提交一次
			Rs.AddNew
			Rs("UserName") = KSUser.UserName
			RS("RealName") = KSUser.GetUserInfo("RealName")
			RS("TradeNo") = TradeNo
			Rs("Money") = Round(Money,2)
			Rs("Status") = 0
			Rs("AddDate") = Now
			Rs("IP") = KS.GetIP()
			Rs.Update
			Rs.Close
			Set Rs = Nothing
			Session("AutoCZ") = Session("AutoCZ") + 1
			KS.AlertHintScript "提交成功！\n\n系统将会在1分钟左右充值完毕！请稍候刷新查看！"
	   End Sub
End Class
%> 
