<%
'##################################################################                                                                 
'★         web08.net - 威博购物系统                                              
'★  版权所有: web08.net                                                                                                       
'★  程序制作: 威博网络技术公司                                     
'★           email:web08net@hotmail.com                           
'★            Q Q :645095280,475980829
'★	       电话:021-55520018                                                                                                         
'★  相关网址: [产品介绍] http://www.021web.com.cn/gwxt.html
'★            [支持论坛] http://bbs.web08.net/                                                                                     
'★  主页地址: http://www.web08.net/  
'★		http://www.021web.com.cn/			                                                                 
'###################################################################
%>
<%
 Function Get_Brand_List()
	OpenRs()
	tablename="web_brand"
	fldname="id,b_name"
	sql="select "&fldname&" from web_brand order by id asc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_guide_List()
	OpenRs()
	tablename="web_guidepro"
	fldname="id,g_title"
	sql="select "&fldname&" from web_guidepro where g_flag=1 order by id asc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_act_List()
	OpenRs()
	tablename="web_activity"
	fldname="id,a_name"
	sql="select "&fldname&" from web_activity where a_flag=1 order by a_addtime desc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_gift_List()
	OpenRs()
	tablename="web_gifts"
	fldname="id,g_name"
	sql="select "&fldname&" from web_gifts where g_state=1 order by g_addtime desc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_hclass_List()
	OpenRs()
	tablename="web_helpclass"
	fldname="id,name"
	sql="select "&fldname&" from web_helpclass order by id asc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_help_List()
	OpenRs()
	tablename="web_help"
	fldname="id,h_title"
	sql="select "&fldname&" from web_help order by id asc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_yhq_List()
	OpenRs()
	tablename="Web_Benefit"
	fldname="id,bf_name"
	sql="select "&fldname&" from "&tablename&" order by bg_addtime desc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function Get_feel_List()
	OpenRs()
	tablename="Web_CustomFeel"
	fldname="id,c_title"
	sql="select "&fldname&" from "&tablename&" order by c_addtime desc"
	rs.open sql,conn
	if rs.eof then
		closers
		exit function
	end if 
	iRs=Rs.GetRows()
	CloseRs
	for i=0 to Ubound(iRs,2)
		response.write "<option value='"&iRs(0,i)&"'>"&iRs(1,i)&"</option>"
	next
 End Function

 Function web_ClassSxList(w_varprice)
	if isnull(w_varprice)=true or trim(w_varprice)="" then
		web_class_sxlist="" 
		exit function
	end if 
	p_varprice_1=split(w_varprice,"**")
	w_pstr="属性组合：<select name='w_varprice'><option value=''>请选择...</option>"
	
	for i=0 to ubound(p_varprice_1)
		p_sid=split(split(p_varprice_1(i),"~")(1),"|")(0)
		p_sid_1=split(p_varprice_1(i),"~")(0)
		if p_sid_1=1 then
			w_selected="selected"
		else
			w_selected=""
		end if
		w_pstr_1=w_pstr_1&"<option value='"&p_sid&"' "&w_selected&">"&web_zh_name(p_sid)&"</option>"
	next
	w_pstr=w_pstr&w_pstr_1&"</select>"
	web_ClassSxList=w_pstr
 End Function

 Function web_zh_name(w_price_id)
	if trim(w_price_id)="" or isnull(w_price_id)=true then
		exit function
	end if
	set rec=server.createobject("adodb.recordset")
	sql="select s_value from web_sxvalue where id in("&w_price_id&") order by id desc"
	rec.open sql,conn
	if rec.eof then
		rec.close : set rec=nothing
		exit function
	end if 
	iRs=rec.GetRows()
	for i=0 to Ubound(iRs,2)
		if i=0 then
			web_zh_name=iRs(0,i)
		else
			web_zh_name=web_zh_name&"+"&iRs(0,i)
		end if 
	next
 '1~7,10,13|1|@3,2@1,3@6,4@33,5@34,6**0~7,9,13|11|@3,22@1,33@6,44@33,55@34,66
 End Function

 Function web_get_zhprice_mem(w_memprice,w_myprice,w_zh,w_varprice)
	if isnull(w_varprice)=true or trim(w_varprice)="" then
		web_get_zhprice_mem= w_memberprice
		exit function
	end if 
	p_varprice_1=split(w_varprice,"**")
	for i=0 to ubound(p_varprice_1)
		p_sid=split(split(p_varprice_1(i),"~")(1),"|")
		if cstr(trim(w_zh))=cstr(trim(p_sid(0))) then
			web_get_zhprice_mem=web_get_memprice(w_memprice,p_sid(1),p_sid(2))
			w_exist=true
			exit function
		end if 
	next
	if w_exist<>true then
		web_get_zhprice_mem=w_memprice
	end if
	'1~7,10,13|1|@3,2@1,3@6,4@33,5@34,6**0~7,9,13|11|@3,22@1,33@6,44@33,55@34,66
 End Function

 Function web_get_memprice(w_price,w_defprice,w_levelprice)
	if w_defprice="" then
		w_price_user=w_price
	else
		w_price_user=w_defprice
	end if
	'response.write w_price_user
	'response.end
	w_level=split(w_levelprice,"@")
	u_levelid=ReTurnUserClassid(session("kkuid"))
	u_disrate=web_Getclassdiscount(session("kkuid"))
	for w_i=1 to ubound(w_level)
		w_level_1=split(w_level(w_i),",")
		if cstr(u_levelid)=cstr(w_level_1(0)) then
			if w_level_1(1)="" then
				web_get_memprice=w_price_user*u_disrate/100
			else
				web_get_memprice=w_level_1(1)
			end if
			w_exist=true
			exit function
		end if
	next
	'@3,2@1,3@6,4@33,5@34,6
End Function

Function web_get_extpid(w_classid_2)
	w_pid_1=split(w_classid_2,",")
	set rec=server.createobject("adodb.recordset")
	sql="select id,p_extfid from web_product where p_extfid<>'' and p_extfid is not null"
	rec.open sql,conn
	if rec.eof then
		rec.close : set rec=nothing
		exit function
	end if 
	iRs=rec.GetRows()
	for w_i=0 to ubound(w_pid_1)
		for w_j=0 to Ubound(iRs,2)
			w_extid=split(iRs(1,w_j),",")
			for w_k=0 to ubound(w_extid)
				if trim(cstr(w_extid(w_k)))=cstr(w_pid_1(w_i)) then
					w_pid=w_pid&","&irs(0,w_j)
					exit for
				end if 
			next
		next
	next
	web_get_extpid=replace(w_pid,",","",1,1)
End Function

Function Web_Restore_zh(byval w_zhstr)
	if w_zhstr="" or isnull(w_zhstr) then
		Web_Restore_zh=""
		exit function
	end if 
	dim w_str
	w_str_1=split(w_zhstr,"**")
	for i=0 to ubound(w_str_1)
		w_str_2=split(split(split(w_str_1(i),"@")(0),"|")(0),"~")
		w_str_3=split(w_str_2(1),",")
		if i=0 then 
			for j=0 to ubound(w_str_3)
				ReDim Preserve a(j)
				a(j)=a(j)&","&w_str_2(0)&"|"&w_str_3(j)
			next
		else
			for j=0 to ubound(w_str_3)
				a_1=split(a(j),",")
				for k=1 to ubound(a_1)
					if clng(w_str_3(j))=clng(split(a_1(k),"|")(1)) then
						if clng(w_str_2(0))=1 then
							a(j)=replace(a(j),"0|"&clng(split(a_1(k),"|")(1))&",","")
							a(j)=replace(a(j),",0|"&clng(split(a_1(k),"|")(1)),"")
							a(j)=a(j)&",1|"&clng(w_str_3(j))
						end if 
						w_exist=true
						exit for
					else
						w_exist=false
					end if
				next
				if w_exist<>true then
					a(j)=a(j)&","&w_str_2(0)&"|"&w_str_3(j)
				end if 
			next
		end if
	next
	for w_j=0 to ubound(a)
		str="<td><select name='w_zh_"&w_j&"'>"&vbcrlf
		str_1=""
		w_str_1=split(a(w_j),",")
		for w_jj=1 to ubound(w_str_1)
			w_zh_1=split(w_str_1(w_jj),"|")
			if w_jj=1 then
				s_cid=getonevalue("web_sxvalue","s_id","id="&clng(w_zh_1(1)))
				s_name=getonevalue("web_sx","s_name","id="&s_cid)
			end if
			if w_zh_1(1)=1 then	
				selected="selected"
			else
				selected=""
			end if
			str_1=str_1&"<option value='"&w_zh_1(1)&"' "&selected&">"&getonevalue("web_sxvalue","s_value","id="&clng(w_zh_1(1)))&"</option>"
		next
		str="<tr><td>"&s_name&"：</td>"&str&str_1&"</select></td></tr>"
		w_str=w_str&str
	next
	Web_Restore_zh="<table>"&w_str&"</table>"
End Function

'+++++++++++++++++++++++++++++++++
'MPRO_count 修改商品卖出量和订单量 
'+++++++++++++++++++++++++++++++++
Function MPRO_count_sp1(orderid)
	set rec=server.createobject("adodb.recordset")
	sql="select * from web_soldgoods where orderid='"&orderid&"'"
	rec.open sql,conn
	do while not rec.eof 
		shopid=rec("sc_goodid")
		if rec("sc_sxid")="" or isnull(rec("sc_sxid"))=true then
			sql="update web_product set p_solded=p_solded+" & rec("sc_shopcount") &", p_ordernums=p_ordernums-" & rec("sc_shopcount") & " where id=" & shopid
			conn.execute(sql)
		else
			w_stocktmp=w_modify_zhstock(shopid,rec("sc_sxid"),rec("sc_shopcount"))
			sql="update web_product set p_zhstock='"&w_stocktmp&"' where id=" & shopid
			'response.write sql
			conn.execute(sql)
		end if
	rec.movenext
	loop
	rec.close : set rec=nothing
End Function

Function w_modify_zhstock(pid,byval w_zhstock,w_cartcount)
	w_nowstock=trim(getonevalue("web_product","p_zhstock","id="&pid))
	if isnull(w_nowstock)=true or w_nowstock="" then
		//有异常，退出
		exit function
	end if 
	p_stock=split(w_nowstock,"**")
	for i=0 to ubound(p_stock)
		p_stockcount=split(p_stock(i),"|")
		if cstr(trim(w_zhstock))=cstr(trim(p_stockcount(0))) then
			w_stocktmp=cstr(trim(w_zhstock))&"|"&clng(p_stockcount(1))-clng(w_cartcount)
			w_nowstock=replace(w_nowstock,p_stock(i),w_stocktmp)
			exit for
		end if
	next
	w_modify_zhstock=w_nowstock
End Function

Function timeformat(byval strtime,byval strtype)
	select case strtype
		case "0":
			timeformat=year(strtime)&"-"& month(strtime)&"-"& day(strtime)& " "& hour(strtime) &":"& minute(strtime)&":"&second(strtime)
	end select
End Function
%> 