weigang 5 years ago
parent
commit
49383d9ab5
  1. 20
      app/Controller/NotifyController.php

20
app/Controller/NotifyController.php

@ -20,6 +20,7 @@ use Hyperf\DbConnection\Db;
use Hyperf\Guzzle\CoroutineHandler; use Hyperf\Guzzle\CoroutineHandler;
use Exception; use Exception;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpMessage\Stream\SwooleStream;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
class NotifyController extends BaseController class NotifyController extends BaseController
@ -65,12 +66,10 @@ class NotifyController extends BaseController
$app['request'] = new Request($get,$post,[],$cookie,$files,$server,$xml); $app['request'] = new Request($get,$post,[],$cookie,$files,$server,$xml);
var_dump('inside');
// 通知回调,进行业务处理 // 通知回调,进行业务处理
$response = $app->handlePaidNotify(function ($message, $fail) use ($app) { $response = $app->handlePaidNotify(function ($message, $fail) use ($app) {
Db::beginTransaction(); Db::beginTransaction();
try { try {
var_dump('message', $message);
// 支付失败或者通知失败 // 支付失败或者通知失败
if ( if (
empty($message) empty($message)
@ -93,7 +92,7 @@ class NotifyController extends BaseController
'type' => OrderMain::ORDER_TYPE_ONLINE 'type' => OrderMain::ORDER_TYPE_ONLINE
]) ])
->first(); ->first();
var_dump('$orderMain', $orderMain);
// 订单不存在 // 订单不存在
if (empty($orderMain)) { if (empty($orderMain)) {
$this->log->event( $this->log->event(
@ -166,31 +165,34 @@ class NotifyController extends BaseController
// 喇叭通知,兼容旧音响,MQTT+IOT // 喇叭通知,兼容旧音响,MQTT+IOT
$res = $this->mqttSpeakerService->speakToStore($orderMain->id); $res = $this->mqttSpeakerService->speakToStore($orderMain->id);
var_dump('speakToStore',$res);
$res = $this->deviceService->pubMsgToStoreByOrderMainId($orderMain->id); $res = $this->deviceService->pubMsgToStoreByOrderMainId($orderMain->id);
var_dump('pubMsgToStoreByOrderMainId',$res);
// 公众号模板消息 // 公众号模板消息
// $res = $this->miniprogramService->sendTemMsgForOnlineOrder($orderMain->id); // $res = $this->miniprogramService->sendTemMsgForOnlineOrder($orderMain->id);
// var_dump('sendTemMsgForOnlineOrder',$res);
// 打印订单,自动打印 TODO 后续优化调用逻辑 // 打印订单,自动打印 TODO 后续优化调用逻辑
$res = $this->feiePrintService->feiePrint($orderMain->global_order_id); $res = $this->feiePrintService->feiePrint($orderMain->global_order_id);
var_dump('feiePrint',$res);
Db::commit(); Db::commit();
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
var_dump($e->getMessage());
$this->log->event(
LogLabel::PAY_NOTIFY_WXMINI,
['exception_fail' => $e->getMessage()]
);
Db::rollBack(); Db::rollBack();
$fail('Exception'); $fail('Exception');
} }
}); });
$response->send();
var_dump('reponse',$response->getContent());
return $this->response
->withHeader('Content-Type', 'application/xml')
->withStatus(200)
->withBody(new SwooleStream($response->getContent()));
} }

Loading…
Cancel
Save