<!--#include file="../../Groupon/Config.asp"-->
<%
'**************************************
'* 最后更新 2013-10-17 by 56770.Kingdge
'* Copyright www.56770.com
'**************************************
Dim basket_cash,sum1,sum2,sum3,js,totalcash,sum_weight,fei,fei1,fei2,fei_z,z_price,strdiscount,error_type
Dim yy,mm,dd,ymd,xiaoshi,fenzhong,miao,billno,order_number,userid,orderid,rss,order_coupon_price,sql,order_id,CookiesId
Dim from_name,from_adds,from_email,from_tel,from_zip,from_other,from_mobile,to_name,to_adds,to_tel,to_tel2,to_zip,to_other,to_mobile,sendtype1,fukuan_id,paymenttype_id,paymenttype,sendtype,jifen,fapiao_company,fapiao_adds,fapiao_zip,iffapiao,from_adds2,from_city,from_state,from_country
Dim Quatity,casherror,z_discount,dis_sum,z_str1,z_str2,z_str3,z_str4,Use_Coupon,coupon_num,Scoupon,coupon_type,coupon_price,coupon_discount,basketlastprice,fapiao_money,pro_money,fei_money,sum_money,packing_price,packing_id,is_booking,advance_money,sum4,odd_money,low_money,cbprice,Uid,Uparent
rem <-{增加外部提交检测 by 56770.Kingdge 2009-3-22
Dim server_v1,server_v2
server_v1 = Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2 = Cstr(Request.ServerVariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2)) <> server_v2  Then
		response.redirect Eshop_url
		response.End
End If
rem }->
checkuser()
CookiesId = CheckNum(request.cookies(cookiesname&"_user")("cookiesid"),0)
If CookiesId = 0 Then
        response.redirect Eshop_url & PagePath(1) &"?action=nocookies&HTTP_REFERER="& server.urlencode(Eshop_url & PagePath(3)) &""
		response.End
End If
If CInt(getGradePurview(0)) <> 1 Then
		response.redirect Eshop_url & PagePath(1) &"?action=notgrade"
		response.End
End If 
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Showpath = "<a href='"& Eshop_url & LangPath &"'>"& Lebi_word(0) &"</a> → "& Lebi_cart(109)
from_name=Safereplace(trim(request.form("from_name")))
from_adds=Safereplace(trim(request.form("from_adds")))
from_email=Safereplace(trim(request.form("from_email")))
from_tel=Safereplace(trim(request.form("from_tel")))
from_zip=Safereplace(trim(request.form("from_zip")))
from_other=Safereplace(trim(request.form("from_other")))
from_mobile=Safereplace(trim(request.form("from_mobile")))
from_adds2=Safereplace(trim(request.form("from_adds2")))
from_city=Safereplace(trim(request.form("from_city")))
from_state=Safereplace(trim(request.form("from_state")))
from_country=Safereplace(trim(request.form("from_country")))
to_name=Safereplace(trim(request.form("to_name")))
to_adds=Safereplace(trim(request.form("to_adds")))
to_tel=Safereplace(trim(request.form("to_tel")))
to_tel2=Safereplace(trim(request.form("to_tel2")))
to_zip=Safereplace(trim(request.form("to_zip")))
to_other=Safereplace(trim(request.form("to_other")))
to_mobile=Safereplace(trim(request.form("to_mobile")))
sendtype=safereplace(request.form("sendtype"))
paymenttype=safereplace(request.form("paymenttype"))
paymenttype_id = safereplace(request.form("paymenttype_id"))
rem <-{兼容跳过预览页提交订单 2010-07-29 by 56770.Kingdge
fei = CheckNum(request.form("deliver_price"),56770)
If fei = 56770 Then fei = CheckNum(request.form("fei"),0)
rem }->
totalcash = CheckNum(request.form("totalcash"),0)
jifen = CheckNum(request.form("jifen"),0)
userid=safereplace(request.form("userid"))
z_discount = CheckNum(request.form("z_discount"),0)
dis_sum = CheckNum(request.form("dis_sum"),0)
rem	<-{ 包装 b 56770.WangLei
packing_price= CDbl(CheckNum(request.form("packing_price"),0))
packing_id = CheckNum(request.form("packing_id"),0)
rem	}->
rem	<-{ 预订 b 56770.WangLei
is_booking= CheckNum(request.form("is_booking"),0)
advance_money = CDbl(CheckNum(request.form("advance_money"),0))
low_money = CDbl(CheckNum(request.form("low_money"),0))
odd_money = CDbl(CheckNum(request.form("odd_money"),0))
rem	}->
'发票信息
fapiao_company=safereplace(request.form("fapiao_company"))
fapiao_adds=safereplace(request.form("fapiao_adds"))
fapiao_zip=safereplace(request.form("fapiao_zip"))
iffapiao=safereplace(request.form("iffapiao"))
If Iffapiao=1 Then
		If Config_Lebi_Eshop(2)="1" Then
				fapiao_money=(dis_sum*Config_Lebi_Eshop(14)/100)
		Else
				fapiao_money=0
		End If
Else
		fapiao_money=0
End If
order_number = SaveOrderNo
dis_grade = CheckNum(request.cookies(cookiesname&"_user")("user_grade"),0)
'If totalcash = 0 Then
'		response.redirect Eshop_url & PagePath(1) &"?action=nothing"
'		response.End()
'End If
If Len(from_name)<2 Or Len(from_name)>30 Or from_name="" Then
		casherror=True
		error_type = error_type &",6,"
End If
If Len(from_tel)<6 Or Len(from_tel)>50 Then
		casherror=True
		error_type = error_type &",2,"
End If
If IsValidEmail(from_email)=false Then
		casherror=True
		error_type = error_type &",3,"
End If
If Len(from_zip)>7 or Len(from_zip)<3 Then
		casherror=True
		error_type = error_type &",4,"
End If
If Len(from_adds)<2 Or Len(from_adds)>100 Or from_adds="" Then
		casherror=True
		error_type = error_type &",7,"
End If
If sys_soft = 0 Then 
		If Len(to_name)<2 Or Len(to_name)>30 Or to_name="" Then
				casherror=True
				error_type = error_type &",1,"
		End if
		If Len(to_tel)<6 Or Len(to_tel)>50 Then
				casherror=True
				error_type = error_type &",2,"
		End If
		If Len(to_zip)>7 or Len(to_zip)<3 Then
				casherror=True
				error_type = error_type &",4,"
		End If
		If Len(to_adds)<2 Or Len(to_adds)>100 Or to_adds="" Then
				casherror=True
				error_type = error_type &",5,"
		End If
End If 
If trim(sendtype)="" Or fei=56770 Then
		casherror=True
		error_type = error_type &",8,"
End If
If casherror=true Then
		response.redirect Eshop_url & PagePath(1) &"?action=basket_cashsave&error_type="& error_type
End If
Set rss = conn.execute("select coupon_num from [Lebi_lshy] where sessionid="& CookiesId &"")
If Not rss.eof Then
		If Trim(rss(0)) <> "" Then
				coupon_num = rss(0)
				Set Scoupon = server.CreateObject("adodb.recordset")
				Scoupon.open "select c_type,c_price,c_discount,user_id,c_state,c_ondate from [Lebi_coupon] where c_num = '"& coupon_num &"'",conn,1,3
				coupon_type = Scoupon(0)
				coupon_price = Scoupon(1)
				coupon_discount = Scoupon(2)
				If Lebi_UserId <> "" Then
						Scoupon("user_id") = Lebi_UserId
				End If
				Scoupon("c_state") = 1
				Scoupon("c_ondate") = Now()
				Scoupon.update
				Scoupon.close : Set Scoupon = Nothing
				If coupon_type = 0 Then coupon_price = coupon_price
				If coupon_type = 1 Then coupon_price = formatnumber2(dis_sum * (100-coupon_discount)/100)
		Else
				z_str4=(totalcash*z_discount)/moneyhl
		End If
Else
		z_str4=(totalcash*z_discount)/moneyhl
End If
rss.close : Set rss = Nothing
If IsNull(coupon_price) Or IsEmpty(coupon_price) Then coupon_price = 0
set rs = conn.execute("select * from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <> ''))")
If rs.eof Then
		Write_Lebi_Eshop("<SCRIPT language=JavaScript>alert('["&Lebi_cart(39)&"]\n\n"&Lebi_cart(98)&"');document.location.href='"& Eshop_url & LangPath &"';</SCRIPT>")
		response.End
Else
		If Lebi_UserId <>"" Then 
				Set user = server.CreateObject("adodb.recordset")
				user.open "select * from [Lebi_user] where User_Id = '"& Lebi_UserId &"'",conn,1,3
				Uid = user("id")
				If UnionApi = "1" Then
						Uparent = user("u_parent")
				Else 
						Uparent = 0
				End If 
				if from_name <>"" then
						user("user_name") = from_name
				end If
				if from_tel <>"" then
						user("user_tel") = from_tel
				end If
				if from_email <>"" then
						user("user_mail") = from_email
				end If
				if from_zip <>"" then
						user("user_postalcode") = from_zip
				end If
				if from_adds <>"" then
						user("user_adds") = from_adds
				end If
				If sys_soft = 1 Then 
						if from_adds2 <>"" then
								user("user_adds2") = from_adds2
						end If
						if from_city <>"" then
								user("city") = from_city
						end If
						if from_state <>"" then
								user("state") = from_state
						end If
						if from_country <>"" then
								user("country") = from_country
						end If
				End If 
				if from_mobile <>"" then
						user("user_mobile") = from_mobile
				end If
				If iffapiao = "1" Then
						if fapiao_company<>"" then
								user("fapiao_company") = fapiao_company
						end if
						if fapiao_adds<>"" then
							   user("fapiao_adds") = fapiao_adds
						end if
						if fapiao_zip<>"" then
							   user("fapiao_zip") = fapiao_zip
						end If
				End If 
				user.update
				user.close : Set user = Nothing
		End     If
		Set rs=Server.CreateObject("ADODB.Recordset")
		sql="select * from [Lebi_orders]"
		rs.open sql, conn, 1, 3
		rs.addnew
				rs("order_number")=order_number
				rs("order_time")=now()
				rs("user_id")=Lebi_UserId
				rs("to_name")=to_name
				rs("to_tel")=to_tel
				rs("to_tel2")=to_tel2
				rs("to_zip")=to_zip
				rs("to_adds")=to_adds
				rs("to_other")=to_other
				rs("to_mobile")=to_mobile
				rs("sendtype")=sendtype
				rs("from_name")=from_name
				rs("from_tel")=from_tel
				rs("from_email")=from_email
				rs("from_zip")=from_zip
				rs("from_adds")=from_adds
				rs("from_other")=from_other
				rs("from_mobile")=from_mobile
				If sys_soft = 1 Then 
						rs("from_adds2")=from_adds2
						rs("from_city")=from_city
						rs("from_state")=from_state
						rs("from_country")=from_country
				End If 
				rs("paymenttype")=paymenttype
				rs("fei")=fei
				rs("totalcash")=totalcash
				rs("jifen")=jifen
				rs("orderzt")=0
				rs("discount")=z_discount
				rs("dis_sum")=dis_sum
				rs("zt")=0
				rs("coupon_num") = coupon_num
				rs("coupon_price") = coupon_price
				rem	<-{ 包装 2008-3-19 b 56770.WangLei
				rs("packing_price")=packing_price
				rs("packing_id")=packing_id
				rem	}->
				rem	<-{ 预订 2008-3-19 b 56770.WangLei
				rs("is_booking")=is_booking
				rs("advance_money")=advance_money
				rem	}->
				'rs("userid")=userid
				'增加发票信息
				if iffapiao=1 then
						rs("fapiao_company")=fapiao_company
						rs("fapiao_adds")=fapiao_adds
						rs("fapiao_zip")=fapiao_zip
						rs("iffapiao")=1
						rs("fapiao_money") = FormatNumber2(fapiao_money)
				else
						rs("iffapiao")=0
						rs("fapiao_money") = 0
				end If
				rs("is_jifen") = 0
				rs("LangName") = LangName
				rs("LangTxt") = LangTxt
				rs("lastmoney") = CDbl(dis_sum)+CDbl(fei)+CDbl(packing_price)+CDbl(fapiao_money)-CDbl(coupon_price)
		rs.update
		rs.close:Set rs=Nothing
		'取得订单ID
		sql="select id from [Lebi_orders] where order_number='"& order_number &"'"
		set Rs = conn.execute(sql)
		If rs.eof Then
				order_id="56770"
		Else
				order_id=rs("id")
		End If
		rs.close:set rs=nothing
		'取得订单信息
		cbprice = 0
		Dim rsb
		set rs = conn.execute("select l.cpid,p.product_name"& LangTxt &",l.bianhao,l.basket_count,l.price,l.spname,l.spvalue,l.father,l.IsGift,l.product_type,l.is_booking,l.advance_money,p.cbprice from [Lebi_lsbuy] as l,[Lebi_Product] as p where p.id = l.cpid and (sessionid="& CookiesId &" or (l.User_Id = '"& Lebi_UserId &"' and l.User_Id <> '')) and l.Isgift = 0 and l.product_type <> 'unite' and l.product_type <> 'groupon' and l.cpid > 0")
		If Not rs.eof Then
				Do While Not rs.eof
				cbprice = cbprice + (rs("cbprice") * rs("basket_count"))
				If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-14
					conn.execute("update [Lebi_product] set buys = buys + "& rs("basket_count")&",kucun = kucun - "& rs("basket_count") &",html = 0 where id = " & rs("cpid") &"")
					conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys + "& rs("basket_count") &",p_stock = p_stock - "& rs("basket_count") &" where p_id = " & rs("cpid") &" and s_value"& LangTxt &" = '"& rs(6) &"'")
				End If 
				Set rsb=Server.CreateObject("ADODB.Recordset")
				rsb.open "select order_number,id,product_name,bianhao,basket_count,basket_date,price,user_id,spname,spvalue,father,IsGift,product_type,is_booking,advance_money from [Lebi_basket]", conn, 1, 3
				rsb.addnew
				rsb("order_number")=order_id
				rsb("id")=rs(0)
				rsb("product_name")=rs(1)
				rsb("bianhao")=rs(2)
				rsb("basket_count")=rs(3)
				rsb("basket_date")=Now()
				rsb("price")=rs(4)
				rsb("user_id")=Lebi_UserId
				rsb("spname")=rs(5)
				rsb("spvalue")=rs(6)
				rsb("father")=rs(7)
				rsb("IsGift")=rs(8)
				rsb("product_type") = rs(9)
				rsb("is_booking") = rs(10)
				rsb("advance_money") = rs(11)
				rsb.update
				rsb.close:Set rsb=nothing
				rs.movenext
				loop
		End If
		rs.close:Set rs=Nothing
		set rs = conn.execute("select l.cpid,p.product_name"& LangTxt &",l.bianhao,l.basket_count,l.price,l.spname,l.spvalue,l.father,l.IsGift,l.product_type,l.is_booking,l.advance_money,p.product_unite_info from [Lebi_lsbuy] as l,[Lebi_Product_Unite] as p where p.id = l.cpid and (l.sessionid="& CookiesId &" or (l.User_Id = '"& Lebi_UserId &"' and l.User_Id <> '')) and l.Isgift = 0 and l.product_type = 'unite' and l.cpid > 0")
		If Not rs.eof Then
				Do While Not rs.eof
				child_arr = Split(rs("product_unite_info"),"||||")
				for j=0 to ubound(child_arr)  ' 捆绑子商品循环
						sArr = Split(child_arr(j),"||")
						If UBound(sArr) > 3 Then
								set rsp = conn.execute("Select cbprice from [Lebi_Product] where id = "& sArr(0) &"")
								If Not rsp.eof Then 
										Do While Not rsp.eof 
										cbprice = cbprice + (rsp(0) * sArr(4))
										rsp.movenext 
										Loop
								End If 
								rsp.close : Set rsp = Nothing
						End If
				Next
				If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-14
					conn.execute("update [Lebi_product_unite] set buys = buys + "& rs("basket_count") &",kucun = kucun - "& rs("basket_count") &",html = 0 where id=" & rs("cpid") &"")
				End If 
				Set rsb=Server.CreateObject("ADODB.Recordset")
				rsb.open "select order_number,id,product_name,bianhao,basket_count,basket_date,price,user_id,spname,spvalue,father,IsGift,product_type,is_booking,advance_money from [Lebi_basket]", conn, 1, 3
				rsb.addnew
				rsb("order_number")=order_id
				rsb("id")=rs(0)
				rsb("product_name")=rs(1)
				rsb("bianhao")=rs(2)
				rsb("basket_count")=rs(3)
				rsb("basket_date")=Now()
				rsb("price")=rs(4)
				rsb("user_id")=Lebi_UserId
				rsb("spname")=rs(5)
				rsb("spvalue")=rs(6)
				rsb("father")=rs(7)
				rsb("IsGift")=rs(8)
				rsb("product_type") = rs(9)
				rsb("is_booking") = rs(10)
				rsb("advance_money") = rs(11)
				rsb.update
				rsb.close:Set rsb=nothing
				rs.movenext
				loop
		End If
		rs.close:Set rs=Nothing
		If Groupon_State = 1 Then 
		set rs = conn.execute("select l.cpid,p.product_name"& LangTxt &",l.bianhao,l.basket_count,l.price,l.spname,l.spvalue,l.father,l.IsGift,l.product_type,l.is_booking,l.advance_money,p.cbprice from [Lebi_lsbuy] as l,[Lebi_Groupon_Product] as p where p.id = l.cpid and (l.sessionid="& CookiesId &" or (l.User_Id = '"& Lebi_UserId &"' and l.User_Id <> '')) and l.Isgift = 0 and l.product_type = 'groupon' and l.cpid > 0")
		If Not rs.eof Then
				Do While Not rs.eof
				If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-14
					conn.execute("update [Lebi_Groupon_Product] set buys=buys+"& rs("basket_count") &",kucun=kucun-"& rs("basket_count") &" where id=" & rs("cpid") &"")
				End If 
				Set rsb=Server.CreateObject("ADODB.Recordset")
				rsb.open "select order_number,id,product_name,bianhao,basket_count,basket_date,price,user_id,spname,spvalue,father,IsGift,product_type,is_booking,advance_money from [Lebi_basket]", conn, 1, 3
				rsb.addnew
				rsb("order_number")=order_id
				rsb("id")=rs(0)
				rsb("product_name")=rs(1)
				rsb("bianhao")=rs(2)
				rsb("basket_count")=rs(3)
				rsb("basket_date")=Now()
				rsb("price")=rs(4)
				rsb("user_id")=Lebi_UserId
				rsb("spname")=rs(5)
				rsb("spvalue")=rs(6)
				rsb("father")=rs(7)
				rsb("IsGift")=rs(8)
				rsb("product_type") = rs(9)
				rsb("is_booking") = rs(10)
				rsb("advance_money") = rs(11)
				rsb.update
				rsb.close:Set rsb=nothing
				rs.movenext
				loop
		End If
		rs.close:Set rs=Nothing
		End If 
		'取得积分换购礼品信息  2007-10-15 b 56770.kingdge
		Dim TotalGIftScore,rsGift,Getuserinfo
		TotalGIftScore = conn.execute("select sum(price*basket_count) from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <> '')) and Isgift = 1")(0)
		If IsNull(TotalGIftScore) Or IsEmpty(TotalGIftScore) Then TotalGIftScore = 0
		Set Getuserinfo = Server.CreateObject("ADODB.Recordset")
		Getuserinfo.open "select jifen from [Lebi_user] where user_id = '"& Lebi_UserId &"'",conn,1,3
		If Not Getuserinfo.eof Then
			 If CLng(Getuserinfo("jifen"))>CLng(TotalGIftScore) Then
					 set rs = conn.execute("select * from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <> '')) and Isgift = 1 and cpid > 0")
					 If Not rs.eof Then
							 Do While Not rs.eof
							 conn.execute("update [Lebi_vipproduct] set kucun = kucun-"& rs("basket_count") &" where id=" &rs("cpid")&"")
							 Set rsGift=Server.CreateObject("ADODB.Recordset")
							 rsGift.open "select * from [Lebi_basket]", conn, 1, 3
							 rsGift.addnew
									  rsGift("order_number")=order_id
									  rsGift("id")=rs("cpid")
									  rsGift("product_name")=rs("product_name")
									  rsGift("bianhao")=rs("bianhao")
									  rsGift("basket_count")=rs("basket_count")
									  rsGift("basket_date")=Now()
									  rsGift("price")=rs("price")
									  rsGift("user_id")=Lebi_UserId
									  rsGift("spname")=rs("spname")
									  rsGift("spvalue")=rs("spvalue")
									  rsGift("father")=1
									  rsGift("IsGift")=1
							 rsGift.update
							 rsGift.close:Set rsGift=nothing
							 rs.movenext
							 loop
					  End If
					  rs.close:Set rs=Nothing
					  Getuserinfo("jifen") = Getuserinfo("jifen") - TotalGIftScore
					  Getuserinfo.update
			 End If
		End If
		Getuserinfo.close : Set Getuserinfo = Nothing
		rem <-{写入联盟系统日志 2011-01-13 by 56770.kingdge
		If Uparent <> 0 Then
				conn.execute("insert into [Lebi_union_log](l_time,l_price,l_price2,l_state,order_number,uid)values("& sqlnowstring &","& dis_sum &","& dis_sum - cbprice &",0,'"& order_number &"',"& Uid &")")
		End If
		rem }->
		'删除临时购物表
		conn.execute("Delete from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <> ''))")
		conn.execute("Delete from [Lebi_lshy] where sessionid="& CookiesId &"")
		If SMS_State = "1" Then
				Dim LoadSMSInfo,SMSMsg
				LoadSMSInfo = LoadStyle(Eshop_url&"include/lebi_data/SMS"& LangTxt &".data")
				If CheckMobile(from_mobile) Then
						If InStr(","& SMS_SendMode &",",",2,") > 0 Then
								SMSMsg = splits(Split(LoadSMSInfo,"@@@")(1))
								ReplaceStyle "user_id",Lebi_UserId,SMSMsg
								ReplaceStyle "user_name",user_name,SMSMsg
								ReplaceStyle "time",Now(),SMSMsg
								ReplaceStyle "order_number",order_number,SMSMsg
								ReplaceStyle "money",formatnumber2((CDbl(dis_sum)+CDbl(fei)+CDbl(packing_price)+CDbl(fapiao_money)-CDbl(coupon_price))/moneyhl),SMSMsg
								Call RedirectSendSMS(from_mobile,SMSMsg,0,"",sms_sendtype)
						End If
				End If
				If CheckMobile(sms_receiveno) Then
						If InStr(","& SMS_SendMode &",",",9,") > 0 Then
								SMSMsg = splits(Split(LoadSMSInfo,"@@@")(8))
								ReplaceStyle "user_id",Lebi_UserId,SMSMsg
								ReplaceStyle "user_name",user_name,SMSMsg
								ReplaceStyle "mobile",from_mobile,SMSMsg
								ReplaceStyle "time",Now(),SMSMsg
								ReplaceStyle "order_number",order_number,SMSMsg
								ReplaceStyle "money",formatnumber2((CDbl(dis_sum)+CDbl(fei)+CDbl(packing_price)+CDbl(fapiao_money)-CDbl(coupon_price))/moneyhl),SMSMsg
								Call RedirectSendSMS(sms_receiveno,SMSMsg,1,"",sms_sendtype)
						End If
				End If
		End If
		If jmail_type<>0 Then
				Dim useremail,topic,mailbody,sendmsg,linkurl
				Dim topic_admin,mailbody_admin
				Dim LoadMailInfo
				rem 增加自定义邮件内容 2008-1-21 b 56770.kingdge
				LoadMailInfo = LoadStyle(EShop_url &"include/Lebi_data/E-mail"& LangTxt &".data")
				rem 获取真实URL地址 2005-12-25 b 56770.kingdge
				If request.ServerVariables("SERVER_PORT") <> 80 Then
						linkurl = "http://"&Request.ServerVariables("SERVER_NAME")&":"&request.ServerVariables("SERVER_PORT")
				Else
						linkurl = "http://"&Request.ServerVariables("SERVER_NAME")
				End If
				linkurl = linkurl & Eshop_url & LangPath &"Search/Order.asp?order_number="& order_number
				useremail=from_email
				topic=splits(Split(LoadMailInfo,"@@@")(2))
				ReplaceStyle "user_id",Lebi_UserId,topic
				topic_admin=Lebi_cart(85)
				mailbody = Split(LoadMailInfo,"@@@")(3)
				ReplaceStyle "user_id",from_name,mailbody
				ReplaceStyle "order_number",order_number,mailbody
				ReplaceStyle "order_time",Now(),mailbody
				ReplaceStyle "order_price",dw & formatnumber2(dis_sum/moneyhl) & dw2,mailbody
				ReplaceStyle "order_fei",dw & formatnumber2(fei/moneyhl) & dw2,mailbody
				ReplaceStyle "order_total",dw & formatnumber2((CDbl(dis_sum)+CDbl(fei)+CDbl(packing_price)+CDbl(fapiao_money)-CDbl(coupon_price))/moneyhl) & dw2,mailbody
				ReplaceStyle "order_url",linkurl,mailbody
				ReplaceStyle "from_name",from_name,mailbody
				ReplaceStyle "from_tel",from_tel,mailbody
				ReplaceStyle "from_email",from_email,mailbody
				ReplaceStyle "from_adds",from_adds,mailbody
				ReplaceStyle "from_zip",from_zip,mailbody
				ReplaceStyle "from_mes",from_other,mailbody
				ReplaceStyle "from_mobile",from_mobile,mailbody
				ReplaceStyle "to_name",to_name,mailbody
				ReplaceStyle "to_tel",to_tel,mailbody
				ReplaceStyle "to_adds",to_adds,mailbody
				ReplaceStyle "to_zip",to_zip,mailbody
				ReplaceStyle "to_mes",to_other,mailbody
				ReplaceStyle "to_mobile",to_mobile,mailbody
				rem	<-{  b 56770.WangLei
				ReplaceStyle "packing_price",dw & FormatNumber2(packing_price/moneyhl) & dw2,mailbody
				ReplaceStyle "packing_id",packing_id,mailbody
				ReplaceStyle "is_booking",is_booking,mailbody
				ReplaceStyle "advance_money",dw & FormatNumber2(advance_money/moneyhl) & dw2,mailbody
				ReplaceStyle "low_money",dw & FormatNumber2(low_money/moneyhl) & dw2,mailbody
				ReplaceStyle "odd_money",dw & FormatNumber2(odd_money/moneyhl) & dw2,mailbody
				ReplaceStyle "fapiao_money",dw & FormatNumber2(fapiao_money/moneyhl) & dw2,mailbody
				ReplaceStyle "paymenttype",paymenttype,mailbody
				rem	}->
				mailbody_admin = "<html><head><style>body{font-size:12px;color:#000;}table{width:600px;}th,td{text-align:left;font-size:12px;color:#000;}</style></head><body>"&Replace(Lebi_cart(92),"[user_id]",from_name)&"，<br><br> "&Lebi_cart(86)&"："&order_number&"<br> "&Lebi_cart(87)&"："&Now()&"<br> "&Lebi_cart(77)&"："&dw & formatnumber2(dis_sum/moneyhl) & dw2&"<br> "&Lebi_cart(78)&"："&dw & formatnumber2(fei/moneyhl) & dw2&"<br> "&Lebi_cart(80)&"："&dw & formatnumber2((CDbl(dis_sum)+CDbl(fei)+CDbl(packing_price)+CDbl(fapiao_money)-CDbl(coupon_price))/moneyhl) & dw2&"<br><br>"&Lebi_cart(141)&"：<br> "&Lebi_cart(142)&"："&Trim(from_name)&"<br>"&Lebi_cart(43)&"："&Trim(from_tel)& "<br>"&Lebi_cart(44)&"："&Trim(from_email)& "<br> "&Lebi_cart(144)&"："&Trim(from_adds)&"<br>"&Lebi_cart(45)&"："&Trim(from_zip)&"<br>Url：<a href="& linkurl &" target=_blank>"& linkurl &"</a></body></html>"
				Dim Email_Lebi
				Set Email_Lebi = New Dv_SendMail
				Email_Lebi.SendObject = jmail_type
				Email_Lebi.ServerLoginName = jmail_sendmail
				Email_Lebi.ServerLoginPass = jmail_sendpass
				Email_Lebi.SendSMTP = jmail_smtp
				Email_Lebi.SendFromEmail = jmail_frommail
				Email_Lebi.SendFromName = jmail_sendname
				If Email_Lebi.ErrCode = 0 Then
						if jmail_cashon=1 then
								Email_Lebi.SendMail useremail,topic,splits(mailbody)	'执行发送邮件
						end if
						Email_Lebi.SendMail jmail_frommail,topic_admin,mailbody_admin
						If jmail_sendmail<>"" And jmail_sendpass<>"" And jmail_smtp<>"" Then
								sendmsg = Lebi_cart(93)
						Else
								sendmsg = Lebi_cart(94)
						End If
				Else
						sendmsg= Lebi_cart(94)
				End If
				Set Email_Lebi = Nothing
		End If
End If
If IsSqlDataBase = 1 Then
		Set rss=conn.execute("select top 1 z_price,z_discount from [Lebi_discount] where z_price<="& totalcash &" and charindex('"& dis_grade &"',z_flag)>0 order by z_id desc")
Else
		Set rss=conn.execute("select top 1 z_price,z_discount from [Lebi_discount] where z_price<="& totalcash &" and instr(z_flag,"& dis_grade &")>0 order by z_id desc")
End If
If rss.eof Then
		z_price="0"
		z_discount="1.00"
Else
		z_price=rss("z_price")
		z_discount=rss("z_discount")
		strdiscount=inttotext(1-rss("z_discount"))
End if
rss.close:Set rss=Nothing
Set rss = conn.execute("select coupon_num from [Lebi_orders] where order_number='"& order_number &"'")
If Trim(rss(0)) <> "" Then
		coupon_num = rss(0)
		Set Scoupon = conn.execute("select c_type,c_price,c_discount from [Lebi_coupon] where c_num = '"& coupon_num &"'")
		coupon_type = Scoupon(0)
		coupon_price = Scoupon(1)/moneyhl
		coupon_discount = Scoupon(2)
		Scoupon.close : Set Scoupon = Nothing
		If coupon_type = 0 Then z_str4 = (totalcash*z_discount) - coupon_price
		If coupon_type = 1 Then z_str4 = (totalcash*z_discount) * coupon_discount/100
		Use_Coupon = True
Else
		z_str4=(totalcash*z_discount)/moneyhl
		Use_Coupon = False
End If
rss.close : Set rss = Nothing
z_str1=dw & formatnumber2(z_price/moneyhl) & dw2
z_str2=strdiscount
z_str3=dw & formatnumber2(totalcash*z_discount/moneyhl) & dw2
Dim discountinfo
If z_price=0 Then
		discountinfo = Lebi_cart(27)
Else
		discountinfo = replace(replace(Replace(Lebi_cart(28),"[z_str1]",z_str1),"[z_str2]",z_str2),"[z_str3]","<span class='discountprice'>"& z_str3 &"</span>")
End If
Dim couponinfo
If coupon_type = 0 Then
		couponinfo = Lebi_cart(137) &" "& Lebi_cart(138)&" "& dw & formatnumber2(coupon_price) & dw2
Else
		couponinfo = Lebi_cart(137) &" "& Lebi_cart(139)&" "& coupon_discount &"%"
End If
payprice = formatnumber2((CDbl(dis_sum)+CDbl(fei)+CDbl(packing_price)+CDbl(fapiao_money)-CDbl(coupon_price))/moneyhl)
Dim items_money
items_money = formatnumber2(totalcash/moneyhl) 'formatnumber2(totalcash*z_discount/moneyhl)
Dim total_money
total_money = payprice 'formatnumber2(z_str4+fei+request("fapiao_money")+formatnumber2(packing_price))
fei = formatnumber2(fei/moneyhl)
packing_price = formatnumber2(packing_price/moneyhl)
fapiao_money = formatnumber2(fapiao_money/moneyhl)
jifen = formatnumber2(jifen/moneyhl)
Dim paymentlink
Select Case paymenttype_id
	   Case "001"
				If Pay_chinabank(7) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=4&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_chinabank(4) &"&remark1="& LangPath &"|' title='"& Pay_chinabank(10) &"' target='_blank'><img src='"& Eshop_url & Pay_chinabank(7) &"' alt='"& Pay_chinabank(10) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=4&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_chinabank(4) &"&remark1="& LangPath &"|');"" value='"& Pay_chinabank(10) &"' class='button'>"
				End If
	   Case "002"
				If Pay_alipay(9) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=1&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_alipay(6) &"&extra_common_param="& LangPath &"|' title='"& Pay_alipay(12) &"' target='_blank'><img src='"& Eshop_url & Pay_alipay(9) &"' alt='"& Pay_alipay(12) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=1&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_alipay(6) &"&extra_common_param="& LangPath &"|');"" value='"& Pay_alipay(12) &"' class='button'>"
				End If
	   Case "003"
				If Pay_paypal(5) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=3&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paypal_currency_code="& paypal_currency_code &"&paybackurl="& Pay_paypal(7) &"&custom="& LangPath &"|' title='"& Pay_paypal(10) &"' target='_blank'><img src='"& Eshop_url & Pay_paypal(5) &"' alt='"& Pay_paypal(10) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=3&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paypal_currency_code="& paypal_currency_code &"&paybackurl="& Pay_paypal(7) &"&custom="& LangPath &"|');"" value='"& Pay_paypal(10) &"' class='button'>"
				End If
	   Case "004"
				If Pay_bill(6) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=2&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_bill(3) &"&ext1="& LangPath &"|' title='"& Pay_bill(9) &"' target='_blank'><img src='"& Eshop_url & Pay_bill(6) &"' alt='"& Pay_bill(9) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=2&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_bill(3) &"&ext1="& LangPath &"|');"" value='"& Pay_bill(9) &"' class='button'>"
				End If
	   Case "005"
				If Pay_tenpay(7) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=5&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_tenpay(4) &"&Pay_tenpay_attach="& LangPath &"|' title='"& Pay_tenpay(10) &"' target='_blank'><img src='"& Eshop_url & Pay_tenpay(7) &"' alt='"& Pay_tenpay(10) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=5&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_tenpay(4) &"&Pay_tenpay_attach="& LangPath &"|');"" value='"& Pay_tenpay(10) &"' class='button'>"
				End If
	   Case "006"
				If Pay_tenpay2(7) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=6&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_tenpay2(4) &"&Pay_tenpay_attach="& LangPath &"|' title='"& Pay_tenpay2(10) &"' target='_blank'><img src='"& Eshop_url & Pay_tenpay2(7) &"' alt='"& Pay_tenpay2(10) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=6&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_tenpay2(4) &"&Pay_tenpay_attach="& LangPath &"|');"" value='"& Pay_tenpay2(10) &"' class='button'>"
				End If
	   Case "007"
				If Pay_paypal_cn(5) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=3&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_paypal_cn(7) &"&custom="& LangPath &"|' title='"& Pay_paypal_cn(10) &"' target='_blank'><img src='"& Eshop_url & Pay_paypal_cn(5) &"' alt='"& Pay_paypal_cn(10) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=3&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_paypal_cn(7) &"&custom="& LangPath &"|');"" value='"& Pay_paypal_cn(10) &"' class='button'>"
				End If
	   Case "008"
				If Pay_ips(7) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=8&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_ips(4) &"' title='"& Pay_ips(10) &"&attach="& LangPath &"|' target='_blank'><img src='"& Eshop_url & Pay_ips(7) &"' alt='"& Pay_ips(10) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=8&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_ips(4) &"&attach="& LangPath &"|');"" value='"& Pay_ips(10) &"' class='button'>"
				End If
	   Case "009"
				If Pay_baofu(7) <> "" Then
						paymentlink = "<a href='"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=9&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_baofu(4) &"&AdditionalInfo="& LangPath &"|' title='"& Pay_baofu(10) &"' target='_blank'><img src='"& Eshop_url & Pay_baofu(7) &"' alt='"& Pay_baofu(10) &"' border='0' align='absmiddle'></a>"
				Else
						paymentlink = "<input type='button' onclick=""window.open('"& Eshop_url &"plus/Onlinepay.asp?pay_page=2&pay_type=9&pro_id=0&subject="& order_number &"&trade_no="& order_number &"&price="& payprice &"&md5char="& md5(payprice) &"&paybackurl="& Pay_baofu(4) &"&AdditionalInfo="& LangPath &"|');"" value='"& Pay_baofu(10) &"' class='button'>"
				End If
End Select
Public Function Basket_Cashsave_Product()
		Dim strFile,LoopStr(4),loop_gift,loop_bank,tstr,tmpstr,tmpstr2
		strFile = Eshop_url& Style_Folder &"Lebi.Basket_Cashsave_Product."
		Dim rs_bof_eof_product,rs_bof_eof_gift,rs_bof_eof_bank
	    sql="select id,bianhao,product_name,price,basket_count,spname,spvalue from [Lebi_basket] where order_number="& order_id &" and Isgift = 0 order by id desc"
'	    If IsSqlDataBase = 1 Then sql=sql&" and datediff(s,basket_date,"& sqlnowstring &")<172800 order by basket_date desc"
'        If IsSqlDataBase = 0 Then sql=sql&" and datediff('h',basket_date,"& sqlnowstring &")<48 order by basket_date desc"
	    set rs = conn.execute(sql)
		rs_bof_eof_product=rs.eof and rs.bof
        If Not (rs.eof And rs.bof) Then
				Basket_Cashsave_Product = splits(LoadStyle(strFile&"0.style"))
				ReplaceStyle "property0","",Basket_Cashsave_Product
				LoopStr(0) = LoadStyle(strFile&"2.style")
				LoopStr(1) = LoadStyle(strFile&"3.style")
				LoopStr(2) = LoadStyle(strFile&"4.style")
				LoopStr(3) = LoadStyle(strFile&"5.style")
				Do While Not rs.EOF
						tmpstr = LoopStr(0)
						property_item = ""
						If rs("spname") <> "" Then 
								property_item = splits(LoadStyle(strFile&"3.style"))
								spstr = ""
								If InStr(rs("spname"),",") > 0 Then 
										arr_spname = Split(rs("spname"),",")
										arr_spvalue = Split(rs("spvalue"),",")
										For s = 0 To UBound(arr_spname)
												spstr = spstr & arr_spname(s) &"："& arr_spvalue(s)
												If s < UBound(arr_spname) Then spstr = spstr & "&nbsp;&nbsp;"
										Next 
								Else
										spstr = rs("spname") &"："& rs("spvalue")
								End If 
								ReplaceStyle "property_item",spstr,property_item
						End If 
						ReplaceStyle "property1","",tmpstr
						ReplaceStyle "property_item",property_item,tmpstr
						ReplaceStyle "number",rs("bianhao"),tmpstr
						ReplaceStyle "name",rs("product_name"),tmpstr
						ReplaceStyle "price",Formatnumber2(rs("price")/moneyhl),tmpstr
						ReplaceStyle "count",rs("basket_count"),tmpstr
						ReplaceStyle "total",FormatNumber2(rs("price")*rs("basket_count")/moneyhl),tmpstr
						ReplaceStyle "correlative_product","",tmpstr
						Basket_Cashsave_Product = Basket_Cashsave_Product & tmpstr
				rs.MoveNext
				Loop
				Basket_Cashsave_Product = Basket_Cashsave_Product & LoadStyle(strFile&"6.style")
		End If
        rs.close:Set rs=Nothing
End Function
Public Function Basket_Cashsave_Gift()
		Dim strFile,LoopStr,tmpstr,tstr
		strFile = Eshop_url& Style_Folder &"Lebi.Basket_Cashsave_Gift."
		set rs = conn.execute("select Basket_count,product_name,price from [Lebi_basket] where order_number="& order_id &" and Isgift = 1 order by Basket_date desc")
		If Not rs.eof Then
				Basket_Cashsave_Gift = splits(LoadStyle(strFile&"0.style"))
				tmpstr = LoadStyle(strFile&"1.style")
				tstr = ""
				Do While Not rs.eof
						loopstr = tmpstr
						ReplaceStyle "name",rs("product_name"),LoopStr
						ReplaceStyle "price",FormatNumber2(rs("price")/moneyhl),LoopStr
						ReplaceStyle "count",rs("basket_count"),LoopStr
						ReplaceStyle "total",FormatNumber2(rs("price")*rs("basket_count")/moneyhl),LoopStr
						tstr = tstr & loopstr
						rs.movenext
				Loop
		        Basket_Cashsave_Gift = Basket_Cashsave_Gift & tstr & LoadStyle(strFile&"2.style")
		End If
		rs.close:Set rs=Nothing
End Function
Public Function Basket_Cashsave_Bank()
		Dim strFile,LoopStr,tmpstr,tstr
		strFile = Eshop_url& Style_Folder &"Lebi.Basket_Cashsave_Bank."
		Dim paymenttype_check,content
		paymenttype_check = "001,002,003,004,005,006,007,008,009,010,011,012,013"
		If instr(paymenttype_check,request("paymenttype_id"))<= 0 Then
				Basket_Cashsave_Bank = splits(LoadStyle(strFile&"0.style"))
				Set rs=conn.execute("select bank"& LangTxt &" from [Lebi_bank] where zf_fs='"& paymenttype &"' order by id desc")
				If Not(rs.eof And rs.bof) Then
						tmpstr = LoadStyle(strFile&"2.style")
						tstr = ""
						Do While Not rs.eof
								loopstr = tmpstr
								If InStr(LCase(rs(0)),"<table")>0 Then
										content=rs(0)
								Else
										content = replace(bank, chr(32), "&nbsp;")
										content = replace(rs(0), chr(13), "<br>")
								End If
								ReplaceStyle "content",content,LoopStr
								tstr = tstr & loopstr
								rs.movenext
						Loop
						Basket_Cashsave_Bank = Basket_Cashsave_Bank & tstr
				Else
						Basket_Cashsave_Bank = Basket_Cashsave_Bank & splits(LoadStyle(strFile&"1.style"))
				End If
				Basket_Cashsave_Bank = Basket_Cashsave_Bank & LoadStyle(strFile&"3.style")
				rs.close:set rs=Nothing
		Else
				Basket_Cashsave_Bank = "<br />"& paymentlink
        End If
End Function
%>