<!--#include file="../setting/conn.asp"--><!--#include file="../inc/md5.asp"-->
<%:act=SoonBiz.ract:Select Case act:Case "mycar" : mycar :Case "myinfo" : myinfo :Case "delcar" : delcar :Case "makeorder" : makeorder :Case "saveorder" : saveorder :Case "myorder" : myorder:Case "submitorder" : submitorder :Case "delorder" : delorder :Case "readorder" : readorder :Case "pay" : pay :End Select:SoonBiz.AdFoot():Setallnothing:Sub mycar():Dim buycar:Dim sql:SoonBiz.LoadTemplatesAdmin("user_buycar"):buycar=SoonBiz.execute("select [user_buycar] from "& sheethead &"_user where id=" & SoonBiz.user_id)(0)
If len(buycar)=0 Then
ShowErr("购物车里还没有商品")
End If:sql="select * from ["& sheethead &"_article] where id in (0"& buycar &") and isdel=0" :SoonBiz.title="我的购物车":SoonBiz.adhead:SoonBiz.Nstate("我的购物车"):HtmlStr=Template.html(4):HtmlStr=Replace(HtmlStr,"{$trhtml}",SoonBiz.ReplaceMdb("mycar",sql,Template.html(5),"",1)):Response.Write HtmlStr:End Sub:Sub delcar() :Dim buycar:Dim sql:buycar=SoonBiz.execute("select user_buycar from "& sheethead &"_user where id=" & SoonBiz.user_id)(0):buycar=SoonBiz.outs(buycar,SoonBiz.rids) :sql="update "& sheethead &"_user set user_buycar='"& SoonBiz.checkstr(buycar) &"' where id=" & SoonBiz.user_id:SoonBiz.execute(sql):SoonBiz.ok:End Sub:Sub makeorder():Response.Redirect "?act=submitorder&id="&SoonBiz.rids :End Sub:Sub submitorder() :Dim ids:Dim sql:SoonBiz.LoadTemplatesAdmin("user_buycar"):sql="select * from ["& sheethead &"_article] where id in (0,"& rids &") and isdel=0":SoonBiz.title="生成定单":SoonBiz.adhead:SoonBiz.Nstate("生成定单"):HtmlStr=template.html(0):HtmlStr=Replace(Htmlstr,"{$ids}",rids):HtmlStr=Replace(HtmlStr,"{$trhtml}",SoonBiz.ReplaceMdb("",sql,template.html(1),"",1)) :Htmlstr=SoonBiz.ReplaceMdb("","select * from ["& sheethead &"_user] where id="&SoonBiz.user_id,Htmlstr,"",1) :Htmlstr=Replace(HtmlStr,"{$translist}",SoonBiz.ReplaceMdb("","select * from ["& sheethead &"_trans] where typeid=1 order by cls asc,id asc",template.html(2),"",1)):Response.Write HtmlStr:End Sub:Sub saveorder():Dim sql,rs,i,arrs,jinfang:Dim id :Dim orderid,o_title,productcount,o_moneycount,o_mailpay:Dim idstr,pricestr,translist,weightlist,countstr,productname:Dim transid,transname:Dim o_count :Dim ids,aids,c_count,Ac_count:Dim o_name,o_country,o_province,o_city,o_address,o_email,o_tel,o_zipcode,o_sendway,o_other:Dim o_state :Dim delbuycar :Dim thecount :ids=Rids:transid=SoonBiz.rid("transid"):o_title=SoonBiz.Requeststr("定单名称","o_title","post",1,1,50,30,1):o_name=SoonBiz.Requeststr("收货人姓名","o_name","post",1,1,32,30,1):o_country=SoonBiz.Requeststr("国家","o_country","post",1,2,50,20,1):o_province=SoonBiz.Requeststr("省份","o_province","post",1,2,50,20,1):o_city=SoonBiz.Requeststr("城市","o_city","post",1,2,50,20,1):o_address=SoonBiz.Requeststr("收货地址","o_address","post",1,5,255,30,1):o_email=SoonBiz.Requeststr("邮箱","o_email","post",3,8,100,30,1):o_tel=SoonBiz.Requeststr("电话","o_tel","post",1,6,50,30,1):o_zipcode=SoonBiz.Requeststr("邮政编码","o_zipcode","post",1,4,10,30,1):o_other=SoonBiz.Requeststr("备注","o_other","post",1,0,255,30,0):delbuycar=SoonBiz.rid("delbuycar"):ShowErr(""):aids=Split(ids,","):For i=0 To UBound(aids)
If SoonBiz.rid ("o_count" & aids(i)) < 0 Then
ErrMsg=ErrMsg + "<li>定购数量请填写数字"& aids(i) &"</li>"
End If:Next:For i=1 To Request.Form.count
If InStr(Request.Form(i),"|") > 0 Then
ShowErr("<li>提交内容不能包含|</li>")
End If:Next:ShowErr(""):orderid=SoonBiz.Format_Time(Now(),7) & SoonBiz.User_id:Set rs=SoonBiz.execute("select title from "& sheethead &"_trans where id="&transid)
If rs.eof Then
ShowErr("请选择送货方式")'::"didsuch':"ifcould::our:'all"still:
Else:transname=rs(0)
End If:Rs.Close:Set Rs=Nothing
If SoonBiz.rid("o_state")=1 Then
o_state=1
Else:o_state=0
End If:Set rs=SoonBiz.execute("select id,price,title,trans"& transid &",weight from "& sheethead &"_article where id in ("& ids &")")':::byinsaid"himhe#::these:inbut"their!
If rs.bof And rs.eof Then
ShowErr("定单中的产品不存在")
Else:arrs=rs.getrows(-1)
End If:Rs.close:set Rs=nothing:jinfang=UBound(arrs,2)
If UBound(aids) <> jinfang Then
ShowErr("非法操作") '*that:":see:dodo:'been:?:atsince)since
End If:For i=0 To jinfang:thecount=SoonBiz.rid("o_count" & arrs(0,i)):idstr=idstr & arrs(0,i) & "|||":pricestr=pricestr & arrs(1,i) & "|||":translist=translist & arrs(3,i) & "|||" :weightlist=weightlist & arrs(4,i) & "|||" :countstr=countstr & thecount & "|||" :productname=productname & arrs(2,i) & "" & "|||":o_mailpay=o_mailpay+arrs(3,i)*thecount:o_moneycount=o_moneycount + (arrs(1,i)*thecount) :Next:Set rs=server.CreateObject("adodb.recordset"):SoonBiz.ConnectionDatabase:rs.open sheethead &"_productorder",conn,1,3:rs.addnew:Rs("o_userid")=SoonBiz.User_id:Rs("o_orderid")=orderid:Rs("o_transid")=transid:Rs("o_transname")=transname:Rs("o_title")=o_title:Rs("o_idlist")=idstr:Rs("o_count")=countstr:Rs("o_pricelist")=pricestr:Rs("o_translist")=translist:Rs("o_weightlist")=weightlist:Rs("o_productname")=productname:Rs("o_name")=o_name:Rs("o_country")=o_country:Rs("o_province")=o_province:Rs("o_city")=o_city:Rs("o_address")=o_address:Rs("o_email")=o_email:Rs("o_tel")=o_tel:Rs("o_zipcode")=o_zipcode:Rs("stime")=now:Rs("o_state")=o_state:Rs("o_moneycount")=o_moneycount:Rs("o_mailpay")=o_mailpay:Rs("o_other")=o_other:Rs("isdel")=0:Rs("o_username")=SoonBiz.user_name:Rs("o_nickname")=SoonBiz.user_nickname:rs.update:id=rs("id")
If delbuycar=1 Then
Dim buycar:buycar=SoonBiz.execute("select user_buycar from "& sheethead &"_user where id=" & SoonBiz.user_id)(0):buycar=SoonBiz.outs(buycar,ids):SoonBiz.execute("update "& sheethead &"_user set user_buycar='"& buycar &"' where id=" & SoonBiz.user_id)
End If:Response.redirect("?act=readorder&id="&id):End Sub:Sub myorder() :Dim myordertype,arrmyordertype,myordertypeName:Dim tr,sql,i:SoonBiz.LoadTemplatesAdmin("user_buycar"):arrmyordertype=split(ordertype,"|"):myordertype=SoonBiz.rid("myordertype")
If myordertype>-1 and myordertype<4 Then
myordertypeName=arrmyordertype(myordertype)':#':.:'/_comethem:*=between:theiralsoas
Else:myordertypeName="全部定单"
End If:sql="select * from ["& sheethead &"_productorder] where isdel=0 and o_userid="&SoonBiz.user_id
If myordertype>-1 Then
sql=sql & " and o_state="&myordertype
End If:sql=sql & " order by id desc ":SoonBiz.title="定单管理":SoonBiz.topplus="<script type=""text/javascript"">var ordertype="""& ordertype &""";</script>":SoonBiz.adhead:SoonBiz.Nstate(myordertypeName)
If SoonBiz.rid("page")=-1 Then orderintroduce':"getnowcan:::::take::all:$'::
listfilter:HtmlStr=Template.html(6):Response.Write Replace(HtmlStr,"{$trhtml}",SoonBiz.replacemdb("定单列表",sql,template.html(7),"",0)):Response.write SoonBiz.PageList(""):Response.Write "<script type=""text/javascript"">":Response.Write " CheckSel(""myordertype"","""& myordertype &""");":Response.Write "</script>":End Sub:Sub listfilter():Dim arrordertype,i:arrordertype=split(ordertype,"|"):Response.Write "<div class=""listfilter"">":Response.Write " <form method=get action=""?"">":Response.Write " <input type=""hidden"" name=""act"" value=""myorder"" />":Response.Write " <select id=""myordertype"" name=""myordertype"">":Response.Write " <option value="""" selected=""selected"">全部定单</option>":For i=0 To ubound(arrordertype):Response.Write " <option value="""& i &""">"& arrordertype(i) &"</option>":Next:Response.Write " </select> ":Response.write " <input type=""submit"" value=""搜索""></td>":Response.write " </form>":Response.write "</div>":End Sub:Sub orderintroduce():Response.Write "<table cellspacing=1 class=tableborder1>":Response.Write "<tr>":Response.Write "<td>等待支付的定单:"& SoonBiz.execute("select count(*) from "& sheethead &"_productorder where (o_state=0 or o_state=2) and isdel=0 and o_userid="&SoonBiz.user_id)(0)&"</td>":Response.Write "<td>等待客服确认的定单:"& SoonBiz.execute("select count(*) from "& sheethead &"_productorder where o_state=1 and isdel=0 and o_userid="&SoonBiz.user_id)(0)&"</td>":Response.Write "</tr>":Response.Write "<tr>":Response.Write "<td>正在配货的定单:"& SoonBiz.execute("select count(*) from "& sheethead &"_productorder where o_state=3 and isdel=0 and o_userid="&SoonBiz.user_id)(0)&"</td>":Response.Write "<td>已经发货的定单:"& SoonBiz.execute("select count(*) from "& sheethead &"_productorder where o_state=4 and isdel=0 and o_userid="&SoonBiz.user_id)(0)&"</td>":Response.Write "</tr>":Response.Write "</table>":Response.Write "<br />":End Sub:Sub readorder() :Dim id,sql:SoonBiz.LoadTemplatesAdmin("user_buycar"):id=SoonBiz.rid("id"):sql="select * from ["& sheethead &"_productorder] where id=" & id & " and o_userid=" & SoonBiz.user_id:SoonBiz.title="我的定单":SoonBiz.topplus="<script type=""text/javascript"">var ordertype="""& ordertype &""";</script>":SoonBiz.adhead:SoonBiz.Nstate("我的定单"):Response.Write "<table cellspacing=1 class=tableborder1>":Response.Write "<tr>":Response.Write "<th colspan=2>定单信息</th>":Response.Write "</tr>":Response.Write SoonBiz.ReplaceMdb("查看定单",sql,template.html(3),"",1):Response.write "</table>":Response.Write "<br />":Response.Write "<table cellspacing=1 class=tableborder1>":Response.Write "<tr>":Response.Write "<th>产品名称</th>":Response.Write "<th>价格</th>":Response.Write "<th>运费</th>":Response.Write "<th>数量</th>":Response.Write "<th>小记</th>":Response.Write "</tr>":Dim o_idlist,o_count,o_pricelist,o_translist,o_weightlist,o_productname,o_state:Dim jinfang:Dim rs,i:sql="select o_idlist,o_count,o_pricelist,o_productname,o_state,o_translist from "& sheethead &"_productorder where id=" & id & " and o_userid=" & SoonBiz.user_id:Set rs=SoonBiz.Execute(sql):o_idlist=rs(0):o_idlist=Split(o_idlist,"|||"):o_count=rs(1):o_count=Split(o_count,"|||"):o_pricelist=rs(2):o_pricelist=Split(o_pricelist,"|||"):o_productname=rs(3):o_productname=Split(o_productname,"|||"):o_state=cint(rs(4)):o_translist=rs(5):o_translist=Split(o_translist,"|||"):rs.close:Set rs=Nothing:jinfang=UBound(o_idlist):For i=0 To jinfang-1:Response.write "<tr>":Response.write "<td>"& o_productname(i) &"</td>" :Response.write "<td><script type=""text/javascript"">format_currency("& o_pricelist(i) &");</script> * "& o_count(i) &"</td>" :Response.write "<td><script type=""text/javascript"">format_currency("& o_translist(i) &");</script> * "& o_count(i) &"</td>" :Response.write "<td>"& o_count(i) & "</td>" :Response.Write "<td><script type=""text/javascript"">format_currency("& o_pricelist(i)*o_count(i) + o_translist(i)* o_count(i) &");</script></td>":Response.write "</tr>":Next:Response.write "</table>":Response.Write "<br />":Response.Write "<div class='operate'>":Response.Write "<span id=""prosing"">":Response.Write "<form method=""post"" id=""payform"" action=""?act=pay&id="& id &"""> ":Response.Write "<input type='button' onClick=""history.back()"" value='返回上一页'> "
If o_state=0 or o_state=1 or o_state=2 Then
Response.Write "<input type='submit' value='确认支付' name=submit onclick='payorder' /> ":Response.Write "<input type=""password"" name=""user_paypass"" value="""" size=16 maxlength=16 />(支付密码)"
End If:Response.Write "</span>":Response.write "</form>":Response.write "</div>":End Sub:Sub delorder() :id=SoonBiz.rid("id"):SoonBiz.execute("update "& sheethead &"_productorder set isdel=1 where id=" & id & " and o_userid=" & SoonBiz.user_id&" and o_state<>3") :SoonBiz.ok:End Sub:Sub pay() :Dim user_id,user_money :Dim moneycount :Dim arrs,rs,sql:Dim user_paypass,user_paypass_mdb,user_name:id=SoonBiz.rid("id") :user_paypass=SoonBiz.Requeststr("支付密码","user_paypass","post",1,5,16,40,0):Set rs=SoonBiz.execute("select o_orderid,o_title,o_moneycount,o_mailpay,o_state,o_username from "& sheethead &"_productorder where id=" & id &" and o_userid="&SoonBiz.user_id )
If rs.eof Then
ShowErr("定单不存在") ':about:eachby":{::'any::thenthen\eachsee
Else:arrs=rs.getrows(1)
End If:Rs.close:set Rs=nothing
If cint(arrs(4,0))=3 or cint(arrs(4,0))=4 Then
ShowErr("这个定单已经支付过了")
End If:Set rs=SoonBiz.execute("select user_money,user_paypass from "& sheethead &"_user where id=" & SoonBiz.user_id)
If rs.eof Then']must+over:;:::+'might.hadmorehimselfthe""
ShowErr(1022) 
Else:user_money=rs(0):user_paypass_mdb=rs(1)
End If:Rs.close:set Rs=nothing
If len(user_paypass_mdb&"")>0 Then 
user_paypass=md6(SoonBiz.user_name,user_paypass)
If user_paypass <> user_paypass_mdb Then'herhowsome'@becauseout?came~:thatare:'{and::
ShowErr("支付密码错误")
End If
End If:moneycount=arrs(2,0) + arrs(3,0)
If user_money < moneycount Then
ShowErr("您的款项不足,请将相应款项汇至本站后再支付定单") 
End If:SoonBiz.execute("update "& sheethead &"_user set user_money=user_money - "& moneycount &" where id=" & SoonBiz.user_id):sql="insert into "& sheethead &"_money (m_userid,m_username,m_nickname,m_count,m_orderid,m_title,m_donickname,m_paytype,stime) values (":sql=sql & SoonBiz.user_id :sql=sql & ",'"& SoonBiz.user_name &"'":sql=sql & ",'"& SoonBiz.user_nickname &"'":sql=sql & ",-" & moneycount :sql=sql & ",'" & arrs(0,0) & "'" :sql=sql & ",'支付定单(" & arrs(1,0) & ")'" :sql=sql & ",'" & SoonBiz.user_nickname & "'":sql=sql & ",2" :sql=sql & ","& soonbizcom :sql=sql & ")":SoonBiz.execute(sql):SoonBiz.execute("update "& sheethead &"_productorder set o_state=3 where id="& id & " and o_userid=" & SoonBiz.user_id) :SoonBiz.AdSuccess("支付成功,您可以从定单管理中查询发货状态"):End Sub:sub myinfo():Dim tr,sql:SoonBiz.geturl:sql="select * from ["& sheethead &"_article] where id="& id &" and classid="& classid &" and isdel=0 and ispass=1":tr="<h1>商品名称:</h1><p>{$content}</p>":SoonBiz.title="商品资料":SoonBiz.adhead:Response.Write "<div class=""myinfo"">":Response.Write SoonBiz.replacemdb("user_buycar",sql,tr,"",1):Response.Write "</div>":End Sub:Function Rids() :Dim tid :tid=Trim(Request.QueryString("id"))':now':'}about'my&therefrombefore'isbecause(fromother
If Len(tid)=0 Then
ShowErr ("<li>请选择要购买的产品</li><li><a href='" & request.ServerVariables("HTTP_REFERER") & "'>返回上一页</a></li>")
Else
If Not IsNumeric(Replace(Replace(tid,",","")," ","")) Then 
ShowErr(1022)
End If:Rids=Replace(Trim(tid)," ","")'andalso"$anotherthere:\:":"likeanother|'hisget:
End If:End Function
%>