From 51308e7b249e2218c1f07abf2ce285e973add0b9 Mon Sep 17 00:00:00 2001 From: Anyon Date: Sat, 12 Dec 2020 19:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=AF=E4=BB=98=20openid?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/api/Auth.php | 2 ++ app/data/controller/api/auth/Order.php | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/data/controller/api/Auth.php b/app/data/controller/api/Auth.php index f89ba8314..2fef462cc 100644 --- a/app/data/controller/api/Auth.php +++ b/app/data/controller/api/Auth.php @@ -15,6 +15,8 @@ abstract class Auth extends Controller { /** * 当前接口类型 + * 小程序使用 wxapp + * 服务号使用 wechat * @var string */ protected $type; diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index c0c76c8e0..94f4638bc 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -193,7 +193,15 @@ class Order extends Auth if ($order['status'] != 2) $this->error('该订单不能发起支付哦!'); if ($order['payment_status']) $this->error('订单已经支付,不需要再次支付哦!'); try { - $params = PaymentService::build($data['payid'])->create($this->user['openid'], $order['order_no'], $order['amount_total'], '商城订单支付', ''); + $openid = ''; + if ($this->type === 'wxapp') { + $openid = $this->user['openid1']; + } elseif ($this->type === 'wechat') { + $openid = $this->user['openid2']; + } else { + $this->error("接口类型{$this->type}未绑定支付"); + } + $params = PaymentService::build($data['payid'])->create($openid, $order['order_no'], $order['amount_total'], '商城订单支付', ''); $this->success('获取支付参数成功!', $params); } catch (HttpResponseException $exception) { throw $exception;