<!--#include file="head.asp"-->
<style>body{background-color: #fff;}</style>

<%
call chkyanzheng("mydingdan")

rs.open "select ayjihuakamiday from ayquanju" ,conn,1,1
ayjihuakamiday=rs("ayjihuakamiday")
rs.close

id=SafeRequest("id")
ddh=SafeRequest("ddh")
dl=SafeRequest("dl")



if SafeRequest("act")="nobuy" then
buyid=SafeRequest("buyid")
if buyid="" then call PopErr("缺少参数")

	sql="select * from ayname where aynameid="&request.Cookies("aynameid")&"" 
	rs.open sql,conn,1,3
	if not(rs.bof and rs.eof) then
	
		if trim(rs("nobuyid"))<>"" and isnull(trim(rs("nobuyid")))=false then
		
			if instr(1,trim(rs("nobuyid")),buyid&",")<>0 then
			call PopErr("该买家ID已存在，不能重复操作")
			else
			
			rs("nobuyid")=rs("nobuyid")&buyid&","
			rs.update
			call logadd(request.Cookies("aynameid"),"限制买家购买添加成功",0,0)
			call PopErr("添加成功")
			end if
		
		else
		
		rs("nobuyid")=buyid&","
		rs.update
		call logadd(request.Cookies("aynameid"),"限制买家购买添加成功",0,0)
		call PopErr("添加成功")
		
		end if
	
	end if
	rs.close

end if


if id="" then call PopErr("获取参数错误")

if SafeRequest("act")="ok" then
sql="select * from "&getddku(ddh)&" where aydingdanid="&clng(id)&"" 
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then

	if trim(rs("dailikuo"))<>"" then
		dailistr=split(trim(rs("dailikuo")),"|")
		dailiuserstr=split(dailistr(Ubound(dailistr)),",")
	
		if clng(dailiuserstr(4))<>clng(request.Cookies("aynameid")) then
		call PopErr("代理代充商品状态由总代处理")
		response.End()
		end if
	else
		if clng(rs("aydingdanuser"))<>clng(request.Cookies("aynameid")) then
		call PopErr("未找到订单")
		response.End()
		end if
	end if

	rs.update
	
else
call PopErr("未找到该订单")
end if
rs.close

	if dl="yes" then
	call PopErr2("订单状态转成功成功","mydingdan_daili")
	else
	call PopErr2("订单状态转成功成功","mydingdan")
	end if
end if

if SafeRequest("act")="no" then
sql="select * from "&getddku(ddh)&" where aydingdanid="&clng(id)&"" 
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then

	if trim(rs("dailikuo"))<>"" then
		dailistr=split(trim(rs("dailikuo")),"|")
		dailiuserstr=split(dailistr(Ubound(dailistr)),",")
	
		if clng(dailiuserstr(4))<>clng(request.Cookies("aynameid")) then
		call PopErr("代理代充商品状态由总代处理")
		response.End()
		end if
	else
		if clng(rs("aydingdanuser"))<>clng(request.Cookies("aynameid")) then
		call PopErr("未找到订单")
		response.End()
		end if
	end if

	rs.update
		
else
call PopErr("未找到该订单")
end if
rs.close
	if dl="yes" then
	call PopErr2("订单状态转成功成功","mydingdan_daili")
	else
	call PopErr2("订单状态转成功成功","mydingdan")
	end if
end if




sql="select * from "&getddku(ddh)&" where aydingdanid="&clng(id)&"" 
rs.open sql,conn,1,1
if rs.bof and rs.eof then
call PopErr("未找到订单")
response.End()
end if


if trim(rs("dailikuo"))<>"" then
	dailistr=split(trim(rs("dailikuo")),"|")
	dailiuserstr=split(dailistr(Ubound(dailistr)),",")
	
	if clng(dailiuserstr(4))<>clng(request.Cookies("aynameid")) and clng(rs("aydingdanuser"))<>clng(request.Cookies("aynameid")) then
	call PopErr("未找到订单")
	response.End()
	end if
else
	if clng(rs("aydingdanuser"))<>clng(request.Cookies("aynameid")) then
	call PopErr("未找到订单")
	response.End()
	end if
end if





%>



<main>
<div  class="container">
<div class="ui-lrctnei">
<%call userleft()%>
<div class="r"> 
<div class="ui-content">
                        
					
                            
<div class="neiye">

                            
            
            <!-------------------------------------- 开始 -------------------------------------->		
            <div class="neibiaoti"></div>
            <div class="neibiaoti2">订单详情</div>	
            <div class="gexian20"></div>						
                	<div class="neitable">
					<table>
                        <tr>
        					<td width="25%">订单编号</td>
                            <td width="25%">
							<%=rs("aydingdansum")%>
							<%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 width="25%">订单状态</td>
                            <td width="25%">
							<%
									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"))=1 and cint(rs("kamino"))=1 then
								
								dailikuo=trim(rs("dailikuo"))'代理关系
								dailiku=""					'总代理卡密库 
								if dailikuo<>"" then
								dailistr=split(dailikuo,"|")
								dailiuserstr=split(dailistr(Ubound(dailistr)),",")
								dailiku=trim(dailiuserstr(5))	'总代卡密库
								end if
								
								yifenpei=getddokkami(trim(rs("aydingdansum")),request.Cookies("aynameid"),dailiku)
								if ccur(yifenpei)<ccur(rs("ayddquantity")) then%>

<a style="color:#00CC00" href="mydingdanok?id=<%=trim(rs("aydingdansum"))%>&did=<%=rs("aydingdansum")%>" onClick="javascript:return confirm('确定已添加足够卡密并且需要补发卡密吗？');">[已分配卡密<%=yifenpei%>/购卡数量<%=rs("ayddquantity")%> 点击补卡]</a>

								<%end if
							end if
							
                            %>
                            </td>
                      </tr>
                      
                        <tr>
        					<td>付款交易号</td>
                            <td>
							<%
                            if trim(rs("aydingdanjjhao"))<>"" then
                            response.Write rs("aydingdanjjhao")
                            else
                            response.Write("-")
                            end if
                            %>
                            </td>
                            <td>买家联系方式</td>
                            <td>
							<%
                            if trim(rs("ayddcontact"))<>"" then
                            response.Write rs("ayddcontact")
                            else
                            response.Write("-")
                            end if
                            %>
                            </td>
                      </tr>
                      
                        <tr>
        					<td>订单单价</td>
                            <td><%=Formatnumber(rs("aydingdanjin"),2,true,-1,0)%>元</td>
                            <td>订单原价</td>
                            <td><%=Formatnumber(rs("aydingdanyj"),2,true,-1,0)%>元</td>
                       </tr>     

                        <tr>
        					<td>订单总价</td>
                            <td><%=Formatnumber(rs("aydingdanzj"),2,true,-1,0)%>元</td>
                            <td>购买数量</td>
                            <td><%=rs("ayddquantity")%>张</td>
                       </tr> 
                       
                        <tr>
        					<td>所属商品</td>
                            <td>
							<%
							aygooddlid=0
                            set rsshang=server.CreateObject("adodb.recordset")
                            sqlshang="select aygoodid,aygoodname,aygooddlid,aysjgid from aygood where aygoodid="&clng(rs("ayddshangid"))&"" 
                            rsshang.open sqlshang,conn,1,1
                            if not(rsshang.bof and rsshang.eof) then
							aygooddlid=rsshang("aygooddlid")  '上级代理ID 默认0无代理
							aysjgid=rsshang("aysjgid") 		 '上级商品ID
							aygoodsuoyouid=request.Cookies("aynameid")
                            response.Write rsshang("aygoodname")
                            end if
                            rsshang.close
                            %>
                            </td>
                            <td>所属分类</td>
                            <td>
							<%
                            set rsfl=server.CreateObject("adodb.recordset")
                            sqlfl="select aykafenleiname,aykafenleiid from aykafenlei where aykafenleiid="&clng(rs("ayddfeileiid"))&"" 
                            rsfl.open sqlfl,conn,1,1
                            if not(rsfl.bof and rsfl.eof) then
                            response.Write rsfl("aykafenleiname")
                            end if
                            rsfl.close
                            %>
                            </td>
                       </tr> 
                       
                        <tr>
        					<td>订单时间</td>
                            <td><%=rs("aydingdansj")%></td>
                            <td>提卡密码</td>
                            <td>
							<%
                            'if trim(rs("aydingdanka"))<>"" then
                            '    aa=split(rs("aydingdanka"),",")
                            '    i=1
                            '    For sum=0 To Ubound(aa) 
                            '    if i mod 5<>0 then
                            '    response.Write aa(sum)&"&nbsp;"
                            '    else
                            '    response.Write aa(sum)&"<br>"
                            '    end if
                            '    i=i+1
                            '    next
                            
                            'else
                            'response.Write("-")
                            'end if
                            %>
							<%if trim(rs("aydingdanpass"))<>"" and isnull(trim(rs("aydingdanpass")))=false then 
                            response.Write trim(rs("aydingdanpass"))
                            else
                            response.Write "未设置"
                            end if
                            %>
                            </td>
                       </tr> 
					
                        <tr>
        					<td>优惠券</td>
                            <td>
							<%if trim(rs("ayddyouhuiquan"))<>"" then
                            response.Write rs("ayddyouhuiquan")
                            else
                            response.Write("-")
                            end if
                            %>
                            </td>
                            <td>优惠幅度</td>
                            <td>
							<%
                            if trim(rs("ayddyouhuiquanzhi"))<>"" then
                            
                            youhuiquanstr=split(trim(rs("ayddyouhuiquanzhi")),"%")
                            if Ubound(youhuiquanstr)>0 then
                            response.Write rs("ayddyouhuiquanzhi")
                            else
                            response.Write rs("ayddyouhuiquanzhi")&"元"
                            end if
                            
                            else
                            response.Write("-")
                            end if
                            %>
                            
                            </td>
                       </tr> 
                       
                        <tr>
        					<td>买家平台ID</td>
                            <td>
							<%if cint(rs("ayddbuyid"))<>0 then
                            response.Write rs("ayddbuyid")&" <a href=?act=nobuy&buyid="&rs("ayddbuyid")&" style=color:#FF6600>[限制买家购买我的商品]</a>"
                            else
                            response.Write("-")
                            end if
                            %>
                            </td>
                            <td></td>
                            <td></td>
                       </tr> 
                    
                     
                    </table>
            		</div>
                    
            <!-------------------------------------- 结束 -------------------------------------->
                        
            
             <div class="gexian20"></div>

<%if cint(rs("aydingdanzt"))=1 then%>
            <!-------------------------------------- 开始 -------------------------------------->		
            <div class="neibiaoti"></div>
            <div class="neibiaoti2"><%response.Write"卡密信息"%></div>	
            <div class="gexian20"></div>						
                	<div class="neitable">
                    
                    
<%
'卡密订单
	'查找是否为代理商品
	isdailiok="yes"   '代理关系是否正常
	isshowkaok="yes"  '是否允许查看卖出卡密
	
	if clng(aygooddlid)<>0 then '是代理商品 
	isdailiok="yes"   '代理关系是否正常
	isshowkaok="yes"  '是否允许查看卖出卡密
	
				For dsum=1 To 10 '10层代理关系
				set rsd=server.CreateObject("adodb.recordset")
							
					'验证代理关系                                                                               '代理商 商户ID                        上级代理 商户ID 
					rsd.open "select aydluserid,aydlsjuserid,aydlistongguo from aydailishang where aydluserid='"&aygoodsuoyouid&"' and aydlsjuserid='"&clng(aygooddlid)&"' and aydlistongguo=1",conn,1,1
					if rsd.bof and rsd.eof then 
					isdailiok="no"
					end if
					rsd.close
					
					 
					'获取代理商品ID                                                                                 '上级商品ID                          上级代理 商户ID 
					rsd.open "select aygiska,aygsumid,aygoodsuoyouid,aysjgid,aygooddlid,aygoodid from aygood where aygoodid="&clng(aysjgid)&" and aygoodsuoyouid="&clng(aygooddlid)&"",conn,1,1
					if not(rsd.bof and rsd.eof) then 
						if clng(rsd("aygooddlid"))=0 then '已是顶级代理
							if clng(rsd("aygiska"))=0 then 
							isshowkaok="no"
							end if
						sjgoodid=aygooddlid
						aysjgid=aysjgid
						rsd.close
						exit for
						else
						aysjgid=rsd("aysjgid") 			     '上级商品ID 
						aygoodsuoyouid=rsd("aygoodsuoyouid") '代理商 商户ID  
						aygooddlid=rsd("aygooddlid")		 '上级代理 商户ID 
						end if
					else
					isshowkaok="no"		 					 '未找到代理商品
					end if
					rsd.close
					
				next 
			
	end if





%>
			  <table>
                        <tr>
        					<td width="25%">序号</td>
        					<td width="25%">卡号</td>
                            <td width="50%">密码</td>
                       </tr> 
                      <%
					  if isdailiok="yes" and isshowkaok="yes" then
						
							'if trim(rs("aydingdanka"))<>"" and isnull(trim(rs("aydingdanka")))=false then
							set rsk=server.CreateObject("adodb.recordset")
								
								'diankastr=split(trim(rs("aydingdanka")),",")
								n=0
								'For sum=0 To Ubound(diankastr) 
								n=n+1
										if trim(rs("dailikuo"))<>"" then
										dailistr=split(trim(rs("dailikuo")),"|")
										dailiuserstr=split(dailistr(Ubound(dailistr)),",")
										sqlk="select aykaid,ayka,aykapass,aykasuoyou,aykasuoyoudd,aykayesno from "&trim(dailiuserstr(5))&" where aykasuoyoudd='"&trim(rs("aydingdansum"))&"' and aykayesno=1" 
										else
										sqlk="select aykaid,ayka,aykapass,aykasuoyou,aykasuoyoudd,aykayesno from "&request.Cookies("kamiku")&" where aykasuoyoudd='"&trim(rs("aydingdansum"))&"' and aykayesno=1" 
										end if
										rsk.open sqlk,conn,1,1
										if not(rsk.bof and rsk.eof) then
										do while not rsk.eof
										%>
										<tr>
										  <td><%=n%></td>
										  <td><%=trim(rsk("ayka"))%></td>
										  <td>
											<%if trim(rsk("aykapass"))<>"0" then 
											response.Write trim(rsk("aykapass"))
											else
											response.Write ("未设置密码")
											end if%>
										  </td>
									   </tr> 
									   <%
									   rsk.movenext 
									   loop
									   else
									   %>
										<tr>
											<td><%=n%></td>
											<td>未找到卡密信息</td>
											<td>-</td>
									   </tr> 
									   <%end if
										rsk.close	
								'next
							'end if
						end if
						%>
                      </table>
<%end if%>
                    
                    
                    
                  
                    
            </div>
                    <%rs.close%>
                    
                                                                   
                   
            <div class="gexian20"></div>
            <div class="mzsmbox2" style="padding-top:20px;">
            重要提示：已卖出卡密在本平台只保存<%=ayjihuakamiday%>天，请通知买家及时使用，或下载到电脑妥善保存，本平台不提供保管卖出卡密责任！
            </div>

            </div>
            
           





        <div class="clearfix"></div>



</div>








</div>
</div>
</div>
</div>
</main>


<footer>
<div class="container">
</div>
</footer>

</body>
</html>