mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-15 04:10:51 +08:00
Revert "fix: resolve PHPStan static analysis warnings"
This reverts commit 2d3e4b4a95.
This commit is contained in:
@@ -15,7 +15,6 @@ use App\Utils\Helper;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
@@ -28,7 +27,7 @@ class OrderController extends Controller
|
||||
if ($order->surplus_order_ids) {
|
||||
$order['surplus_orders'] = Order::whereIn('id', $order->surplus_order_ids)->get();
|
||||
}
|
||||
$order['period'] = PlanService::getLegacyPeriod((string) $order->period);
|
||||
$order['period'] = PlanService::getLegacyPeriod($order->period);
|
||||
return $this->success($order);
|
||||
}
|
||||
|
||||
@@ -46,21 +45,17 @@ class OrderController extends Controller
|
||||
|
||||
$this->applyFiltersAndSorts($request, $orderModel);
|
||||
|
||||
/** @var \Illuminate\Pagination\LengthAwarePaginator $paginatedResults */
|
||||
$paginatedResults = $orderModel
|
||||
->latest('created_at')
|
||||
->paginate(
|
||||
perPage: $pageSize,
|
||||
page: $current
|
||||
);
|
||||
|
||||
$paginatedResults->getCollection()->transform(function($order) {
|
||||
$orderArray = $order->toArray();
|
||||
$orderArray['period'] = PlanService::getLegacyPeriod((string) $order->period);
|
||||
return $orderArray;
|
||||
});
|
||||
|
||||
return response()->json($paginatedResults);
|
||||
return response()->json(
|
||||
$orderModel
|
||||
->latest('created_at')
|
||||
->paginate(
|
||||
perPage: $pageSize,
|
||||
page: $current
|
||||
)->through(fn($order) => [
|
||||
...$order->toArray(),
|
||||
'period' => PlanService::getLegacyPeriod($order->period)
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
private function applyFiltersAndSorts(Request $request, Builder $builder): void
|
||||
@@ -117,8 +112,8 @@ class OrderController extends Controller
|
||||
'lte' => '<=',
|
||||
'like' => 'like',
|
||||
'notlike' => 'not like',
|
||||
'null' => static fn($q) => $q->whereNull($field),
|
||||
'notnull' => static fn($q) => $q->whereNotNull($field),
|
||||
'null' => static fn($q) => $q->whereNull($queryField),
|
||||
'notnull' => static fn($q) => $q->whereNotNull($queryField),
|
||||
default => 'like'
|
||||
}, match (strtolower($operator)) {
|
||||
'like', 'notlike' => "%{$filterValue}%",
|
||||
@@ -189,7 +184,7 @@ class OrderController extends Controller
|
||||
try {
|
||||
$order->update($params);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e);
|
||||
\Log::error($e);
|
||||
return $this->fail([500, '更新失败']);
|
||||
}
|
||||
|
||||
@@ -220,12 +215,11 @@ class OrderController extends Controller
|
||||
$orderService = new OrderService($order);
|
||||
$order->user_id = $user->id;
|
||||
$order->plan_id = $plan->id;
|
||||
$period = $request->input('period');
|
||||
$order->period = (int) PlanService::getPeriodKey((string) $period);
|
||||
$order->period = PlanService::getPeriodKey($request->input('period'));
|
||||
$order->trade_no = Helper::guid();
|
||||
$order->total_amount = $request->input('total_amount');
|
||||
|
||||
if (PlanService::getPeriodKey((string) $order->period) === Plan::PERIOD_RESET_TRAFFIC) {
|
||||
if (PlanService::getPeriodKey($order->period) === Plan::PERIOD_RESET_TRAFFIC) {
|
||||
$order->type = Order::TYPE_RESET_TRAFFIC;
|
||||
} else if ($user->plan_id !== NULL && $order->plan_id !== $user->plan_id) {
|
||||
$order->type = Order::TYPE_UPGRADE;
|
||||
|
||||
Reference in New Issue
Block a user