<?php


		require_once("./include/conn_1.php");
		require_once("./include/public.php");

		$datac = '2015122110152100';
		$tradeAmt = 100000;
		$sqlsc = "select username,amount,status,ordernumber from  {$db_prefix}member_order where ordernumber = '".$datac."'";
		$rssc = $db->get_one($sqlsc);
	
		if($rssc['status'] == 1){
			$url = "notify.php";
			Header("Location: $url");
			return true;
		}else if((int)$rssc['amount'] !== (int)$tradeAmt){
			echo "金额不相等";
			return false;
		}else{

			$addamount    = $rssc['amount'];
			$username  	  = $rssc['username'];
			
			//查询上家
			$sqlSj 	 = "select inviter from {$db_prefix}member where username = '".$username."'";
			echo $sqlSj;
			$rs_sj   = $db->get_one($sqlSj);
			$Topusername  = $rs_sj['inviter'];	//上线
			

			if(!empty($Topusername)){
				echo 'ok';
			}else{
				echo 1;
			}	

			die();
			//发送记录
			$compnayN = configW('webname');
			$title    = "尊敬的".$username."会员您好！您成功充值".$addamount."元";
			$content  = "您成功充值".$addamount."元";
			$memo     = "在线充值";
			$rs_msg   = sendMsg($username,$compnayN,$title,$content,$memo);

			//增加积分
			$sql_amo = "update {$db_prefix}member set amount = amount + {$addamount}  where  username = '".$username."'";
			$rs_amo  =$db->query($sql_amo);

			//更新状态，插入记录
			$sql_lgn = "update {$db_prefix}member_order set status = 1,paytime = '".time()."',accNo = '".$data['accNo']."'  where  ordernumber = '".$data['orderNo']."'";
			$rs_plus =$db->query($sql_lgn);

			//对下线充值奖励
			if(!empty($Topusername)){

				//查询奖励比例
				$sqlpr = "select XiaXianFenCheng from  {$db_prefix}member_config where id = 1";
				$rssc = $db->get_one($sqlpr);
				$XiaXianFenCheng = $rssc['XiaXianFenCheng'];	//下线分成比例
				$XiaXianAmount   = $rssc['XiaXianFenCheng'] * $addamount;	//抽成金额
				$XiaXianAmount   = intval($XiaXianAmount); 
				
				//插入分成数据
				$sqlFc="insert into {$db_prefix}member_cashback(username,xxusername,amount,preamount,type,status,posttime) values('{$Topusername}','{$username}','{$addamount}','{$XiaXianAmount}','下线分成',1,'".time()."')";
				$db->query($sqlFc);

				//发送记录
				$title    = "尊敬的".$Topusername."会员您好！您的下线分成".$XiaXianAmount."元";
				$content  = "您的下线".$username."充值分成".$XiaXianAmount."元,已赠送到您的账号。";
				$memo     = "下线分成";
				$rs_msg   = sendMsg($Topusername,$compnayN,$title,$content,$memo);

				//增加金额
				$sql_inver = "update {$db_prefix}member set amount = amount + {$XiaXianAmount}  where  username = '".$Topusername."'";
				$db->query($sql_inver);
			}

			if($rs_msg && $rs_amo && $rs_plus){
				//$url = "notify.php";
				//Header("Location: $url");
				echo "充值成功!";
				return true;
			}else{
				echo $rssc['ordernumber'].",充值不成功";
				return false;
			}
		}


?>