<?php
/**
 * @version        Somao_Search X1.0 9:23 2012-1-1 Somao $
 * @package        Somao_Search.Site
 * @copyright      Copyright (c) 2009 - 2012, Somao, Inc.
 * @license        http://www.somao123.com/
 * @link           http://www.somao.cc/
 */
require_once("global.php");
require_once("lib/alipay_notify.class.php");
//计算得出通知验证结果
$alipayNotify = new AlipayNotify($aliapy_config);
$verify_result = $alipayNotify->verifyReturn();
if($verify_result) {//验证成功
    $out_trade_no	= $_GET['out_trade_no'];	//获取订单号
    $trade_no		= $_GET['trade_no'];		//获取支付宝交易号
    $total_fee		= $_GET['total_fee'];		//获取总价格
    if($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
    }
    else {
      echo "trade_status=".$_GET['trade_status'];
    }
	$row3 = $db->get_one("select * from ve123_member_orders where oid='$out_trade_no'");
	if($row3['state']==0){
	  $utime=time();
	  $array=array('state'=>1,'utime'=>$utime);
	  $db->update("ve123_member_orders",$array,"oid='$out_trade_no' and uid='$uid'"); 
	  $total_fee2=$total_fee*$config['alipay_propor'];  //充值比例
	  $point=$total_fee2+$points;
	  $array2=array('points'=>$point);
      $db->update("ve123_member",$array2,"user_name='$uname'");  
      echo "<script> alert('充值成功')</script>";
	  echo "<script> alert('"."您的订单号是：".$trade_no."已经完成支付手续，您当前账号余款为".$point."')</script>";
	}else{
	  echo "<script> alert('充值成功,请不要重复操作')</script>";
	}
}
else {
    //验证失败
    //如要调试，请看alipay_notify.php页面的verifyReturn函数，比对sign和mysign的值是否相等，或者检查$responseTxt有没有返回true
	 echo "<script> alert('充值失败,请检查你的支付宝账号是否输入正确或者请联系管理员直接充值')</script>";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>支付宝即时到帐接口</title>
<script type="text/javascript">
function gourl()
{
	location.href='/tg/'
}
</script>
</head>
<body onload="gourl()">
</body>
</html>
