|
|
@ -4,19 +4,24 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Controller\Payment;
|
|
|
|
namespace App\Controller\Payment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\Helper\Efps\Result;
|
|
|
|
use App\Helper\Efps\Signer;
|
|
|
|
use App\Helper\Efps\Signer;
|
|
|
|
use App\Helper\Log;
|
|
|
|
use App\Helper\Log;
|
|
|
|
use App\Helper\Platform\Notification;
|
|
|
|
use App\Helper\Platform\Notification;
|
|
|
|
use App\Model\App;
|
|
|
|
use App\Model\App;
|
|
|
|
use App\Model\Order;
|
|
|
|
use App\Model\Order;
|
|
|
|
use App\Model\RefundOrder;
|
|
|
|
use App\Model\RefundOrder;
|
|
|
|
|
|
|
|
use App\Service\PaymentService;
|
|
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
|
|
|
|
|
|
|
|
class NotifyController extends AbstractController
|
|
|
|
class NotifyController extends AbstractController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
private PaymentService $paymentService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(PaymentService $paymentService)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->paymentService = $paymentService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function payment(RequestInterface $request)
|
|
|
|
public function payment(RequestInterface $request)
|
|
|
@ -56,20 +61,10 @@ class NotifyController extends AbstractController
|
|
|
|
];
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($params['payState'] === '00') {
|
|
|
|
$params['returnCode'] = '0000';
|
|
|
|
$order->status = Order::STATUS_PAYED;
|
|
|
|
$params['returnMsg'] = '成功';
|
|
|
|
$order->fee = $params['procedureFee'] ?: 0;
|
|
|
|
$result = new Result($params);
|
|
|
|
$order->pay_order_no = $params['transactionNo'] ?: '';
|
|
|
|
$this->paymentService->handlePayResult($result, $order);
|
|
|
|
$order->channel_order_no = $params['channelOrder'] ?: '';
|
|
|
|
|
|
|
|
$order->payed_at = date('Y-m-d H:i:s');
|
|
|
|
|
|
|
|
$order->save();
|
|
|
|
|
|
|
|
} elseif ($params['payState'] === '01') {
|
|
|
|
|
|
|
|
$order->status = Order::STATUS_FAILED;
|
|
|
|
|
|
|
|
$order->error_code = '01';
|
|
|
|
|
|
|
|
$order->error_msg = '处理失败';
|
|
|
|
|
|
|
|
$order->payed_at = date('Y-m-d H:i:s');
|
|
|
|
|
|
|
|
$order->save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->notify($order->notify_url, $app, [
|
|
|
|
$result = $this->notify($order->notify_url, $app, [
|
|
|
|
'outTradeNo' => $params['outTradeNo'] ?: '',
|
|
|
|
'outTradeNo' => $params['outTradeNo'] ?: '',
|
|
|
@ -121,23 +116,18 @@ class NotifyController extends AbstractController
|
|
|
|
'returnMsg' => '处理成功'
|
|
|
|
'returnMsg' => '处理成功'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($params['payState'] === '00') {
|
|
|
|
|
|
|
|
$order->status = RefundOrder::STATUS_REFUND_SUCCESS;
|
|
|
|
$params['returnCode'] = '0000';
|
|
|
|
$order->fee = $params['procedureFee'] ?: 0;
|
|
|
|
$params['returnMsg'] = '成功';
|
|
|
|
$order->refunded_at = date('Y-m-d H:i:s');
|
|
|
|
$refundState = $params['refundState'] ?? null;
|
|
|
|
$order->save();
|
|
|
|
$refundState = is_null($refundState) ? ($params['payState'] ?? null) : $refundState;
|
|
|
|
} elseif ($params['payState'] === '01') {
|
|
|
|
$result = new Result($params);
|
|
|
|
$order->status = RefundOrder::STATUS_REFUND_FAILED;
|
|
|
|
$this->paymentService->handleRefundResult($result, $order);
|
|
|
|
$order->error_code = '01';
|
|
|
|
|
|
|
|
$order->error_msg = '处理失败';
|
|
|
|
|
|
|
|
$order->refunded_at = date('Y-m-d H:i:s');
|
|
|
|
|
|
|
|
$order->save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->notify($order->notify_url, $app, [
|
|
|
|
$result = $this->notify($order->notify_url, $app, [
|
|
|
|
'outRefundNo' => $params['outRefundNo'] ?: '',
|
|
|
|
'outRefundNo' => $params['outRefundNo'] ?: '',
|
|
|
|
'transactionNo' => $params['transactionNo'] ?: '',
|
|
|
|
'transactionNo' => $params['transactionNo'] ?: '',
|
|
|
|
'payState' => $params['payState'],
|
|
|
|
'payState' => $refundState,
|
|
|
|
'amount' => $params['amount'] ?: 0,
|
|
|
|
'amount' => $params['amount'] ?: 0,
|
|
|
|
'refundAmount' => $params['refundAmount'] ?: 0,
|
|
|
|
'refundAmount' => $params['refundAmount'] ?: 0,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|