<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../Task/TaskConfig.asp"-->
<!--#include file="../HSK_Cls/HSK.MemberCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<!--#include file="../Plus/md5.asp"-->
<%
'****************************************************
' 提现与提现明细页
'****************************************************
Dim KSCls
Set KSCls = New User_LogMoney
KSCls.HSK_Run()
Set KSCls = Nothing

Class User_LogMoney
        Private KS,KSUser
		Private CurrentPage,totalPut
		Private RS,MaxPerPage
		Private TempStr,SqlStr
		Private Sub Class_Initialize()
			MaxPerPage =20
		  Set KS=New PublicCls
		  Set KSUser = New UserCls
		  Session(KS.SiteSN&"UserInfo") = Empty
		End Sub
        Private Sub Class_Terminate()
		 Set KS=Nothing
		 Set KSUser=Nothing
		 Call CloseConn()
		End Sub
		%>
		<!--#include file="../HSK_Cls/UserFunction.asp"-->
		<%
       Public Sub loadMain()

		IF Cbool(KSUser.UserLoginChecked)=false Then
		  Response.Write "<script>top.location.href='Login';</script>"
		  Exit Sub
		End If
		Call KSUser.Head()
		 If KS.S("page") <> "" Then
			  CurrentPage = CInt(KS.S("page"))
		Else
			  CurrentPage = 1
		End If
		%>
		<div class="tabs">	
			<ul>
				<li<%If KS.S("Action")="" then response.write " class='select'"%>><a href="User_TiXian.asp">申请提现</a></li>
              	<li<%If lcase(KS.S("Action"))="list" then response.write " class='select'"%>><a href="User_TiXian.asp?Action=List">提现明细</a></li>
      			<li><a href="user_logmoney.asp">资金明细</a></li>
				<li><a href="user_logpoint.asp"><%=KS.Setting(45)%>明细</a></li>
				<li><a href="user_logcollectpoint.asp">收藏点明细</a></li>
				<li><a href="user_logflowpoint.asp">流量点明细</a></li>
			</ul>
		</div>
        
		<%
		Select Case KS.LoseHtml(KS.S("Action"))
		 Case "List"  Call TiXianList()
		 Case "Add" Call DoSave()
		 Case "Del"	Call DoDel()
		 Case Else  Call Main()
		End Select
	   End Sub

	   Sub DoDel()
	   	Dim ID
		Dim Rs
		ID = KS.ChkClng(KS.S("ID"))
		IF KS.ChkClng(Session("DelTimes")) < 2 Then
			Set Rs = Conn.Execute("Select Top 1 ID,Money From TiXian Where UserName='" & KSUser.UserName & "' And Status=0 And (DateDiff("& DataPart_S &",AddDate,"& SqlNowString &")<600) And ID=" & ID)
			If Not Rs.Eof Then
				Call KS.MoneyInOrOut(KSUser.UserName,KSUser.GetUserInfo("RealName"),Rs("Money"),4,1,Now,0,"系统","撤销申请提现",0,0,1)
				Conn.Execute("Delete From TiXian Where ID=" & ID)
				Session("DelTimes") = Session("DelTimes") + 1
				Session("SMS_SendTimesTiXian") = Session("SMS_SendTimesTiXian") - 1
				KS.AlertHintScript "提现申请撤销成功！"
			Else
				KS.AlertHintScript "抱歉！该提现申请已经过许可撤销时间或管理员正在处理中。"
			End If
			Set Rs = Nothing
		Else
			KS.AlertHintScript "抱歉！为了防止恶意，平台限制只允许撤销2次。"
		End IF
	   End Sub

	   Sub Main()
		Call KSUser.InnerLocation("申请提现")
		IF TiXian_Enabled <> 1 Then
			KS.AlertHintScript "抱歉！提现功能暂时关闭，具体恢复时间请留意平台最新公告消息。"
		End IF
	    %>
   <script type="text/javascript">
     function ChangeType(v){
        if (v==1){
             $('#Name_Flag').html('你的支付宝姓名');
             $('#Acc_Flag').html('你的支付宝账号');
             $('#Bank_Flag').hide();
             }
         if (v==2){
             $('#Name_Flag').html('你的掌柜名称');
             $('#Acc_Flag').html('淘宝商品地址');
             $('#Bank_Flag').hide();
             }
         if (v==3){
             $('#Name_Flag').html('你的财付通姓名');
             $('#Acc_Flag').html('你的财付通账号');
             $('#Bank_Flag').hide();
             }
         if (v==4){
             $('#Name_Flag').html('开户姓名');
             $('#Acc_Flag').html('银行卡号');
             $('#Bank_Flag').show();
             }
     }
	 
     function Confirm(){
      var Money = document.myform.Money.value ;
      if (Money=="" || (isNaN(Money)) || (Money.indexOf("-")!=-1))
      {
       alert('请输入正确的提现金额!');
       document.myform.Money.focus();
       return false;
      }
     if (Money < <%=TiXian_MinMoney%>){
       alert('低于<%=TiXian_MinMoney%>元的请通过发布任务的方法提现，即得到信誉又快速提现！');
       document.myform.Money.focus();
       return false; }
     if (document.myform.RealName.value==""){
         alert('请输入姓名!');
         document.myform.RealName.focus();
         return false }
     if (document.myform.Account.value==""){
         alert('收款账号/地址不能为空!');
         document.myform.Account.focus();
         return false }
     if (document.myform.SecurityCode.value==""){
         alert('请输入操作安全码!');
         document.myform.SecurityCode.focus();
         return false }
	 if (document.myform.VerifyCode.value==""){
         alert('请输入手机验证码，如尚未收到，请耐心等多几分钟或者联系客服索取验证码!');
         document.myform.VerifyCode.focus();
         return false }
         
      return true;
      }
      
     function SendSMS(){
        var ajaxchk;
        var ajaxstr;
        if (document.myform.SecurityCode.value =="")
            {
            alert("请填写您的安全密码！");
            document.myform.SecurityCode.focus();
            return false;
        }
        document.myform.Send_bt.disabled=true;
        $.ajax({type:"post",url:"/Plus/Ajax_SMS.asp",data:"Action=SendSMS&Mobile=<%=KSUser.GetUserInfo("Mobile")%>&N=<%=KS.IIF(KS.ChkClng(KSUser.GroupID)=UserGroupVipID,TiXian_VIPDayNum,TiXian_CommonDayNum)%>&Flag=TiXian&C="+ document.myform.SecurityCode.value +"&CC=1&anticache=" + Math.floor(Math.random()*1000),cache:false,dataType:"html",success:function(d){
        var s=unescape(d);
        ajaxchk=s.split('|')[0];
        ajaxstr=s.split('|')[1];
        if (ajaxstr!=null){
            if (ajaxchk=='ok'){alert(ajaxstr);}
            else{alert(ajaxstr);document.myform.Send_bt.disabled=false;}
        }
    } });
    }
   </script>
<FORM name=myform action="User_TiXian.asp" method="post" onsubmit="return Confirm()">
  <table class=border cellSpacing=1 cellPadding=2 width="100%" align=center border=0>
    <tr>
      <td colSpan=2>
      <div id="tips" style="border:1px #A7DDFE solid; width:auto; height:auto; padding:8px; display:; background:url(/style/images/msg_b_bg.png) #ECF8FF no-repeat 10px -964px; padding-left: 85px;">
        <p>受理金额：系统只接受<%=TiXian_MinMoney%>元以上的申请，低于<%=TiXian_MinMoney%>元的请通过发布任务的方式进行提现。<br />
提现次数：普通会员一天只能提现<%=TiXian_CommonDayNum%>次，VIP会员可以提现<%=TiXian_VIPDayNum%>次且优先处理。<%IF KS.ChkClng(KSUser.GroupID) <> UserGroupVipID Then KS.Echo "<a href=""user_card.asp"" style=""color:blue"">立即升级为VIP会员>></a>"%><br />
        处理时间：统一下午15-18点处理，18点之后提现的，视工作状况而定在当晚或次日处理。 <br />
        <span class="red">平台建议：请尽量使用支付宝收款直接提现来完成资金周转! 因支付宝直接收款每个用户有1W元的免费交易量。提现首先到支付宝网站点击&ldquo;<strong>我要收款</strong>&rdquo;, 创建一个交易，填写官方支付宝账户：<strong><%=Conn.Execute("SELECT TOP 1 AccountID FROM KS_PaymentPlat WHERE (ID = 7)")(0)%></strong>&nbsp;完成后再到平台申请提现，切记支付宝收款金额和平台的提现金额必须一致！如果不创建收款交易，直接使用支付宝提现，我们将按照支付宝超额费率收取1%的手续费！</span> <a href="#" target="_blank">支付宝收款提现教程</a></p>
      </div></td>
    </tr>
    <tr class=tdbg>
      <td align=right width=150>用户名：</td>
      <td><%=KSUser.UserName%> &nbsp; [<%=KS.U_G(KSUser.GroupID,"groupname")%>]</td>
    </tr>
    <tr class=tdbg>
      <td align=right>账户余额：</td>
      <td><strong style="color:red">￥<%=formatnumber(KSUser.GetUserInfo("Money"),2,-1)%></strong> 元</td>
    </tr>
    <tr class=tdbg>
        <td align=right><span style="font-weight: bold">第一步：</span></td>
      <td></td>
    </tr>
    <tr class=tdbg>
      <td align=right valign="top">&nbsp;</td>
      <td>

<div style="line-height:20px;padding:0px 0px 10px 0px;border-bottom:1px dashed #999999">
<script language="javascript">
function CheckCZ(){
	if (document.getElementById("CZMoney").value == "" || document.getElementById("CZMoney").value <= 0){
	   alert('请输入大于0的数字，谢谢！');
	   document.getElementById("CZMoney").focus();
	   return false;
	}
	var url="https://shenghuo.alipay.com/transfer/gathering/create.htm?optEmail=" + document.getElementById("AlipayAccount").innerHTML + "&totleFee=" + document.getElementById("CZMoney").value + "&title=提现:" + document.getElementById("UserName").value;
	window.open(url);
}
</script>	
<input name="PaymentType" type="radio"  id="PaymentType" onclick="ChangeType(this.value)" value="1" checked="checked" /><img src="/style/images/icoalipay.jpg" align="absmiddle" /> 支付宝提现 <span class="red">（请先在下面提交收款交易，再提交下面的第二步）</span>
<p style="color:#0066FF">
<input type="hidden" name="UserName" id="UserName" value="<%=KSUser.UserName%>" readonly="readonly" />
输入提现金额： <input name="CZMoney" id="CZMoney" type="text" class="textbox" size="10" maxlength="8" onKeyUp="this.value=this.value.replace(/[^0123456789.]/g,'');$('#Money').val(this.value);" onafterpaste="this.value=this.value.replace(/[^0123456789.]/g,'')" /> &nbsp;
<input class="button" type="button" value="提交收款交易"  onclick="CheckCZ()" /> 
在支付宝页面提交后,再完成下面的第二步,即可到账！
<span id="AlipayAccount" style="display:none"><%=Conn.Execute("SELECT TOP 1 AccountID FROM KS_PaymentPlat WHERE (ID = 7)")(0)%></span>
</p>
</div> 
   
<div style="line-height:20px; padding:10px 0px 10px 0px;border-bottom:1px dashed #999999">
<input id="PaymentType" name="PaymentType" value="2" type="radio" onclick="ChangeType(this.value)" /><img src="/style/images/icotao.jpg" align="absmiddle" /> 淘宝店铺链接提现
<span class="red">（提现金额=商品(+运费)的总价格，请勿做回评）</span>
</div>

<div style="line-height:20px; padding:10px 0px 10px 0px;border-bottom:1px dashed #999999">
<script language="javascript">
function Checktx(){
   if (document.getElementById("txMoney").value == "" || document.getElementById("txMoney").value <= 0){
	   alert('请输入大于0的数字，谢谢！');
	   document.getElementById("txMoney").focus();
	   return false;
   }
   var url="https://www.tenpay.com/v2/account/receive/index.shtml?pay_uin=" + document.getElementById("tenpayAccount").innerHTML + "&amount=" + document.getElementById("txMoney").value + "&remark=提现:" + document.getElementById("UserName").value;
   window.open(url);
}
</script>
<input id="PaymentType" name="PaymentType" value="3" type="radio" onclick="ChangeType(this.value)" />
<img src="/style/images/icotenpay.jpg" align="absmiddle" />财付通提现 <span class="red">（请先在下面提交收款交易，再提交下面的第二步）</span> 
<p style="color:#0066FF">
输入提现金额： <input name="txMoney" id="txMoney" type="text" class="textbox" size="10" maxlength="8" onKeyUp="this.value=this.value.replace(/[^0123456789.]/g,'');$('#Money').val(this.value);" onafterpaste="this.value=this.value.replace(/[^0123456789.]/g,'')" /> &nbsp;
<input class="button" type="button" value="提交收款交易" onclick="Checktx()" />
在财付通页面提交后,再完成下面的第二步,即可到账！
<span id="tenpayAccount" style="display:none"><%=Conn.Execute("SELECT TOP 1 AccountID FROM KS_PaymentPlat WHERE (ID = 10)")(0)%></span>
</p>
</div>

<div style="padding:10px 0px 0px 0px;">
<input id="PaymentType" name="PaymentType" value="4" type="radio" onclick="ChangeType(this.value)"<%if KS.ChkClng(KSUser.GroupID)<>UserGroupVipID And KS.ChkClng(KSUser.GroupID)<>AdminGroupID then KS.Echo " disabled='disabled'"%> />
<img src="/style/images/icobank.jpg" align="absmiddle" /> 银行提现 
<span class="red"><%
if KS.ChkClng(KSUser.GroupID)<>UserGroupVipID And KS.ChkClng(KSUser.GroupID)<>AdminGroupID then%>
<strong>只对VIP会员开放</strong> <a href="user_card.asp" style="color:blue">立即升级为VIP会员>></a>
<%else%>
（1-199元扣1元手续费，200-10000扣0.5%手续费）24小时内到账
<%end if%></span>
</div></td>
    </tr>
    <tr class=tdbg>
      <td height="25" align=right valign="top"><span style="font-weight: bold">第二步：</span> </td>
      <td>&nbsp;</td>
    </tr>
    <tr class=tdbg>
      <td align=right>提现金额：</td>
      <td><input class="textbox" style="width:60px;" id="Money" name="Money" maxlength="8" title="请输入需要提现的金额" onKeyUp="this.value=this.value.replace(/[^0123456789.]/g,'')"  onafterpaste="this.value=this.value.replace(/[^0123456789.]/g,'')" /> 元
      </td>
    </tr>
    <tr class=tdbg>
      <td align=right><span id="Name_Flag">你的支付宝姓名</span>：</td>
      <td><input class="textbox" style="width:100px;" maxlength="30" id="RealName" name="RealName" /></td>
    </tr>
    <tr class=tdbg>
      <td align=right><span id="Acc_Flag">你的支付宝账号</span>：</td>
      <td><input class="textbox" style="width:250px;" maxlength="200" id="Account" name="Account" title="收款账号" /></td>
    </tr>
    <tr class=tdbg id="Bank_Flag" style="display:none;">
      <td align=right>收款银行名称：</td>
      <td><input class="textbox" style="width:250px;" maxlength="50" id="BankName" name="BankName" title="输入银行名称及开户地址" /> 
      例如：工商银行/广东省广州市天河区天河路支行</td>
    </tr>
    <tr class=tdbg>
      <td align=right>平台安全密码：</td>
      <td><input class="textbox" style="width:100px;" type="password" id="SecurityCode" maxlength="30" name="SecurityCode" value="" title="安全密码主要用于资金流转、账户安全二层保护作用。&#13;&#10;注：安全密码不是登录密码" /> <span style="color:blue;margin-top:5px">注册平台账号时填写的安全密码，不要设置过于简单，以免被盗！ <a href="/user/User_EditInfo.asp?Action=PassInfo" target="_blank">点此修改安全密码</a></span></td>
    </tr>
    <tr class="tdbg">
      <td align=right>手机验证码：</td>
      <td><input class="textbox" style="width:100px;" type="text" name="VerifyCode" id="VerifyCode" size="30" maxlength="6" onKeyUp="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')" value="" />&nbsp; <input class="button" name="Send_bt" id="Send_bt" type="button" value="获取手机短信验证码" onclick="SendSMS()" /><%
	  If Not KS.IsNul(KSUser.GetUserInfo("Mobile")) Then%><span style="color:#999">接收手机号：<%=Left(KSUser.GetUserInfo("Mobile"),3) & "******" & Right(KSUser.GetUserInfo("Mobile"),2)%> &nbsp;每次提现只可以获取一次验证码</span>
       <%Else%><strong style="color:red">尚未通过手机认证的用户不可以申请提现</strong> &nbsp; <a href="User_IDAuthentication.asp">我要现在去认证>></a>
       <%End If%>
       </td>
    </tr>
    <tr class=tdbg>
      <td align=middle colSpan=2 height=100>
        <input id="Action" type="hidden" value="Add" name="Action"> 
        <button type="submit" class="pn"<% IF Round(KSUser.GetUserInfo("Money"),2) < Round(TiXian_MinMoney,2) Then KS.Echo " disabled='disabled'" %>><strong> OK 确认提交</strong></button>
         </td>
    </tr>
  </table>
</FORM>
<%
	   	IF Round(KSUser.GetUserInfo("Money"),2) < Round(TiXian_MinMoney,2) Then 
			KS.Alert "温馨提示！平台限定最低提现为"& TiXian_MinMoney &"元，你当前资金尚未达到，所以暂时不能提现！",""
		End IF
	   End Sub
	   
	   
	   Sub TiXianList()
		Call KSUser.InnerLocation("查看提现明细")
%>
<script language="javascript">
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>
			<div style="text-align:right;height:30px;line-height:30px;"> <a href='User_TiXian.asp?Action=List'><font color=red>＋所有记录</font></a> ＋<a href='?Action=List&PaymentType=1'>支付宝提现[<%=conn.execute("select count(id) from TiXian where PaymentType=1 and username='" & KSUser.UserName & "'")(0)%>]</a> ＋<a href='?Action=List&PaymentType=2'>淘宝店铺提现[<%=conn.execute("select count(id) from TiXian where PaymentType=2 and username='" & KSUser.UserName & "'")(0)%>]</a> ＋<a href='?Action=List&PaymentType=3'>财付通提现[<%=conn.execute("select count(id) from TiXian where PaymentType=3 and username='" & KSUser.UserName & "'")(0)%>]</a> ＋<a href='?Action=List&PaymentType=4'>银行提现[<%=conn.execute("select count(id) from TiXian where PaymentType=4 and username='" & KSUser.UserName & "'")(0)%>]</a>
		   </div>
				<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" class="border">
					<tr class=titlename align=middle>
					  <td nowrap width=80 height="25">提现编号</td>
					  <td nowrap width=80>用户姓名</td>
					  <td nowrap width=70>提现方式</td>
					  <td nowrap width=110>提现账户</td>
					  <td nowrap width=70>提现金额</td>
					  <td nowrap width=70>余额</td>
					  <td nowrap width=80>提现日期</td>
					  <td nowrap width=50>状态</td>
					  <td nowrap>备注/说明</td>
					</tr>
					<%  If KS.ChkClng(KS.S("PaymentType")) <> 0 Then
						  SqlStr="Select * From TiXian Where PaymentType=" & KS.ChkClng(KS.S("PaymentType")) & " And  UserName='" & KSUser.UserName &"' order by id desc"
 					    Else
						  SqlStr="Select * From TiXian Where UserName='" & KSUser.UserName &"' order by id desc"
						End if
						 Set RS=Server.createobject("adodb.recordset")
						 RS.open SqlStr,conn,1,1

						 If RS.EOF And RS.BOF Then
								  Response.Write "<tr class='tdbg'><td align=center height=25 colspan=9 valign=top>还没有任何提现记录!</td></tr>"
								 Else
									totalPut = RS.RecordCount
						
											If CurrentPage < 1 Then
												CurrentPage = 1
											End If
			
								If (CurrentPage - 1) * MaxPerPage > totalPut Then
									If (totalPut Mod MaxPerPage) = 0 Then
										CurrentPage = totalPut \ MaxPerPage
									Else
										CurrentPage = totalPut \ MaxPerPage + 1
									End If
								End If
			
								If CurrentPage = 1 Then
									Call ShowContent
								Else
									If (CurrentPage - 1) * MaxPerPage < totalPut Then
										RS.Move (CurrentPage - 1) * MaxPerPage
										Call ShowContent
									Else
										CurrentPage = 1
										Call ShowContent
									End If
								End If
				End If
						 %>
					
          </table>
		  </td>
		  </tr>
</table>
		  <%
		  Call KS.ShowPage(totalput, MaxPerPage, "", CurrentPage,false,true)%>
		  <%
  End Sub
    
  Sub ShowContent()
     on error resume next
     Dim I,totalmoney
     Do While Not rs.eof 
	%>
    <tr class=tdbg onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
      <td  class="splittd" align=middle width=80><%=rs("OrderID")%></td>
      <td  class="splittd" align=middle width=80><%=rs("RealName")%></td>
	  <td  class="splittd" align=middle width=80>
	  <% Select Case rs("PaymentType")
	      Case 1:Response.WRite "支付宝"
		  Case 2:Response.Write "淘宝商品"
		  Case 3:Response.Write "财付通"
		  Case 4:Response.Write "银行"
		  Case 5:Response.Write "提现任务"
		 End Select	
	   %></td>
      <td  class="splittd" align=middle width=110><span title="<%if rs("BankName")<>"" then ks.echo "银行信息：" & rs("BankName") Else KS.Echo rs("Account")%>"><%if KS.ChkClng(rs("PaymentType"))=2 then KS.Echo "<a href=""javascript:void(0);"" onclick=""openPrdUrl('" & rs("Account") & "',this)"">" & left(rs("Account"),7) & "***" & Right(rs("Account"),6) & "</a>" Else KS.Echo rs("Account")%></span></td>
      <td  class="splittd" align=center width=70>
	  <% Response.Write formatnumber(rs("money"),2,-1)
		 totalmoney = totalmoney + rs("money")
		%></td>
      <td  class="splittd" align=center width=70><% =formatnumber(rs("MoneyCurrent"),2,-1)%></td>
      <td  class="splittd" align=center width=80><% =rs("AddDate")%>
	  </td>
      <td  class="splittd" align=center width=50>
	  <% Select Case RS("Status")
	      Case 0
		  		Response.WRite "待处理"
		  		IF DateDiff("s",Rs("AddDate"),Now)<600 Then
				Response.WRite "<br><a href=""?Action=Del&ID=" & rs("ID") & """ title=""撤销本次提交的提现申请，申请后10分钟内可以撤销。"" onclick=""return confirm('您确定要撤销申请吗？');""><font color=red>撤销申请</font></a>"
				End IF
'		  Case 1:Response.WRite "已撤销"
		  Case 1:Response.Write "<font color=red>已拒绝</font>"
		  Case 2:Response.Write "<font color=red>处理中</font>"
		  Case 3:Response.Write "已完成"
		 End Select	
	   %></td>
      <td  class="splittd" align=middle><%=rs("Description")%><a></a></td>
    </tr>
	<%
	I = I + 1
	RS.MoveNext
	If I >= MaxPerPage Then Exit Do
	loop
	%>
    <tr class=tdbg onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
      <td class="splittd"  align=right colSpan=4>本页合计提现金额：</td>
      <td class="splittd" align=right><%=formatnumber(totalmoney,2,-1)%></td>
      <td class="splittd" colSpan=4>&nbsp;</td>
    </tr>
    <tr class=tdbg onMouseOver="this.className='tdbgmouseover'" onMouseOut="this.className='tdbg'">
      <td class="splittd" align=right colSpan=4>总计金额：</td>
	  	  <%totalmoney=Conn.execute("Select Sum(Money) From TiXian Where UserName='" & KSUser.UserName & "'")(0)
	    if not isnumeric(totalmoney) then totalmoney=0
	  %>
      <td class="splittd" align=right><%=formatnumber(totalmoney,2,-1)%></td>
      <td class="splittd" align=right>&nbsp;</td>
      <td class="splittd" align=middle colSpan=3>资金余额：<%=formatnumber(KSUser.GetUserInfo("Money"),2,-1)%></td>

    </tr>
  </table>
<%
End Sub
  
Sub DoSave()
Dim RealName	:	RealName = KS.FilterIllegalChar(KS.LoseHtml(KS.S("RealName")))
Dim Account		:	Account = KS.FilterIllegalChar(KS.LoseHtml(KS.S("Account")))
Dim BankName	:	BankName = KS.FilterIllegalChar(KS.LoseHtml(KS.S("BankName")))
Dim PaymentType	:	PaymentType = KS.ChkClng(KS.S("PaymentType"))
Dim Money		:	Money = KS.S("Money")

IF Not IsNumeric(Money) Then KS.AlertHistory "系统提示：\n\n提现金额请输入有效的数字!","-1"
IF Round(Money,2) >= TiXian_MinMoney Then
	Money = Round(Money ,2)
Else
	KS.AlertHistory "系统提示：\n\n提现金额有误!","-1"
End If
IF KS.IsNul(RealName) Then	KS.AlertHistory "系统提示：\n\n姓名不能为空!","-1"
IF KS.IsNul(Account) Then	KS.AlertHistory "系统提示：\n\n收款账号不能为空!","-1"
IF KS.ChkClng(PaymentType)=0 Then	KS.AlertHistory "系统提示：\n\n请选择提现方式!","-1"
IF DateDiff("s",Session("TiXianTime"),Now) < 10 Then KS.AlertHistory "系统提示：\n\n请不要频繁提交申请!","-1"
IF Md5(Trim(KS.S("SecurityCode")),16) <> KSUser.GetUserInfo("KS_SecurityCode") Then KS.AlertHistory "系统提示：\n\n您输入的安全密码不对!","-1"
IF Trim(KS.S("VerifyCode")) <> KSUser.GetUserInfo("CheckNum") Then KS.AlertHistory "系统提示：\n\n您输入的手机验证码不对，如尚未收到，请耐心等多几分钟或者联系客服索取验证码!","-1"

Dim UserMoney: UserMoney = KSUser.GetUserInfo("Money")
IF Round(UserMoney,2) < Round(Money,2) Then KS.AlertHistory "系统提示：\n\n提现金额不能大于你账号余额!","-1"

Dim RSObj: Set RSObj=Server.CreateObject("Adodb.Recordset")
Dim Sql: Sql = "Select top 5 * From TiXian Where Year(AddDate)=Year(" & SQLNowString & ") And Month(AddDate)=Month(" & SQLNowString & ") And Day(AddDate)=Day(" & SQLNowString & ") And UserName='" & KSUser.UserName & "'"
RSObj.Open Sql,Conn,1,3

	IF KS.ChkClng(KSUser.GroupID) <> AdminGroupID Then
		IF KS.ChkClng(KSUser.GroupID) = UserGroupVipID And RSObj.RecordCount >= TiXian_VIPDayNum Then
			RSObj.Close: Set RSObj=Nothing
			KS.AlertHistory "抱歉！VIP会员每天只允许申请提现" & TiXian_VIPDayNum & "次!","-1"
		ElseIF KS.ChkClng(KSUser.GroupID) <> UserGroupVipID And RSObj.RecordCount >= TiXian_CommonDayNum Then
			RSObj.Close: Set RSObj=Nothing
			KS.AlertHistory "抱歉！普通会员每天只允许申请提现" & TiXian_CommonDayNum & "次!\n\n升级为VIP会员可以提现" & TiXian_VIPDayNum & "次","-1"
		End IF
	End IF

	RSObj.AddNew
	Session("TiXianTime")		= 	Now()
	RSObj("OrderID")			= 	GetOrderID()
	RSObj("PaymentType")		=	PaymentType
	RSObj("UserName")			=	KSUser.UserName
	RSObj("RealName")			=	RealName
	RSObj("Account")			=	Account
	If BankName <> "" Then 			RSObj("BankName") = BankName
	RSObj("Money")				=	Money
	RSObj("MoneyOld")			=	UserMoney
	RSObj("MoneyCurrent")		=	Round(UserMoney,2) - Round(Money,2)
	RSObj("Adddate")			=	Now
	RSObj("UserIP") 			=	KS.GetIP()
	RSObj.Update
	RSObj.Close
	Set RSObj=Nothing
	
	Call KS.MoneyInOrOut(KSUser.UserName,KSUser.GetUserInfo("RealName"),Money,4,2,Now,0,"系统","申请提现",0,0,1)
	
	Conn.Execute("Update KS_User Set CheckNum = '" & KS.MakeRandom(6) & "' Where UserName = '" & KSUser.UserName & "'")
	
	KS.Alert "恭喜！提现申请成功，你的资金将会在1到2个工作日内到账！","User_TiXian.asp?Action=List"
End Sub
	
Function GetOrderID()
   Dim TableNameStr,ID
   TableNameStr = "Select top 1 ID From TiXian Where OrderID='"
   Do While True
	   ID = Day(Now()) & hour(Now()) & minute(Now()) & second(Now()) & KS.MakeRandom(2)
	   If Conn.Execute(TableNameStr & ID & "'").Eof Then Exit Do
   Loop
	GetOrderID=ID
End Function

End Class
%> 
