<!--#include file="conn.asp"-->
<%if request.cookies("godbook")("username")="" then
response.write "<script language=javascript>alert('对不起，您还没有登陆！');history.go(-1);</script>"
response.End
end if%>
<!--#include file="webconfig.asp"-->
<html><head><title><%=webname%>--我要下订单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!--#include file="webtop.asp"-->
<%dim bookid,action,i
action=request("action")
set rs=server.CreateObject("adodb.recordset")
rs.open "select count(*) as rec_count from shop_action where username='"&request.cookies("godbook")("username")&"' and zhuangtai=7",conn,1,1
if rs("rec_count")=0 then
response.write "<script language=javascript>alert('对不起，您购物车没有商品，请在购物后，再去“结算中心”！');window.close();</script>"
response.End
end if
rs.close
set rs=nothing
//////////////////////////////////
select case action
case ""
set rs=server.CreateObject("adodb.recordset")
rs.open "select shop_action.actionid,shop_action.bookid,shop_action.bookcount,shop_action.zonger,shop_books.bookname,shop_action.shjiaid,shop_books.shichangjia,shop_books.huiyuanjia,shop_books.vipjia from shop_books inner join  shop_action on shop_books.bookid=shop_action.bookid where shop_action.username='"&request.cookies("godbook")("username")&"' and shop_action.zhuangtai=7",conn,1,1 
%>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td class="table-shangxia" background="images/class_bg.jpg" height=50>　<img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> 下定单 <font color="#FF6633"><b>(在最后结算前您还可以修改购物车内容)</b></font></td>
</tr>
</table>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr><td bgColor=#ffffff colSpan=6 height=1></TD></tr>
<form name='form1' method='post' action=jszx.asp?action=shop1>
<tr bgcolor="#f1f1f1" align="center">
<td width=20% height="30">商家名称</td> 
<td width=25%>商品名称 </td>
<td width=15%>市场价</td>
<td width=15%>单价 
          <%if request.cookies("godbook")("reglx")=2 then %>
          (VIP) 
          <%else%>
          (会员) 
          <%end if%>
</td>
<td width=15%>数量</td>
<td width=10%>总价</td>
</tr>
<tr><td bgColor=#cccccc colSpan=6 height=1></TD></tr>
<tr><td bgColor=#f1f1f1 colSpan=6 height=3></TD></tr>
<%shuliang=rs.recordcount
jianshu=0
zongji=0
do while not rs.eof%>
<tr bgcolor="#ffffff">
<td height="30" width="20%" align="center" class="table-xia"><%id=rs("shjiaid")
	if id>1 then
	set rs_shj=server.CreateObject("adodb.recordset")
	rs_shj.open "select name from shjia where shjiaid="&id,conn,1,1%> 
	<font color=#ff6600><%=rs_shj("name")%>
	<%
	rs_shj.close
	set rs_shj=nothing
	else
	response.write "<font color=#ff6600>"&webname&""
	end if%>
	</font></td>
      <td height="30" width="25%" class="table-xia">
	  <%=rs("bookname")%>
	  <input name=bookid type=hidden value="<%=rs("bookid")%>">
	  <input name=actionid type=hidden value="<%=rs("actionid")%>">
      </td>
      <td align="center" class="table-xia"><%=rs("shichangjia")%></td>
      <td align="center" class="table-xia"> 
	<%
	if request.Cookies("godbook")("reglx")=2 then 
	response.write rs("vipjia")
	else
	response.write rs("huiyuanjia")
	end if%>
	元</td>
<td align="center" class="table-xia"><%=rs("bookcount")%></td>
<td align="center" class="table-xia"><%=rs("zonger")%> 元</td>
</tr>
<%
jianshu=jianshu+rs("bookcount")
zongji=zongji+rs("zonger")
rs.movenext
loop
rs.close
set rs=nothing%>
<tr bgcolor=#ffffff align=center> 
<td height=30 colspan=6>
您的购物车里有商品：<%=shuliang%> 件　总数量：<%=jianshu%> 件　共计：<font color=red><%=zongji%></font> 元　您有预存款：<%=request.cookies("godbook")("yucun")%> 元
</td>
</tr>
<tr bgcolor=#ffffff align=center> 
<td height=40 colspan=6>
	  <input class="go-wenbenkuang" type="button" name="Submit" value="修改购物车" onClick="this.form.action='gouwu.asp?action=show';this.form.submit()">
	  <input class="go-wenbenkuang" type="submit" name="Submit3" value="OK,下一步">
      </td>
    </tr>
    <%set godbook=server.CreateObject("adodb.recordset")
	godbook.open "select * from shop_action_jp where username='"&request.cookies("godbook")("username")&"' and zhuangtai=7",conn,1,1
	if godbook.recordcount>0 then%>
    <tr bgcolor="#ffffff"> 
      <td colspan=6> 
        <table width="95%" border="0" cellspacing="1" cellpadding="1" bgcolor="#cccccc" align="center">
          <tr bgcolor="#ffffff"> 
          <td colspan="2" align="center" height="30">您已选择的奖品清单</td>
          </tr>
          <tr bgcolor="#cccccc" align="center"> 
            <td height="30"><b><font color="#ffffff">奖品名称</font></b></td>
            <td height="30"><b><font color="#ffffff">使用积分</font></b></td>
          </tr>
          <%while not godbook.eof%>
          <tr bgcolor="#ffffff"> 
            <td> 
              <%
	set godbook1=server.CreateObject("adodb.recordset")
	godbook1.open "select * from shop_jiangpin where bookid="&godbook("bookid"),conn,1,1
	if godbook1.recordcount=1 then
	response.write "<font color=blue>"&godbook1("bookname")&"</font>"
	end if
	godbook1.close
	set godbook1=nothing%>
	</td>
	<td align="center"><%=godbook("jifen")%></td>
	</tr>
<%godbook.movenext
wend%>
</table></td></tr>
<%end if
godbook.close
set godbook=nothing%>
</form>
</table>
<%
/////////////////////////////////////////
case "shop1"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [user] where username='"&request.cookies("godbook")("username")&"'",conn,1,1
userid=rs("userid")
%>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td class="table-shangxia" background="images/class_bg.jpg" height=50>　<img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> 填写收货信息</td>
</tr>
</table>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr><td bgColor=#ffffff colSpan=2 height=1></TD></tr>
<tr bgcolor="#ffffff"> 
<td bgColor="#f1f1f1" colspan="2" height="30" align="center">请正确填写以下收货信息</td>
</tr>
<tr><td bgColor=#cccccc colSpan=2 height=1></TD></tr>
<tr><td bgColor=#f1f1f1 colSpan=2 height=3></TD></tr>
<form name="shouhuoxx" method="post" action="jszx.asp?action=shop2" onsubmit="ssxx">
<tr bgcolor="#ffffff"> 
<td width="30%" height="30" align="right" class="table-xia">收货人真实姓名：</td>
<td width="70%" height="30" style="PADDING-LEFT: 20px" class="table-xia">
                                <input name=userid type=hidden value="<%=userid%>">
                                <input name="userzhenshiname" class="wenbenkuang" type="text" id="userzhenshiname" size="16" value=<%=trim(rs("userzhenshiname"))%>>
								性别：
								<select class="wenbenkuang" name="shousex" id="shousex">
                                  <option value=1 <%if rs("sex")="1" then%>selected<%end if%>>男</option>
                                  <option value=2 <%if rs("sex")="0" then%>selected<%end if%>>女</option>
                                  <option value=0 <%if rs("sex")="2" then%>selected<%end if%>>保密</option>
                                </select>
								</td>
								</tr>
                            <tr bgcolor="#ffffff"> 
                              <td width="30%" height="30" align="right" class="table-xia">详细地址：</td>
                              <td width="70%" height="30" style="PADDING-LEFT: 20px" class="table-xia">
							  <input class="wenbenkuang" name="shouhuodizhi" type="text" id="shouhuodizhi" size="50" value=<%=trim(rs("shouhuodizhi"))%>>
							</td>
                            </tr>
                            <tr bgcolor="#ffffff"> 
                              <td width="30%" height="30" align="right" class="table-xia">邮政编码：</td>
                              <td width="70%" height="30" style="PADDING-LEFT: 20px" class="table-xia">
							  <input class="wenbenkuang" name="youbian" type="text" id="youbian" size="16" value="<%=rs("youbian")%>" ONKEYPRESS="event.returnValue=IsDigit();"></td>
                            </tr>
                            <tr bgcolor="#ffffff"> 
                              <td width="30%" height="30" align="right" class="table-xia">联系电话：</td>
                              <td width="70%" height="30" style="PADDING-LEFT: 20px" class="table-xia">
							  <input class="wenbenkuang" name="usertel" type="text" id="usertel" size="16" value=<%=trim(rs("usertel"))%>>
							  </td>
                            </tr>
                            <tr bgcolor="#ffffff"> 
                              <td width="30%" height="30" align="right" class="table-xia">电子邮件：</td>
                              <td width="70%" height="30" style="PADDING-LEFT: 20px" class="table-xia">
							  <input class="wenbenkuang" name="useremail" type="text" id="useremail" size="30" value=<%=trim(rs("useremail"))%>>
							</td>
                            </tr>
                            <tr bgcolor="#ffffff"> 
                              <td width="30%" height="30" align="right" class="table-xia">送货方式：</td>
                              <td width="70%" height="30" style="PADDING-LEFT: 20px" class="table-xia">
		<%
          set rs2=server.CreateObject("adodb.recordset")
          rs2.Open "select * from youbian where youbian='"&trim(request("youbian"))&"'",conn,1,1
          if rs2.recordcount=1 then
          shangmen=1
          else
          shangmen=0
          end if
          rs2.close
          set rs2=nothing
          '//////////判断送货方式
          set rs3=server.CreateObject("adodb.recordset")
          rs3.Open "select * from shop_songhuo where fangshi=0 order by songidorder",conn,1,1
          response.Write "<select name=songhuofangshi size=5 style='width:180px'>"
          do while not rs3.EOF
          if not(shangmen=3 and trim(rs3("songid"))=3) then          '显示不显示“送货上门”
          	response.Write "<option value="&rs3("songid")
          	if int(rs("songhuofangshi"))=int(rs3("songid")) then 
          	response.Write " selected>"
          	else
          	response.Write ">"
          	end if
			response.Write trim(rs3("subject"))&"</option>"          
			end if
			rs3.MoveNext
			loop
			response.Write "</select>"
			rs3.Close
			set rs3=nothing
			%>
</td>
</tr>
<tr bgcolor="#ffffff"> 
<td width="30%" height="30" align="right" class="table-xia">支付方式：</td>
<td width="70%" height="30" style="PADDING-LEFT: 20px" class="table-xia">
		<%
		'set rs2=server.CreateObject("adodb.recordset")
          'rs2.Open "select * from shop_songhuo where songid="&trim(request("songhuofangshi")),conn,1,1
          if cint(request("songhuofangshi"))=3 then
          fukuan=1
          else
          fukuan=0
          end if
          'rs2.close
          'set rs2=nothing
          '//////////判断支付方式
          set rs3=server.CreateObject("adodb.recordset")
          rs3.open "select * from shop_songhuo where fangshi=1 order by songidorder",conn,1,1
          response.Write "<select name=zhifufangshi size=5 style='width:180px'>"
          do while not rs3.eof
          if not(fukuan=4 and trim(rs3("songid"))=4) then	'显示不显示“货到付款”
          	response.Write "<option value="&rs3("songid")
          	if int(rs("zhifufangshi"))=int(rs3("songid")) then
          	response.Write " selected>"
          	else
          	response.Write ">"
          	end if
          	response.Write trim(rs3("subject"))&"</option>"
          end if
          rs3.movenext
          loop
          response.Write "</select>"
          rs3.close
          set rs3=nothing
		  %>
</td>
</tr>
<tr bgcolor="#ffffff"> 
<td height="40" colspan="2" align=center> 
<input class="go-wenbenkuang" type="button" name="Submit2" value="上一步" onclick="javascript:history.go(-1)">
<input class="go-wenbenkuang" type="submit" name="Submit4" value="OK,下一步" onclick='return ssxx();'>
</td>
</tr>
</form>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function ssxx()
{
   if(checkspace(document.shouhuoxx.userzhenshiname.value)) {
	document.shouhuoxx.userzhenshiname.focus();
    alert("对不起，请填写收货人姓名！");
	return false;
  }
  if(checkspace(document.shouhuoxx.shouhuodizhi.value)) {
	document.shouhuoxx.shouhuodizhi.focus();
    alert("对不起，请填写收货人详细收货地址！");
	return false;
  }
  if(checkspace(document.shouhuoxx.youbian.value)) {
	document.shouhuoxx.youbian.focus();
    alert("对不起，请填写邮编！");
	return false;
  }
  if(document.shouhuoxx.youbian.value.length!=6) {
	document.shouhuoxx.youbian.focus();
    alert("对不起，请正确填写邮编！");
	return false;
  } 
    if(checkspace(document.shouhuoxx.usertel.value)) {
	document.shouhuoxx.usertel.focus();
    alert("对不起，请留下您的电话！");
	return false;
  }
    if(checkspace(document.shouhuoxx.songhuofangshi.value)) {
	document.shouhuoxx.songhuofangshi.focus();
    alert("对不起，请选择送货方式！");
	return false;
  }
  if(document.shouhuoxx.useremail.value.length!=0)
  {
    if (document.shouhuoxx.useremail.value.charAt(0)=="." ||        
         document.shouhuoxx.useremail.value.charAt(0)=="@"||       
         document.shouhuoxx.useremail.value.indexOf('@', 0) == -1 || 
         document.shouhuoxx.useremail.value.indexOf('.', 0) == -1 || 
         document.shouhuoxx.useremail.value.lastIndexOf("@")==document.shouhuoxx.useremail.value.length-1 || 
         document.shouhuoxx.useremail.value.lastIndexOf(".")==document.shouhuoxx.useremail.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.shouhuoxx.useremail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空！");
   document.shouhuoxx.useremail.focus();
   return false;
   }
   
}
//-->
</script>
<%
rs.close
set rs=nothing
'/////////////////////////////////////////
case "shop2"
%>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td class="table-shangxia" background="images/class_bg.jpg" height=50>　<img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> 提交定单</td>
</tr>
</table>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr><td bgColor=#ffffff height=1></TD></tr>
<tr bgcolor="#ffffff"> 
<td bgColor="#f1f1f1" height="30" align="center">请正确填写定单以便收货 </td>
</tr>
<tr><td bgColor=#cccccc height=1></TD></tr>
<tr><td bgColor=#f1f1f1 height=3></TD></tr>
<tr> 
<td> 
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#ffffff"> 
<td align="center" valign="top" height=50 colspan=2> 
<%set rs=server.CreateObject("adodb.recordset")
rs.open "select shop_action.actionid,shop_action.bookid,shop_action.bookcount,shop_action.zonger,shop_books.bookname,shop_action.shjiaid,shop_books.anclassid,shop_books.banci,shop_books.shichangjia,shop_books.huiyuanjia,shop_books.vipjia from shop_books inner join  shop_action on shop_books.bookid=shop_action.bookid where shop_action.username='"&request.cookies("godbook")("username")&"' and shop_action.zhuangtai=7 order by shop_books.shjiaid",conn,1,1 
%>
<br>
				<table width=95% border=0 align=center cellpadding=2 cellspacing=1 bgcolor=#cccccc>
                                <tr align=center bgcolor=#f1f1f1>
				<td width=20%>商品名称</td> 
                                  <td width=25%>商品名称</td>
                                  <td width=10%>市 场 价</td>
                                  <td width=15%>单 价
                                      <%if request.cookies("godbook")("reglx")=2 then %>
                                      (VIP) 
                                      <%else%>
                                      (会员) 
                                      <%end if%>
					</td>
                                  <td width=10%>数 量</td>
                                  <td width=10%>邮寄浮动(单价)</td>
                                  <td width=15%>总 价</td>
                                </tr>
<%shuliang=rs.recordcount
jianshu=0
zongji=0
fudongjia=0
do while not rs.eof
%>
<tr align="center" bgcolor=#ffffff>
<td height="30">
	<%id=rs("shjiaid")
	if id>1 then
set rs_shj=server.CreateObject("adodb.recordset")
rs_shj.open "select name from shjia where shjiaid="&id,conn,1,1%>
	<font color=#ff6600><%=rs_shj("name")%>
	<%
	rs_shj.close
	set rs_shj=nothing
	else
	response.write "<font color=#ff6600>"&webname&""
	end if%>
	</font></td> 
<td align="left"><%=rs("bookname")%>
<input name=bookid2 type=hidden value="<%=rs("bookid")%>">
<input name=actionid2 type=hidden value="<%=rs("actionid")%>">
</td>
<td><s><%=rs("shichangjia")%></s>元</td>
<td>
	<%
	if request.Cookies("godbook")("reglx")=2 then 
	response.write rs("vipjia")
	else
	response.write rs("huiyuanjia")
	end if%>
	元</td>
	<td><%=rs("bookcount")%></td>
	<td>
	<%
set rs_s=server.CreateObject("adodb.recordset")
rs_s.open "select * from shop_fudong where id="&rs("banci"),conn,1,1
if cint(request("songhuofangshi"))=3 then	'看是不是“送货上门”
	if request.Cookies("godbook")("reglx")=2 then
		fudongjia_dj=rs_s("smvip")
	else
		fudongjia_dj=rs_s("smhy")
	end if
	elseif cint(request("songhuofangshi"))=1 then	'看是不是“平邮”
	if request.Cookies("godbook")("reglx")=2 then
		fudongjia_dj=rs_s("pyvip")
		else
		fudongjia_dj=rs_s("pyhy")
		end if
		else
	if request.Cookies("godbook")("reglx")=2 then
		fudongjia_dj=rs_s("emsvip")
		else
		fudongjia_dj=rs_s("emshy")
		end if
		end if
response.write fudongjia_dj
rs_s.close
set rs_s=nothing
%>
</td>
<td><%=rs("zonger")%> 元</td>
</tr>
	<%
jianshu=jianshu+rs("bookcount")
zongji=zongji+rs("zonger")
'算每件商品的浮动价
set rs_s=server.CreateObject("adodb.recordset")
rs_s.open "select * from shop_fudong where id="&rs("banci"),conn,1,1 
fudongjia=fudongjia+rs("bookcount")*fudongjia_dj
rs_s.close
set rs_s=nothing

firstshjid=rs("shjiaid")
rs.movenext
if not rs.eof then
nextshjid=rs("shjiaid")
end if
if rs.recordcount<>1 and firstshjid<>nextshjid then
response.write "<script language=javascript>alert('对不起，您选购的商品不属于同一个商家，请重新下订单！');window.close();</script>"
exit do
end if
loop
rs.close
set rs=nothing%>
<tr bgcolor=#ffffff> 
<td height=30 colspan=7 align=center>货款总计：<font color=red><%=zongji%></font> 元</td>
</tr>
<%set godbook=server.CreateObject("adodb.recordset")
godbook.open "select * from shop_action_jp where username='"&request.cookies("godbook")("username")&"' and zhuangtai=7",conn,1,1
if godbook.recordcount>0 then%>
<tr> 
<td colspan=7 bgcolor=#ffffff> 
<table width="95%" border="0" cellspacing="1" cellpadding="1" bgcolor="#cccccc" align="center">
<tr bgcolor="#ffffff"> 
<td colspan="2" align="center">您已选择的奖品清单</td>
</tr>
<tr align="center" bgcolor="#f1f1f1"> 
<td>奖品名称</td>
<td>使用积分</td>
</tr>
<%
while not godbook.eof%>
<tr bgcolor="#ffffff"> 
<td align="center"> 
<%
	set godbook1=server.CreateObject("adodb.recordset")
	godbook1.open "select * from shop_jiangpin where bookid="&godbook("bookid"),conn,1,1
	if godbook1.recordcount=1 then
	response.write "<font color=blue>"&godbook1("bookname")&"</font>"
	end if
	godbook1.close
	set godbook1=nothing%>
</td>
<td align="center"><%=godbook("jifen")%></td>
</tr>
<%godbook.movenext
wend%>
</table>
</td>
</tr>
<%end if
godbook.close
set godbook=nothing%>
</table><br>
</td>
</tr>
<tr bgcolor="#ffffff"> 
<td width="50%" align="center" valign="top"> 
<table width="90%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
<tr> 
<td colspan="2" height="24" bgcolor="#f1f1f1" align="center">您的订单信息</td>
</tr>
<tr bgcolor="ffffff"> 
<td width="30%" align="center">姓名：</td>
<td width="70%" style="PADDING-LEFT: 20px"><%=request("userzhenshiname")%></td>
</tr>
<tr bgcolor="ffffff"> 
<td align="center">邮编：</td>
<td style="PADDING-LEFT: 20px"><%=request("youbian")%></td>
</tr>
<tr bgcolor="ffffff"> 
<td align="center">地址：</td>
<td style="PADDING-LEFT: 20px"><%=request("shouhuodizhi")%></td>
</tr>
<tr bgcolor="ffffff"> 
<td align="center">电话：</td>
<td style="PADDING-LEFT: 20px"><%=request("usertel")%></td>
</tr>
<tr bgcolor="ffffff"> 
<td align="center">邮箱：</td>
<td style="PADDING-LEFT: 20px"><%=request("useremail")%></td>
</tr>
<tr bgcolor="ffffff"> 
<td align="center">送货：</td>
<td style="PADDING-LEFT: 20px"> 
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_songhuo where songid="&request("songhuofangshi"),conn,1,1
response.write rs("subject")
rs.close
set rs=nothing%>
</td>
</tr>
<tr bgcolor="ffffff"> 
<td align="center">支付：</td>
<td style="PADDING-LEFT: 20px"> 
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_songhuo where songid="&request("zhifufangshi"),conn,1,1
response.write rs("subject")
rs.close
set rs=nothing%>
</td>
</tr>
</table>
</td>
<td width="50%" align="center" valign="top"> 
<table width="90%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
<tr> 
<td colspan="2" height="24" bgcolor="#f1f1f1" align="center">送货费计算</td>
</tr>
<%
'计算费用
'先取出参数
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_sys ",conn,1,1
t_sm1=rs("sm1")
t_sm2=rs("sm2")
t_sm3=rs("sm3")
t_py1=rs("py1")
t_py2=rs("py2")
t_py3=rs("py3")
t_ems1=rs("ems1")
t_ems2=rs("ems2")
t_ems3=rs("ems3")

'先看是不是送货
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_songhuo where songid="&trim(request("songhuofangshi")),conn,1,1
if cint(request("songhuofangshi"))=3 then	'先看是不是送货
	rs.close
	if request.cookies("godbook")("reglx")=2 then
		if zongji>=t_sm3 then 
		jijia=0
		else
		jijia=t_sm1
		end if
	else
		if zongji>=t_sm2 then 
		jijia=0
		else
		jijia=t_sm1
		end if
	end if
	feiyong=jijia+fudongjia
else
	'不是送货上门的还要看是什么方式送货
	if cint(request("songhuofangshi"))=1 then	'看是不是"普通平邮"
		rs.close
		if request.cookies("godbook")("reglx")=2 then
			if zongji>=t_py2 then 
			jijia=t_py1-t_py3
			else
			jijia=t_py1
			end if
			else
			jijia=t_py1
		end if
		else
		rs.close
		if request.cookies("godbook")("reglx")=2 then
			if zongji>=t_ems2 then 
			jijia=t_ems1-t_ems3
			else
			jijia=t_ems1
			end if
			else
			jijia=t_ems1
		end if
		end if
	'算商品基价+浮动价=费用
	
	feiyong=jijia+fudongjia
	if request("zhifufangshi")=17 then
          '得到预存款
          set rs2=server.CreateObject("adodb.recordset")
          rs2.Open "select yucun from [user] where username='"&request.cookies("godbook")("username")&"'",conn,1,1
          yucunkuan=rs2("yucun")
          rs2.close
          set rs2=nothing
	  if yucunkuan<feiyong+zongji then
	  	response.write "<script language=javascript>alert('您的预存款不足，请更换支付方式！');history.go(-1);</script>"
	end if
	end if
	end if%>
<tr> 
<td style="PADDING-right: 20px" align="right" bgcolor="ffffff">您的送货费用计：<%=feiyong%> 元<br>
其中基价：<%=jijia%> 元<br>
浮动价：<%=fudongjia%> 元</td>
</tr>
<tr> 
<td style="PADDING-right: 20px" align="right" bgcolor="ffffff"><font color=red>您的订单总金额： <%=feiyong+zongji%> 元</font></td>
</tr>
<tr> 
<td style="PADDING-right: 20px" align="right" bgcolor="ffffff"><a href="help.asp?action=feiyong" target=_blank>查看送货费用说明</a></td>
</tr>
</table>
</td>
</tr>
<form name="shouhuoxx" method="post" action="jszx.asp?action=ok">
<tr bgcolor="#ffffff" align="center"> 
<td colspan="2"> 
<table width="95%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="20%"> 
			<input type="checkbox" name="fapiao" value="1">
			是否要发票？ 
			<input name="userzhenshiname" type="hidden" value=<%=trim(request("userzhenshiname"))%>>
			<input name="shousex" type="hidden" value=<%=trim(request("shousex"))%>>
			<input name="useremail" type="hidden" value=<%=trim(request("useremail"))%>>
			<input name="shouhuodizhi" type="hidden" value=<%=trim(request("shouhuodizhi"))%>>
			<input name="youbian" type="hidden" value=<%=trim(request("youbian"))%>>
			<input name="usertel" type="hidden" value=<%=trim(request("usertel"))%>>
			<input name="songhuofangshi" type="hidden" value=<%=trim(request("songhuofangshi"))%>>
			<input name="zhifufangshi" type="hidden" value=<%=trim(request("zhifufangshi"))%>>
			<input name="feiyong" type="hidden" value=<%=feiyong%>>
			<input name="zongji" type="hidden" value=<%=zongji%>>
			<input name=userid type=hidden value="<%=request("userid")%>" >
</td>
<td width="60%">
<input class="wenbenkuang" type="text" name="liuyan" size="35" maxlength="30"> 您对此订单的特殊说明(30字内)
</td>
<td width="20%" align="center" height="60"> 
<input class="go-wenbenkuang" type="button" name="Submit22" value="上一步" onClick="javascript:history.go(-1)">
<input class="go-wenbenkuang" type="submit" name="Submit42" value="完　成">
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>

<%
case "ok"
'/////////////////////////////////////////////////
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function

'修改用户的送货信息
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [user] where username='"&request.cookies("godbook")("username")&"'",conn,1,3
rs("userzhenshiname")=trim(request("userzhenshiname"))
rs("sex")=trim(request("shousex"))
rs("useremail")=trim(request("useremail"))
rs("shouhuodizhi")=trim(request("shouhuodizhi"))
rs("youbian")=trim(request("youbian"))
rs("usertel")=trim(request("usertel"))
rs("songhuofangshi")=trim(request("songhuofangshi"))
rs("zhifufangshi")=trim(request("zhifufangshi"))
rs.update
rs.close
set rs=nothing

if session("xiadan")<>minute(now) then
'再判断库存
'未写

dim shijian,dingdan
shijian=now()
'dingdan=year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
'response.write bookid
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_action where username='"&request.cookies("godbook")("username")&"' and zhuangtai=7",conn,1,3
dingdan=year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
do while not rs.eof
'得到价格，减库存
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from shop_books where bookid="&rs("bookid"),conn,1,3
if request.Cookies("godbook")("reglx")=2 then 
danjia=rs2("vipjia")
else
danjia=rs2("huiyuanjia")
end if
rs2("chengjiaocount")=rs2("chengjiaocount")+rs("bookcount")
rs2("kucun")=rs2("kucun")-rs("bookcount")
rs2.update
rs2.close
set rs2=nothing
'rs.addnew
'rs("username")=trim(request.cookies("bookshop")("username"))
'rs("bookid")=rs2("bookid")
rs("actiondate")=shijian
'rs("bookcount")=CInt(Request("godbook"&rs2("bookid")))
if request("zhifufangshi")=17 then    '送货上门或预存款支付，直接改为订单完成（已收到款）
rs("zhuangtai")=3
else
rs("zhuangtai")=1
end if
rs("dingdan")=dingdan
rs("youbian")=int(request("youbian"))
rs("shouhuoname")=trim(request("userzhenshiname"))
rs("shouhuodizhi")=trim(request("shouhuodizhi"))
rs("zhifufangshi")=int(request("zhifufangshi"))
rs("songhuofangshi")=int(request("songhuofangshi"))
rs("shousex")=int(request("shousex"))
rs("liuyan")=HTMLEncode2(trim(request("liuyan")))
'rs("zonger")=request("zongji")
rs("userzhenshiname")=trim(request("userzhenshiname"))
rs("useremail")=trim(request("useremail"))
rs("usertel")=trim(request("usertel"))
rs("userid")=request("userid")
'新增
if request("fapiao")<>1 then 
fapiao=0
else
fapiao=1
end if
rs("fapiao")=fapiao
rs("feiyong")=request("feiyong")
rs("danjia")=danjia
rs.update
'rs.close
'set rs=nothing
'conn.execute "delete from shop_action where username='"&request.cookies("bookshop")("username")&"' and bookid in ("&bookid&") and zhuangtai=6"
rs.movenext
loop
rs.close
set rs=nothing
'再改奖品
z_jifen=0
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_action_jp where username='"&request.cookies("godbook")("username")&"' and zhuangtai=7",conn,1,3
do while not rs.eof
rs("actiondate")=shijian
rs("zhuangtai")=5
rs("dingdan")=dingdan
rs("userid")=request("userid")
z_jifen=z_jifen+rs("jifen")
rs.update
rs.movenext
loop
rs.close
set rs=nothing
'减去积分
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [user] where username='"&request.cookies("godbook")("username")&"'",conn,1,3
rs("jifen")=rs("jifen")-z_jifen
'如果是在线支付，要扣预存款
if request("zhifufangshi")=17 then 
rs("yucun")=rs("yucun")-request("feiyong")-request("zongji")
end if
rs.update
rs.close
set rs=nothing

session("xiadan")=minute(now)
else
response.Write "<center>您不能重复提交！</center>"
response.End
end if

%>

<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td class="table-shangxia" background="images/class_bg.jpg" height=50>　<img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >>定单提交成功</td>
</tr>
</table>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr><td bgColor=#ffffff height=1></TD></tr>
<tr bgcolor="#ffffff"> 
<td bgColor="#f1f1f1" height="30" align="center">您的订单已经成功提交，我们会在第一时间进行处理，请记清您的订单号以备查询。</td>
</tr>
<tr><td bgColor=#cccccc height=1></TD></tr>
<tr><td bgColor=#f1f1f1 height=3></TD></tr>
<tr> 
<td height="30" bgcolor="ffffff" style="PADDING-LEFT: 100px">订单号：<font color=red><%=dingdan%></font></td>
</tr>
<tr> 
<td height="30" bgcolor="ffffff" style="PADDING-LEFT: 100px">订单查询：您可通过“<a href="javascript:;" onclick="javascript:window.open('user.asp','','')">我的专区</a>”&gt;&gt;“<a href="javascript:;" onclick="javascript:window.open('user.asp?action=dingdan','','')">我的订单</a>”查询您的订单状态。</td>
</tr>
<tr> 
<td height="30" bgcolor="ffffff" style="PADDING-LEFT: 100px">购物积分：请在收货后通过“<a href="javascript:;" onclick="javascript:window.open('user.asp','','')">我的专区</a>”&gt;&gt;“<a href="javascript:;" onclick="javascript:window.open('user.asp?action=dingdan','','')">我的订单</a>”及时更改您的订单状态为“完成”，因为每笔订单的积分只有在订单完成后才能累计到您的购物积分中。 </td>
</tr>
<%if request("zhifufangshi")=17 then %>
<tr> 
<td height="30" bgcolor="ffffff" style="PADDING-LEFT: 100px">您是通过预存款支付的，我们会尽快地给你发货的！</td>
<script language=javascript>alert('您是通过预存款支付的，我们会尽快地给你发货的！');</script>
</tr>
<%else
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_songhuo where songid="&trim(request("zhifufangshi")),conn,1,1
if trim(rs("subject"))="货到付款" then
rs.close
set rs=nothing
%>
<tr> 
<td height="30" bgcolor="ffffff" style="PADDING-LEFT: 100px">您是选择的“货到付款”，我们会尽快给您送货的！</td>
<script language=javascript>alert('您是选择的“货到付款”，请确认您的订单，我们会尽快给您送货的！');</script>
</tr>
<%else
rs.close
set rs=nothing%>
<tr> 
<td height="30" bgcolor="ffffff" style="PADDING-LEFT: 100px">请您在一周内依照您选择的支付方式进行汇款，汇款时请注明您的<font color="#FF0000">订单号</font>！</td>
<script language=javascript>alert('请您在一周内依照您选择的支付方式进行汇款，汇款时请注明您的订单号！');</script>
</tr>
<%end if%>
<%end if%>
<tr> 
<td height="30" bgcolor="ffffff" style='PADDING-LEFT: 100px' align="right"> 
<a href="#" onClick=javascript:window.close()> 
关闭窗口</a><font color="#999999">　订单提交完成 
创建时间：<%=shijian%>&nbsp;</font>
</td>
</tr>
</table>
<%end select%>
<!--#include file="service.asp"-->
<!--#include file="copyright.asp"-->
</body>
</html>
<script language=javascript>
<!--
function regInput(obj, reg, inputStr)
{
	var docSel	= document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT")	return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange	= obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
   //-->
</script>