feat: 微客宝H5客户端 - 基础架构+核心页面
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Client;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\Finance\AccountTransaction;
|
||||
use App\Models\Finance\CustomerAccount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
/**
|
||||
* 我的账户列表
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
/** @var Customer $customer */
|
||||
$customer = $request->user();
|
||||
|
||||
$accounts = CustomerAccount::withoutGlobalScope('store')
|
||||
->where('customer_id', $customer->id)
|
||||
->get();
|
||||
|
||||
return $this->success($accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户流水记录(分页)
|
||||
*/
|
||||
public function transactions(Request $request): JsonResponse
|
||||
{
|
||||
/** @var Customer $customer */
|
||||
$customer = $request->user();
|
||||
|
||||
$query = AccountTransaction::withoutGlobalScope('store')
|
||||
->whereHas('account', fn ($q) => $q->where('customer_id', $customer->id));
|
||||
|
||||
if ($request->filled('account_id')) {
|
||||
$query->where('customer_account_id', (int) $request->input('account_id'));
|
||||
}
|
||||
|
||||
return $this->paginate(
|
||||
$query->orderByDesc('id')->paginate(20)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user