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