<%
'**************************************
'* 最后更新 2013-05-13 by 56770.kingdge
'* Copyright www.56770.com
'*************************************
Dim usermoney,ifpay,lastmoney,paidmoney,order_number,orderzt,o_jifen
strwebtitle = Lebi_cart(103) &"-"
sitename = site_name
description = Replace(safereplace(Sys_description)," ","")
keywords = Replace(safereplace(Sys_keywords)," ","")
ShowPath = "<a href='"& Eshop_url & LangPath &"'>"& Lebi_word(0) &"</a> → <a href='"& Eshop_url & PagePath(0) &"'>"& Lebi_word(8) &"</a> → "& Lebi_cart(103) &""
paytype = request("paytype")
order_number=safereplace(request("order_number"))
'If Lebi_UserId ="" Then
'		response.redirect Eshop_url & PagePath(1) &"?action=needlogin"
'		response.End
'End If
If Lebi_UserId <> "" Then 
set Rs = conn.execute("select user_id,usermoney,ifpay from [Lebi_user] where user_id='"& Lebi_UserId &"'")
usermoney = Replace(formatnumber2(rs("usermoney")/moneyhl),",","")
lb_usermoney = rs("usermoney")
ifpay = rs("ifpay")
rs.close : set rs=Nothing
set rs = conn.execute("select * from [Lebi_orders] where order_number='"& order_number &"'")
is_booking = rs("is_booking")
is_pay_advance = rs("is_pay_advance")
orderzt=rs("orderzt")
o_jifen=rs("jifen")
oid = rs("id")
paidmoney = Replace(formatnumber2(rs("paidmoney")/moneyhl),",","")
advance_money = Replace(formatnumber2(rs("advance_money")/moneyhl),",","")
lastmoney = Replace(formatnumber2(rs("lastmoney")/moneyhl),",","")
lb_paidmoney = rs("paidmoney")
lb_advance_money = rs("advance_money")
lb_lastmoney = rs("lastmoney")
rs.close : set rs=Nothing
If paytype <> "" Then
		Select Case paytype
		Case "0" paidmoney = lastmoney : lb_paidmoney = lb_lastmoney
		Case "1" paidmoney = advance_money : lb_paidmoney = lb_advance_money
		Case "2" paidmoney = lastmoney : lb_paidmoney = lb_lastmoney
		End Select 
		If CDbl(lb_paidmoney) <= CDbl(lb_usermoney) And lb_paidmoney > 0 Then
				Set rs = server.CreateObject("adodb.recordset")
				rs.open "select * from [Lebi_orders] where order_number='"& order_number &"'",conn,1,3
				rs("paymenttype") = Lebi_cart(103)
				If CDbl(lb_paidmoney) = CDbl(lb_lastmoney) Then 
						rs("orderzt") = rs("orderzt") &",2"
						If Config_Lebi_Eshop(23) = 1 Then '付单后扣除库存 by 56770.kingdge 2012-05-16
							Set rsbasket = conn.execute("select id,basket_count,spvalue from [lebi_basket] where order_number = "& rs("id") &"")
							Do While Not rsbasket.eof 
							conn.execute("update [Lebi_product] set buys = buys + "& rsbasket("basket_count")&",kucun = kucun - "& rsbasket("basket_count") &",html = 0 where id = " & rsbasket("id") &"")
							conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys + "& rsbasket("basket_count") &",p_stock = p_stock - "& rsbasket("basket_count") &" where p_id = " & rsbasket("id") &" and s_value"& rs("LangTxt") &" = '"& rsbasket("spvalue") &"'")
							rsbasket.movenext 
							Loop
							rsbasket.close : Set rsbasket = Nothing 
						End If 
				End If 
				If is_booking = "1" Then
						If paytype = "1" Then
								rs("is_pay_advance") = 1
						End If
				End If
				rs("paidmoney") = rs("paidmoney") + lb_paidmoney
				rs("lastmoney") = rs("lastmoney") - lb_paidmoney
				rs.update
				rs.close : Set rs = Nothing
				conn.execute "update [Lebi_user] set usermoney=usermoney-"& lb_paidmoney &",sumpay=sumpay+"& lb_paidmoney &" where user_id='"& Lebi_UserId &"'"
				rem 预存款消费明细 2006-1-2 by 56770.kingdge
				conn.execute("insert into [Lebi_money_log](m_user_id,m_order_num,m_sj,m_type,m_price,m_zt)values('"& Lebi_UserId &"','"&order_number&"',"&sqlnowstring&",'"&Lebi_cart(103)&"',"& lb_paidmoney &",1)")
				conn.execute("insert into [Lebi_Orders_Paylog](p_price,p_type,p_content,p_time,oid)values("& lb_paidmoney &",1,'"& Lebi_cart(103) &"',"& sqlnowstring &","& oid &")")
		End If
End If
End If 
%>