<?php
require '../conn/conn.php';
require '../conn/function.php';
require '../conn/sendmail.php';

$money=t($_GET["money"]);
$name=t($_GET["name"]);
$pid=t($_GET["pid"]);
$out_trade_no=t($_GET["out_trade_no"]);
$trade_no=t($_GET["trade_no"]);
$trade_status=t($_GET["trade_status"]);
$type=t($_GET["type"]);
$sign=t($_GET["sign"]);
$sign_type=t($_GET["sign_type"]);

$O=getrs("select * from sl_orders where O_no='$out_trade_no'");

if($O["O_mid"]==0){
    $pkey=$C_pkey;
    $M_id=0;
}else{
	$M=getrs("select * from sl_member where M_id=".$O["O_mid"]);
	$M_id=$M["M_id"];
	if($C_pay==1){//如果是平台代收款
		$pkey=$C_pkey;
	}else{
		$pkey=$M["M_pkey"];
	}
}

$arr=array(
	"pid" => $pid,
	"type" => $type,
	"notify_url" => $notify_url,
	"out_trade_no" => $out_trade_no,
	"trade_no" => $trade_no,
	"name" => $name,
	"money"	=> $money,
	"trade_status"	=> $trade_status,
	"sign_type"	=> $sign_type
);

if($sign==get_sign($arr,$pkey)){
	echo notify($tradeno,$out_trade_no,$M_id);
}else{
	echo "fail";
}
?>