<% '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&_ ""&vbcrlf&_ ""&vbcrlf&_ " "&vbcrlf&_ " " tcount = 0 pcount=0 If Not IsEmpty(Session("Cart")) Then Set dic = Session("Cart") For Each md In dic dim proid : proid=md sql = "select P_Price,IndexImage,title,contentid from {prefix}Content where contentid=" & proid Set rs = GetRS(sql) dim img if rs("IndexImage") = "" then img="../Images/nopic.gif" else img=rs("IndexImage") end if result = result &""&vbcrlf&_ ""&vbcrlf&_ ""&vbcrlf&_ "" if pcount=0 then result = result &"" end if total = total + (dic(md) * rs("P_Price")) tcount = tcount + dic(md) pcount = pcount + 1 rs.close:set rs = nothing Next End If result=replace(result,"{allnumpro}",pcount) Session("Print.Ordertotal")=total result=result&"
货品单价(元)数量优惠(元)金额(元)运费(元)
"&rs("title")&"
"&vbcrlf&_ "
"&rs("title")&"
"&vbcrlf&_ "
自定义参数:
"&rs("P_Price")&"
"&dic(md)&"
--
"&dic(md) * rs("P_Price")&"
包邮
"&vbcrlf&_ "" else result=result&"
  • 返回购物车 提交订单
  • "&vbcrlf&_ "" end if '""&vbcrlf&_ '""&vbcrlf SelectProductList = result End Function '======================================= '添加订单 '======================================= Function GetRS(sql) On Error Resume Next Set GetRS = conn.exec(sql,"r1") If Err Then 'echo sql 'die err.description die "错误,表结构不是最新版本" End If End Function '======================================= '订单打印 '======================================= Sub OrderPrint if needCheck then if getForm("code","post")<>Session("Code") then alertMsgAndGo "验证码不正确","-1" end if dim sql dim id, sortID,SortAndID dim qs 'qs = Session("Cart_QS") 'SortAndID=split(replaceStr(qs,FileExt,""),"_") 'if isNul(replaceStr(qs,FileExt,"")) then echoMsgAndGo "页面不存在",3 SortID = SortAndID(0) if not isNul(SortID) and isNum(SortID) then SortID=clng(SortID) else echoMsgAndGo "页面不存在",3 end if id=SortAndID(1) if not isNul(id) and isNum(id) then id=clng(id) else echoMsgAndGo "页面不存在",3 end if if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1" if isnul(sortID) or not isnum(sortID) then alertMsgAndGo "请选择产品!","-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&"/productprint.html" if not CheckTemplateFile(templatePath) then echo "productprint.html"&err_16 set rsObj=conn.exec("select * from {prefix}Sort where SortID="&sortID, "exe") if rsObj.eof then echoMsgAndGo "页面不存在",3 : exit sub with templateObj .content=loadFile(templatePath) .parseHtml() .indexpath() '订单号码:{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}",Session("Print.OrderState")) '订单总金额:{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 OrderComfirm() 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 dim sql orderno=filterPara(getForm("orderno","post")) username=filterPara(getForm("username","post")) nicename=filterPara(getForm("nicename","post")) m_state=0 address=filterPara(getForm("address","post")) zipcode=filterPara(getForm("zipcode","post")) cellphone=filterPara(getForm("cellphone","post")) tel=filterPara(getForm("tel","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 dim id, sortID,SortAndID dim qs qs = filterPara(Session("Cart_QS")) SortAndID=split(replaceStr(qs,FileExt,""),"_") if isNul(replaceStr(qs,FileExt,"")) then echoMsgAndGo "页面不存在",3 SortID = SortAndID(0) if not isNul(SortID) and isNum(SortID) then SortID=clng(SortID) else echoMsgAndGo "页面不存在",3 end if id=SortAndID(1) if not isNul(id) and isNum(id) then id=clng(id) else echoMsgAndGo "页面不存在",3 end if if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1" if isnul(sortID) or not isnum(sortID) then alertMsgAndGo "请选择产品!","-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 "页面不存在",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")) if isnul(rsObj("PageKeywords")) then templateObj.content=replace(templateObj.content,"{aspcms:sortkeyword}",setting.siteKeyWords) else templateObj.content=replace(templateObj.content,"{aspcms:sortkeyword}",rsObj("PageKeywords")) end if if isnul(rsObj("PageDesc")) then templateObj.content=replace(templateObj.content,"{aspcms:sortdesc}",setting.sitedesc) else templateObj.content=replace(templateObj.content,"{aspcms:sortdesc}",rsObj("PageDesc")) end if if isnul(rsObj("PageTitle")) then templateObj.content=replace(templateObj.content,"{aspcms:sorttitle}",rsObj("SortName")) else templateObj.content=replace(templateObj.content,"{aspcms:sorttitle}",rsObj("PageTitle")) end if templateObj.parsePosition(sortID) Dim m_username,gender if isnul(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 rsObj.close() Dim dic,dicPrice,d,oTotal,oCount oTotal = 0:oCount = 0 Set dic = Session("Cart") Set dicPrice = Session("Cart.Price") For Each d In dic dim prices if isnul(dicPrice(d)) then prices=0 else prices=dicPrice(d) oTotal = oTotal + Eval(dic(d) * prices) oCount = oCount + dic(d) Next Set dic = nothing:Set dicPrice = nothing dim hidden hidden = "
    " hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" hidden = hidden & "" 'hidden = hidden & "" hidden = hidden & "

    " hidden = hidden & "

    " '订单参数传递 {aspcms:order.$trigger$} templateObj.content=replace(templateObj.content,"{aspcms:order.$trigger$}",hidden) If m_username = "" then m_username = "游客" '订单号码:{aspcms:order.no} templateObj.content=replace(templateObj.content,"{aspcms:order.no}",orderno) Session("Print.OrderNo") = orderno '订单日期:{aspcms:order.date} templateObj.content=replace(templateObj.content,"{aspcms:order.date}",addtime) Session("Print.OrderDate") = addtime '用 户 名:{aspcms:order.username} templateObj.content=replace(templateObj.content,"{aspcms:order.username}",m_username) Session("Print.OrderUserName") = m_username '订单状态:{aspcms:order.state} templateObj.content=replace(templateObj.content,"{aspcms:order.state}","未处理") Session("Print.OrderState") = "未处理" '订单总金额:{aspcms:order.total}元 templateObj.content=replace(templateObj.content,"{aspcms:order.total}",oTotal) Session("Print.OrderTotal") = oTotal '商品总数量:{aspcms:order.count} templateObj.content=replace(templateObj.content,"{aspcms:order.count}",oCount) Session("Print.OrderCount") = oCount '客户姓名:{aspcms:order.nicename} templateObj.content=replace(templateObj.content,"{aspcms:order.nicename}",nicename) Session("Print.OrderNiceName") = nicename '联系电话:{aspcms:order.tel} templateObj.content=replace(templateObj.content,"{aspcms:order.tel}",tel) Session("Print.OrderTel") = tel '手机号码:{aspcms:order.cellphone} templateObj.content=replace(templateObj.content,"{aspcms:order.cellphone}",cellphone) Session("Print.OrderCellphone") = cellphone '邮政编码:{aspcms:order.zipcode} templateObj.content=replace(templateObj.content,"{aspcms:order.zipcode}",zipcode) Session("Print.OrderZipcode") = zipcode '联系地址:{aspcms:order.address} templateObj.content=replace(templateObj.content,"{aspcms:order.address}",address) Session("Print.OrderAddress") = address '电子邮箱:{aspcms:order.email} templateObj.content=replace(templateObj.content,"{aspcms:order.email}",email) Session("Print.OrderEmail") = email '简单留言:{aspcms:order.note} templateObj.content=replace(templateObj.content,"{aspcms:order.note}",note) Session("Print.OrderNote") = note '支付方式 templateObj.content=replace(templateObj.content,"{aspcms:order.payment}",Payment) Session("Print.OrderPayMent") = Payment select case Payment 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 %>