mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 19:40:53 +08:00
fix: resolve PHPStan static analysis warnings
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user