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;