调整接口授权通道(wap,web,wxapp,wechat,ios,android)

This commit is contained in:
Anyon 2020-12-15 10:24:38 +08:00
parent 40e2e6f0b3
commit e90ceaac25
2 changed files with 15 additions and 11 deletions

View File

@ -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) {

View File

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