%
'if session("userID")="" then
'alertMsgAndGo "您还未登陆,请登录!","../member/login.asp"
'end if
dim action,needCheck
action=getForm("act","both")
needCheck = false
Select Case LCase(action)
Case "buy" '提交订单
addOrder()
Case "comfirm" '2订单确认
OrderComfirm()
Case "complete" '3成功下单
OrderComplete()
Case "echo" '1填写信息
echoContent()
case "directbuy" '0直接购买
DirectBuy()
case "print" '4打印订单
OrderPrint()
Case Else
echoContent()
End Select
Sub OrderComplete
dim id, sortID,SortAndID
dim qs
'qs = Session("Cart_QS")
'SortAndID=split(replaceStr(qs,FileExt,""),"_")
'if isNul(replaceStr(qs,FileExt,"")) then echoMsgAndGo "页面不存在1",3
'SortID = SortAndID(0)
'if not isNul(SortID) and isNum(SortID) then SortID=clng(SortID) else echoMsgAndGo "页面不存在2",3 end if
'id=SortAndID(1)
'if not isNul(id) and isNum(id) then id=clng(id) else echoMsgAndGo "页面不存在3",3 end if
'if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品1!","-1"
'if isnul(sortID) or not isnum(sortID) then alertMsgAndGo "请选择产品2!","-1"
dim templateobj,channelTemplatePath : set templateobj = new TemplateClass
dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype
Dim templatePath,tempStr
templatePath=sitePath&"/"&"templates/"&setting.defaultTemplate&"/"&setting.htmlFilePath&"/productcomfirm.html"
if not CheckTemplateFile(templatePath) then echo "productcomfirm.html"&err_16
'set rsObj=conn.exec("select * from {prefix}Sort where SortID="&sortID, "exe")
'if rsObj.eof then echoMsgAndGo "页面不存在4",3 : exit sub
with templateObj
.content=loadFile(templatePath)
.parseHtml()
.indexpath()
'templateObj.content=replace(templateObj.content,"{aspcms:sortname}",rsObj("SortName"))
'templateObj.content=replace(templateObj.content,"{aspcms:parentsortid}",rsObj("parentid"))
'templateObj.content=replace(templateObj.content,"{aspcms:sortid}",sortID)
'templateObj.content=replace(templateObj.content,"{aspcms:topsortid}",rsObj("topsortid"))
templateObj.content=replace(templateObj.content,"{aspcms:sortkeyword}",setting.siteKeyWords)
templateObj.content=replace(templateObj.content,"{aspcms:sortdesc}",setting.sitedesc)
'templateObj.content=replace(templateObj.content,"{aspcms:sorttitle}",rsObj("SortName"))
'templateObj.parsePosition(sortID)
'rsObj.close()
dim hidden
'订单参数传递 {aspcms:order.$trigger$}
templateObj.content=replace(templateObj.content,"{aspcms:order.$trigger$}",hidden)
'订单号码:{aspcms:order.no}
templateObj.content=replace(templateObj.content,"{aspcms:order.no}",Session("Print.Orderno"))
'订单日期:{aspcms:order.date}
templateObj.content=replace(templateObj.content,"{aspcms:order.date}",Session("Print.OrderDate"))
'用 户 名:{aspcms:order.username}
templateObj.content=replace(templateObj.content,"{aspcms:order.username}",Session("Print.OrderUserName"))
'订单状态:{aspcms:order.state}
templateObj.content=replace(templateObj.content,"{aspcms:order.state}","未付款(成功下单)")
'订单总金额:{aspcms:order.total}元
templateObj.content=replace(templateObj.content,"{aspcms:order.total}",Session("Print.OrderTotal"))
'商品总数量:{aspcms:order.count}
templateObj.content=replace(templateObj.content,"{aspcms:order.count}",Session("Print.OrderCount"))
'客户姓名:{aspcms:order.nicename}
templateObj.content=replace(templateObj.content,"{aspcms:order.nicename}",Session("Print.OrderNiceName"))
'联系电话:{aspcms:order.tel}
templateObj.content=replace(templateObj.content,"{aspcms:order.tel}",Session("Print.OrderTel"))
'手机号码:{aspcms:order.cellphone}
templateObj.content=replace(templateObj.content,"{aspcms:order.cellphone}",Session("Print.OrderCellphone"))
'邮政编码:{aspcms:order.zipcode}
templateObj.content=replace(templateObj.content,"{aspcms:order.zipcode}",Session("Print.OrderZipcode"))
'联系地址:{aspcms:order.address}
templateObj.content=replace(templateObj.content,"{aspcms:order.address}",Session("Print.OrderAddress"))
'电子邮箱:{aspcms:order.email}
templateObj.content=replace(templateObj.content,"{aspcms:order.email}",Session("Print.OrderEmail"))
'简单留言:{aspcms:order.note}
templateObj.content=replace(templateObj.content,"{aspcms:order.note}",Session("Print.OrderNote"))
'支付方式
templateObj.content=replace(templateObj.content,"{aspcms:order.payment}",Session("Print.OrderPayMent"))
select case Session("Print.OrderPayMent")
case "在线支付"
templateObj.content=replace(templateObj.content,"{aspcms:order.paymentdesc}",Payment_Online)
case "银行支付"
templateObj.content=replace(templateObj.content,"{aspcms:order.paymentdesc}",Payment_Bank)
case "邮局付款"
templateObj.content=replace(templateObj.content,"{aspcms:order.paymentdesc}",Payment_PostOffice)
end select
'商品列表
templateObj.content=replace(templateObj.content,"{aspcms:selectproduct}",SelectProductList)
.parseCommon()
echo .content
end with
set templateobj =nothing : terminateAllObjects
End Sub
'=======================================
'直接购买
'=======================================
Sub DirectBuy
Dim dicCount,dicPrice
Dim proid,count,proprice
Session.Contents.Remove("Cart")
Session.Contents.Remove("Cart.")
Session.Contents.Remove("Cart.Price")
End Sub
'=======================================
'订单信息填写
'=======================================
Sub echoContent()
dim total
dim templateobj,channelTemplatePath : set templateobj = new TemplateClass
dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype
Dim templatePath,tempStr
templatePath=sitePath&"/"&"templates/"&setting.defaultTemplate&"/"&setting.htmlFilePath&"/productcheckout.html"
if not CheckTemplateFile(templatePath) then echo "productcheckout.html"&err_16
Session.Contents.Remove("Print.Orderno")
with templateObj
.content=loadFile(templatePath)
.parseHtml()
.indexpath()
templateObj.content=replace(templateObj.content,"{aspcms:topsortid}",0)
templateObj.content=replace(templateObj.content,"{aspcms:sortid}",0)
templateObj.content=replace(templateObj.content,"{aspcms:sortkeyword}",setting.siteKeyWords)
templateObj.content=replace(templateObj.content,"{aspcms:sortdesc}",setting.sitedesc)
Dim m_username,gender
if session("loginstatus")="" then session("loginstatus")="0"
if session("loginstatus")="1" then
set rsObj=conn.Exec("select * from {prefix}User where UserID="&trim(session("userID")),"r1")
m_username = rsObj("loginname")
else
gender=1
end if
.content=replaceStr(.content,"{aspcms:selectproduct}",SelectProductList)
randomize
.content=replaceStr(.content,"{aspcms:order.orderno}",Year(Now)&MOnth(Now)&Day(Now)&Int(10000000* Rnd))
.content=replaceStr(.content,"{aspcms:order.username}",m_username)
.content=replaceStr(.content,"{aspcms:order.total}",session("total"))
.parseCommon()
echo .content
end with
set templateobj =nothing : terminateAllObjects
End Sub
'=======================================
'添加订单
'=======================================
Sub addOrder
if needCheck then
if getForm("code","post")<>Session("Code") then alertMsgAndGo "验证码不正确","-1"
end if
dim orderno, username, m_state, payment, nicename, tel,cellphone, zipcode, address, email, note, m_to, invoice,addtime,province,city,area,pname,post,mobile,phone
dim sql
orderno=filterPara(getForm("orderid","post"))
username=session("loginName") 'filterPara(getForm("username","post"))
m_state=0
pname=filterPara(getForm("pname","post"))
province=filterPara(getForm("province","post"))
city=filterPara(getForm("city","post"))
area=filterPara(getForm("area","post"))
address=filterPara(getForm("address","post"))
post=filterPara(getForm("post","post"))
mobile=filterPara(getForm("mobile","post"))
phone=filterPara(getForm("phone","post"))
'email=filterPara(getForm("email","post"))
'm_to=filterPara(getForm("to","post"))
note=filterPara(getForm("note","post"))
'invoice=filterPara(getForm("invoice","post"))
'payment=filterPara(getForm("payment","post"))
addtime = now
if isnul(orderno) then alertMsgAndGo "订单号为空?请重新提交!","-1"
if username = "" then username = "游客"
dim userid : userid=session("userID")
if session("norefresh") <> orderno then
if isnul(userid) then userid=0
sql = "INSERT INTO {prefix}order2( orderno, username, ordertime, state,nicename, province,city,area,address,zipcode, mobile, phone, [note], userid,Invoice)VALUES('"&orderno&"', '"&username&"',now(), "&m_state&", '"&pname&"', '"&province&"', '"&city&"', '"&area&"', '"&address&"', '"&post&"', '"&mobile&"', '"&phone&"','"¬e&"', "&userid&",0)"
Conn.Exec sql,"exe"
session("norefresh") = orderno
Session("Print.OrderNo")=orderno
Session("Print.OrderNiceName")=pname
Session("Print.OrderTel")=phone
Session("Print.OrderCellphone")=mobile
Session("Print.OrderZipcode")=post
Session("Print.OrderAddress")=province&city&area&address
Session("Print.OrderNote")=note
dim dic,md,dicPrice,mds
Set dic = Session("Cart")
Set dicPrice=Session("Cart.Price")
for each md in dic
'dim prices:prices=0
'prices=dicPrice(md)
'die prices
'if isnul(prices) then prices=0
'sql = "insert into {prefix}OrderProduct (orderno,productid,[count],instantprice) values ('"&orderno&"',"&md&","&dic(md)&",(select P_Price from content where contentid="&dic(md)&"))"
sql = "insert into {prefix}OrderProduct (orderno,productid,[count],instantprice) select '"&orderno&"',"&md&","&dic(md)&", P_Price from {prefix}content where contentid="&md
conn.exec sql,"exe"
'echo sql & "
"
'sql = "update {prefix}content set P_sales=cast(P_sales as int)+"&dic(md)&"where contentid="&md
'conn.exec sql,"exe"
next
if orderReminded then sendMail messageAlertsEmail,setting.sitetitle,setting.siteTitle&setting.siteUrl&"--订单信息提醒邮件!","您的网站"&setting.siteTitle&"有新的订单信息!
订单编号:"&orderno&"
会员帐号:"&username&"
联系人:"&nicename&"
电话号码:"&tel&"
手机号码:"&cellphone&"
电子信箱:"&Email&"
备注:"¬e&"
申请时间:"&addtime
'else
'alertMsgAndGo "该订单已经提交,请勿重复提交! ","-1"
end if
'alertMsgAndGo "产品订购成功!","?act=complete"
OrderComplete()
'if Session("Cart_QS") <> "" then Session.Contents.Remove("Cart_QS")
'Session.Contents.Remove("norefresh")
End Sub
'=======================================
'订单详细列表
'=======================================
Function SelectProductList
Dim dic,md
Dim rs,sql
Dim result,total,tcount,pcount
result="
货品 | 单价(元) | 数量 | 优惠(元) | 金额(元) | 运费(元) |
---|---|---|---|---|---|
| "&vbcrlf&_
""&rs("P_Price")&" | "&vbcrlf&_
""&dic(md)&" | "&vbcrlf&_
"-- | "&dic(md) * rs("P_Price")&" | "
if pcount=0 then
result = result &"包邮 |