<!--#include file="conn.asp"-->
<!--#include file="webconfig.asp"-->
<!--#include file="md52.asp"-->
<%
'//产品，判断是否存在
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from card where bookid="&request("bookid")&" and used=0 " ,conn,1,1
if rs.eof And rs.bof then
response.write "<script language=javascript>alert('你选购的产品暂时缺货不能放到购物车里，请选购其它产品！');window.close();</script>"
response.end
end if


	'接收来自上页所有订单信息
	v_rcvname=request("userzhenshiname")
	v_rcvaddr=request("shouhuodizhi")
	v_rcvtel=request("usertel")
	v_rcvpost=request("youbian")
	v_ordername=request("userzhenshiname")
	v_amount=formatnumber(request("bookcount")*request("danjia"),2,true)
	
	'根据系统时间产生订单，格式：YYYYMMDD HHMMSS
	yy=year(date)
	mm=right("00"&month(date),2)
	dd=right("00"&day(date),2)
	v_ymd=yy&mm&dd

	'生成订单号所有所需元素,格式为：小时，分钟，秒
	xiaoshi=right("00"&hour(time),2)
	fenzhong=right("00"&minute(time),2)
	miao=right("00"&second(time),2)

	'产生6位订单号BillNo
	BillNo=xiaoshi&fenzhong&miao

	'定义相关必要参数，如商户号、私钥、推荐的标准形式订单号、币种、配货状态、返回url地址KEY后为在网银申请的帐号
	v_mid = "3999"
	key = "" 
	'以下v_oid为网银推荐标准订单号
	v_oid=v_ymd&"-"&v_mid&"-"&BillNo
	session("v_oid")=v_oid
	v_moneytype = "0" '0为rmb 1为dollor
	v_orderstatus = "0" '0未配齐 1为配齐
	v_url="http://"&weburl&"/receive2.asp" '譬如http://www.xxx.com/xxx.asp
	
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from card_dingdan " ,conn,1,3
rs.addnew
rs("dingdanhao")=session("v_oid")
rs("bookid")=request("bookid")
rs("danjia")=request("danjia")
rs("bookcount")=request("bookcount")
rs("userzhenshiname")=request("userzhenshiname")
rs("sex")=request("sex")
rs("shouhuodizhi")=request("shouhuodizhi")
rs("usertel")=request("usertel")
rs("youbian")=request("youbian")
rs("useremail")=request("useremail")
if request("userid")<>"" then
rs("userid")=request("userid")
end if
rs.update

dim iii,ooo
iii=split(v_amount,".")
if ubound(iii)=0 then
v_amount=cstr(v_amount) & ".00"
else
if len(iii(1))=1 then v_amount=cstr(iii(0)) & "." &cstr(iii(1)) & "0"
if len(iii(1))=2 then v_amount=cstr(v_amount)
if len(iii(1))>2 then v_amount=cstr(iii(0)) & "." & left(iii(1),2)
end if

yy=year(date)
mm=month(now)
if len(mm)=1 then mm="0"&mm
dd=day(Date)
if len(dd)=1 then dd="0"&dd
v_ymd=yy&mm&dd 
key_key = v_moneytype&v_ymd&v_amount&v_oid&v_mid&v_url&key
'拼凑串里勿使用中文字符，目前MD5在ASP、asp.net、java等环境下对中文处理有偏差现象
f=Ucase(trim(md5(key_key)))
'md5.asp文件中，LCase是将字符转换为小写; Ucase是将字符转换为大写
'网银支付平台对MD5值只认大写字符串，所以小写的MD5值得转换为大写
%>
<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">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!--#include file="top.asp"-->
<table width=100% align=center border=0 cellspacing=0 cellpadding=0 class=table-zuoyou bordercolor=#CCCCCC><tr><td background=images/class_bg.jpg height=50 class=table-shangxia>　<img src=images/ring02.gif align=absmiddle> <a href=index.asp><%=webname%></a> >> 在线取卡</td>
</tr></table>
<table width=100% align=center border=0 cellspacing=0 cellpadding=0 class=table-zuoyou bordercolor=#CCCCCC>
  <tr>
    <td height=50 class=table-shangxia><div align="center">
<br>
<table border="0" width="80%" align=center>
  <tr>
    <td width="100%">请您确认您的地址:<br><table border="0" width="80%" align="center"
    bgcolor="#f0f0f0">
      <tr>
        <td align="left" width="20%">收货人姓名：</td>
        <td><%=v_rcvname%>
</td>
      </tr>
      <tr>
        <td align="left" width="20%">收货人地址：</td>
        <td><%=v_rcvaddr%>
</td>
      </tr>
      <tr>
        <td align="left" width="20%">收货人电话：</td>
        <td><%=v_rcvtel%>
</td>
      </tr>
      <tr>
        <td align="left" width="20%">收货人邮编：</td>
        <td><%=v_rcvpost%>
</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td><br>
    您购物的总金额为:<font color=red><%=v_amount%></font><br>
    如果以上资料正确，请您前往交费。交费后自动拿到你要的账号和密码！</td>
  </tr>
</table>
<form method="post" action="https://pay.chinaebank.cn/select_bank.jsp" name="E_FORM" target=new>
	<center>
    <input type=submit name=v_action value="咕噜噜电子商务网上安全支付平台">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--

Sub button1_onclick
	window.history.back 
End Sub

-->
</SCRIPT>
    <input type="button" name="button1" id="button1" value="返回">
  </center>
	<input type="hidden" name="v_md5info" size="100"  value="<%=f%>">
	<input type="hidden" name="v_mid" value="<%=v_mid%>">
	<input type="hidden" name="v_oid" value="<%=session("v_oid")%>">
	<input type="hidden" name="v_rcvname" value="<%=v_rcvname%>">
	<input type="hidden" name="v_rcvaddr" value="<%=v_rcvaddr%>">
	<input type="hidden" name="v_rcvtel" value="<%=v_rcvtel%>">
	<input type="hidden" name="v_ymd" value="<%=v_ymd%>">
	<input type="hidden" name="v_rcvpost" value="<%=v_rcvpost%>">
	<input type="hidden" name="v_amount" value="<%=v_amount%>">
	<input type="hidden" name="v_orderstatus"  value="<%=v_orderstatus%>">
	<input type="hidden" name="v_ordername"  value="<%=v_ordername%>">
	<input type="hidden" name="v_moneytype"  value="<%=v_moneytype%>">
	<input type="hidden" name="v_url" value="<%=v_url%>">
</form>
    </div></td>
  </tr>
</table>
<!--#include file="copyright.asp"-->
</body>
</html>






