<!--#include file="../check.asp"--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>商户后台 - 商户结算</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link type="text/css" rel="stylesheet" href="/css/reset.css" />
<link type="text/css" rel="stylesheet" href="/css/main.css" />
<link type="text/css" rel="stylesheet" href="/css/template_vendor.css" />
<script type="text/javascript" src="/scripts/common.js"></script>
<script type="text/javascript" src="/scripts/nav.js"></script>
<script type="text/javascript" src="/scripts/footerdock.js"></script>
</head>
<body>
<!--#include file="top.asp"-->


<%
Set Rs=Server.CreateObject("ADODB.Recordset")
set Rs=GrateRs("select * from member where username='"&session("Usr_UserName")&"'",1)
moneyTotal=Rs("moneyTotal")
removeMoney=Rs("removeMoney")
userid=Rs("id")
money=moneyTotal-removeMoney
payee=Rs("payee")
bank_card=Rs("bank_card")
rs.close
set rs=nothing
%>


<%
if request("submit")="m" then

set Rs=GrateRs("select * from M_tixian where username='"&session("Usr_UserName")&"' order by id desc",3)
if not rs.eof then
if datediff("h",rs("addtime"),now())=0 then
response.Write("<script>alert('对不起，一天只能提现一次！');history.back();</script>")
response.End()
end if
end if

set Rs=GrateRs("select * from member where username='"&session("Usr_UserName")&"'",3)
'Rs("moneyTotal")=FormatNumber(Rs("moneyTotal")-trim(FormatNumber(request("money"),2)),2)
Rs("removeMoney")=FormatNumber(Rs("removeMoney")+trim(FormatNumber(request("txmoney"),2)),2)
rs.update
'rs.close
'set rs=nothing
'保存提现记录
set Rs=GrateRs("select * from M_tixian",3)
rs.addnew
rs("username")=session("Usr_UserName")
rs("userid")=userid
rs("money")=trim(FormatNumber(request("txmoney"),2))
rs("addtime")=now()
rs.update

response.write "<script language='JavaScript'>{window.alert('恭喜，提现成功！');window.location='"&Request.ServerVariables("HTTP_REFERER")&"';}</script>"
response.End()
end if

%>


<script language="javascript">
  function tixian()
  {
    if(form1.txmoney.value=="" || isNaN(form1.txmoney.value))
	{
	  alert('输入的金额不正确！');
	  form1.txmoney.focus();
	  return false;
	}
	if(form1.txmoney.value><%=money%>)
	{
	  alert('对不起，您的余额不足！')
	  form1.txmoney.focus();
	  return false;
	}
	if(form1.txmoney.value<<%=JS_count%>)
	{
	  alert('对不起，最低提现金额为 <%=JS_count%> 元。')
	  form1.txmoney.focus();
	  return false;
	}
	return true;
  }
</script>


	<div id="mainborder">
		<div id="main">
			
		<h3 class="bigico bigico_money">商户结算</h3>
		<div class="vspace"></div>
		
		<div class="shrink">
			<form name="form1" onSubmit="return tixian();" method="post" action="?submit=m">



			
				<div id="summary">
					您的帐户余额:
					<span class="red big bold">
			  <%
			  if money=0 then
			  response.Write "0.00"
			  else
			  response.Write zero(FormatNumber(money,2))
			  end if
			  %></span> 元
					&nbsp; &nbsp;
					
					结算帐号:
					<span class="red big bold"><%=left(bank_card,7)&"******"%></span>
					(<span class="t1"><%=payee%></span>)
					<div class="vspace"></div>
				</div>
			
				<div>
					<input name="txmoney" type="text" id="txmoney" <%
			  if money<JS_count then
			  response.Write "disabled=""disabled"""
			  end if
			  %> class="aspNetDisabled" style="width:80px;" />
					<input type="submit" name="encashButton" value="申请提现" id="encashButton" <%
			  if money<JS_count then
			  response.Write "disabled=""disabled"""
			  end if
			  %> class="aspNetDisabled button" />
					&nbsp;
					<span class="orange">最低提现金额为 <%=JS_count%> 元。一天只能提现一次！</span>
				</div>
			
				

				<div class="vspace"></div>
				<div class="vspace"></div>
			
				



			<div class="gridwrap">
				<table class="fixed grid">
					<thead>
						<th width="60">划款金额</th>
						<th width="60">划款手续费</th>
						<th width="90">申请提现金额</th>
						<th width="100">申请日期</th>
						<th width="100">处理时间</th>
						<th width="145">处理备注</th>
						<th width="100">处理状态</th>
					</thead>
					

                  <%
		   set Rs=GrateRs("select * from M_tixian where username='"&session("usr_username")&"'  order by id desc",1)
		   if not Rs.eof then 
		   	do while not Rs.eof		   
		   %>
								<tr>
								<td><%=zero(formatnumber(Rs("huakuan")))%></td>
								<td><%=zero(formatnumber(Rs("shouxufei")))%></td>
								<td><%=zero(formatnumber(Rs("money")))%></td>
								<td><%=Rs("addtime")%></td>
								<td><%=Rs("lastdate")%></td>
								<td><%=Rs("beizhu")%></td>
								<td><%if rs("state")=0 then response.Write("处理中")%>
                        <%if rs("state")=1 then response.Write("<font color=red>支付成功</font>")%>
                        <%if rs("state")=2 then response.Write("<font color=red>拒绝支付</font>")%></td>
								</td>
								</tr>
                  <%
		   Rs.movenext
		   loop
		   else
		   response.Write("<tr id=zero>")
		   response.Write("<td colspan=""7"" class=""t3"">暂无提现记录。</td>")
		   response.Write("</tr>")
		   end if
		  %>



						
				</table>
			</div>
		
			</form>
		</div>
	
		</div>
	</div>
</div>
</body>
</html>



  