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


<script>document.getElementById('o_1').setAttribute("class", "ed"); document.getElementById("t_1").style.display="";document.getElementById('s_1_5').setAttribute("class", "ed4");</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title><%=webname%>-代理商</title>

<%
act=trim(SafeRequest("act"))
id=SafeRequest("id")

if SafeRequestform("cact")="edit" then
did=SafeRequestform("did")
aydliska=SafeRequestform("aydliska")
aydlismka=SafeRequestform("aydlismka")
aydlfandian=trim(SafeRequestform("aydlfandian"))
aydlfeiyongf=SafeRequestform("aydlfeiyongf")
if did="" then call PopErr("出现错误")
if aydlfandian="" then call PopErr("返点输入有误")
if aydliska="" then aydliska=0
if aydlismka="" then aydlismka=0

'检查返点输入是否合法
yfd=aydlfandian
strf=split(yfd,"%")
if Ubound(strf)<>0 then '有%操作
	if Ubound(strf)>1 then call PopErr("返点输入有误1")
	yfd=replace(yfd,"%"," ")
	yfd=trim(yfd)
	call cisnum(yfd)
	strd=split(yfd,".")	
	if Ubound(strd)>1 then call PopErr("返点输入有误2")
	if Ubound(strd)=1 then
		For dsum=0 To Ubound(strd) 
		if isNumeric(strd(dsum))=false then call PopErr("返点输入有误3")
		next
	else
		if not isNumeric(yfd) then call PopErr("返点输入有误4")
	end if
else '无%操作
	call cisnum(yfd)
	strd=split(yfd,".")	
	if Ubound(strd)>1 then call PopErr("返点输入有误5")
	if Ubound(strd)=1 then
		For dsum=0 To Ubound(strd) 
		if isNumeric(strd(dsum))=false then call PopErr("返点输入有误6")
		next
	else
		if not isNumeric(yfd) then call PopErr("返点输入有误7")
	end if
end if


sql="select * from aydailishang where aydlid="&did&"" 
rs.open sql,conn,1,3
if rs.bof and rs.eof then
call PopErr("未找到该代理关系")
else
if clng(rs("aydlsjuserid"))<>clng(request.Cookies("aynameid")) then  call PopErr("出现错误")
rs("aydliska")=aydliska
rs("aydlismka")=aydlismka
rs("aydlfandian")=aydlfandian
rs("aydlfeiyongf")=aydlfeiyongf
rs.update
call logadd(request.Cookies("aynameid"),"代理关系设置成功-"&did,0,0)
call PopErr2("代理关系设置成功","dailiedit?act=edit&id="&id&"")

end if
rs.close

end if


if SafeRequestform("act")="allgedit" then
n=SafeRequestform("n")
id=SafeRequestform("id")
uid=SafeRequestform("uid")   '下级代理ID 

if trim(SafeRequestform("aysjjiage"))="" then call PopErr("代理价格请填写完整")
if trim(SafeRequestform("aygoodid"))="" then call PopErr("出现错误E2-1")
if trim(SafeRequestform("aygsumid"))="" then call PopErr("出现错误E3-2")
if trim(SafeRequestform("aygoodfl"))="" then call PopErr("出现错误E4-3")
if trim(SafeRequestform("ayjiage"))="" then call PopErr("出现错误E4-4")
if trim(SafeRequestform("aygoodzhuangtai"))="" then call PopErr("出现错误E4-5")


if id="" or uid="" then call PopErr("出现错误E5")
if len(id)>5 then call PopErr("出现错误E6")
if isNumeric(id)=false then call PopErr("出现错误E7")
if n="" then call PopErr("出现错误E8")

'代理关系确定
rs.open "select * from aydailishang where aydlid="&id&"",conn,1,1
if not(rs.bof and rs.eof) then
if clng(rs("aydlsjuserid"))<>clng(request.Cookies("aynameid")) then  call PopErr("权限错误E1")
if uid<>rs("aydluserid") then  call PopErr("权限错误E2")
sid=rs("aydlsjuserid")       '上级代理ID 
else
call PopErr2("未找到代理关系","userdaili")
end if
rs.close

aygoodid=split(trim(SafeRequestform("aygoodid")),",")       '商品ID
aygoodfl=split(trim(SafeRequestform("aygoodfl")),",")       '分类ID
aygsumid=split(trim(SafeRequestform("aygsumid")),",")       '唯一标示
ayjiage=split(trim(SafeRequestform("ayjiage")),",")         '价格
aysjjiage=split(trim(SafeRequestform("aysjjiage")),",")      '代理价格
aygiska=split(trim(SafeRequestform("aygiska")),",")          '是否可以查看卡密
aygismka=split(trim(SafeRequestform("aygismka")),",")        '是否可以查看已卖出卡密
aygoodisydl=split(trim(SafeRequestform("aygoodisydl")),",")  '是否允许代理该商品
aygoodzhuangtai=split(trim(SafeRequestform("aygoodzhuangtai")),",")  '商品状态


'检查返点输入是否合法
For sum = 0 To n-1
yjg=trim(ayjiage(sum))
yfd=trim(aysjjiage(sum))
if ccur(yfd)>ccur(yjg) then call PopErr("代理价格不得高于销售价格")
if yfd="" then call PopErr("代理价格有误E4")
if yfd=0 then call PopErr("代理价格不能为0")
	call cisnum(yfd)
	strd=split(yfd,".")	
	if Ubound(strd)>1 then call PopErr("代理价格有误E5")
	if Ubound(strd)=1 then
		For dsum=0 To Ubound(strd) 
		if isNumeric(strd(dsum))=false then call PopErr("代理价格有误E6")
		next
	else
		if not isNumeric(yfd) then call PopErr("代理价格有误E7")
	end if
Next

		set rs2=server.CreateObject("adodb.recordset")
		set rsfl=server.CreateObject("adodb.recordset")
		set rsej=server.CreateObject("adodb.recordset")
		set rsejb=server.CreateObject("adodb.recordset")
		
		
		
		'获取上级代理商品分类信息
		rs.open "select * from aykafenlei where aykanamesuoyou="&sid&" order by ayshangjiid asc",conn,1,1
		if rs.bof and rs.eof then call PopErr("还未添加商品分类")
		do while not rs.eof
		
				'查询上级分类ID
				fenleierji=0
				ayflsumid=""
				if clng(rs("ayshangjiid"))<>0 then '属于二级分类  获取上级分类唯一标示
					rs2.open "select aykafenleiid,aykanamesuoyou,ayflsumid from aykafenlei where aykafenleiid="&rs("ayshangjiid")&" and aykanamesuoyou="&sid&"",conn,1,1
					if not(rs2.eof) then
					ayflsumid=trim(rs2("ayflsumid"))
					end if
					rs2.close
					'获取本地上级分类ID
					if ayflsumid<>"" then
						rs2.open "select aykafenleiid,ayflsumid,aykanamesuoyou from aykafenlei where ayflsumid='"&ayflsumid&"' and aykanamesuoyou="&uid&"",conn,1,1
						if not(rs2.eof) then
						fenleierji=rs2("aykafenleiid")
						end if
						rs2.close
					end if
				end if
				
				'添加本地分类
				rs2.open "select * from aykafenlei where ayflsumid='"&trim(rs("ayflsumid"))&"' and aykanamesuoyou="&uid&" and ayfenleidlid="&sid&"",conn,1,3
				if rs2.bof and rs2.eof then
				rs2.addnew
				rs2("aykafenleiname")=trim(rs("aykafenleiname"))
				rs2("ayshangjiid")=clng(fenleierji)
				rs2("aykafenleisx")=rs("aykafenleisx")
				rs2("aykanamesuoyou")=uid
				rs2("ayfenleidlid")=clng(sid)
				rs2("ayflsumid")=trim(rs("ayflsumid"))
				rs2("ayfenleidlfid")=rs("aykafenleiid")
				rs2("aykafenleikg")=rs("aykafenleikg")
				rs2("aykafenleishuoming")=trim(rs("aykafenleishuoming"))
				rs2.update
				end if
				rs2.close
				
				'获取本地分类MD5 ID
				rs2.open "select top 1 * from aykafenlei where ayflsumid='"&trim(rs("ayflsumid"))&"' and aykanamesuoyou="&uid&" and ayfenleidlid="&sid&"",conn,1,3
				if not(rs2.eof) then
				md51=md5d(rs2("aykafenleiid"))
				md52=md5user(rs2("aykafenleiid"))
				rs2("aykafenleimd5")=md51
				rs2("ayfldlmd5url")=md52
				rs2.update
				end if
				rs2.close
				
		rs.movenext 
		loop
		rs.close


For sum = 0 To n-1

conn.execute "update aygood set aygiska='"&aygiska(sum)&"',aygismka='"&aygismka(sum)&"' where aygoodid='"&aygoodid(sum)&"' and aygoodsuoyouid='"&clng(request.Cookies("aynameid"))&"'"

sql="select * from aygood where aygsumid='"&trim(aygsumid(sum))&"' and aygoodsuoyouid="&uid&" and aygooddlid="&sid&"" 
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then

	'本地              '上级
	rs("ayjiage")=trim(ayjiage(sum))
	rs("aychenben")=trim(aysjjiage(sum))
	rs("aysjjiage")=trim(aysjjiage(sum))
	rs("aygiska")=trim(aygiska(sum))
	rs("aygismka")=trim(aygismka(sum))
	rs("aygoodisydl")=trim(aygoodisydl(sum))
	rs("aysjgid")=aygoodid(sum)
	rs("aygoodzhuangtai")=aygoodzhuangtai(sum)
	rs("kahaoname")="卡号"
	rs("kaminame")="密码"
	rs("aygoodiskucun")=1	'代理商品 不显示实际库存		
	'rs("aygoodtodaili")=trim(aysjjiage(sum))
	rs.update

else

	'新建本地商品
	fenleiid=0
	set rsg=server.CreateObject("adodb.recordset")
	sqlg="select * from aygood where aygoodid="&aygoodid(sum)&" and aygoodsuoyouid="&sid&"" 
	rsg.open sqlg,conn,1,3
	if rsg.bof and rsg.eof then call PopErr("商品信息错误")
		'查找总代商品分类
		set rsf=server.CreateObject("adodb.recordset")
		sqlf="select aykafenleiid,ayflsumid from aykafenlei where aykafenleiid="&rsg("aygoodfl")&"" 
		rsf.open sqlf,conn,1,1
		if rsf.bof and rsf.eof then call PopErr("商品分类错误")
		 	'查找代理商商品分类ID
			set rsd=server.CreateObject("adodb.recordset")
			sqld="select aykafenleiid,ayflsumid,aykanamesuoyou from aykafenlei where ayflsumid='"&rsf("ayflsumid")&"' and aykanamesuoyou="&uid&""
			rsd.open sqld,conn,1,1
			if rsd.bof and rsd.eof then call PopErr("查找代理商商品分类错误")
			fenleiid=rsd("aykafenleiid")
			rsd.close
		rsf.close
	
	'添加本地商品
	set rsgg=server.CreateObject("adodb.recordset")
	sqlgg="select * from aygood" 
	rsgg.open sqlgg,conn,1,3
	rsgg.addnew
	rsgg("aygoodsuoyouid")=uid
	rsgg("aygoodfl")=fenleiid
	rsgg("aygoodsx")=rsg("aygoodsx")
	rsgg("aygoodname")=trim(rsg("aygoodname"))
	rsgg("ayjiage")=rsg("ayjiage")
	
	rsgg("ayxiangou")=rsg("ayxiangou") '限购
	rsgg("aypifayes")=rsg("aypifayes") '批发
	
	
	if clng(rsg("aypifa1"))<>0 and rsg("dailij1")<>0 then 
	rsgg("aypifa1")=rsg("aypifa1")
	rsgg("aypifaj1")=rsg("aypifaj1")
	rsgg("dailicb1")=rsg("dailij1")
	end if
	if clng(rsg("aypifa2"))<>0 and rsg("dailij2")<>0 then 
	rsgg("aypifa2")=rsg("aypifa2")
	rsgg("aypifaj2")=rsg("aypifaj2")
	rsgg("dailicb2")=rsg("dailij2")
	end if
	if clng(rsg("aypifa3"))<>0 and rsg("dailij3")<>0 then 
	rsgg("aypifa3")=rsg("aypifa3")
	rsgg("aypifaj3")=rsg("aypifaj3")
	rsgg("dailicb3")=rsg("dailij3")
	end if
	if clng(rsg("aypifa4"))<>0 and rsg("dailij4")<>0 then 
	rsgg("aypifa4")=rsg("aypifa4")
	rsgg("aypifaj4")=rsg("aypifaj4")
	rsgg("dailicb4")=rsg("dailij4")
	end if
	if clng(rsg("aypifa5"))<>0 and rsg("dailij5")<>0 then 
	rsgg("aypifa5")=rsg("aypifa5")
	rsgg("aypifaj5")=rsg("aypifaj5")
	rsgg("dailicb5")=rsg("dailij5")
	end if

	rsgg("aysjjiage")=trim(aysjjiage(sum))
	rsgg("aychenben")=trim(aysjjiage(sum))

	rsgg("kahaoname")="卡号"
	rsgg("kaminame")="密码"
	rsgg("ayshmiaoshu")=trim(rsg("ayshmiaoshu"))
	rsgg("goodxx")=trim(rsg("goodxx"))
	rsgg("goodbuyxx")=trim(rsg("goodbuyxx"))
	
	rsgg("aygoodzhuangtai")=aygoodzhuangtai(sum)
	rsgg("aygooddlid")=sid
	'rsgg("aygshouxuf")=trim(aygshouxuf(sum))
	rsgg("aygiska")=trim(aygiska(sum))
	rsgg("aygismka")=trim(aygismka(sum))
	rsgg("aygoodisydl")=trim(aygoodisydl(sum))
	rsgg("aygsumid")=trim(rsg("aygsumid"))
	rsgg("aysjgid")=aygoodid(sum)
	rsgg("aygoodiskucun")=1	'代理商品 不显示实际库存	
	gudinggoodid=trim(rsg("aygsumid"))
	
	rsgg.update
	rsgg.close
	rsg.close
	
	'获取本地商品MD5 ID
	set rsgid=server.CreateObject("adodb.recordset")
	sqlgid="select top 1 aygoodsuoyouid,aygoodid,aygsumid,aygoodmd5,aygdlmd5url from aygood where aygsumid='"&gudinggoodid&"' and aygoodsuoyouid="&uid&"" 
	rsgid.open sqlgid,conn,1,3
	if not(rsgid.bof and rsgid.eof) then
	md51=md5d(rsgid("aygoodid"))
	md52=md5user(rsgid("aygoodid"))
	rsgid("aygoodmd5")=md51
	rsgid("aygdlmd5url")=md52
	rsgid.update
	end if
	rsgid.close
		
	
end if
rs.close





'response.Write aygoodid(sum)&"<br>" 
'response.Write aygoodfl(sum)&"<br>" 
'response.Write aygsumid(sum)&"<br>" 
'response.Write aysjjiage(sum)&"<br>" 
'response.Write aygshouxuf(sum)&"<br>" 
'response.Write aygiska(sum)&"<br>" 
'response.Write aygoodisydl(sum)&"<br>" 





Next


		'删除上级代理已删除的商品
		set rsd=server.CreateObject("adodb.recordset")
		set rsd2=server.CreateObject("adodb.recordset")
		sqld="select * from aygood where aygoodsuoyouid='"&uid&"' and aygooddlid='"&sid&"'" 
		rsd.open sqld,conn,1,3
		do while not rsd.eof
			sqld2="select * from aygood where aygoodid='"&rsd("aysjgid")&"' and aygoodsuoyouid='"&sid&"'" 
			rsd2.open sqld2,conn,1,1
			if rsd2.bof and rsd2.eof then
			rsd.delete
			end if
			rsd2.close
		rsd.movenext 
		loop
		rsd.close
		
		'删除上级代理已删除的商品分类
		sqld="select * from aykafenlei where aykanamesuoyou='"&uid&"' and ayfenleidlid='"&sid&"'" 
		rsd.open sqld,conn,1,3
		do while not rsd.eof
			sqld2="select * from aykafenlei where aykafenleiid='"&rsd("ayfenleidlfid")&"' and aykanamesuoyou='"&sid&"'" 
			rsd2.open sqld2,conn,1,1
			if rsd2.bof and rsd2.eof then
			rsd.delete
			end if
			rsd2.close
		rsd.movenext 
		loop
		rsd.close




call logadd(request.Cookies("aynameid"),"代理商品全部设置并同步成功-"&id,0,0)
call PopErr2("代理关系设置成功","dailiedit?act=edit&id="&id&"")
end if





if SafeRequest("act")="sdel" then
id=trim(SafeRequest("id"))
if id="" then call PopErr("出现错误")
if len(id)>5 then call PopErr("出现错误")
if isNumeric(id)=false then call PopErr("出现错误")
sql="select * from aydailishang where aydlid="&id&"" 
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
if clng(rs("aydlsjuserid"))<>clng(request.Cookies("aynameid")) then  call PopErr("出现错误")
uid=trim(rs("aydluserid"))
sid=trim(rs("aydlsjuserid"))
rs.delete
rs.close
sql="select aydluserid from aydailishang where aydluserid='"&clng(uid)&"' and aydlistongguo=1" 
rs.open sql,conn,1,1
if rs.bof and rs.eof then
	set rsu=server.CreateObject("adodb.recordset")
	sqlu="select aynameid,ayisdaili from ayname where aynameid="&clng(uid)&"" 
	rsu.open sqlu,conn,1,3
	if not(rsu.bof and rsu.eof) then
	rsu("ayisdaili")=0
	rsu.update
	else
	rsu("ayisdaili")=1
	rsu.update
	end if
	rsu.close
end if
rs.close
sql="select aygoodsuoyouid,aygooddlid from aygood where aygoodsuoyouid="&clng(uid)&" and aygooddlid="&clng(sid)&"" 
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
do while not rs.eof
rs.delete
rs.movenext 
loop
end if
rs.close
sql="select aykanamesuoyou,ayfenleidlid from aykafenlei where aykanamesuoyou="&clng(uid)&" and ayfenleidlid="&clng(sid)&"" 
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
do while not rs.eof
rs.delete
rs.movenext 
loop
end if
rs.close
call logadd(request.Cookies("aynameid"),"代理关系删除成功-"&id,0,0)
call PopErr2("代理关系删除成功","userdaili")
else
call PopErr("未找到该代理关系")
end if
rs.close
end if






if SafeRequest("act")="quxiaodl" then
id=trim(SafeRequest("id"))
if id="" then call PopErr("出现错误")
if len(id)>5 then call PopErr("出现错误")
if isNumeric(id)=false then call PopErr("出现错误")

sql="select * from aydailishang where aydlid="&id&"" 
rs.open sql,conn,1,3
if not(rs.bof and rs.eof) then
if clng(rs("aydlsjuserid"))<>clng(request.Cookies("aynameid")) then  call PopErr("出现错误")
uid=trim(rs("aydluserid"))
rs("aydlistongguo")=2
rs.update
rs.close

call logadd(request.Cookies("aynameid"),"代理关系取消成功-"&id,0,0)
call PopErr2("操作成功","userdaili")
else
call PopErr("未找到该代理关系")
end if
rs.close
end if








if SafeRequest("act")="tongbu" then

id=trim(SafeRequest("id"))
if id="" then call PopErr("出现错误")
if len(id)>5 then call PopErr("出现错误")
if isNumeric(id)=false then call PopErr("出现错误")

	'获取代理关系信息 
	sql="select * from aydailishang where aydlid="&id&"" 
	rs.open sql,conn,1,1
		if rs.bof and rs.eof then
		call PopErr("未找到该代理关系")
		rs.close
		else

			if clng(rs("aydlsjuserid"))<>clng(request.Cookies("aynameid")) then  call PopErr("无权限")
			if cint(rs("aydlistongguo"))<>1 then call PopErr("代理关系不成立")
		uid=rs("aydluserid")
		sid=rs("aydlsjuserid")
		sfd=rs("aydlfandian")
		shou=rs("aydlfeiyongf")
		kami=rs("aydliska")
		kami2=rs("aydlismka")
		rs.close

		'清空现有分类与商品
		sql="select aygooddlid,aygoodsuoyouid from aygood where aygooddlid="&sid&" and aygoodsuoyouid="&uid&"" 
		rs.open sql,conn,1,3
		if not(rs.bof and rs.eof) then
		do while not rs.eof
		rs.delete
		rs.movenext 
		loop
		end if
		rs.close
		sql="select ayfenleidlid,aykanamesuoyou from aykafenlei where ayfenleidlid="&sid&" and aykanamesuoyou="&uid&"" 
		rs.open sql,conn,1,3
		if not(rs.bof and rs.eof) then
		do while not rs.eof
		rs.delete
		rs.movenext 
		loop
		end if
		rs.close

		'获取上级代理商品分类信息
		sql="select * from aykafenlei where aykanamesuoyou="&sid&" order by ayshangjiid asc" 
		rs.open sql,conn,1,1
		if rs.bof and rs.eof then
		call PopErr("未找到上级代理商品分类信息")
		else
		do while not rs.eof

			'添加本地商品分类
			fenleierji=0
			if clng(rs("ayshangjiid"))<>0 then '二级分类
			
			set rsej=server.CreateObject("adodb.recordset")
			sqlej="select aykafenleiid,aykanamesuoyou,ayflsumid from aykafenlei where aykafenleiid="&rs("ayshangjiid")&" and aykanamesuoyou="&sid&"" 
			rsej.open sqlej,conn,1,1
			if not(rsej.bof and rsej.eof) then
				'查找本地二级分类ID
				set rsejb=server.CreateObject("adodb.recordset")
				sqlejb="select aykafenleiid,ayflsumid,aykanamesuoyou from aykafenlei where ayflsumid='"&trim(rsej("ayflsumid"))&"' and aykanamesuoyou="&uid&"" 
				rsejb.open sqlejb,conn,1,1
				if not(rsejb.bof and rsejb.eof) then
				fenleierji=rsejb("aykafenleiid")
				end if
				rsejb.close
			end if
			rsej.close
			end if
			
			set rsfl=server.CreateObject("adodb.recordset")
			sqlfl="select * from aykafenlei" 
			rsfl.open sqlfl,conn,1,3
			rsfl.addnew
			rsfl("aykafenleiname")=trim(rs("aykafenleiname"))
			rsfl("ayshangjiid")=clng(fenleierji)
			rsfl("aykafenleisx")=rs("aykafenleisx")
			rsfl("aykanamesuoyou")=clng(uid)
			rsfl("ayfenleidlid")=clng(sid)
			rsfl("ayflsumid")=trim(rs("ayflsumid"))
			rsfl.update
			rsfl.close
			'获取本地分类MD5 ID
			set rsfid=server.CreateObject("adodb.recordset")
			sqlfid="select top 1 aykafenleiid,aykanamesuoyou,ayfenleidlid,aykafenleimd5,ayfldlmd5url from aykafenlei where aykanamesuoyou="&uid&" and ayfenleidlid="&sid&" order by aykafenleiid desc" 
			rsfid.open sqlfid,conn,1,3
			if not(rsfid.bof and rsfid.eof) then
			md51=md5d(rsfid("aykafenleiid"))
			md52=md5user(rsfid("aykafenleiid"))
			rsfid("aykafenleimd5")=md51
			rsfid("ayfldlmd5url")=md52
			fenleiid=rsfid("aykafenleiid")
			rsfid.update
			end if
			rsfid.close
	
	
			'获取上级代理商品信息
			set rssgood=server.CreateObject("adodb.recordset")
			sqlsgood="select * from aygood where aygoodsuoyouid="&sid&" and aygoodfl="&rs("aykafenleiid")&" and aygoodisydl=0 and isptdx=0" 
			rssgood.open sqlsgood,conn,1,1
			if rssgood.bof and rssgood.eof then
			call PopErr("未找到上级代理商品信息")
			else
			do while not rssgood.eof
	
				'添加本地商品
				set rsg=server.CreateObject("adodb.recordset")
				sqlg="select * from aygood" 
				rsg.open sqlg,conn,1,3
				rsg.addnew
				rsg("aygoodsuoyouid")=uid
				rsg("aygoodfl")=fenleiid
				rsg("aygoodsx")=rssgood("aygoodsx")
				rsg("aygoodname")=trim(rssgood("aygoodname"))
				rsg("ayjiage")=rssgood("ayjiage")
				rsg("aychenben")=rssgood("ayjiage")
				rsg("aypifayes")=0
				rsg("ayxiangou")=0
				rsg("aygoodzhuangtai")=0
				rsg("aygooddlid")=rssgood("aygoodsuoyouid")
				rsg("aysjjiage")=trim(sfd)
				'rsg("aygshouxuf")=shou
				rsg("aygiska")=kami
				rsg("aygismka")=kami2
				rsg("aygsumid")=trim(rssgood("aygsumid"))
				rsg("aygoodiskucun")=1	'代理商品 不显示实际库存	
				rsg.update
				rsg.close
	
			rssgood.movenext 
			loop
			end if
			rssgood.close


		rs.movenext 
		loop
		rs.close
		

		'增加商品MD5数据
		sql="select aygoodid,aygoodsuoyouid,aygooddlid,aygoodmd5,aygdlmd5url from aygood where aygoodsuoyouid="&uid&" and aygooddlid="&sid&" and aygoodmd5 is null" 
		rs.open sql,conn,1,3
		if not(rs.bof and rs.eof) then
		do while not rs.eof
		md51=md5d(rs("aygoodid"))
		md52=md5user(rs("aygoodid"))
		rs("aygoodmd5")=md51
		rs("aygdlmd5url")=md52
		rs.update
		rs.movenext 
		loop
		end if
		rs.close

		end if
		call logadd(request.Cookies("aynameid"),"代理商品同步成功-"&id,0,0)
		call PopErr2("同步成功","dailiedit?act=edit&id="&id&"")
		end if

end if

%>
<script type="text/javascript">
function check_add()
{
   if(myformadd.aydlsjuserid.value=="")
   {alert("请填写上级商户ID");return false}
	 
}
</script>


<style>
table{font-size:14px; font-weight:normal;line-height:27px;}
.regts{width:440px; height:36px; border:#CCC solid 1px; background:#f1f1f1; color:#666666; line-height:36px; padding-left:10px}
.reginput{width:290px; height:36px; border:#CCC solid 1px; color:#949494; text-indent:10px; line-height:36px}
.gexian20{float:left;width:100%;height:20px;}
.mzsmbox2{width:90%; height:auto; overflow:hidden; background:#fcf8e2; border-left:#edd28a solid 5px; color:#956825; line-height:22px; padding:20px;margin-left:40px; margin-bottom:60px; font-size:13px;padding-top:20px;}
.neitable table{border: 1px solid #E8E8E8;width: 100%;}
.neitable table tr{border-bottom: 1px solid #E8E8E8;}
.neitable table tr td{line-height: 42px;text-align: center;color: #1b1b1b;font-size: 14px;}
.neitable table tr.hd td{line-height: 35px;background-color: #F7F7F7;}
.btnFn1 {cursor:pointer!important;cursor:hand;  height:40px; width:101px; padding:0px 0px 0 0; }
.btnFn2 {cursor:pointer!important;cursor:hand;  height:40px; width:101px; padding:0px 0px 0 0; font-weight:bold; }
.logindlreg2{cursor:pointer;margin-left:5px; padding:7px;font-family:"Microsoft YaHei",Verdana,Arial; font-size:13px; text-align:center; color:#505050; font-weight:bold; background:#F2F2F2; border:#C3C3C3 solid 1px; border-radius:2px; }
.logindlreg2:hover{color:#505050;border:#999999 solid 1px; border-radius:2px; }
.logindlregedit{ margin-top:3px;height:36px;font-family:"Microsoft YaHei",Verdana,Arial; line-height:30px; font-size:13px; text-align:center; color:#505050; font-weight:bold; background:#F2F2F2;  border:#C3C3C3 solid 1px; border-radius:2px; }
.logindlregedit:hover{color:#505050;border:#999999 solid 1px; border-radius:2px; }
.logindlreg2tj{ margin-top:4px;height:36px;font-family:"Microsoft YaHei",Verdana,Arial; line-height:30px; font-size:13px; text-align:center; color:#ffffff; font-weight:bold; background:#F79740; border:0; border-radius:2px; }
.logindlreg2tj:hover{background:#F99C48; }
.reginputd{ width:190px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.reginputdd{ width:110px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.reginputddd{ width:40px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.reginputdddd{ width:50px; height:36px; border:#CCC solid 1px; text-indent:10px; line-height:36px}
.regt3{ width:650px; height:36px; border:#CCC solid 1px; background:#F9F9F9; color:#999999; line-height:36px; padding-left:10px}
</style>
<br>
<DIV id=main2> 
<DIV id=main_right>
<DIV id=main_right_content>



<H2><SPAN>代理系统</SPAN></H2>
<DIV class=main4>



<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: bold; font-size: 14px; color: #FF0000">代理关系信息</span><br>
  <div class="neitable">
                    <%
                    id=trim(SafeRequest("id"))
                    if id="" then call PopErr("出现错误")
                    if len(id)>5 then call PopErr("出现错误")
                    if isNumeric(id)=false then call PopErr("出现错误")
                    sql="select * from aydailishang where aydlid="&id&"" 
                    rs.open sql,conn,1,1
                    if rs.bof and rs.eof then call PopErr2("未找到代理关系","/user")
                    if not(rs.bof and rs.eof) then 
                    if trim(rs("aydlsjuserid"))<>trim(request.Cookies("aynameid")) then call PopErr("无权限")
                    uid=rs("aydluserid")
                    aydlfeiyongf2=rs("aydlfeiyongf")
                    aydlfandian2=rs("aydlfandian")
                    aydliska2=rs("aydliska")
                    aydlismka2=rs("aydlismka")
					%>
                     <form action="" method="post" name="myform" id="myform"> 
                     <table class="neitableanquan">
           		  		<tr class="hd">
                          <td align="center">上级代理商户ID</td>
                          <td>代理商ID</td>
                          <td>代理状态</td>
                          <td>申请时间</td>
                          <td>通过时间</td>
                          <td>相关操作</td>
                        </tr>
                        
           		  		<tr>
                          <td><%=rs("aydlsjuserid")%></td>
                          <td>
						  <%=rs("aydluserid")%>
                          <%xjdluid=rs("aydluserid")%>
                          </td>
                          <td>
						 <%
                          if rs("aydlistongguo")=0 then response.Write("等待确认")
                          if rs("aydlistongguo")=1 then response.Write("正常")
                          if rs("aydlistongguo")=2 then response.Write("关闭")
                          if rs("aydlistongguo")=3 then response.Write("拒绝申请")
                          %>
                          </td>
                          <td><%=rs("aydlsdate")%></td>
                          <td>
							<%
                            if trim(rs("aydltdate"))<>"" and isnull(trim(rs("aydltdate")))=false then
                            response.Write rs("aydltdate")
                            else
                            response.Write "-"
                            end if
                            %>
                          </td>
                          <td>
							<%if rs("aydlistongguo")=1 then%>
                            <a href="?act=quxiaodl&id=<%=rs("aydlid")%>" onClick="javascript:return confirm('您确定要取消代理吗？');">取消代理</a>
                            <%elseif rs("aydlistongguo")=2 or rs("aydlistongguo")=3 then%>
                            <a href="?act=sdel&id=<%=rs("aydlid")%>" onClick="javascript:return confirm('您确定要删除代理吗？');">删除代理</a>
                            <%else
                            response.Write "-"
                            end if%>
                          </td>
                        </tr>
                        
                        
                    </table>
                    </form>
                    
				<%end if%>
                </div>
                
                
                
<br>


<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: bold; font-size: 14px; color: #FF0000">代理商信息</span><br>
<div class="neitable">
                         <table class="neitableanquan">
                            <tr class="hd">
                              <td align="center">代理商户ID</td>
                              <td>名称</td>
                              <td>站点名称</td>
                              <td>站点url</td>
                              <td>成交笔数</td>
                              <td>累计结算</td>
                              <td>VIP</td>
                              <td>购买链接</td>
                            </tr>
							<%
                            set rsu=server.CreateObject("adodb.recordset")
                            sqlu="select * from ayname where aynameid="&rs("aydluserid")&"" 
                            rsu.open sqlu,conn,1,1
                            if rsu.bof and rsu.eof then call PopErr("未找到该代理商")
                       		%>
                            <tr>
                              <td><%=rsu("aynameid")%></td>
                              <td><%=rsu("aytrueuser")%></td>
                              <td><%=rsu("aywebname")%></td>
                              <td><a href="<%=trim(rsu("ayweburl"))%>" target="_blank"><%=trim(rsu("ayweburl"))%></a></td>
                              <td><%=rsu("aychengjiao")%></td>
                              <td><%=rsu("ayljjs")%>元</td>
                              <td>
								<%
                                if cint(rsu("ayisxiaobao"))=0 then response.Write "未加入"
                                if cint(rsu("ayisxiaobao"))=1 then response.Write "已加入"
                                %>
                              </td>
                              <td>
							<%if isnull(trim(rsu("aygename")))=false and trim(rsu("aygename"))<>"" then%>
                            <a href="<%=weburl%><%=trim(rsu("aygename"))%>" target="_blank">查看</a> 
                            <%elseif rsu("ayismd5")=1 then%>
                            <a href="<%=weburl%><%=trim(rsu("aymd5"))%>" target="_blank">查看</a> 
                            <%else%>
                            <a href="<%=weburl%><%=rsu("aynameid")%>" target="_blank">查看</a> 
                            <%end if%>
                              </td>
                            </tr>
                            <%rsu.close%>
                            
                        </table>                   
						<%rs.close%>
                        </div>




<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: bold; font-size: 14px; color: #FF0000">商品详细设置</span><br>
 <div class="neitable">
                        <form action="" method="post" name="myform" id="myform"> 
                         <table class="neitableanquan">
                            <tr class="hd">
                              <td align="center">商品名称<input name="uid" type="hidden" id="uid" value="<%=uid%>"></td>
                              <td>商品分类</td>
                              <td>商品价格</td>
                              <td>成本价格</td>
                              <td><span title="下级代理拿货价格">代理价格</span></td>
                              <td><span title="是否允许下级代理查看卡密">查看卡密</span></td>
                              <td><span title="已成功的交易是否允许卖家查看卡密">卖出卡密</span></td>
                              <td><span title="该商品是否允许下级代理商获取并代理">允许代理</span></td>
                            </tr>        
							<%
                            set rs=server.CreateObject("adodb.recordset")
                            sql="select * from aygood where aygoodsuoyouid="&request.Cookies("aynameid")&" and isptdx=0 order by aygoodfl asc,aygoodid asc" 
                            rs.open sql,conn,1,1
                            if rs.bof and rs.eof then response.Write "名下还没有商品"
                            n=0
                            do while not rs.eof
                            'aygoodisydl2=rs("aygoodisydl")
                            n=n+1
                       		%>
                            <tr onmouseover=this.bgColor='#FAFAFA' onmouseout=this.bgColor='#ffffff'>
                              <td><%=rs("aygoodname")%>
                        		<input name="aygoodid" type="hidden" id="aygoodid" value="<%=rs("aygoodid")%>">
                                <input name="aygsumid" type="hidden" id="aygsumid" value="<%=trim(rs("aygsumid"))%>">
                                <input name="aygoodzhuangtai" type="hidden" id="aygoodzhuangtai" value="<%=rs("aygoodzhuangtai")%>">
                               </td>
                              <td>
							 <%
                              set rsf=server.CreateObject("adodb.recordset")
                              sqlf="select aykafenleiid,aykafenleiname from aykafenlei where aykafenleiid="&rs("aygoodfl")&"" 
                              rsf.open sqlf,conn,1,1
                              if not(rsf.bof and rsf.eof) then
                              response.Write trim(rsf("aykafenleiname"))
                              else
                              response.Write "-"
                              end if
                              rsf.close
                              %>
                              <input name="aygoodfl" type="hidden" id="aygoodfl" value="<%=rs("aygoodfl")%>">
                              </td>
                              <td><input name="ayjiage" type="hidden" id="ayjiage" value="<%=rs("ayjiage")%>"><%=Formatnumber(rs("ayjiage"),2,true,-1,0)%>元</td>
                              <td><%=Formatnumber(rs("aychenben"),2,true,-1,0)%>元</td>
                              <td>
					 		 <%
                              set rsxj=server.CreateObject("adodb.recordset")
                              sqlxj="select * from aygood where aygoodsuoyouid="&xjdluid&" and aysjgid="&rs("aygoodid")&" and isptdx=0" 
                              rsxj.open sqlxj,conn,1,1
                              %>
                              
                              <input class="reginputmb" name="aysjjiage" type="text" id="aysjjiage" 
                              <%if not(rsxj.bof and rsxj.eof) then
                                  if ccur(rsxj("aysjjiage"))<>0 then 
                                  response.Write "value="&Formatnumber(rsxj("aysjjiage"),2,true,-1,0)&""   
                                  else
                                  response.Write "value="&Formatnumber(rs("aygoodtodaili"),2,true,-1,0)&""   
                                  end if
                              else
                              response.Write "value="&Formatnumber(rs("aygoodtodaili"),2,true,-1,0)&""
                              end if
                              %> size="5" maxlength="6">元
                              </td>
                              <td>
                    			<select name="aygiska" id="aygiska" class="reginputmb">
                                <option value="0" 
                                <%if not(rsxj.bof and rsxj.eof) then 
                                if cint(rsxj("aygiska"))=0 then response.Write "selected"
                                end if%>>禁止</option>
                                <option value="1" <%if not(rsxj.bof and rsxj.eof) then 
                                if cint(rsxj("aygiska"))=1 then response.Write "selected"
                                end if%>>允许</option>
                               </select>
                              </td>
                              <td>
                    			<select name="aygismka" id="aygismka" class="reginputmb">
                                <option value="1" <%if not(rsxj.bof and rsxj.eof) then 
                                if cint(rsxj("aygismka"))=1 then response.Write "selected"
                                end if%>>允许</option>
                               <option value="0" <%if not(rsxj.bof and rsxj.eof) then 
                                if cint(rsxj("aygismka"))=0 then response.Write "selected"
                                end if%>>禁止</option>
                            	</select>
                              </td>
                              <td>
                    			<select name="aygoodisydl" id="aygoodisydl" class="reginputmb">
                                <option value="0"  <%if not(rsxj.bof and rsxj.eof) then 
                                if cint(rsxj("aygoodisydl"))=0 then response.Write "selected"
                                end if%>>允许</option> 
                                <option value="1" <%if not(rsxj.bof and rsxj.eof) then 
                                if cint(rsxj("aygoodisydl"))=1 then response.Write "selected"
                                end if%>>禁止</option>
                               </select>	
                              </td>
                            </tr>
							<%
                            rsxj.close
                            rs.movenext 
                            loop
                            %>
                            
                              <tr>
                                <td colspan="8" align="center">
                                <input name="act" type="hidden" id="act" value="allgedit">
                                <input name="n" type="hidden" id="n" value="<%=n%>">
                                <input name="id" type="hidden" id="id" value="<%=id%>">
                                <input type="submit" name="Submit2" value=" 保 存 并 同 步 商 品 "  class="logindlregedit">
                                </td>
                              </tr>
                        </table>   
                        </form>  
                        <%rs.close%>     
                        </div>
  <br>
</DIV>
</DIV></DIV>
<DIV class=clear></DIV></DIV>
</DIV>

<br>

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


