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' => '', - ], ]; /**