zhifu
This commit is contained in:
@@ -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]);
|
||||
|
||||
21
app/model/Payment.php
Normal file
21
app/model/Payment.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use think\Model;
|
||||
use think\model\relation\BelongsTo;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
protected $autoWriteTimestamp = true;
|
||||
|
||||
public function onBeforeInsert()
|
||||
{
|
||||
$this->trade_no = time();
|
||||
}
|
||||
|
||||
public function orders(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user