<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.AdministratorCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%
'****************************************************
' 提现后台处理  2010-11-29
'****************************************************
Dim KSCls
Set KSCls = New Admin_TiXian
KSCls.HSK_Run()
Set KSCls = Nothing

Class Admin_TiXian
        Private KS,KSCls
		Private totalPut,rs, Page, MaxPerPage,DomainStr,SearchType,SQLParam
		Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		 Set KSCls=Nothing
		End Sub
		Public Sub HSK_Run()
	    If Not (KS.ReturnPowerResult(0, "KMUA10007") or KS.ReturnPowerResult(5,"M510014"))Then
			  Call KS.ReturnErr(1, "")
			End If
		SearchType=KS.ChkClng(KS.G("SearchType"))
		 dim begindate:begindate=request("begindate")
		 dim enddate:enddate=request("enddate")

		Dim Action : Action=KS.S("Action")
		Dim Step:	 Step = KS.S("Step")
		Dim Msg:	 Msg = KS.S("Msg")
		Dim ID	:	 ID	= KS.ChkClng(KS.S("ID"))
		IF Action = "Status" Then
			Select Case Step
				Case 1
					Set Rs = Conn.Execute("Select Top 1 ID,UserName,Money,RealName From TiXian Where Status < 3 And ID=" & ID)
					If Not Rs.Eof Then
						Conn.Execute("UPDate TiXian Set Status=1,EndDate="& SqlNowString &",ManageIP='"& KS.GetIP() &"',Description='" & Msg & "',ManageName='" & KS.C("AdminName") & "' Where ID=" & ID)
						Call KS.MoneyInOrOut(Rs("UserName"),Rs("RealName"),Rs("Money"),4,1,Now,0,"系统","申请提现被拒绝",1000,ID,0)
						KS.AlertHintScript "提现拒绝成功！"
					Else
						KS.AlertHintScript "抱歉！该申请已经撤销或已经处理完成了。"
					End If
					Set Rs = Nothing
				Case 2
					Set Rs = Conn.Execute("Select Top 1 ID From TiXian Where Status < 3 And ID=" & ID)
					If Not Rs.Eof Then
						Conn.Execute("UPDate TiXian Set Status=2,EndDate="& SqlNowString &",ManageIP='"& KS.GetIP() &"',ManageName='" & KS.C("AdminName") & "' Where ID=" & ID)
						KS.AlertHintScript "申请已设为处理中状态！"
					Else
						KS.AlertHintScript "抱歉！该申请已经撤销或已经处理完成了。"
					End If
					Set Rs = Nothing
				Case 3
					Set Rs = Conn.Execute("Select Top 1 ID From TiXian Where Status=2 And ID=" & ID)
					If Not Rs.Eof Then
						Conn.Execute("UPDate TiXian Set Status=3,EndDate="& SqlNowString &",ManageIP='"& KS.GetIP() &"',ManageName='" & KS.C("AdminName") & "' Where ID=" & ID)
						KS.AlertHintScript "提现申请已完成！"
					Else
						KS.AlertHintScript "抱歉！该申请已经撤销或已经处理完成了。"
					End If
					Set Rs = Nothing
			End Select
			
		ElseIF Action="del" then
			Dim Param
			Select Case KS.ChkClng(KS.G("DelType"))
				Case 1 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>11"
				Case 2 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>31"
				Case 3 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>61"
				Case 4 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>91"
				Case 5 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>181"
				Case 6 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>366"
			End Select
			If Param<>"" Then
				Conn.Execute("Delete From TiXian Where 1=1 and " & Param)
				KS.AlertHintScript "已按所选的条件，删除了提现明细的相关记录！"
			End IF
		End If
		%>
<html>
<head><title>提现申请查询</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<link href="include/Admin_Style.css" type=text/css rel=stylesheet>
<script src="../HSK_JS/jquery.js" type="text/javascript"></script>
<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;
}
//复制内容进剪贴板
function copyToClipboard(txt,msg) {
      if(window.clipboardData) {
              window.clipboardData.clearData();
              window.clipboardData.setData("Text", txt);
      } else if(navigator.userAgent.indexOf("Opera") != -1) {
           window.location = txt;
      } else if (window.netscape) {
           try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
           } catch (e) {
                alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");
           }
           var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
           if (!clip)
                return;
           var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
           if (!trans)
                return;
           trans.addDataFlavor('text/unicode');
           var str = new Object();
           var len = new Object();
           var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
           var copytext = txt;
           str.data = copytext;
           trans.setTransferData("text/unicode",str,copytext.length*2);
           var clipid = Components.interfaces.nsIClipboard;
           if (!clip)
                return false;
           clip.setData(trans,null,clipid.kGlobalClipboard);
      }
	  msg = (typeof(msg)=="undefined")?'复制成功':msg;
      alert(msg+'!');
}
</script>
</head>
<body leftMargin=2 topMargin=0 marginheight="0" marginwidth="0">
  <div class="topdashed" style="padding:4px;">
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
<FORM name=form1 action=? method=get>
      <td>提现申请查询：</td>
      <td valign="top">快速查询： 
<Select onchange=javascript:submit() size=1 name=SearchType class='textbox'> 
  <Option value=0<%If SearchType="0" Then Response.write " selected"%>>所有提现申请记录</Option> 
  <Option value=1<%If SearchType="1" Then Response.write " selected"%>>3天内的提现申请</Option> 
  <Option value=2<%If SearchType="2" Then Response.write " selected"%>>已经完成的申请</Option> 
  <Option value=3<%If SearchType="3" Then Response.write " selected"%>>处理中的申请</Option> 
  <Option value=6<%If SearchType="6" Then Response.write " selected"%>>已拒绝的申请</Option> 
  <Option value=4<%If SearchType="4" Then Response.write " selected"%>>等待处理申请</Option> 
</Select>
	  </td></FORM>
<FORM name=form2 action=? method=post>
      <td style="border:1px #cccccc dashed">高级查询： 
<Select id=Field name=Field class='textbox'> 
  <Option value=2 selected>用户名</Option> 
  <Option value=1>客户姓名</Option> 
  <Option value=3>提现时间</Option>
  <Option value=4>提现编号</Option>
</Select> 
  <Input id=Keyword class='textbox' maxLength=30 name=Keyword> 
  <Input class='button' type=submit value=" 查 询 " name=Submit2> 
        <Input id=SearchType type=hidden value=5 name=SearchType> </td></FORM>
    </tr>
  </table>
  </div>

  <div style="border:1px #cccccc dashed;overflow:hidden"></div>
  
   <table width="100%" border="0">
<form action="?action=search&SearchType=100" method=post name="myform">
   
   <tr>
     <td width="12%"><strong>按时间段查询</strong></td>
     <td width="48%">
       
       <table width="100%"  align="center" border=0 cellPadding=0 cellSpacing=0>
         <tr>
           <td nowrap="nowrap" class=form-left>起始日期：
             <%if isdate(begindate) then%>
             <input type="text" name="begindate" value="<%=begindate%>" size="12" class="form-input">
             <%else%>
             <input type="text" name="begindate" value="<%=year(now)&"-"&month(now)&"-1"%>" size="12" class="form-input">
             <%end if%>
            </td>    
		    <td  class=form-left>终止日期：  
		      <%if isdate(enddate) then%>            
		      <input type="text" name="enddate" value="<%=enddate%>" size="12" class="form-input">
		      <%else%>
		      <input type="text" name="enddate" value="<%=formatdatetime(now,2)%>" size="12" class="form-input">
		      <%end if%>
		      </td>    
			</tr>
        </table>	 </td>
     <td width="43%"><!--关键字:
      <input type="text" class='textbox' name="keyword" size="10" value="<%=request("keyword")%>"/>-->
      <input name="submit2" type="submit" value="按日期查找" class='button' />
      </td>
    </tr>
</form>
 </table>
<table width="100%">
    <tr>
      <td align=left>
	  <%
	  if begindate<>"" and enddate<>"" then
	   response.write "<br><div align=center style='font-size:14px'>"
	 response.write "查询时间段 <font color=red>" & begindate & "</font> 至 <font color=red>" & enddate & "</font><br></div>"
	  end if
	  %></td>
    </tr>
  </table>
  
  
  
  <table width="100%">
    <tr>
      <td align=left>您现在的位置：<a href="LogTiXian.asp">提现申请管理</a>&nbsp;&gt;&gt;&nbsp;
	  <%Dim SearchTypeStr,SQLStr,TotalPages
	    Dim KeyWord:KeyWord=KS.G("KeyWord")
	  Select Case SearchType
	     Case 0 :SearchTypeStr="所有提现明细记录"
		 Case 1 :SearchTypeStr="3天内的提现申请"
		 Case 2 :SearchTypeStr="已经完成的申请"
		 Case 3 :SearchTypeStr="处理中的申请"
		 Case 6 :SearchTypeStr="已拒绝的申请"
		 Case 4 :SearchTypeStr="等待处理申请"
		 Case 5 
		    Select Case KS.ChkClng(KS.G("Field"))
			  Case 1:SearchTypeStr="客户姓名含有<font color=red>""" & KeyWord & """</font>"
			  Case 2:SearchTypeStr="用户名含有<font color=red>""" & KeyWord & """</font>"
			  Case 3:SearchTypeStr="提现时间含有<font color=red>""" & KeyWord & """</font>"
			  Case 4:SearchTypeStr="提现编号含有<font color=red>""" & KeyWord & """</font>"
			End Select
		Case 100:SearchTypeStr="时间段查询结果"
	  End Select
	  Response.Write SearchTypeStr%></td>
    </tr>
  </table>
    <div style="border:1px #cccccc dashed;overflow:hidden"></div>

  <table cellSpacing=0 cellPadding=0 width="100%" border=0>
    <tr class=sort align=middle>
      <td width="5%" nowrap>ID</td>
      <td width="10%" nowrap>提现编号</td>
      <td width="10%" nowrap>用户名</td>
      <td width="8%">收款姓名</td>
      <td width="8%">提现方式</td>
      <td width="10%">收款账号</td>
      <td width="9%">提现银行</td>
      <td width="8%">提现金额</td>
      <td width="8%">余额</td>
      <td width="14%">状态/操作</td>
      <td>备注/说明</td>
    </tr>
	<%
			MaxPerPage=20
			Page = KS.ChkClng(KS.G("page"))
			If Page<=0 Then  Page = 1
			SqlParam="1=1"
            If SearchType<>"0" Then
			  Select Case SearchType
			   Case 1
			   		if DataBaseType=1 then
					SqlParam=SqlParam &" And datediff(d,AddDate," & SqlNowString & ")<=3"
				   else
					SqlParam=SqlParam &" And datediff('d',AddDate," & SqlNowString & ")<=3"
				   end if
			  Case 2 : SqlParam = SqlParam & "And Status=3"
			  Case 3 : SqlParam = SqlParam & "And Status=2"
			  Case 4 : SqlParam = SqlParam & "And Status=0"
			  Case 6 : SqlParam = SqlParam & "And Status=1"
			  Case 5
			      Select Case KS.ChkClng(KS.G("Field"))
				   Case 1
				     SqlParam=SqlParam &" And RealName Like '%" & Keyword & "%'"
				   Case 2
				     SqlParam=SqlParam &" And UserName Like '%" & Keyword & "%'"
				   Case 3
				     SqlParam=SqlParam &" And AddDate Like '%" & Keyword & "%'"
				   Case 4
				     SqlParam=SqlParam &" And OrderID Like '%" & Keyword & "%'"
				  End Select
			  End Select
			End If
			If CInt(DataBaseType) = 1 Then         'Sql
				if isdate(begindate) then SqlParam=SqlParam & " and AddDate>='" & begindate & "'"
				if isdate(enddate) then enddate=DateAdd("d", 1,EndDate):SqlParam=SqlParam & " and AddDate<='" & enddate & "'"
			else
				if isdate(begindate) then SqlParam=SqlParam & " and AddDate>=#" & begindate & "#"
				if isdate(enddate) then enddate=DateAdd("d", 1,EndDate):SqlParam=SqlParam & " and AddDate<=#" & enddate & "#"
			end if


    If DataBaseType=1 Then
					Dim Cmd : Set Cmd = Server.CreateObject("ADODB.Command")
					Set Cmd.ActiveConnection=conn
					Cmd.CommandText="KS_GetPageRecords"
					Cmd.CommandType=4	
					CMD.Prepared = true 
					Cmd.Parameters.Append cmd.CreateParameter("@tblName",202,1,200)
					Cmd.Parameters.Append cmd.CreateParameter("@fldName",202,1,200)
					Cmd.Parameters.Append cmd.CreateParameter("@pagesize",3)
					Cmd.Parameters.Append cmd.CreateParameter("@pageindex",3)
					Cmd.Parameters.Append cmd.CreateParameter("@ordertype",3)
					Cmd.Parameters.Append cmd.CreateParameter("@strWhere",202,1,1000)
					Cmd.Parameters.Append cmd.CreateParameter("@fieldIds",202,1,1000)
					Cmd("@tblName")="TiXian"
					Cmd("@fldName")= "ID"
					Cmd("@pagesize")=MaxPerPage
					Cmd("@pageindex")=page
					Cmd("@ordertype")=1
					Cmd("@strWhere")=SqlParam
					Cmd("@fieldIds")="*"
					Set Rs=Cmd.Execute
					Set Cmd = Nothing
	 Else
			SQLStr=KS.GetPageSQL("TiXian","ID",MaxPerPage,Page,1,SqlParam,"*")
			Set RS = Server.CreateObject("AdoDb.RecordSet")
			RS.Open SQLStr, conn, 1, 1
	 End If
	If RS.Eof AND RS.Bof Then
	 Response.WRITE "<tr class=list onmouseover=""this.className='listmouseover'"" onmouseout=""this.className='list'""><td colspan=11 align=center height='25'>找不到" & SearchTypeStr & "!</td></tr>"
   Else
        totalPut = Conn.Execute("Select Count(1) From TiXian Where "& SQLParam)(0)
		Call showContent()
   End If
   RS.Close:Set RS=Nothing
   %>
     <div align=right>
         <%
		   	  '显示分页信息
  Call KS.ShowPage(totalput, MaxPerPage, "", Page,true,true)
		   %>
    </div>
	<br><br/>
	<br/>	<br>
<div class="attention">
<strong>特别提醒：</strong>
如果提现明细记录太多，影响了系统性能，可以删除一定时间段前的记录以加快速度。
<br />
<iframe src='about:blank' style='display:none' name='_hiddenframe' id='_hiddenframe'></iframe>
<form action="?action=del" target="_hiddenframe" method=post onSubmit="return(confirm('确实要删除有关记录吗？请慎重!'))">
删除范围：<input name="deltype" type="radio" value=1>
10天前 
    <input name="deltype" type="radio" value="2" />
    1个月前
    <input name="deltype" type="radio" value="3" />
    2个月前
    <input name="deltype" type="radio" value="4" />
    3个月前
    <input name="deltype" type="radio" value="5" />
    6个月前
    <input name="deltype" type="radio" value="6" checked="checked" />
    1年前
    <input type="submit" value="执行删除" class="button">
	</form>
</div>
	<br/>
</body>
</html>
   <%
   End Sub
  
  Sub ShowContent()
     on error resume next
     Dim I,totalmoney
     Do While Not rs.eof 
	%>
    <tr class=list onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'">
      <td class="splittd" align=middle onClick="$('#C<%=rs("id")%>').toggle()" style="cursor:pointer"><%=rs("ID")%></td>
      <td class="splittd" align=middle onClick="$('#C<%=rs("id")%>').toggle()" style="cursor:pointer"><%=rs("OrderID")%></td>
      <td class="splittd" align=middle><a href="javascript:;" onClick="if(confirm('选“确定”查询该用户资金明细！\n\n选“取消”查看该用户提现明细！')){self.location.href='LogMoney.asp?keyword=<%=rs("username")%>&field=2&searchtype=5';}else{self.location.href='?keyword=<%=rs("username")%>&field=2&searchtype=5';}"><%=rs("username")%></a> <font color="#FF0000" title="提现次数"><strong>(<%=Conn.Execute("SELECT Count(0) From TiXian Where UserName ='" & rs("username") & "'")(0)%>)</strong></font></td>
	  <td class="splittd" align=middle><%=rs("RealName")%></td>
      <td class="splittd" align=middle>
	  <% Select Case rs("PaymentType")
	      Case 1:Response.WRite "支付宝"
		  Case 2:Response.Write "淘宝商品"
		  Case 3:Response.Write "财付通"
		  Case 4:Response.Write "银行"
		 End Select
	 %>
	  </td>
      <td class="splittd" align=middle onClick="$('#C<%=rs("id")%>').toggle()" style="cursor:pointer"><span title="<%
	  If rs("BankName")<>"" Then
	  	KS.Echo "银行信息：" & rs("BankName")
	  Else
	  	KS.Echo "请登录支付宝给此账号打款"
	  End If
	  %>"><%
	  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 "<a href=""javascript:void(0);"" onclick=""copyToClipboard('" & rs("Account") & "','" & rs("Account") & " 已复制成功')"">" & rs("Account") & "</a>"
	  End If
	  %></span></td>
      <td class="splittd" align=center><%=rs("BankName")%>&nbsp;</td>
      <td class="splittd" align=center>
	  <% Response.Write formatnumber(rs("money"),2)
		 totalmoney = totalmoney+rs("money")
		%></td>
      <td class="splittd" align=center><% =formatnumber(rs("MoneyCurrent"),2,-1) %></td>
      <td class="splittd" align=middle><%
	  Select Case RS("Status")
	      Case 0
		  		Response.WRite "<font color=blue>待处理</font>|<a href=""javascript:void(0);"" onclick=""if(confirm('您确定该申请不符合提现要求吗？')){var a=prompt('请填写拒绝原因！','提现商品的价格与提现金额不一致');if(a!=null){self.location.href='?Action=Status&Step=1&ID=" & rs("ID") & "&msg='+ a;}}""><font color=red>拒绝</font></a>|<a href=""?Action=Status&Step=2&ID=" & rs("ID") & """ onclick=""return confirm('您确定现在要处理吗？');""><font color=red>处理</font></a>"
		  Case 1:Response.Write "<font color=green>已拒绝</font>"
		  Case 2:Response.Write "<font color=blue>处理中</font>|<a href=""javascript:void(0);"" onclick=""if(confirm('您确定该申请不符合提现要求吗？')){var a=prompt('请填写拒绝原因！','提现帐号错误');if(a!=null){self.location.href='?Action=Status&Step=1&ID=" & rs("ID") & "&msg='+ a;}}""><font color=red>拒绝</font></a>|<a href=""?Action=Status&Step=3&ID=" & rs("ID") & """ onclick=""return confirm('您确定已经给客户支付了吗？');"" title=""确定已经给客户支付成功后再点击此按钮""><font color=red>已打款</font></a>"
		  Case 3:Response.Write "已完成"
	  End Select	
	   %></td>
      <td class="splittd" align=middle><%=rs("Description")%>&nbsp;</td>
    </tr>
    <tr id="C<%=rs("id")%>" bgcolor="#EEEEEE" style="display:none;">
      <td class="splittd" align=center colSpan=11>用户IP：<%=rs("UserIP")%> &nbsp; &nbsp; 申请提现时间：<%=rs("AddDate")%> &nbsp; &nbsp; 更新/完成日期：<%=rs("EndDate")%> &nbsp; &nbsp; 操作员：<%=rs("ManageName")%></td>
    </tr>
	<%
	I = I + 1
	RS.MoveNext
	If I >= MaxPerPage Then Exit Do
	loop
	%>
    <tr class=list onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'">
      <td class="splittd" align=right colSpan=7>本页合计：</td>
      <td class="splittd" align=right><%=formatnumber(totalmoney,2)%></td>
      <td class="splittd" colSpan=3>&nbsp;</td>
    </tr>
    <tr class=list onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'">
      <td class="splittd" align=right colSpan=7>总计金额：</td>
	  <%totalmoney=Conn.execute("Select Sum(Money) From TiXian Where "& SqlParam)(0)
	    if not isnumeric(totalmoney) then totalmoney=0
	  %>
      <td class="splittd" align=right><%=formatnumber(totalmoney,2)%></td>
      <td class="splittd" align=middle colSpan=3>&nbsp;</td>
    </tr>
  </table>
		<%
		End Sub
End Class
%> 
