<?php
	session_start();
	
	require_once("db/db.php");	
	require_once("common/common.php");
	
	//设置统一语言格式
	header("Content-type: text/html; charset=gb2312"); 
	
	$price = trim($_REQUEST['preprice']);
	$orderno = trim($_REQUEST['orderno']);
	$paytype = trim($_REQUEST['paytype']);
	$wxorderno = trim($_REQUEST['wxbill']);	//威信支付订单号 
	
	//判断是否已经提交过
	$strpayforxz=trim($_SESSION["main_wxpayforyd"]);
	if($strpayforxz==1)
	{	
		$sql=sprintf("Select count(*) as count from TR_Consume_List where Order_No='%s'", $orderno);	 
		$result = querySql($sql);
		$row = fetch_array($result);
		$count = $row['count'];
		freeResult($result);
		if($count == 0)
		{
			$sql ="";
			if($paytype == 1)
			{	
				$strremarks="";
				$sql = sprintf("EXECUTE TRS_OrderAddPayForVal '%s','','%s',%f,'%s'", $orderno, '会员卡', $price,$strremarks);
			}
			else if($paytype == 2)
			{
				$strremarks="微信订房,[/*".$wxorderno."*/]";
				$sql = sprintf("EXECUTE TRS_OrderAddPayForVal '%s','','%s',%f,'%s'", $orderno, '微信支付', $price,$strremarks);//wx
			}
			$result = querySql($sql);
		}
	}
	$_SESSION["main_wxpayforyd"]="";
	//echo $sql;	
	//$row = fetch_array($result);
	//var_dump($row);
	

	/*
	$strroomtypeid=$_REQUEST['romtype'];				//入住房型ID
		
	$retval=0;

	$strchainno = $_SESSION["main_order_chainno"];
	$strsubno = $_SESSION["main_vipnosk"];
	$strcheckinday = $_SESSION["main_order_checkinday"];	//入住日期
	$strcheckoutday = $_SESSION["main_order_checkoutday"];	//入住日期
	$strroomcount = trim($_REQUEST['rmcount']);				//订房数量
	$strremarks = trim($_REQUEST['rmtxt']);					//预订说明
	$strmanname = trim($_REQUEST['rmname']);				//预订人
	$strmantelno = trim($_REQUEST['rmtelno']);				//联系电话
	$strkeeptime = trim($_REQUEST['rmkptime']);				//保留时间
	$strroomprice = trim($_REQUEST['rmprice']);				//价格
	$strbreakfast = "0";	//是否含早餐
	$strinvoice = "0";		//是否开发票
	$strneworderno = "";	//返回的单号
	
	//得到房型
	$sql=sprintf("SELECT Room_Type FROM TR_Room_Type WHERE ListNo=%s;",$strroomtypeid);
	$result = querySql($sql);
	$row = fetch_array($result);
	$strroomtype = trim($row['Room_Type']); //预订房型
	freeResult($result);
	
	
	//开始创建
	$sql = sprintf("EXECUTE TRS_CancelOrderNoBook '%s','APP预订取消订单'",$strorderno);
	
	$sql = sprintf("EXECUTE TRS_WebNewBookOrder '%s','%s','%s',%s,'%s','%s',%s,'%s','%s','%s','%s','2012-02-01 %s',0,0,'';",
				$strchainno,$strsubno,$strroomtype,$strroomprice,$strcheckinday,$strcheckoutday,$strroomcount,$strremarks,$strmanname,$strmanname,$strmantelno,$strkeeptime);

	$strRet=0;		//得到处理返回值
	$retval=0;
	
	$result = querySql($sql);
	if($row = fetch_array($result))
	{
		$strRet=$row['Res'];
		if($strRet=='1')
		{
			$retval=1;	
			//无此会员或已注销
		}
		elseif($strRet=='2')
		{
			$retval=2;
			//分店信息不正确
		}
		elseif($strRet=='3')
		{
			$retval=3;
			//可用房数不足
		}
		elseif($strRet=='4')
		{
			$retval=4;
			//保存订单失败
		}
	}
	freeResult($result);
	closeDb();
	
	if($retval<1)
	{	
		//header('Location: index.php');
		//echo "<script>window.location.href='index.php#page1';</script>";
		echo "<script>window.location.href='paysel.php?price=".$strroomprice."';</script>";
	}
	else
	{
		//重新编辑
		$strurl='ordernew.php?romtype='.$strroomtypeid.'&stext='.$retval;
		
		//header('Location: ' .$strurl);
		echo "<script>window.location.href='ordernew.php?romtype=".$strroomtypeid."&stext=".$retval."';</script>";		
	}*/
?>
<html>
<head>
	<meta charset="gb2312">	
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
	<meta name="apple-mobile-web-app-capable" content="1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=0">
	<meta name="apple-touch-fullscreen" content="1">
	<title>在线支付</title>
	<script src="jsp4/jquery.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 
	
	<script>
		setTimeout("window.location='orderlist.php'",1000);
		//setTimeout("window.location='hotelsel.php?chidno='<?php echo $_SESSION["main_defhotelcode"]?>'&chsel='<?php echo $_SESSION["main_defhotelsel"]?>''",1000) 
	</script>

	<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>
</head>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
&nbsp;<br>
<center><span style='color:green;font-size:22px'><b>付款成功</b></span></center>
<p>
</body>

</html>



