From a15297de9243cc9fb5a7f6dd2cd5491596fcba24 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 9 Sep 2022 14:46:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=BB=E8=BE=91=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Wechat.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controller/Wechat.php b/app/controller/Wechat.php index 56f9b8b..e583cd3 100644 --- a/app/controller/Wechat.php +++ b/app/controller/Wechat.php @@ -58,7 +58,7 @@ class Wechat $user = AppUser::where('openid', $user->getId())->find(); - if (!$user) { + if (! $user) { $user = AppUser::create([ 'nickname' => $user->getNickname(), 'avatar' => $user->getAvatar(), @@ -80,6 +80,13 @@ class Wechat */ public function payment() { + $userId = $GLOBALS['data']['userid']; + if (empty($userId)) { + return show("未登录!", NEED_LOGIN); + } + + $user = AppUser::find($userId); + $notifyUrl = Route::buildUrl('wechat/paid') ->suffix(false) ->domain(true); @@ -91,7 +98,7 @@ class Wechat 'total_fee' => 100, 'notify_url' => $notifyUrl, 'trade_type' => 'JSAPI', - 'openid' => '$openid', + 'openid' => $user->openid, ]); dump($unify); // $prepayId = $unify->prepay_id;