<!--#include file="conn.asp"-->
<!-- 支付宝 包含头文件 放在顶部 开始-->
<!--#include file="Alipay/Alipay_Payto.asp"-->
<!-- 支付宝 包含头文件 放在顶部 结束-->
<%if request.Cookies("bjx")("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">
<style type="text/css">
<!--
.style1 {color: #000000}
.style2 {font-weight: bold}
.style3 {font-weight: bold}
.style4 {font-size: 10pt}
.style5 {font-size: 10}
.style6 {font-size: 14px}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%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("bjx")("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("bjx")("username")&"' and shop_action.zhuangtai=7",conn,1,1 
%>
<table width="900" align="center" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height=30 class="table-shangxia" >　<a href=index.asp><%=webname%></a> &nbsp;    
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td width="100%"><!--#include file=top.asp--></td>
        </tr>
        <tr>
          <td width="100%" bgcolor="#E1E1E1" height="25"> >> 下定单 <span class="style1">(在最后结算前您还可以修改购物车内容)</span></td>     
        </tr>
      </table>
    </td>
  </tr>
</table>
<table width="900" align="center" border="0" cellspacing="0" cellpadding="0" bordercolor="#ffffff">
  <form name='form1' method='post' action=jszx.asp?action=shop1>
    <tr bgcolor="#ff6600" align="center">
      <td width=20% height="10">商家名称</td>
      <td width=25%>产品名称 </td>
      <td width=15%>市场价</td>
      <td width=15%>单价     
          <%if request.Cookies("bjx")("reglx")=2 then %>
        (VIP)     
        <%else%>
        (会员)     
        <%end if%>
      </td>
      <td width=15%>数量</td>
      <td width=10%>总价</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("bjx")("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("bjx")("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("bjx")("username")&"' and zhuangtai=7",conn,1,1
	if Godbook.recordcount>0 then%>
    <tr bgcolor="#ffffff">
      <td colspan=6><table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#ffffff" align="center">
          <tr bgcolor="#ffffff">
            <td colspan="2" align="center" height="30">您已选择的奖品清单</td>
          </tr>
          <tr bgcolor="#ff6600" align="center">
            <td height="10"><b><font color="#ffffff">奖品名称</font></b></td>
            <td height="10"><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("bjx")("username")&"'",conn,1,1
userid=rs("userid")
%>
<table width="900" align="center" border="0" cellspacing="0" cellpadding="0">
  <tr>
          <td width="100%"><!--#include file=top.asp--></td>
  </tr>
  <tr>
          <td width="100%" bgcolor="#E1E1E1" height="28"> >> 填写收货信息</td>     
  </tr>
</table>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr bgcolor="#ff6600">
    <td height="10" colspan="2" align="center">请正确填写以下收货信息</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
		  %><!-- 支付宝 代码 开始-->
<img src="alipay/images/icon_anniu.gif" width="25" height="32"><a href="alipay/alipay.htm" target="_blank">使用支付宝说明</a>
<!-- 支付宝 代码 结束-->
      </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="900" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#ffffff">
  <tr>
          <td width="100%"><!--#include file=top.asp--></td>
  </tr>
  <tr>
          <td width="100%" bgcolor="#E1E1E1" height="28"> >> 提交定单</td>    
  </tr>
</table>
<table width="900" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#ffffff">

  <tr bgcolor="#ffffff">
    <td bgColor="#ff6600" height="10" align="center">请正确填写定单以便收货 </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("bjx")("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=#ffffff>
                <tr align=center bgcolor=#ff6600>
                  <td width=18%>产品名称</td>
                  <td width=23%>产品名称</td>
                  <td width=9%>市 场 价</td>
                  <td width=14%>单 价     
                      <%if request.Cookies("bjx")("reglx")=2 then %>
                    (VIP)     
                  <%else%>
                  (会员)     
                  <%end if%>
                  </td>
                  <td width=9%>数 量</td>     
                  <td width=13%>邮寄浮动(单价)</td>
                  <td width=14%>总 价</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("bjx")("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("bjx")("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("bjx")("reglx")=2 then
		fudongjia_dj=rs_s("pyvip")
		else
		fudongjia_dj=rs_s("pyhy")
		end if
		else
	if request.Cookies("bjx")("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("bjx")("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="#ffffff" align="center">
                      <tr bgcolor="#ffffff">
                        <td colspan="2" align="center">您已选择的奖品清单</td>
                      </tr>
                      <tr align="center" bgcolor="#ff6600">
                        <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="#ffffff">
              <tr bgcolor="#ff6600">
                <td colspan="2" height="10" 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="#ffffff">
              <tr>
                <td colspan="2" height="10" bgcolor="#ff6600" 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("bjx")("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("bjx")("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("bjx")("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("bjx")("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" >查看送货费用说明</a></td>
              </tr>
              <tr>
                <td style="PADDING-right: 20px" align="right" bgcolor="ffffff"><a href="user/about.asp?id=<%=id%>">查看商家汇款方式</a></td>
              </tr>
              <tr>
                <td style="PADDING-right: 20px" align="right" bgcolor="ffffff"><a href="user/about.asp?id=<%=id%>">查看商家联系方式</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("bjx")("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("bjx")("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("bjx")("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("bjx")("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("bjx")("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="900" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#ffffff">
  <tr>
          <td width="100%"><!--#include file=top.asp--></td>
  </tr>
  <tr>
          <td width="100%" bgcolor="#E1E1E1" height="28"> &nbsp;>>定单提交成功</td> 
  </tr>
  <tr>
    <td class="table-shangxia" height=25><a href=index.asp><%=webname%></a> </td>   
  </tr>
</table>
<table width="900" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#ffffff">
  <tr bgcolor="#ffffff">
    <td bgColor="#ff6600" height="10" align="center">您的订单已经成功提交，我们会在第一时间进行处理，请记清您的订单号以备查询。</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>
<!-- 支付宝 接口代码 开始 -->
<%
dim cmd,subject,body,order_no,prices,rurl,types,number,transport,ordinary_fee,express_fee,readonly,buyer_msg,buyer,buyer_name,buyer_address,buyer_zipcode,buyer_tel,buyer_mobile,partner
dim t1,t2,t3,t4,t5
dim AlipayObj
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("bjx")("username")&"'",conn,1,1 
bookname=rs("bookname")	
huiyuanjia=rs("huiyuanjia")
bookcount=rs("bookcount")
set rsbook=server.createobject("adodb.recordset")
rsbook.open "select * from shop_books where bookid="&rs("bookid"),conn,1,1
bookcontent=rsbook("bookcontent")
set rss=server.CreateObject("adodb.recordset")
rss.open "select * from shjia where shjiaid="&rs("shjiaid"),conn,1,1
PayMail=rss("PayMail")
PayPassword=rss("PayPassword")
liuyan=trim(request("liuyan"))
userzhenshiname=trim(request("userzhenshiname"))
useremail=trim(request("useremail"))
shouhuodizhi=trim(request("shouhuodizhi"))
youbian=trim(request("youbian"))
usertel=trim(request("usertel"))
songhuofangshi=trim(request("songhuofangshi"))
zhifufangshi=trim(request("zhifufangshi"))
url="http://www.guluu.com/list.asp?id="&rs("bookid")&""

	t1				=	"https://www.alipay.com/payto:"	'支付接口
	t2				=	PayMail			'商户支付宝账户（改成你自己的）
	t3				=	PayPassword								'安全校验码（改成你自己的）		
	t4				=	"alipay/images/alipay_bwrx.gif"		'支付宝按钮图片
	t5				=	"推荐使用支付宝付款"						'按钮悬停说明
	cmd				=	"0001"						'cmd			命令码
	subject			=	bookname 			'subject		商品名称
	body			=	bookcontent			'body			商品描述
	order_no		=	dingdan	'order_no		商户订单号
	prices			=	huiyuanjia  					'price			商品单价			0.01～50000.00
	rurl			=	url	'url			商品展示网址
	types			=	"1"						'type支付类型			1：商品购买2：服务购买3：网络拍卖4：捐赠
	number			=	bookcount						'number			购买数量
	transport		=	songhuofangshi					'transport		发货方式			1：平邮2：快递3：虚拟物品
	ordinary_fee	=	"10.00"			'ordinary_fee	平邮运费
	express_fee		=	"20.00"				'express_fee	快递运费
	readonly		=	""				'readonly		交易信息是否只读
	buyer_msg		=	liuyan				'buyer_msg		买家给卖家的留言
	buyer			=	useremail						'buyer			买家Email
	buyer_name		=	userzhenshiname			'buyer_name		买家姓名
	buyer_address	=	shouhuodizhi	'buyer_address	买家地址
	buyer_zipcode	=	youbian		'buyer_zipcode	买家邮编
	buyer_tel		=	usertel			'buyer_tel		买家电话号码
	buyer_mobile	=	""	'buyer_mobile	买家手机号码
	partner			=	""						'partner		合作伙伴ID			保留字段

	Set AlipayObj	= New creatAlipayItemURL
	itemUrl=AlipayObj.creatAlipayItemURL(t1,t2,t3,t4,t5,cmd,subject,body,order_no,prices,rurl,types,number,transport,ordinary_fee,express_fee,readonly,buyer_msg,buyer,buyer_name,buyer_address,buyer_zipcode,buyer_tel,buyer_mobile,partner)

%>
<table width="98%" border="1" cellspacing="0" cellpadding="0" align="center" style="border-collapse: collapse" bordercolor="#CCCCCC">
 <tr>
    <td height="30" align="center">
	<%=itemUrl%>
</td>
  </tr>
</table>

<!-- 支付宝 接口代码 结束 -->

<%end select%>
<!--#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>















































































































