efps-version
ljl 1 year ago
parent c4c5bf3b2e
commit 615a966aa5

@ -61,6 +61,11 @@ class PayController extends AbstractController
return $this->success($data); return $this->success($data);
} }
public function query(RequestInterface $request) {
$data = $this->paymentService->query($request->all());
return $this->success($data);
}
public function payment(RequestInterface $request) { public function payment(RequestInterface $request) {
$data = $this->paymentService->payment($request->all()); $data = $this->paymentService->payment($request->all());
return $this->success($data); return $this->success($data);

@ -363,4 +363,34 @@ class PaymentService extends AbstractService
return ['payUrl' => 'http://146.70.113.165:9501/payment.html?token=' . $token]; return ['payUrl' => 'http://146.70.113.165:9501/payment.html?token=' . $token];
} }
public function query($params)
{
$req = new PaymentQueryRequest($params);
$data = $req->getData();
$app = $req->getApp();
if (empty($data['outOrderNo'])) {
throw new BusinessException('订单号不能为空');
}
$order = Order::where('app_id', $app->app_id)->where('out_order_no', $data['outOrderNo'])->first();
if ($order) {
throw new BusinessException('订单不存在');
}
$result = Api::paymentQuery(['outTradeNo' => $order->order_no]);
if (!$result->isSuccess()) {
throw new BusinessException($result->getMessage());
}
$this->handlePayResult($result, $order);
return [
'outOrderNo' => $data['outOrderNo'],
'orderNo' => $order->order_no,
'payState' => $result->get('payState'),
'amount' => $result->get('amount'),
];
}
} }

@ -21,6 +21,7 @@ Router::addGroup('/payment',function () {
Router::post('/protocol-pay-confirm', [PayController::class, 'protocolPayConfirm']); Router::post('/protocol-pay-confirm', [PayController::class, 'protocolPayConfirm']);
Router::post('/refund-query', [PayController::class, 'refundQuery']); Router::post('/refund-query', [PayController::class, 'refundQuery']);
Router::post('/payment-query', [PayController::class, 'paymentQuery']); Router::post('/payment-query', [PayController::class, 'paymentQuery']);
Router::post('/query', [PayController::class, 'query']);
Router::post('/pay', [PayController::class, 'payment']); Router::post('/pay', [PayController::class, 'payment']);
}, ['middleware' => [\App\Middleware\RequestLogMiddleware::class]]); }, ['middleware' => [\App\Middleware\RequestLogMiddleware::class]]);

Loading…
Cancel
Save