<!--#include file="conn.asp"-->
<%
page_title=Eval("order_title"&Language)
page_keywords=Eval("order_keywords"&Language)
page_description=Eval("order_description"&Language)
if page_title="" then
page_title=city_title
page_keywords=city_keywords
page_description=city_description
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%=page_title%></title>
<meta name="keywords" content="<%=page_keywords%>" />
<meta name="description" content="<%=page_description%>" />
<!--#include file="top.asp"-->
<!--#include file="header.asp"-->
<link href="<%=filepath%>inc/cart.css" rel="stylesheet" type="text/css">
<script src="../inc/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="../inc/jquery.placeholder.min.js" type="text/javascript"></script>
<script src="../inc/jzoshow.js" type="text/javascript"></script>
<script src="../inc/bo.js" type="text/javascript"></script>
<%
if session("user_xxx_name")<>"" then
username=trim(session("user_xxx_name"))
else
	if request.Cookies("shopxp")("dingdanusername")="" then
	username=now()
	username=replace(trim(username),"-","")
	username=replace(username,"/","")
	username=replace(username,":","")
	username=replace(username," ","")
	username=username
	response.Cookies("shopxp")("dingdanusername")=username

	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from [com_user] ",conn,1,3
	rs.addnew
	rs("username")=username
	rs("niming")=1
	rs.update
	rs.close
	set rs=nothing
	
	else
	username=request.Cookies("shopxp")("dingdanusername")
	end if
end if
%>
<!--#include file="../inc/geoData.asp"-->
<%
deliveryAddressId=request("deliveryAddressId")
expressId=request("expressId")
deliveryTimeId=request("deliveryTimeId")
deliveryComment=request("deliveryComment")
buy_jifen=request("buy_jifen")
promoRuleId=request("promoRuleId")
couponCodeNumber=request("couponCodeNumber")
isBuyNow=request("isBuyNow")
isCollocationPromo=request("isCollocationPromo")

if deliveryAddressId="" or deliveryAddressId="" then
response.Redirect("step_three_show.asp?submitOK=3&dingdan="&dingdan&"")
end if

'/////////////////////////////////////////////////
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function

'修改用户的送货信息
set rsp=server.CreateObject("adodb.recordset")
rsp.open "select * from com_Uadd where id="&deliveryAddressId,conn,1,1
provinceId=rsp("provinceId")
cityId=rsp("cityId")
countyId=rsp("countyId")
user_01=rsp("receiverName")
user_03=rsp("address")
user_04=rsp("postCode")
user_05=rsp("mobile")
user_06=rsp("splitPhone1")&"-"&rsp("splitPhone2")
rsp.close
set rsp=nothing
	


if session("xiadan")<>minute(now) then
'再判断库存
'未写

set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [com_user] where username='"&username&"'",conn,1,3
if session("user_xxx_name")="" then
rs("UserPassword")=md5(username)
end if

'下单就减积分
if buy_jifen<>"" then
rs("jifen")=rs("jifen")-trim(buy_jifen)
	'记录积份消费
	if buy_jifen<>0 then
	call jifen_record(session("user_xxx_name"),0,buy_jifen,"购买商品使用积分")
	end if
end if

rs.update
rs.close
set rs=nothing


dim shijian,dingdan
shijian=now()
'dingdan=year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
'response.write shopxpptid
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shopxp_action where username='"&username&"' and zhuangtai=9",conn,1,3
if session("user_xxx_name")<>"" then
'dingdan=year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
dingdan=now()
dingdan=replace(trim(dingdan),"-","")
dingdan=replace(dingdan,"/","")
dingdan=replace(dingdan,":","")
dingdan=replace(dingdan," ","")
dingdan=dingdan
else
dingdan=username
end if
do while not rs.eof
'得到价格，减库存
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from com_books where id="&rs("shopxpptid"),conn,1,3
danjia=rs2("shopxphyjia")
rs2("chengjiaocount")=rs2("chengjiaocount")+rs("productcount")
rs2("kucun")=int(rs2("kucun"))-int(rs("productcount"))

	set rs3=server.CreateObject("adodb.recordset")
	rs3.open "select * from com_PCR where proid="&rs("shopxpptid")&" and colorid="&rs("pro_color_id")&" and sizeid="&rs("pro_size_id")&"",conn,1,3
	if not rs3.bof or not rs3.eof then
		if rs3("kucun")<rs("productcount") then
			response.Write "<script language=javascript>alert('对不起，商品："&rs2("titlecn")&"，只剩下"&rs3("kucun")&"份了，请重新修改数量后结算！');location='cart.asp';</script>"
			response.end()
		else
			rs3("kucun")=rs3("kucun")-rs("productcount")
		end if
	rs3.update
	end if
	rs3.close
	set rs3=nothing

rs2.update
rs2.close
set rs2=nothing



'rs.addnew
'rs("username")=trim(request.cookies("bookshop")("username"))
'rs("shopxpptid")=rs2("shopxpptid")
rs("actiondate")=shijian
'rs("productcount")=CInt(Request("Godbook"&rs2("shopxpptid")))

	if expressId=1 then    '送货上门或预存款支付，直接改为订单完成（已收到款）
	rs("zhuangtai")=3
	else
	rs("zhuangtai")=1
	end if
	
rs("dingdan")=dingdan
zongji=zongji+rs("zonger")

rs("provinceId")=provinceId
rs("cityId")=cityId
rs("countyId")=countyId
rs("deliveryTimeId")=deliveryTimeId
rs("promoRuleId")=promoRuleId
rs("couponCodeNumber")=couponCodeNumber

'rs("userid")=session("UserID")

rs("user_01")=user_01
rs("user_03")=user_03
rs("user_04")=user_04
rs("user_05")=user_05
rs("user_06")=user_06
rs("useremail")=session("user_xxx_mail")
rs("shopxp_shfs")=expressId
'rs("zhifufangshi")=trim(request("zhifufangshi"))

rs("liuyan")=HTMLEncode2(deliveryComment)
'rs("delivery")=HTMLEncode2(request("delivery[day]")&"/"&request("delivery[day]")&"/"&request("delivery[time]"))
session("liuyan")=HTMLEncode2(deliveryComment)
session("user_01")=HTMLEncode2(user_01)
session("user_03")=HTMLEncode2(user_03)
session("user_04")=HTMLEncode2(user_04)
session("user_05")=HTMLEncode2(user_05)
session("user_06")=HTMLEncode2(user_06)

'积分
if buy_jifen<>"" then
rs("jifen_dk")=Round(int(buy_jifen)/int(cart_jfdk),2)
else
rs("jifen_dk")=0
end if


'新增发票
if request("fapiao")<>1 then 
fapiao=0
else
fapiao=1
end if
rs("fapiao")=fapiao
rs("fapiaoTt")=request("fapiaoTt")
session("fapiaoTt")=request("fapiaoTt")


	if buy_jifen<>"" then
	buy_jifenA=buy_jifen
	end if
	

if promoRuleId<>"coupon_code" then
	setId=replace(promoRuleId,"act_","")
	set rsp=server.CreateObject("adodb.recordset")
	rsp.open "select * from com_act where id="&setId&"",conn,1,1
	if not rsp.bof or not rsp.eof then
	amount=rsp("amount")
	act_name=rsp("CodeNumber")
	end if
	rsp.close
	set rsp=nothing
elseif promoRuleId="coupon_code" and couponCodeNumber<>"" then
	set rsp=server.CreateObject("adodb.recordset")
	rsp.open "select * from com_coupon where CodeNumber='"&couponCodeNumber&"'",conn,1,3
	if not rsp.bof or not rsp.eof then
	amount=rsp("amount")
	rsp("used")=1
	rsp.update
	end if
	rsp.close
	set rsp=nothing
else
amount=0
end if	



if expressId<>0 then

	set rszf=server.CreateObject("adodb.recordset")
	rszf.open "select * from com_songhuo where id="&expressId&"",conn,1,1
	subject=rszf("subject")
	rszf.close
	set rszf=nothing
	set rsp=server.CreateObject("adodb.recordset")
	rsp.open "select * from com_china where id="&provinceId,conn,1,1
	expressM=rsp("sh"&expressId)
	rsp.close
	set rsp=nothing

	rs("feiyong")=expressM
	if expressM+zongji-amount-Round(int(buy_jifenA)/int(cart_jfdk),2)<0 then
	session("zongji_a")=0
	else
	session("zongji_a")=expressM+zongji-amount-Round(int(buy_jifenA)/int(cart_jfdk),2)
	end if
	session("zongji_b")=trim(zongji)
	session("jifen_dk")=trim(Round(int(buy_jifenA)/int(cart_jfdk),2))
	session("jsmoney")=expressM

else
	if zongji-amount-Round(int(buy_jifenA)/int(cart_jfdk),2) then
	session("zongji_a")=0
	else
	session("zongji_a")=zongji-amount-Round(int(buy_jifenA)/int(cart_jfdk),2)
	end if
	session("zongji_b")=trim(zongji)
	session("jifen_dk")=trim(Round(int(buy_jifenA)/int(cart_jfdk),2))
	session("jsmoney")=0
end if

'rs("feiyong")=request("feiyong")

rs("danjia")=danjia
rs.update
'rs.close
'set rs=nothing
'conn.execute "delete from shopxp_action where username='"&request.cookies("bookshop")("username")&"' and shopxpptid in ("&shopxpptid&") and zhuangtai=8"
rs.movenext
loop
rs.close
set rs=nothing

set rszf=server.CreateObject("adodb.recordset")
rszf.open "select * from com_songhuo where id="&expressId&"",conn,1,1
subject=rszf("subject")
rszf.close
set rszf=nothing

session("xiadan")=minute(now)
response.Cookies("shopxp")("dingdanusername")=""
	submitOK=1
	response.Redirect("step_three_show.asp?submitOK=1&expressId="&expressId&"&dingdan="&dingdan&"")
else
	'response.Write "<center>对不起，同一时间重复提交，请稍候再提交！</center>"
	'response.End
	submitOK=0
	response.Redirect("step_three_show.asp?submitOK=0&dingdan="&dingdan&"")
end if


%>

<script type="text/javascript">
//<![CDATA[
$(function(){
	
});

var goToPay = function() {
	$('body,html').animate({scrollTop:0},1000);
	if ($("input[type='radio'][name='payid']:checked").length == 0) {
		alert("请选择支付方式？");
		return;
	}
	$(".link").click(function(){
	$("#payDialog").css("display", "none");
	app.helper.closeBg();
	});
	app.helper.showBg();
	$("#payDialog").css("display", "block");
	$("#paymentForm").submit();
	return;
};
//]]>
</script>

<!-- start middle -->
<div class="headnav">
	<div class="cart-steps">
		<ul>
			<li><span>1.我的购物车</span></li>
			<li><span>2.填写核对订单</span></li>
			<li class="current"><span>3.成功提交订单</span></li>
			<li class="clear"></li>
		</ul>
	</div>
</div>
<div id="content" class="w990">
	<div class="div-con">
				<div class="buyend">
				
<%if submitOK=0 then%>
	<h2><i class="icon-alert"></i>对不起，同一时间重复提交，请稍候再提交！</h2>
<%else%>

	<h2>
	<i class="icon-success"></i>
	<%if expressId=1 then%>
	您的订单为货到付款，请注意确认收货！
	<%else%>
	您的订单已成功提交，请继续完成支付！
	<%end if%>
	</h2>
	
	<%if expressId=1 then%>
	<p>您的订单号：<a href="orderDetail.asp?dingdan=<%=dingdan%>"><%=dingdan%></a>&nbsp;&nbsp;&nbsp;&nbsp;
	应付金额：<span class="price"><%=Formatnumber(session("zongji_a"),2,-1,-1,0)%></span>元&nbsp;&nbsp;&nbsp;&nbsp;配送方式：<%=subject%></p>
	<%else%>
	<p>您的订单号：<a href="orderDetail.asp?dingdan=<%=dingdan%>"><%=dingdan%></a>&nbsp;&nbsp;&nbsp;&nbsp;应付金额：<span class="price-big"><%=Formatnumber(session("zongji_a"),2,-1,-1,0)%></span>元&nbsp;&nbsp;&nbsp;&nbsp;配送方式：<%=subject%></p>
	<p>还差一步，请继续完成在线支付（您也可以选择稍后付款，本店将会在24小时保留您的订单）。</p>
	<%end if%>

<%end if%>		
				</div>
				
<%if expressId<>1 and submitOK<>0 then%>
			<h3>选择支付方式</h3>
			<div class="hr"></div>
			<div class="w35" style="margin-left: 78px;">
				<form id="paymentForm" name="paymentForm" action="checkout.asp" method="post" target="_blank">
				<input type="hidden" id="orderId" name="orderId" value="<%=dingdan%>">
				<div class="payinline" style="margin-left: 50px;">
					<div class="bankPayName">
						<strong>第三方平台支付：</strong>
					</div>
					<div class="bankSelMiddle">
						<ul>
						<%if ali_pay=1 then%>
							<li><input id="ALIPAY" name="payid" type="radio" value="ALIPAY">
								<label for="ALIPAY"><img id="imgid" src="images/bank_52.gif" alt="支付宝"></label>
							</li>
						<%end if%>
						<%if ten_pay=1 then%>
							<li><input id="TENPAY" name="payid" type="radio" value="TENPAY">
								<label for="TENPAY"><img id="imgid" src="images/bank_53.gif" alt="财付通"></label>
							</li>
							<%end if%>
							<%if bill_pay=1 then%>
							<li><input id="TENPAY" name="payid" type="radio" value="BillPAY">
								<label for="TENPAY"><img id="imgid" src="images/bank_54.gif" alt="快钱"></label>
							</li>
							<%end if%>
						</ul>
					</div>


					<!--
					<div class="bankPayName">
						<strong>其它银行支付：</strong>
					</div>
					<div class="bankSelMiddle">
						<ul>
							<li>
								<input id="ICBCB2C" name="payid" type="radio" value="ICBCB2C"> 
								<label for="ICBCB2C"><img id="imgid" src="images/bank_02.gif" alt="中国工商银行"></label>
							</li>
	
							<li><input id="CMB" name="payid" type="radio" value="CMB">
								<label for="CMB"><img id="imgid" src="images/bank_03.gif" alt="招商银行"></label></li>
	
							<li><input id="CCB" name="payid" type="radio" value="CCB">
								<label for="CCB"><img id="imgid" src="images/bank_04.gif" alt="中国建设银行"></label></li>
	
							<li><input id="BOCB2C" name="payid" type="radio" value="BOCB2C"><label for="BOCB2C"> <img id="imgid" src="images/bank_05.gif" alt="中国银行"></label></li>
	
							<li style="display: none"><input id="ABC" name="payid" type="radio" value="ABC">
								<label for="ABC"><img id="imgid" src="images/bank_06.gif" alt="中国农业银行"></label></li>
	
							<li><input id="COMM" name="payid" type="radio" value="COMM"><label for="COMM"> <img id="imgid" src="images/bank_07.gif" alt="交通银行"></label></li>
	
							<li><input id="SPDB" name="payid" type="radio" value="SPDB"><label for="SPDB"> <img id="imgid" src="images/bank_08.gif" alt="浦发银行"></label></li>
	
							<li><input id="GDB" name="payid" type="radio" value="GDB">
								<label for="GDB"><img id="imgid" src="images/bank_09.gif" alt="广发银行"></label></li>
	
							<li><input id="CITIC" name="payid" type="radio" value="CITIC"><label for="CITIC"> <img id="imgid" src="images/bank_10.gif" alt="中信银行"></label></li>
	
							<li><input id="CEBBANK" name="payid" type="radio" value="CEBBANK"> <label for="CEBBANK"><img id="imgid" src="images/bank_11.gif" alt="中国光大银行"></label></li>
	
							<li><input id="CIB" name="payid" type="radio" value="CIB">
								<label for="CIB"><img id="imgid" src="images/bank_12.gif" alt="兴业银行"></label></li>
	
							<li><input id="SPABANK-1" name="payid" type="radio" value="SPABANK">
								<label for="SPABANK-1"><img id="imgid" src="images/bank_13.gif" alt="深圳发展银行"></label></li>
	
							<li><input id="CMBC" name="payid" type="radio" value="CMBC"><label for="CMBC"> <img id="imgid" src="images/bank_14.gif" alt="中国民生银行"></label></li>
	
							<li><input id="HZCBB2C" name="payid" type="radio" value="HZCBB2C"> <label for="HZCBB2C"><img id="imgid" src="images/bank_15.gif" alt="杭州银行"></label></li>
	
							<li><input id="SHBANK" name="payid" type="radio" value="SHBANK"> <label for="SHBANK"><img id="imgid" src="images/bank_16.gif" alt="上海银行"></label></li>
	
							<li><input id="NBBANK" name="payid" type="radio" value="NBBANK"><label for="NBBANK"> <img id="imgid" src="images/bank_17.gif" alt="宁波银行"></label></li>
	
							<li><input id="SPABANK" name="payid" type="radio" value="SPABANK"> <label for="SPABANK"><img id="imgid" src="images/bank_18.gif" alt="深圳平安银行"></label></li>
	
							<li><input id="BJRCB" name="payid" type="radio" value="BJRCB"> <label for="BJRCB"><img id="imgid" src="images/bank_19.gif" alt="北京农村商业银行"></label></li>
	
							<li><input id="ICBCBTB" name="payid" type="radio" value="ICBCBTB"> <label for="ICBCBTB"><img id="imgid" src="images/bank_20.gif" alt="中国工商银行(企业)"></label>
							</li>
	
							<li><input id="CCBBTB" name="payid" type="radio" value="CCBBTB"> <label for="CCBBTB"><img id="imgid" src="images/bank_21.gif" alt="中国建设银行(企业)"></label>
							</li>
	
							<li><input id="SPDBB2B" name="payid" type="radio" value="SPDBB2B"><label for="SPDBB2B"> <img id="imgid" src="images/bank_22.gif" alt="浦发银行(企业)"></label></li>
	
							<li style="display: none"><input id="ABCBTB" name="payid" type="radio" value="ABCBTB"><label for="ABCBTB"> <img id="imgid" src="images/bank_23.gif" alt="中国农业银行(企业)"></label>
							</li>
	
							<li><input id="FDB" name="payid" type="radio" value="FDB">
								<label for="FDB"><img id="imgid" src="images/bank_24.gif" alt="富滇银行"></label></li>
	
							<li><input id="PSBC-DEBIT" name="payid" type="radio" value="PSBC-DEBIT"> <label for="PSBC-DEBIT"><img id="imgid" src="images/bank_25.gif" alt="中国邮政储蓄银行"></label></li>
						</ul>
					</div>
					-->
				</div>
			</form></div>
			<div class="buyfoot">
				<p>
					<a href="javascript:void(0)" onclick="goToPay();" class="btn-pay">立即支付</a>
				</p>
				<p>
					<span>&gt; 支付成功后，您可以：</span> <a href="orderDetail.asp?dingdan=<%=dingdan%>"><i class="icon-look"></i>查看订单状态</a>
					<a href="../index.asp"><i class="icon-cart"></i>继续购物</a>
				</p>
			</div>
<%end if%>	

	</div>
</div>
<!--end middle-->
	
	
   <div class="clear"></div>
   
  <div id="bg" class="bg" style="display: none;"></div>
	<iframe id="popIframe" class="popIframe" frameborder="0"></iframe>
	<div id="loadingTip" class="loadingTip" style="display: none;">
		数据处理中...
	</div> 
	
   <div id="payDialog" class="dialog" style="display: none; ">
    <div class="dgwrap">
        <div class="icocontent">
            <i class="icon-alert"></i>
            <strong>请你在新打开的支付平台页面上完成付款。</strong>
            <p class="payhint">付款前请不要关闭此窗口。<br>完成付款后请根据您的情况点击下面的按钮。</p>
            <div class="btncon">
                <a href="orderList.asp" class="btn-pay"><span>已完成付款</span></a>
                <a href="#" class="link"><span>付款遇到问题，返回重新支付</span></a>
            </div>
        </div>
        
    </div>
</div>
<!--#include file="foot.asp"--> 

