mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-06 04:28:27 +00:00
- Use chunkById() with default chunk size for batch processing; - Improve plan/package expiration and prepaid activation logic; - Refactor user–node permission update logic - Optimize OrderService state handling - Minor fixes (null handling, query order, comments)
40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\User;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Order;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class InvoiceController extends Controller
|
|
{
|
|
public function index(Request $request): View
|
|
{ // 订单列表
|
|
return view('user.invoices', [
|
|
'orderList' => auth()->user()->orders()->with(['goods', 'payment'])->orderByDesc('id')->paginate(10)->appends($request->except('page')),
|
|
'prepaidPlan' => Order::userPrepay()->exists(),
|
|
]);
|
|
}
|
|
|
|
public function show(string $sn): View
|
|
{ // 订单明细
|
|
return view('user.invoiceDetail', ['order' => Order::uid()->whereSn($sn)->with(['goods', 'coupon'])->firstOrFail()]);
|
|
}
|
|
|
|
public function activate(): JsonResponse
|
|
{ // 激活套餐
|
|
$activePlan = Order::userActivePlan()->first();
|
|
if ($activePlan && $activePlan->expired()) { // 关闭先前套餐后,新套餐自动运行
|
|
if (Order::userActivePlan()->exists()) {
|
|
return response()->json(['status' => 'success', 'message' => trans('common.active_item', ['attribute' => trans('common.success')])]);
|
|
}
|
|
|
|
return response()->json(['status' => 'success', 'message' => trans('common.close')]);
|
|
}
|
|
|
|
return response()->json(['status' => 'fail', 'message' => trans('common.failed_item', ['attribute' => trans('common.close')])]);
|
|
}
|
|
}
|