<!--#include file="head.asp"-->
<!--#include file="subleft.asp"-->

<script>document.getElementById('o_4').setAttribute("class", "ed"); document.getElementById("t_4").style.display="";document.getElementById('s_4_2').setAttribute("class", "ed6");</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="/Template/date.js" type="text/javascript"></script>
<title><%=webname%>-订单交易记录</title>

<br>
<DIV id=main2> 
<%call webleft()%>
<DIV id=main_right>
<DIV id=main_right_content>

<SCRIPT LANGUAGE="JavaScript">
var checkflag1 = "false";
function check1(field) {
if (checkflag1 == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag1 = "true";
return "false"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag1 = "false";
return "true"; }
}

function unselectall1()
{
    if(document.myform.chkAll1.checked){
	document.myform.chkAll1.checked = document.myform.chkAll1.checked&0;
	checkflag1 = "false";
    } 	
}
</script>
<%
call mydingdan_all("mydingdan")

if SafeRequest("isb")<>"y" then
'if Ubound(split(trim(request.ServerVariables("HTTP_REFERER")),"mydingdan.asp"))<=0 then
response.Cookies("date1")=""
response.Cookies("date2")=""
response.Cookies("dingdan")=""
response.Cookies("shangid")=""
response.Cookies("zhuangtai")=""
response.Cookies("youhui")=""
response.Cookies("lianxifs")=""
response.Cookies("qudao")=""
end if



link="mydingdan_all?cact=&isb=y"


act=SafeRequest("act")
if act="cha" then
sqldd=""

date1=SafeRequestform("date1")
date2=SafeRequestform("date2")
qudao=SafeRequestform("qudao")

dingdan=trim(SafeRequestform("dingdan"))
shangid=SafeRequestform("shangid")
zhuangtai=SafeRequestform("zhuangtai")
youhui=SafeRequestform("youhui")
lianxifs=SafeRequestform("lianxifs")

if date1<>"" then
response.Cookies("date1")=date1
else
response.Cookies("date1")=""
end if
if date2<>"" then
response.Cookies("date2")=date2
else
response.Cookies("date2")=""
end if

if dingdan<>"" then
response.Cookies("dingdan")=dingdan
else
response.Cookies("dingdan")=""
end if

if lianxifs<>"" then
response.Cookies("lianxifs")=lianxifs
else
response.Cookies("lianxifs")=""
end if

if shangid<>"0" then
response.Cookies("shangid")=shangid
else
response.Cookies("shangid")=""
end if

if zhuangtai<>"99" then
response.Cookies("zhuangtai")=zhuangtai
else
response.Cookies("zhuangtai")=""
end if

if qudao<>"999" then
response.Cookies("qudao")=qudao
else
response.Cookies("qudao")=""
end if

if youhui<>"" then
response.Cookies("youhui")=youhui
else
response.Cookies("youhui")=""
end if


end if

if request.Cookies("date1")<>"" then 
sqldd=sqldd&" and  datediff(day,aydingdansj,'"&request.Cookies("date1")&"')<=0"
end if
if request.Cookies("date2")<>"" then 
sqldd=sqldd&" and  datediff(day,aydingdansj,'"&request.Cookies("date2")&"')>=0"
end if

if request.Cookies("qudao")<>"" then sqldd=sqldd&" and ayddzffangshi='"&request.Cookies("qudao")&"'"
if request.Cookies("dingdan")<>"" then sqldd=sqldd&" and aydingdansum='"&request.Cookies("dingdan")&"'"
if request.Cookies("shangid")<>"" then sqldd=sqldd&" and ayddshangid='"&request.Cookies("shangid")&"'"
if request.Cookies("zhuangtai")<>"" then sqldd=sqldd&" and aydingdanzt='"&request.Cookies("zhuangtai")&"'"
if request.Cookies("lianxifs")<>"" then sqldd=sqldd&" and ayddcontact='"&request.Cookies("lianxifs")&"'"

if request.Cookies("youhui")<>"" then
if request.Cookies("youhui")=1 then sqldd=sqldd&" and ayddyouhuiquanzhi<>''"
if request.Cookies("youhui")=2 then sqldd=sqldd&" and ayddyouhuiquanzhi is null"
end if



if act="hebin" then
list1=SafeRequestform("list1")
if list1="" then call PopErr("未找到此项目")

	hebinid=split(list1,",")
	
	if Ubound(hebinid)<1 then call PopErr("请至少选择2个订单进行合并")


sql="select aydingdanid,aydingdansum from "&request.Cookies("ddku")&" where aydingdanid="&trim(hebinid(0))&"" 
rs.open sql,conn,1,3 
if not (rs.bof and rs.eof) then
ddd=trim(rs("aydingdansum"))
else
call PopErr("出现错误err1")
end if
rs.close
	
	For dianka=1 To Ubound(hebinid) 
	sql="select aydingdanid,aydingdansum from "&request.Cookies("ddku")&" where aydingdanid="&trim(hebinid(dianka))&"" 
	rs.open sql,conn,1,3 
	if rs.bof and rs.eof then
	call PopErr("未找到此项目err2")
	else
	ddhcard=trim(rs("aydingdansum"))
	rs.close
		
	end if
	next
	call logadd(request.Cookies("aynameid"),"订单合并成功",0,0)
	call PopErr2("订单合并成功！","mydingdan_all")
end if
%>
<H2><SPAN>订单交易记录</SPAN>
<%
rs.open "select aydlsjuserid from aydailishang where aydlsjuserid="&clng(request.Cookies("aynameid"))&"" ,conn,1,1
if not(rs.bof and rs.eof) then
response.Write "<a href=mydingdan_daili>[代理商订单]</a>"
end if
rs.close
%></H2>
<DIV class=main4>

<form action="?act=cha&isb=y" method="post" name="chaxun" id="chaxun">
<br>&nbsp;时&nbsp;&nbsp;间：
<input name="date1" type="text" class="inpcss" id="date1" onFocus="this.select()" onClick="fPopCalendar(event,this,this)" value="<%if request.Cookies("date1")<>"" then
response.Write request.Cookies("date1")
end if%>" size="17" readonly="readonly" /> 
&nbsp;&nbsp;&nbsp;截止至：
<input name="date2" type="text" class="inpcss" id="date2" onFocus="this.select()" onClick="fPopCalendar(event,this,this)" value="
<%if request.Cookies("date2")<>"" then
response.Write request.Cookies("date2")
end if%>" size="17" readonly="readonly" />

<select name="shangid" id="shangid" >
  <option value="0">选择商品</option>
  <%
	  sql="select aygoodsuoyouid,aygoodsx,aygoodid,aygoodname from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" order by aygoodsx asc" 
	  rs.open sql,conn,1,1
	  if rs.bof and rs.eof then %>
	  <option value="0">未找到商品</option>
	  <%else%>
	  <option value="0">不限</option>
	 <% do while not rs.eof%>
    <option value="<%=rs("aygoodid")%>" 
	  <%
	  if request.Cookies("shangid")<>"" then
	  if clng(request.Cookies("shangid"))=clng(rs("aygoodid")) then response.Write("selected")
	  end if%>>
	  <%=rs("aygoodname")%>
	  </option>
  <%	
	  rs.movenext 
	  loop
	  
	  end if
	  rs.close
	  %>
</select>

<br><br>
&nbsp;订单号：
<input name="dingdan" type="text" id="dingdan" class="inpcss" value="<%if request.Cookies("dingdan")<>"" then response.Write server.HTMLEncode(trim(request.Cookies("dingdan")))%>" size="17" maxlength="20">

&nbsp;联系方式：
<input name="lianxifs" type="text" id="lianxifs" class="inpcss" value="<%if request.Cookies("lianxifs")<>"" then response.Write server.HTMLEncode(trim(request.Cookies("lianxifs")))%>" size="17" maxlength="20">

<select name="zhuangtai" id="zhuangtai">
  <option value="99">支付状态</option>
  <option value="99">不限</option>
  <option value="0" 
  <%
    if request.Cookies("zhuangtai")<>"" then
	if cint(request.Cookies("zhuangtai"))=0 then response.Write("selected")
	end if
  %>
  >未支付</option>
  <option value="1"

    <%
    if request.Cookies("zhuangtai")<>"" then
	if cint(request.Cookies("zhuangtai"))=1 then response.Write("selected")
	end if
  %>>支付成功</option>
  <option value="2"
    <%
    if request.Cookies("zhuangtai")<>"" then
	if cint(request.Cookies("zhuangtai"))=2 then response.Write("selected")
	end if
  %>>支付失败</option>
</select>

<select name="qudao" id="qudao">
  <option value="999">支付渠道</option>
  <option value="999">不限</option>
  <option value="0"
  <%
    if request.Cookies("qudao")<>"" then
	if cint(request.Cookies("qudao"))=0 then response.Write("selected")
	end if
  %>>网银</option>
  <option value="1"
  <%
    if request.Cookies("qudao")<>"" then
	if cint(request.Cookies("qudao"))=1 then response.Write("selected")
	end if
  %>>充值卡</option>
  <option value="2"
  <%
    if request.Cookies("qudao")<>"" then
	if cint(request.Cookies("qudao"))=2 then response.Write("selected")
	end if
  %>>支付宝</option>
  <option value="3"
  <%
    if request.Cookies("qudao")<>"" then
	if cint(request.Cookies("qudao"))=3 then response.Write("selected")
	end if
  %>>财付通</option>
  <option value="99"
  <%
    if request.Cookies("qudao")<>"" then
	if cint(request.Cookies("qudao"))=99 then response.Write("selected")
	end if
  %>>账户余额</option>
</select>

<select name="youhui" id="youhui">
  <option value="0">优惠券</option>
  <option value="0">不限</option>
  <option value="1"
  <%
    if request.Cookies("youhui")<>"" then
	if cint(request.Cookies("youhui"))=1 then response.Write("selected")
	end if
  %>>使用</option>
  <option value="2"
  <%
    if request.Cookies("youhui")<>"" then
	if cint(request.Cookies("youhui"))=2 then response.Write("selected")
	end if
  %>>未使用</option>
</select>

&nbsp;
<input type="submit" name="Submit" value=" 订 单 查 询 ">

<br>
&nbsp;
</form>
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_style_a2">
     <form action="" method="post" name="myform" id="myform"> 
       <tr>
        <td height="35" align="center" class="border_bottom" style="font-weight: bold" >合并</td>
        <td align="center" class="border_bottom" style="font-weight: bold" >订单号 </td>       
        <td align="center" class="border_bottom" style="font-weight: bold" >商品</td>
        <td align="center" class="border_bottom" style="font-weight: bold">总价(元)</td>
        <td align="center" class="border_bottom" style="font-weight: bold">订单状态</td>
        <td align="center" class="border_bottom" style="font-weight: bold">支付渠道</td>        
        <td align="center" class="border_bottom" style="font-weight: bold">联系方式</td>
        <td align="center" class="border_bottom" style="font-weight: bold">时间</td>
       </tr>
<%
set rsdd=server.CreateObject("adodb.recordset")
sql="select aydingdanuser,aygooddlid,aydingdanid,ayddzffangshi,aydingdanzt,aydingdansum,isalipayfz,aydingdanzj,ayddshangid,ayddbody,ayddcontact,aydingdansj from "&request.Cookies("ddku")&" where aydingdanuser="&clng(request.Cookies("aynameid"))&""&sqldd&" order by aydingdanid desc" 
rs.open sql,conn,1,1
rs.pagesize=50
pagecount=rs.pagecount 
if request("page")="" then 
page=1
else
page=int(request("page")) 
end if
if page<=0 then page=1 
if request("page")="" then page=1
if not(rs.bof and rs.eof) then
rs.absolutepage=page
n=0
do while not rs.eof%>

	  <tr <%if n mod 2 = 0 then response.Write "bgcolor=#F7FFFF" %> >
        <td height="40" align="center" class="border_bottom">
		<%
		response.Write("&nbsp;")		
		%></td>
        <td align="center" class="border_bottom"><a href="mydingdanc?id=<%=rs("aydingdanid")%>"><%=trim(rs("aydingdansum"))%></a>
<%'上级代理
if clng(rs("aygooddlid"))<>0 and clng(rs("aygooddlid"))=clng(request.Cookies("aynameid")) then%>
<span style="color: #009933">[代<%=rs("aydingdanuser")%>]</span>
<%end if%>

<%'下级代理
if clng(rs("aygooddlid"))<>0 and clng(rs("aygooddlid"))<>clng(request.Cookies("aynameid")) then%>
<span style="color: #009933">[代<%=rs("aygooddlid")%>]</span>
<%end if%>
		<%if cint(rs("isalipayfz"))=1 then%><span style="color: #FF6600">[秒结]</span><%end if%>
		</td>
        <td align="center" class="border_bottom">
<%
set rsgood=server.CreateObject("adodb.recordset")

'上级代理
if clng(rs("aygooddlid"))<>0 and clng(rs("aygooddlid"))=clng(request.Cookies("aynameid")) then
sqlgood="select aygoodid,aygoodname from aygood where aygoodid="&clng(rs("aysgoodid"))&"" 
'下级代理
elseif clng(rs("aygooddlid"))<>0 and clng(rs("aygooddlid"))<>clng(request.Cookies("aynameid")) then
sqlgood="select aygoodid,aygoodname from aygood where aygoodid="&clng(rs("ayddshangid"))&""
else
sqlgood="select aygoodid,aygoodname from aygood where aygoodid="&clng(rs("ayddshangid"))&""
end if

rsgood.open sqlgood,conn,1,1
if not(rsgood.bof and rsgood.eof) then 
if len(trim(rsgood("aygoodname")))>15 then
response.Write left(rsgood("aygoodname"),15)&"…"
else
response.Write rsgood("aygoodname")
end if
else
response.Write("商品或已删除")
end if
rsgood.close

%></td>
        <td align="center" class="border_bottom" style="color: #FF0000; font-weight: bold"><%
		if trim(rs("aydingdanzj"))<>"" then
		response.Write Formatnumber(rs("aydingdanzj"),2,true,-1,0)
		else
		response.Write ("-")
		end if
		%></td>
        <td align="center" class="border_bottom">
		<%

			if cint(rs("aydingdanzt"))=0 then response.Write("未付款")
			if cint(rs("aydingdanzt"))=1 then response.Write("<font color=#00CC00>支付成功</font>")
			if cint(rs("aydingdanzt"))=2 then response.Write("<font color=red>支付失败</font>")
			if cint(rs("aydingdanzt"))=4 then response.Write"<font color=red>[已支付,卡密不足]</font>"

		%>		</td>
        <td align="center" class="border_bottom"><%
		if int(rs("ayddzffangshi"))=0 then response.Write "网银"
		if int(rs("ayddzffangshi"))=1 then response.Write "充值卡"
		if int(rs("ayddzffangshi"))=2 then response.Write "支付宝"
		if int(rs("ayddzffangshi"))=3 then response.Write "财付通"
		if int(rs("ayddzffangshi"))=4 then response.Write "微信"
		if int(rs("ayddzffangshi"))=5 then response.Write "手Q"
		if int(rs("ayddzffangshi"))=10 then response.Write "<span style=color:#F3C>支付宝WAP</span>"
		if int(rs("ayddzffangshi"))=12 then response.Write "<span style=color:#F3C>财付通WAP</span>"
		if int(rs("ayddzffangshi"))=13 then response.Write "<span style=color:#F3C>微信WAP</span>"
		if int(rs("ayddzffangshi"))=99 then response.Write "账户余额"
		%></td>
        <td align="center" class="border_bottom"><%if trim(rs("ayddcontact"))<>"" then
		response.Write rs("ayddcontact")
		else
		response.Write("-")
		end if
		%></td>
        <td align="center" class="border_bottom"><%=rs("aydingdansj")%></td>
	  </tr>
<%
n=n+1
rs.movenext  '指针向下移动
if n>=rs.pagesize then exit do  
loop
end if
zongshu=rs.RecordCount
rs.close%>
	  

      <tr>
        <td height="35" colspan="8">&nbsp;
          <input name="chkAll1" type="checkbox" id="chkAll1" onClick="this.value=check1(this.form.list1)" value="checkbox">
          全选
          <input type="submit" name="Submit2" value="合并订单" onClick="javascript:return confirm('您确定要合并订单吗？');">
		  <input name="act" type="hidden" id="act" value="hebin">
          <%call pageye()
%>		</td>
      </tr></form>
    </table>
</DIV>


</DIV></DIV>
<DIV class=clear></DIV></DIV>
</DIV>

<br>

	<!--#include virtual="/show/foot.asp"-->


