<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/9/11
 * Time: 16:49
 * Modified: 2025-11-13 - 升级到 ThinkPHP 6.0
 */

use think\App;
use think\facade\Request;

error_reporting(E_ERROR);
date_default_timezone_set("Asia/Shanghai");

// 定义项目根目录
define('BASE_ROOT', str_replace('/extend/AliSDK', '', str_replace('\\', '/', realpath(dirname(__FILE__) . '/')) . "/"));
define('SITE_PATH', BASE_ROOT);
define('PUBLIC_PATH', SITE_PATH . 'public/');
define('EXTEND_PATH', BASE_ROOT . 'extend/');
// 定义应用目录
define('APP_PATH', SITE_PATH . 'app/');

// 加载 Composer 自动加载
require_once SITE_PATH . 'vendor/autoload.php';

// 加载自定义配置
if (file_exists(PUBLIC_PATH . 'php/yb.version.php')) {
    require_once PUBLIC_PATH . 'php/yb.version.php';
}

// 引入回调处理类
require_once __DIR__ . '/PayNotifyCallBack.php';

use think\facade\Db;
use think\facade\Log;
// 初始化应用
$http = (new App(SITE_PATH))->http;
$response = $http->run();
$request = Request::instance();

try {

    // 记录回调日志
    Log::write('支付宝支付回调开始', 'info');
    Log::write('回调数据: ' . json_encode($_POST, JSON_UNESCAPED_UNICODE), 'info');
    
    // 处理回调数据
    $objData = $_POST;
    $notify = new \PayNotifyCallBack();
    $notify->Handle($objData);
    
} catch (\Exception $e) {
    Log::error('支付宝回调异常: ' . $e->getMessage());
    echo 'fail';
}

