weigang 5 years ago
parent
commit
5587e759aa
  1. 26
      app/Controller/NotifyController.php

26
app/Controller/NotifyController.php

@ -82,6 +82,7 @@ class NotifyController extends BaseController
LogLabel::PAY_NOTIFY_WXMINI, LogLabel::PAY_NOTIFY_WXMINI,
$message $message
); );
Db::rollBack();
$fail('Unknown error but FAIL'); $fail('Unknown error but FAIL');
} }
@ -89,36 +90,17 @@ class NotifyController extends BaseController
$orderMain = OrderMain::query() $orderMain = OrderMain::query()
->where([ ->where([
'global_order_id' => $message['out_trade_no'], 'global_order_id' => $message['out_trade_no'],
'type' => OrderMain::ORDER_TYPE_ONLINE,
'state' => OrderMain::ORDER_STATE_UNPAY
'type' => OrderMain::ORDER_TYPE_ONLINE
]) ])
->where('time', '>=', date('Y-m-d H:i:s', (time() - 900)))
->first(); ->first();
var_dump('$orderMain', $orderMain); var_dump('$orderMain', $orderMain);
// 订单不存在 // 订单不存在
if (empty($orderMain)) { if (empty($orderMain)) {
$this->log->event( $this->log->event(
LogLabel::PAY_NOTIFY_WXMINI, LogLabel::PAY_NOTIFY_WXMINI,
$orderMain
['global_order_id_fail' => $message['out_trade_no']]
); );
// 去查一下微信订单,只处理未支付的情况 TODO 其他情况处理
$wxOrder = $app->order->queryByOutTradeNumber($message['out_trade_no']);
// 查询成功
if ($wxOrder['return_code'] == 'SUCCESS') {
if ($wxOrder['result_code'] == 'SUCCESS') {
// 看订单支付状态,处理未支付的情况,把订单处理成未支付
if ($wxOrder['trade_state'] != 'NOTPAY') {
OrderMain::query()
->where(['global_order_id' => $message['out_trade_no']])
->update(['state' => OrderMain::ORDER_STATE_UNPAY]);
$fail('Order not paid');
}
}
}
Db::rollBack();
return true; return true;
} }

Loading…
Cancel
Save