feat: 微客宝H5客户端 - 基础架构+核心页面

This commit is contained in:
li
2026-03-14 19:44:03 +08:00
parent 54d2f617bb
commit 0e974da09c
3738 changed files with 811180 additions and 21 deletions
@@ -0,0 +1,90 @@
<?php
namespace App\Http\Controllers\Client;
use App\Http\Controllers\Controller;
use App\Models\Care\CareProfile;
use App\Models\Care\CareRecord;
use App\Models\Care\HealthMetric;
use App\Models\Crm\Customer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CareController extends Controller
{
/**
* 获取当前客户护理档案
*/
public function profile(Request $request): JsonResponse
{
/** @var Customer $customer */
$customer = $request->user();
$profile = CareProfile::withoutGlobalScope('store')
->where('customer_id', $customer->id)
->first();
if ($profile) {
$profile->load(['plans']);
}
return $this->success($profile);
}
/**
* 护理记录列表(分页)
*/
public function records(Request $request): JsonResponse
{
/** @var Customer $customer */
$customer = $request->user();
$profile = CareProfile::withoutGlobalScope('store')
->where('customer_id', $customer->id)
->first();
if (!$profile) {
return $this->paginate(
CareRecord::withoutGlobalScope('store')->whereRaw('0=1')->paginate(10)
);
}
$query = CareRecord::withoutGlobalScope('store')
->where('care_profile_id', $profile->id)
->with('nurse:id,name');
if ($request->filled('type')) {
$query->where('type', (int) $request->input('type'));
}
return $this->paginate($query->latest('recorded_at')->paginate(10));
}
/**
* 健康指标列表(最近30条)
*/
public function metrics(Request $request): JsonResponse
{
/** @var Customer $customer */
$customer = $request->user();
$profile = CareProfile::withoutGlobalScope('store')
->where('customer_id', $customer->id)
->first();
if (!$profile) {
return $this->success([]);
}
$query = HealthMetric::withoutGlobalScope('store')
->where('care_profile_id', $profile->id);
if ($request->filled('metric_type')) {
$query->where('metric_type', $request->input('metric_type'));
}
$list = $query->orderByDesc('measured_at')->limit(30)->get();
return $this->success($list);
}
}