fix: resolve PHPStan static analysis warnings

This commit is contained in:
xboard
2025-04-14 02:12:42 +08:00
parent 3d254c02c1
commit 2d3e4b4a95
84 changed files with 2330 additions and 1190 deletions

View File

@@ -43,16 +43,15 @@ class OrderController extends Controller
$request->validate([
'trade_no' => 'required|string',
]);
$order = Order::with('payment')
$order = Order::with(['payment','plan'])
->where('user_id', $request->user()->id)
->where('trade_no', $request->input('trade_no'))
->first();
if (!$order) {
return $this->fail([400, __('Order does not exist or has been paid')]);
}
$order['plan'] = Plan::find($order->plan_id);
$order['try_out_plan_id'] = (int) admin_setting('try_out_plan_id');
if (!$order['plan']) {
if (!$order->plan) {
return $this->fail([400, __('Subscription plan does not exist')]);
}
if ($order->surplus_order_ids) {
@@ -81,7 +80,7 @@ class OrderController extends Controller
// Validate plan purchase
$planService->validatePurchase($user, $request->input('period'));
return DB::transaction(function () use ($request, $plan, $user, $userService, $planService) {
return DB::transaction(function () use ($request, $plan, $user, $userService) {
$period = $request->input('period');
$newPeriod = PlanService::getPeriodKey($period);
@@ -169,12 +168,13 @@ class OrderController extends Controller
]);
}
$payment = Payment::find($method);
if (!$payment || $payment->enable !== 1)
if (!$payment || !$payment->enable) {
return $this->fail([400, __('Payment method is not available')]);
}
$paymentService = new PaymentService($payment->payment, $payment->id);
$order->handling_amount = NULL;
if ($payment->handling_fee_fixed || $payment->handling_fee_percent) {
$order->handling_amount = round(($order->total_amount * ($payment->handling_fee_percent / 100)) + $payment->handling_fee_fixed);
$order->handling_amount = (int) round(($order->total_amount * ($payment->handling_fee_percent / 100)) + $payment->handling_fee_fixed);
}
$order->payment_id = $method;
if (!$order->save())