<?php
	session_start();
	
	require_once("db/db.php");	
	require_once("common/common.php");
	
	//设置统一语言格式
	header("Content-type: text/html; charset=gb2312"); 
	
	$selsubno=$_SESSION["main_vipno"];
	$fltpayval=$_REQUEST["pval"];
	$fltfreeval=$_REQUEST["fval"];
	$retval=0;
	
	$strselpayforok=trim($_SESSION["main_vipwxpayforyd"]);
	
	//echo $strselpayforok;
	//exit;
	if($strselpayforok=="2")
	{
		$retval="0";
	}
	else
	{
		//开始支付
		//1.得到会员信息
		$strChainNo='';
		$strVipNo='';
		$strSubNo=$selsubno;
	
		$sql = sprintf("SELECT b.Chain_No,a.VIP_No FROM VIP_Item a,VIP_Main b WHERE b.VIP_No=a.VIP_No And a.Sub_No='%s'",$selsubno);
	
		$result = querySql($sql);
		if($row = fetch_array($result))
		{
			//如果有会员号
			$strChainNo=$row['Chain_No'];
			$strVipNo=$row['VIP_No'];
		}
		freeResult($result);
				
		$sql = sprintf("EXECUTE VIP_AddPayForVal '%s','%s','%s','app','微信支付',%s,%s,'手机微信充值','手机微信'",$strChainNo,$strVipNo,$strSubNo,$fltpayval,$fltfreeval);
		if(executeSql($sql))
		{
			$retval="1";
			$_SESSION["main_vipwxpayforyd"]="2";
		}
	}
	//echo $retval;
	echo "<script>window.location.href='vipmain.php';</script>";
	
	//释放数据库
	//freeResult($result);
	closeDb();
?>
<!DOCTYPE html>
<html>
<head>
	<script language="JavaScript"> 
		//不允许进行后退
		javascript:window.history.forward(0); 
	</script>
</head>

<body>
</body>
</html>

