<%
'**************************************
'* 最后更新 2013-05-09 by 56770.Kingdge
'* Copyright www.56770.com
'**************************************
moneyhl = safereplace(request("moneyhl"))
id = checknum(request("id"),0)
Select Case request("do")
       Case "Info" info()
End Select

Dim rsPro

Sub info()
        Dim buys,views,sql,j
		sql = "select buys,views,sprice,cx,cprice,s.price as buyprice,p.P_SpecificationName"
		for j=1 to UserGroupNumber 'ubound(cache_ugrade_dj)
				sql = sql &",(Select price from [Lebi_product_price] where product_id=p.id and grade_id="&j&") as gradePrice_"&j&""
		Next
		sql = sql & " from [Lebi_product] as p,[Lebi_product_price] as s where  p.id="&id&" and s.product_id=p.id and s.grade_id="&Lebi_UserGrade
		Set rsPro = conn.execute(sql)
		If Not rsPro.eof Then
				buys = rsPro(0)
				views = rsPro(1)
		End If
        Select Case request("type")
		       Case "buys"
					response.write("document.write("""& buys &""");")
			   Case "views"
'			        conn.execute("update [Lebi_product] set views = views + 1 where id = "& id &"") 已在 ProductViewHistory.asp 中计算
					response.write("document.write("""& views &""");")
			   Case "buyPrice"
					response.write("document.write("""& ProductInfoBuyPrice(CInt(request("p_type"))) &""");")
			   Case "gradePrice"
					response.write("document.write("""& ProductInfoItemPrice(CInt(request("p_type"))) &""");")
		End Select
		rsPro.close : Set rsPro = Nothing
End Sub

rem 显示购买价格
rem p_type 是否显示节省金额 0 不显示 1 显示
Function ProductInfoBuyPrice(p_type)
	Dim price1,price2
	If RsPro("cx") = 0 Then
		price1 = RsPro("buyprice")
	Else
		price1 = RsPro("cprice")
	End If
'	If IsNumeric(price1) Then price1 = font_price(price1)
	If checkPricePurview(Lebi_UserGrade) Then
			If Trim(RsPro("P_SpecificationName")) <> "" And Not isnull(Trim(RsPro("P_SpecificationName"))) Then 
					Set rsprice = conn.execute("select top 1 p_price from [Lebi_Product_Stock] where p_id = "& id &" order by p_price asc")
					If Not rsprice.eof Then 
							Lowprice = price1 + rsprice(0)
					End If 
					rsprice.close : Set rs = Nothing
					Set rsprice = conn.execute("select top 1 p_price from [Lebi_Product_Stock] where p_id = "& id &" order by p_price desc")
					If Not rsprice.eof Then 
							Highprice = price1 + rsprice(0)
					End If 
					rsprice.close : Set rs = Nothing
					If CDbl(Highprice) = CDbl(Lowprice) Then 
							If p_type = 1 Then
									price2 = formatnumber2(js_price(Lowprice,RsPro("sprice"))/moneyhl)
									price2 = "&nbsp;&nbsp;"&Lebi_pro(108)&"&nbsp;"& dw & price2 & dw2
							End If
							ProductInfoBuyPrice = dw & formatnumber2(price1/moneyhl) & dw2 & price2
					Else
							ProductInfoBuyPrice = dw & formatnumber2(Lowprice/moneyhl) & dw2 &" - "& dw & formatnumber2(Highprice/moneyhl) & dw2
					End If 
			Else
					If p_type = 1 Then
							price2 = formatnumber2(js_price(price1,RsPro("sprice"))/moneyhl)
							price2 = "&nbsp;&nbsp;"&Lebi_pro(108)&"&nbsp;"& dw & price2 & dw2
					End If
					ProductInfoBuyPrice = dw & formatnumber2(price1/moneyhl) & dw2 & price2
			End If 
	Else
			ProductInfoBuyPrice = Lebi_word(66)
	End If
End Function

rem 显示商品价格
rem p_type 价格类型 0 市场价 1,2,3... 为对应会员等级
Function ProductInfoItemPrice(p_type)
	Dim t_price : t_price = 0
	If IsNull(p_type) Or Not IsNumeric(p_type) Then p_type = 0
	If p_type > ubound(cache_ugrade_dj) Then p_type = ubound(cache_ugrade_dj)
	If p_type = 0 Then
	    Lowprice = RsPro("sprice")
	    Highprice = RsPro("sprice")
		Set rsprice = conn.execute("select top 1 p_price from [Lebi_Product_Stock] where p_id = "& id &" order by p_price asc")
		If Not rsprice.eof Then 
				Lowprice = RsPro("sprice") + rsprice(0)
		End If 
		rsprice.close : Set rs = Nothing
		Set rsprice = conn.execute("select top 1 p_price from [Lebi_Product_Stock] where p_id = "& id &" order by p_price desc")
		If Not rsprice.eof Then 
				Highprice = RsPro("sprice") + rsprice(0)
		End If 
		rsprice.close : Set rs = Nothing
		If CDbl(Highprice) = CDbl(Lowprice) Then 
				ProductInfoItemPrice = dw & formatnumber2(Lowprice/moneyhl) & dw2
		Else
				ProductInfoItemPrice = dw & formatnumber2(Lowprice/moneyhl) & dw2 &" - "& dw & formatnumber2(Highprice/moneyhl) & dw2
		End If 
	Else
		If checkPricePurview(p_type) Then
				UserPrice = RsPro(6+p_type)
				If RsPro("cx") = 1 Then UserPrice = RsPro("cprice")
				If RsPro("P_SpecificationName") = "" Then
						ProductInfoItemPrice = dw & formatnumber2(UserPrice/moneyhl) & dw2
				Else 
						Set rsprice = conn.execute("select top 1 p_price from [Lebi_Product_Stock] where p_id = "& id &" order by p_price asc")
						If Not rsprice.eof Then 
								Lowprice = UserPrice + rsprice(0)
						End If 
						rsprice.close : Set rs = Nothing
						Set rsprice = conn.execute("select top 1 p_price from [Lebi_Product_Stock] where p_id = "& id &" order by p_price desc")
						If Not rsprice.eof Then 
								Highprice = UserPrice + rsprice(0)
						End If 
						rsprice.close : Set rs = Nothing
						If CDbl(Highprice) = CDbl(Lowprice) Then 
								ProductInfoItemPrice = dw & formatnumber2(Lowprice/moneyhl) & dw2
						Else
								ProductInfoItemPrice = dw & formatnumber2(Lowprice/moneyhl) & dw2 &" - "& dw & formatnumber2(Highprice/moneyhl) & dw2
						End If 
				End If 
		Else
				ProductInfoItemPrice = Lebi_word(66)
		End If
	End If
End Function
%>
