From 0270a2ca32316575930b0d92e12173b4a5241ecb Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 9 Sep 2022 17:03:30 +0800 Subject: [PATCH] zhifu --- app/controller/Wechat.php | 27 ++++++++++++++------------- app/model/Payment.php | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 app/model/Payment.php diff --git a/app/controller/Wechat.php b/app/controller/Wechat.php index 527bf2b..4d38887 100644 --- a/app/controller/Wechat.php +++ b/app/controller/Wechat.php @@ -3,6 +3,7 @@ namespace app\controller; use app\model\AppUser; +use app\model\Payment; use EasyWeChat\Factory; use EasyWeChat\OfficialAccount\Application; use think\facade\Config; @@ -93,26 +94,26 @@ class Wechat $order = \app\model\Order::find($orderId); - $notifyUrl = Route::buildUrl('wechat/paid') ->suffix(false) ->domain(true) ->build(); - dump($notifyUrl); - dump($order); - exit(); + + dump(Payment::create([ + 'order_id' => $order->id, + ])); $config = Config::get('wechat.payment'); $payment = Factory::payment($config); - $unify = $payment->order->unify([ - 'body' => '商品订单', - 'out_trade_no' => time(), - 'total_fee' => 100, - 'notify_url' => $notifyUrl, - 'trade_type' => 'JSAPI', - 'openid' => $user->openid, - ]); - dump($unify); +// $unify = $payment->order->unify([ +// 'body' => '商品订单', +// 'out_trade_no' => time(), +// 'total_fee' => 100, +// 'notify_url' => $notifyUrl, +// 'trade_type' => 'JSAPI', +// 'openid' => $user->openid, +// ]); +// dump($unify); // $prepayId = $unify->prepay_id; // $jssdk = $payment->jssdk->bridgeConfig($prepayId); // return View::fetch('', ['jssdk' => $jssdk]); diff --git a/app/model/Payment.php b/app/model/Payment.php new file mode 100644 index 0000000..0f0163f --- /dev/null +++ b/app/model/Payment.php @@ -0,0 +1,21 @@ +trade_no = time(); + } + + public function orders(): BelongsTo + { + return $this->belongsTo(Order::class); + } +} \ No newline at end of file