<!--#include virtual="/inc/conn.asp"-->
<%
if SafeRequestform("act")="ckyhq" then

id=SafeRequestform("id")
fenleiid=SafeRequestform("fenleiid")
shangid=SafeRequestform("shangid")
userid=SafeRequestform("userid")

if id="" or fenleiid="" or shangid="" or userid="" then 
response.Write("no")
response.End()
end if
	
	
rs.open "select * from ayyouhuiquan where ayyouhuiquan='"&id&"' and ayyouhuiyesno=0 and ayyouhuijibie=1" ,conn,1,1
	if not(rs.bof and rs.eof) then
		if DateDiff("h",rs("ayyouhuidate"),now())>clng(rs("ayyouhuishixiao"))*24 then
		response.Write("0000")  '过期
		response.end
		else
			if cint(rs("ayyouhuifangshi"))=1 then
			response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)&"|%"
			response.end
			else
			response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)
			response.end
			end if
		end if
	end if
rs.close

rs.open "select * from ayyouhuiquan where ayyouhuiquan='"&id&"' and ayyouhuisuoyou="&clng(userid)&" and ayyouhuiyesno=0" ,conn,1,1
	if rs.bof and rs.eof then
	rs.close
	response.Write("1111")
	response.end
	else
		if cint(rs("ayyouhuiall"))=1 then
			if DateDiff("h",rs("ayyouhuidate"),now())>clng(rs("ayyouhuishixiao"))*24 then
			response.Write("0000")  '过期
			response.end
			else
				if cint(rs("ayyouhuifangshi"))=1 then
				response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)&"|%"
				response.end
				else
				response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)
				response.end
				end if
			end if
		end if
		
		if cint(rs("ayyouhuiall"))=0 then
			if trim(rs("ayyouhuiflid"))<>"0" then    '分类不为空
				flstr=split(trim(rs("ayyouhuiflid")),",")
				isflyes=false
				For fid=0 To Ubound(flstr) 
				if trim(fenleiid)=trim(flstr(fid)) then isflyes=true
				next
 					if isflyes=true then 
						if DateDiff("h",rs("ayyouhuidate"),now())>clng(rs("ayyouhuishixiao"))*24 then
					response.Write("0000")  '过期
					response.end
					else
						if cint(rs("ayyouhuifangshi"))=1 then
						response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)&"|%"
						response.end
						else
						response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)
						response.end
						end if
					end if
					else
						goodstr=split(trim(rs("ayyouhuishangid")),",")
						isgoodyes=false
						For gid=0 To Ubound(goodstr) 
						if trim(shangid)=trim(goodstr(gid)) then isgoodyes=true
						next
							if isgoodyes=true then 
							if DateDiff("h",rs("ayyouhuidate"),now())>clng(rs("ayyouhuishixiao"))*24 then
							response.Write("0000")  '过期
							response.end
							else
								if cint(rs("ayyouhuifangshi"))=1 then
								response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)&"|%"
								response.end
								else
								response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)
								response.end
								end if
							end if
						else
						response.Write("2222")
						response.end
						end if
					end if
			elseif trim(rs("ayyouhuiflid"))="0" then    '分类为空
				goodstr=split(trim(rs("ayyouhuishangid")),",")
				isgoodyes=false
				For gid=0 To Ubound(goodstr) 
				if trim(shangid)=trim(goodstr(gid)) then isgoodyes=true
				next
					if isgoodyes=true then 
						if DateDiff("h",rs("ayyouhuidate"),now())>clng(rs("ayyouhuishixiao"))*24 then
						response.Write("0000")  '过期
						response.end
						else
							if cint(rs("ayyouhuifangshi"))=1 then
							response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)&"|%"
							response.end
							else
							response.Write Formatnumber(rs("ayyouhuijiage"),2,true,-1,0)
							response.end
							end if
						end if
					else
					response.Write("3333") '不允许在此商品下使用
					response.end
					end if
			end if
		end if
	rs.close
	end if

end if
%>
