where('group', 'site')->column('value', 'name'); \think\Config::set('site', $site); $upload = include APP_PATH . 'extra/upload.php'; \think\Config::set('upload', $upload); // 触发 epay 配置初始化 \think\Hook::listen('epay_config_init'); // 选用订单 21 $order = \app\admin\model\shopro\order\Order::get(21); $oldStatus = $order->status; $oldRemainFee = $order->remain_pay_fee; $order->status = 'unpaid'; $order->remain_pay_fee = 0.01; $order->save(); echo "Order 21 temporarily set to unpaid, remain_pay_fee=0.01\n"; $auth = \app\common\library\Auth::instance(); $auth->direct($order->user_id); $request = \think\Request::instance(); $request->post([ 'order_sn' => $order->order_sn, 'payment' => 'wechat', ]); $request->header([ 'platform' => 'WechatMiniProgram', ]); echo "Calling prepay via PayController...\n"; $controller = new \addons\shopro\controller\Pay(); try { $controller->prepay(); } catch (\think\exception\HttpResponseException $e) { $data = $e->getResponse()->getData(); echo "Prepay Result Data:\n"; print_r($data); } catch (\Exception $e) { echo "Exception: " . $e->getMessage() . " at " . $e->getFile() . ":" . $e->getLine() . PHP_EOL; } finally { // 恢复订单 21 $order->status = $oldStatus; $order->remain_pay_fee = $oldRemainFee; $order->save(); echo "Order 21 restored to status: {$oldStatus}\n"; }