<!--#include file="user_Head.Asp" -->
<%Response.Charset="utf-8"%>
<%Call SiteInfo

if DateDiff("s",session("time"),now())<20 then
   response.write "<script language='JavaScript'>alert('防刷新机制启动：请不要在20 秒内重复刷新！');" & "history.back()" & "</script>"
   response.end
else
   session("time")=now()
end If
dim mOrderName,mgoods,mRemark
dim rs,sql,orderid,shijian,ddhm
mOrderName=trim(request.form("OrderName"))
mgoods=request.form("Products")
mRemark=request.form("Remark")
mMemID=request.QueryString("MemberID")
mRealName=trim(request.form("RealName"))
mSex=trim(request.form("Sex"))
mCompany=trim(request.form("Company"))
mAddress=trim(request.form("Address"))
mZipCode=trim(request.form("ZipCode"))
mTelephone=trim(request.form("Telephone"))
mFax=trim(request.form("Fax"))
mMobile=trim(request.form("Mobile"))
muserqq=trim(request.form("userqq"))
mEmail=trim(request.form("Email"))
GetCode = Trim(request.form("GetCode"))
total=Formatnumber(request.form("total"),2,-1,-1,0)
Products_id=trim(request.form("Products_id"))
Products_num=trim(request.form("Products_num"))
amount=trim(request.form("amount"))
Payment_goods=trim(request.form("Payment_goods"))
freight=trim(request.form("freight"))
tax=trim(request.form("tax"))
strMth=trim(request.form("strMth"))

If trim(request("Action_pay"))="yes" Then'过后支付
ddhm=trim(request("ddhm"))
total=Formatnumber(request("total"),2,-1,-1,0)
set rs = server.createobject("adodb.recordset")
sql="select * from BokeCMS_Members where ID="&request.QueryString("MemberID")
rs.open sql,conn,1,1
mRealName=rs("RealName")
mOrderName="Order product"
mAddress=rs("Address")
mZipCode=rs("ZipCode")
mTelephone=rs("Telephone")
mMobile=rs("Mobile")
rs.close
set rs=Nothing
'过后支付应有的操作未有

else'下订单即支付
shijian=now()

If trim(request.form("paymentType"))="cz" Then'如果是充值
session("NoList")="cz"
ddhm="cz"&year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
set rs = server.createobject("adodb.recordset")
sql="select * from BokeCMS_financiallog"
rs.open sql,conn,1,3
rs.addnew
rs("members")=trim(request.form("username"))
rs("ddhm")=ddhm
rs("OrderName")="充值"
rs("income")=total
rs("operator")=trim(request.form("username"))
rs("Operatingtime")=now()
rs.update
orderid=rs("id")
rs.close
set rs=nothing
else'如果是购物
dim ErrMessage,ErrMsg(10),FindErr(10),i
  ErrMsg(0)="请填写订单标题。"
  ErrMsg(1)="请填写订购者姓名。"
  ErrMsg(2)="请填写详细地址。"
  ErrMsg(3)="请正确填写邮政编码。"
  ErrMsg(4)="请正确填写联系电话。联系电话和手机号不能同时为空。"
  ErrMsg(5)="选择要发票单位名称不能为空。"
  ErrMsg(6)="请正确填写手机号码。"
  ErrMsg(7)="电子信箱格式错误。"
  ErrMsg(8)="验证码不能为空，请返回检查。"
  ErrMsg(9)="您在【产品订购】页面停留的时间过长，导致验证码失效。\n请返回并刷新【产品订购】页面重新订购！"
  ErrMsg(10)="您输入的验证码和系统产生的不一致，请重新输入。"
if len(mOrderName)>100 Or len(mOrderName)=0 then
  FindErr(0)=true
end if
if len(mRealName)>50 Or len(mRealName)=0 then
  FindErr(1)=true
end if
if len(mAddress)=0 then
  FindErr(2)=true
end if
if len(mZipCode)<>6 then
  FindErr(3)=true
end if
if len(mMobile)=0 and len(mTelephone)=0 then
  FindErr(4)=true
end If
if tax>0 and len(mCompany)=0 then
  FindErr(5)=true
end If

for i = 0 to UBound(FindErr)
  if FindErr(i)=true then
    ErrMessage=ErrMessage+ErrMsg(i)+"\n"
  end if
next
if not (ErrMessage="" Or isnull(ErrMessage)) then
  WriteMsg(ErrMessage)
  response.end
end If

ddhm="gw"&year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
set rs = server.createobject("adodb.recordset")
sql="select * from BokeCMS_Order"
rs.open sql,conn,1,3
rs.addnew
rs("OrderName")=StrReplace(mOrderName)
rs("goods")=mgoods
rs("Remark")=mRemark
rs("MemID")=mMemID
rs("Linkman")=StrReplace(mRealName)
rs("Sex")=mSex
rs("Company")=StrReplace(mCompany)
rs("Address")=StrReplace(mAddress)
rs("ZipCode")=StrReplace(mZipCode)
rs("Telephone")=StrReplace(mTelephone)
rs("Fax")=StrReplace(mFax)
rs("Mobile")=StrReplace(mMobile)
rs("userqq")=muserqq
rs("Email")=mEmail
rs("ddhm")=ddhm
rs("cash")=total
rs("Products_id")=Products_id'商品ID数组
rs("Products_num")=Products_num'商品数量数组
rs("amount")=amount'商品金额数组
rs("Payment_goods")=Payment_goods'货款
rs("freight")=freight'运费
rs("tax")=tax'发票税款
rs("strMth")=strMth'物流方式
rs("AddTime")=now()
rs.update
orderid=rs("id")
rs.close
set rs=nothing
End If

function NoList()
  if request("UpdateOrder")="更新选择" then
    Session("NoList")=""
  end if
  dim ProductNo,NoArray,i
  if trim(request("ProductNo"))<>"" then ProductNo=trim(request("ProductNo"))&","
  if session("NoList")="" and trim(request("ProductNo"))="" then
    NoList=""
    exit function
  end if
  if instr(ProductNo,",")>0 then
  	NoArray=split(ProductNo, ",")
  	for i = 0 to ubound(NoArray)
      if not instr(session("NoList"),NoArray(i)&",")>0 then session("NoList")=session("NoList")&NoArray(i)&","
  	next
  end if
  for i = 0 to ubound(split(session("NoList"), ","))
    NoList=NoList&"'"&trim(split(session("NoList"),",")(i))&"',"
  next
  NoList=left(NoList,len(NoList)-4)
end Function

buylist = Session("NoList")
if buylist="" then
response.redirect "index.asp"
response.end
end if
total=Formatnumber(total,2,-1,-1,0)%>
<table border="0" cellspacing="1" cellpadding="0" align="center" valign="absmiddle" bgcolor="#E4EFFA" width="960">
<tr><td align="center" valign="middle" height=60><br><br><font color="#FF3333">恭喜您，成功生成订单！请注意您的订单信息! <br></td></tr>
</table>

<%
End if'立即支付与过后支付选择结束

set rs=server.CreateObject("adodb.recordset")
rs.open "select * from BokeCMS_pay",conn,1,1   
pay= rs("pay")
chinaid=rs("chinaid")
chinakey=rs("chinakey")
chinaback=rs("chinaback")
china_dz=rs("china_dz")
china_kg=rs("china_kg")
alipay_id=rs("alipay_id")
alipay_securityCode=rs("alipay_securityCode")
partner=rs("partner")
alipay_dz=rs("alipay_dz")
alipay_kg=rs("alipay_kg")
yeepayid=rs("yeepayid")
yeepaykey=rs("yeepaykey")
yeepay_dz=rs("yeepay_dz")
yeepay_kg=rs("yeepay_kg")
tenpay_id=rs("tenpay_id")
tenpay_key=rs("tenpay_key")
tenpay_name=rs("tenpay_name")
tenpay_dz=rs("tenpay_dz")
tenpay_kg=rs("tenpay_kg")    
rs.close
set rs=Nothing
%>

<table border="0" cellspacing="1" cellpadding="0" align="center" valign="absmiddle" bgcolor="#E4EFFA" width="960">
<tr><td align="center" valign="middle" height=60><br><br><font color="#FF3333">
订单号:<b><%=ddhm%></b>&nbsp;&nbsp;&nbsp;&nbsp;支付金额：<b><%=total%></b>元</font></td></tr>
<tr><td align="center" valign="middle"  height=60>请选择您的支付方式</td></tr>
</table>

<%'在线支付开始
dim inBillNo,total
inBillNo=ddhm '订单号
total=total '支付金额
If trim(request.form("paymentType"))="cz" Then
hkuse="会员"&trim(request.form("username"))&"充值"
else
hkuse="产品订购"
End if
%>
<table border="0" cellspacing="1" cellpadding="0" align="center" valign=absmiddle  bgcolor="#E4EFFA" width="960">
<tr><td  width=50% height=120>
<br>
<%If trim(request.form("paymentType"))<>"cz" Then'=====从钱包支付开始%>                            
<table border="0" cellspacing="1" cellpadding="0" align="center" valign=absmiddle width=960>
<tr><td  width=20% height=80>
<form action="../Include/paywallet.asp" method="post" name="formAlipay" id="formAlipay">
<input type="hidden" name="username" value="<%=session("MemName")%>" />
<input type="hidden" name="ddhm" value="<%=ddhm%>" />
<input type="hidden" name="alimoney" value="<%=total%>" />
<input name="Submit" type="submit" value="从我的钱包支付" />
</form>
</td></tr>
</table>
<%End If
if alipay_kg=1 then'=====支付宝支付开始%>                            
<table border="0" cellspacing="1" cellpadding="0" align="center" valign=absmiddle width=960>
<tr><td  width=20% height=80>
<%If alipay_dz=1 then%>
<form action="../alipay/db/index.asp" method="post" name="formAlipay" id="formAlipay" target=new>
<input type="hidden" name="ddhm" value="<%=ddhm%>" />
<input type="hidden" name="hkuse" value="<%=hkuse%>" />
<input type="hidden" name="alimoney" value="<%=total%>" />
<input type="hidden" name="mainname" value="<%=SiteTitle%>" />
<input type="hidden" name="RealName" value="<%=mRealName%>" />
<input type="hidden" name="OrderName" value="<%=mOrderName%>" />
<input type="hidden" name="Address" value="<%=mAddress%>" />
<input type="hidden" name="ZipCodee" value="<%=mZipCode%>" />
<input type="hidden" name="Telephone" value="<%=mTelephone%>" />
<input type="hidden" name="Mobile" value="<%=mMobile%>" />
<input name="Submit" type="submit" value="支付宝支付--担保交易收款" />
</form>
<%ElseIf alipay_dz=2 then%>
<form action="../alipay/sj/index.asp" method="post" name="formAlipay" id="formAlipay" target=new>
<input type="hidden" name="ddhm" value="<%=ddhm%>" />
<input type="hidden" name="hkuse" value="<%=hkuse%>" />
<input type="hidden" name="alimoney" value="<%=total%>" />
<input type="hidden" name="mainname" value="<%=SiteTitle%>" />
<input type="hidden" name="RealName" value="<%=mRealName%>" />
<input type="hidden" name="OrderName" value="<%=mOrderName%>" />
<input type="hidden" name="Address" value="<%=mAddress%>" />
<input type="hidden" name="ZipCodee" value="<%=mZipCode%>" />
<input type="hidden" name="Telephone" value="<%=mTelephone%>" />
<input type="hidden" name="Mobile" value="<%=mMobile%>" />
<input name="Submit" type="submit" value="支付宝支付--双功能收款" />
</form>
<%else%>
<form action="../alipay/js/index.asp" method="post" name="formAlipay" id="formAlipay" target=new>
<input type="hidden" name="ddhm" value="<%=ddhm%>" />
<input type="hidden" name="hkuse" value="<%=hkuse%>" />
<input type="hidden" name="alimoney" value="<%=total%>" />
<input type="hidden" name="mainname" value="<%=SiteTitle%>" />
<input type="hidden" name="RealName" value="<%=mRealName%>" />
<input type="hidden" name="OrderName" value="<%=mOrderName%>" />
<input type="hidden" name="Address" value="<%=mAddress%>" />
<input type="hidden" name="ZipCodee" value="<%=mZipCode%>" />
<input type="hidden" name="Telephone" value="<%=mTelephone%>" />
<input type="hidden" name="Mobile" value="<%=mMobile%>" />
<input name="Submit" type="submit" value="支付宝支付--即时到帐收款" />
</form>
<%End if%>
</td></tr>
</table>
<%End If

if tenpay_kg=1 then'财付通在线支付%>
<table border="0" cellspacing="1" cellpadding="0" align="center" valign=absmiddle width=960>
<tr><td  width=20% height=80>
<%If tenpay_dz=0 then%>
<form action="../tenpay/b2c/index.asp" method="post" name="formTenpay" id="formTenpay" target=new>
<input type="hidden" name="order_no" value="<%=ddhm%>" />
<input type="hidden" name="hkuse" value="<%=hkuse%>" />
<input type="hidden" name="alimoney" value="<%=total%>" />
<input type="hidden" name="mainname" value="<%=SiteTitle%>" />
<input name="Submit" type="submit" value="财付通支付--即时到帐交易" />
</form>
<%else%>
<form action="../tenpay/med/index.asp" method="post" name="formTenpay" id="formTenpay" target=new>
<input type="hidden" name="order_no" value="<%=ddhm%>" />
<input type="hidden" name="hkuse" value="<%=hkuse%>" />
<input type="hidden" name="alimoney" value="<%=total%>" />
<input type="hidden" name="mainname" value="<%=SiteTitle%>" />
<input name="Submit" type="submit" value="财付通支付--中介担保交易" />
</form>
<%End if%>
</td></tr>
</table>
<%End If
Call CloseRs(rs)
Call CloseDB(conn)%>
