<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="cgi/Config.asp"-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type="text/css"> 
<!--
*{margin:0;padding:0;}
body{font:12px "宋体",Arial,Verdana;color:#000;text-align:left;background-color:#e6e6e6;} 
a:link,a:visited{color:#C00;text-decoration:underline;}a:hover{color:#F00;text-decoration:underline;}
img{border:0 none;vertical-align:middle;margin-top:-5px;}
h1{height:28px;line-height:28px;font-family:"黑体";font-size:20px;font-weight:100;color:#009900;text-align:center;margin-bottom:20px;}
h2{height:28px;line-height:28px;font-family:"黑体";font-size:18px;font-weight:100;text-align:center;margin-top:20px;}
#ddok{width:100%;height:260px;background-color:#FFF;margin:0 auto;padding-top:20px;text-align:center;border:5px solid #CCC;}
#ddok table{margin:0 auto;}
#ddok table td{padding:10px 10px;}
#ddok table td.tda{text-align:right;background-color:#F7F7F7;}
#ddok table td.tdb{color:#bd0000;text-align:left;}
-->
</style>
</head>
<body>

<%


Dim p_count,p_id,consignee,mobile,tel,u_province,u_City,u_district,address,zipcode,best_time,user_note,pay_id,vcode_form,lailu,qudao
Dim dinggouma,froma,isMobile
p_count=trim(request("p_count"))
qudao=trim(request("qudao"))
p_id=trim(request("p_id"))
isMobile=request("isMobile")
Dim isNokia:isNokia=false
if not mobj.testreg(isMobile,"^[1]$") then isMobile=0
isMobile=cint(isMobile)
if not mobj.testreg(p_count,"^\d{1,3}$") then p_count=1
if not mobj.testreg(qudao,"^(\w|-){36}$") then mobj.jscheck "渠道参数非法",1
if not mobj.testreg(p_id,"^(\w|-){36}$") then mobj.jscheck "产品参数非法",1


consignee=mobj.CheckBadstr(trim(request("consignee")))
mobile=mobj.CheckBadstr(trim(request("mobile")))
tel=mobj.CheckBadstr(trim(request("tel")))
address=mobj.CheckBadstr(trim(request("address")))
zipcode=mobj.CheckBadstr(trim(request("zipcode")))
best_time=mobj.CheckBadstr(trim(request("best_time")))
user_note=mobj.CheckBadstr(trim(request("user_note")))
pay_id=mobj.CheckBadstr(trim(request("pay_id")))
vcode_form=Ucase(trim(Request("vcode_form")))
lailu=mobj.CheckBadstr(trim(request("lailu")))
dinggouma=trim(request("dinggouma"))


if not mobj.testreg(dinggouma,"^\d{1,3}$") then dinggouma=0
dinggouma=cint(dinggouma)

froma=mobj.CheckBadstr(trim(request("froma")))

if consignee="" or mobile="" or address="" then mobj.jscheck "姓名、电话、地址不能为空",1
if not mobj.fitlen(consignee,1,12) then mobj.jscheck "姓名最长12个字符",1

if not mobj.fitlen(address,1,60) then mobj.jscheck "地址最长60个字符",1

'严格控制手机格式，可适当禁用此功能
if not mobj.testreg(mobile,RegexMobile) then  mobj.jscheck "手机号不规范",1

if len(tel)>15 then  mobj.jscheck "电话最长15个字符",1
if len(lailu)>60 then lailu=""
if len(user_note)>120 then user_note=left(user_note,120)







if not mobj.testreg(pay_id,"^\d{1}$") then pay_id=1
if not mobj.testreg(best_time,"^\d{1}$") then best_time=1
if not mobj.testreg(zipcode,"^\d{4,10}$") then zipcode=""


mobj.crs rs
rs.open "select * from b2c_qudao where q_sn='"&qudao&"'",dstr,1,1
if rs.eof and rs.bof then 
	mobj.drs rs
	mobj.jscheck "参数非法",1
else
	q_id=rs("q_id")
	q_name=rs("q_name")
	q_check=rs("q_check")
	q_max=rs("q_max")
	q_yangshi=rs("q_yangshi")
	mobj.drs rs
end if

'判断是否需要验证码
if q_check=1 then 
	If vcode_form<>session("GetCode") Then mObj.JsCheck "验证码不正确！",1
end if
userip=mobj.Query()

'判断用户IP每天最大下单量
if q_max>0 then 
	mobj.crs rs
	rs.open "select count(0) as rscount from b2c_order_info where userip='"&userip&"' and add_time>='"&year(now)&"-"&month(now)&"-"&day(now)&" 00:00:00'",dstr,1,1
	rscount=rs("rscount")
	mobj.drs rs
	if rscount>=q_max then  mObj.JsCheck "超标了！",1
end if

'response.Write "select g_name,g_price,g_mprice from b2c_goods where g_qudao='"&qudao&"' and g_id="&p_id
'response.End()
mobj.crs rs
rs.open "select * from b2c_goods where g_qudao='"&qudao&"' and g_guid='"&p_id&"'",dstr,1,1
if rs.eof and rs.bof then 
	mobj.drs rs
	mobj.jscheck "产品不存在",1
else
	g_name=rs("g_name")
	g_price=rs("g_price")
	g_mprice=rs("g_mprice")
	mobj.drs rs
end if

mobj.crs rs
rs.open "select * from b2c_order_info where 1=3",dstr,1,3
rs.addnew()
rs("order_guid")=mobj.GenerateGuid()

rs("consignee")=consignee
rs("address")=address
rs("mobile")=mobile

if zipcode<>"" then rs("zipcode")=zipcode
if tel<>"" then  rs("tel")=tel
if email<>"" then rs("email")=email

rs("best_time")=best_time
rs("pay_id")=pay_id
rs("user_note")=user_note
rs("p_qid")=qudao
rs("p_id")=p_id
rs("p_count")=p_count


rs("dinggouma")=dinggouma
rs("from_ad")=froma
rs("lailu")=lailu
rs("userip")=userip


rs("goods_amount")=p_count*g_price
rs.update
mobj.drs rs

mobj.crs rs
rs.open "select top 1 order_id from b2c_order_info where userip='"&userip&"' order by order_id desc",dstr,1,1
if not (rs.eof and rs.bof) then 
	order_id=rs("order_id")
end if
mobj.drs rs
Dim backUrl:backUrl="pc.asp"
if isMobile=1 then backUrl="wap.asp"

%>
<div id="ddok">
    <h1><img src="images/ok.png" width="24" height="24" /> 恭喜您，订单提交成功！</h1>
	<table width="90%" border="1" cellpadding="0" cellspacing="0" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
	    <tr>
		    <td width="30%" class="tda">订单号：</td>
			<td width="70%" class="tdb"><%=order_id%></td>
		</tr>
		<tr>
		    <td class="tda">收货人姓名：</td>
			<td class="tdb"><%=consignee%></td>
		</tr>
		<tr>
		    <td class="tda">收货人手机号码：</td>
			<td class="tdb"><%=mobile%></td>
		</tr>
		<tr>
		    <td class="tda">收货人详细地址：</td>
			<td class="tdb"><%=u_pname&u_cname&u_dname&address%> </td>
		</tr>
	</table>
<h2 style="color:#009933">我们将第一时间给您安排处理，谢谢！</h2>
    <h2><a href="<%=backUrl%>?qudao=<%=qudao%>&dinggouma=<%=dinggouma%>&lailu=<%=lailu%>">点击返回 >></a></h2>
</div>
<!-------------------------- 统计转化代码 start -------------------------->
 
<!-------------------------- 统计转化代码 end -------------------------->
</body>
</html>
<%
Dim sssmail:sssmail=0
mobj.crs rs
rs.open "select * from b2c_sys where s_id=1",dstr,1,1
if not (rs.eof and rs.bof) then
	s_mailcheck=rs("s_mailcheck")
	s_smtp=rs("s_smtp")
	s_remail=rs("s_remail")
	s_smail=rs("s_smail")
	s_pass=rs("s_pass")
	s_user=rs("s_user")
	sssmail=s_mailcheck
end if 
mobj.drs rs
on error resume next
if sssmail=1 then
	Dim mailc
	mailc=" <table width='750' border='1' cellspacing='0' cellpadding='0'><tr><td width='124' height='30' align='right'>姓名：</td>     <td width='620' align='left'>&nbsp;{$name}</td>   </tr>   <tr>     <td height='30' align='right'>电话：</td>     <td align='left'>&nbsp;{$mobile}</td>   </tr>   <tr>     <td height='30' align='right'>联系地址：</td>     <td align='left'>&nbsp;{$address}</td>   </tr>   <tr>     <td height='30' align='right'>产品：</td>     <td align='left'>&nbsp;{$product}</td>   </tr>   <tr>     <td height='30' align='right'>付款方式：</td>     <td align='left'>&nbsp;{$payment}</td>   </tr>   <tr>     <td height='30' align='right'>送货时间:</td>     <td align='left'>&nbsp;{$sendtime}</td>   </tr>   <tr>     <td height='30' align='right'>订单备注：</td>     <td>&nbsp;{$usernote}</td>   </tr>   <tr>     <td height='30' align='right'>下单日期：</td>     <td>&nbsp;{$addtime}</td>   </tr>   <tr>     <td height='30' align='right'>下单IP:</td>     <td>&nbsp;{$userip}</td>   </tr> </table>"
	
	mailc=replace(mailc,"{$name}",consignee)
	mailc=replace(mailc,"{$mobile}",mobile)
	mailc=replace(mailc,"{$address}",u_pname&u_cname&u_dname&address)
	mailc=replace(mailc,"{$product}",g_name)
	mailc=replace(mailc,"{$payment}",xmlobj.GetTxt(server.MapPath("/xml/payname.xml"),pay_id))
	mailc=replace(mailc,"{$sendtime}",xmlobj.GetTxt(server.MapPath("/xml/sendType.xml"),best_time))
	mailc=replace(mailc,"{$usernote}",user_note)
	mailc=replace(mailc,"{$addtime}",now())
	mailc=replace(mailc,"{$userip}",userip)
	mobj.mailHost		=s_smtp
	mobj.mailUsername	=s_user
	mobj.mailPassword	=s_pass
	mobj.mailFrom		=s_smail
	mobj.mailFromName	="在线订单系统"	
	mobj.SendMail s_remail,"新订单",mailc

end if
%>
