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

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

$M_id=splitx($out_trade_no,"-",0);

$arr=array(
	"pid" => $pid,
	"type" => $type,
	"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,$C_pkey)){
	echo "success"; //返回success说明通知成功，不要删除本行

	$row=getrs("select * from sl_list where L_no='".$trade_no."' and L_mid=$M_id");
	if($row=="") {
	    sql("update sl_member set M_money=M_money+$money where M_id=$M_id");
	    sql("insert into sl_list(L_time,L_title,L_money,L_mid,L_no) values('".date('Y-m-d H:i:s')."','账户充值',".$money.",".$M_id.",'".$trade_no."')");
	    echo "success";
	}else{
	    echo "fail";
	}
}else{
	echo "fail";
}

?>