From e90ceaac250b31e6211515ef49b84f60dc701612 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 15 Dec 2020 10:24:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E9=80=9A=E9=81=93=EF=BC=88wap,web,wxapp,wechat,ios,an?= =?UTF-8?q?droid=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/api/auth/Order.php | 6 +++++- app/data/service/UserService.php | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index 20eeb40df..46fcfb09e 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -195,7 +195,11 @@ class Order extends Auth if ($order['status'] != 2) $this->error('订单不能发起支付哦!'); if ($order['payment_status'] > 0) $this->error('订单已经完成支付!'); try { - $openid = $this->user[UserService::TYPES[$this->type]['auth']] ?? ''; + $openid = ''; + if (in_array($this->type, [UserService::APITYPE_WXAPP, UserService::APITYPE_WECHAT])) { + $openid = $this->user[UserService::TYPES[$this->type]['auth']] ?? ''; + if (empty($openid)) $this->error("无法创建支付,未获取到OPENID"); + } $params = PaymentService::build($data['payid'])->create($openid, $order['order_no'], $order['amount_total'], '商城订单支付', '', $data['back']); $this->success('获取支付参数成功!', $params); } catch (HttpResponseException $exception) { diff --git a/app/data/service/UserService.php b/app/data/service/UserService.php index a24c64097..7dc490bcd 100644 --- a/app/data/service/UserService.php +++ b/app/data/service/UserService.php @@ -21,11 +21,19 @@ class UserService extends Service const TYPES = [ UserService::APITYPE_WAP => [ 'name' => '手机浏览器', - 'auth' => '', + 'auth' => 'phone', ], UserService::APITYPE_WEB => [ 'name' => '电脑浏览器', - 'auth' => '', + 'auth' => 'phone', + ], + UserService::APITYPE_IOSAPP => [ + 'name' => '苹果应用', + 'auth' => 'phone', + ], + UserService::APITYPE_ANDROID => [ + 'name' => '安卓应用', + 'auth' => 'phone', ], UserService::APITYPE_WXAPP => [ 'name' => '微信小程序', @@ -35,14 +43,6 @@ class UserService extends Service 'name' => '微信服务号', 'auth' => 'openid2', ], - UserService::APITYPE_ANDROID => [ - 'name' => '安卓应用', - 'auth' => '', - ], - UserService::APITYPE_IOSAPP => [ - 'name' => '苹果应用', - 'auth' => '', - ], ]; /**