新增功能
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\lists;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\Fan;
|
||||
use app\common\model\FanVisitRecord;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
class FanLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['name', 'phone'],
|
||||
'=' => ['gender', 'status'],
|
||||
];
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Fan::where($this->searchWhere)
|
||||
->field(['id', 'name', 'phone', 'id_card', 'age', 'gender', 'remark', 'creator_id', 'creator_name', 'status', 'create_time', 'update_time'])
|
||||
->append(['gender_desc', 'status_desc'])
|
||||
->order(['id' => 'desc'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$fanIds = array_column($lists, 'id');
|
||||
if (!empty($fanIds)) {
|
||||
$visitCounts = FanVisitRecord::where('fan_id', 'in', $fanIds)
|
||||
->where('delete_time', null)
|
||||
->group('fan_id')
|
||||
->column('count(*) as cnt', 'fan_id');
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['visit_count'] = $visitCounts[$item['id']] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Fan::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
}
|
||||
|
||||
$lists = $query
|
||||
->with(['DiagnosisViewRecord'])
|
||||
->field(['id', 'patient_id', 'patient_name', 'id_card', 'phone', 'gender', 'age', 'diagnosis_date', 'diagnosis_type', 'syndrome_type', 'assistant_id', 'status', 'create_time', 'update_time'])
|
||||
->append(['gender_desc', 'status_desc', 'diagnosis_date_text'])
|
||||
->order(['id' => 'desc'])
|
||||
|
||||
Reference in New Issue
Block a user