You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.4 KiB
83 lines
2.4 KiB
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Constants\LogLabel;
|
|
use App\Model\OrderMain;
|
|
use EasyWeChat\Factory;
|
|
use Hyperf\Guzzle\CoroutineHandler;
|
|
|
|
class NotifyController extends BaseController
|
|
{
|
|
public function wxminiOnline()
|
|
{
|
|
$config = config('wxpay');
|
|
$app = Factory::payment($config);
|
|
$app['guzzle_handler'] = CoroutineHandler::class;
|
|
|
|
// 通知回调,进行业务处理
|
|
$response = $app->handlePaidNotify(function ($message, $fail) use ($app) {
|
|
|
|
$this->log->event(
|
|
LogLabel::PAY_NOTIFY_WXMINI,
|
|
$message
|
|
);
|
|
|
|
// 查询订单
|
|
$orderMain = OrderMain::query()
|
|
->where(['global_order_id' => $message['out_trade_no'], 'type' => OrderMain::ORDER_TYPE_ONLINE, 'state' => OrderMain::ORDER_STATE_UNPAY])
|
|
->where('time', '>=', date('Y-m-d H:i:s', (time()-900)))
|
|
->first();
|
|
|
|
if (empty($orderMain)) {
|
|
// 去查一下微信订单
|
|
$wxOrder = $app->order->queryByOutTradeNumber($orderMain->global_order_id);
|
|
|
|
$this->log->event(
|
|
LogLabel::PAY_NOTIFY_WXMINI,
|
|
$wxOrder
|
|
);
|
|
|
|
// return true;
|
|
}
|
|
});
|
|
|
|
$response->send();
|
|
}
|
|
|
|
public function wxminiOffline()
|
|
{
|
|
$config = config('wxpay');
|
|
$app = Factory::payment($config);
|
|
$app['guzzle_handler'] = CoroutineHandler::class;
|
|
|
|
// 通知回调,进行业务处理
|
|
$response = $app->handlePaidNotify(function ($message, $fail) use ($app) {
|
|
|
|
$this->log->event(
|
|
LogLabel::PAY_NOTIFY_WXMINI,
|
|
$message
|
|
);
|
|
|
|
// 查询订单
|
|
$orderMain = OrderMain::query()
|
|
->where(['global_order_id' => $message['out_trade_no'], 'type' => OrderMain::ORDER_TYPE_OFFLINE, 'state' => OrderMain::ORDER_STATE_UNPAY])
|
|
->where('time', '>=', date('Y-m-d H:i:s', (time()-900)))
|
|
->first();
|
|
|
|
if (empty($orderMain)) {
|
|
// 去查一下微信订单
|
|
$wxOrder = $app->order->queryByOutTradeNumber($orderMain->global_order_id);
|
|
|
|
$this->log->event(
|
|
LogLabel::PAY_NOTIFY_WXMINI,
|
|
$wxOrder
|
|
);
|
|
|
|
// return true;
|
|
}
|
|
});
|
|
|
|
$response->send();
|
|
}
|
|
}
|