更新
This commit is contained in:
@@ -11,6 +11,7 @@ use app\common\model\dict\DictData;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\lists\Traits\HasDataScopeFilter;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 医生预约列表
|
||||
@@ -74,6 +75,46 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 渠道筛选:与 AppointmentLogic 一致,兼容仅有 channel_source、仅有 channels、或两者皆有的表结构
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
private function applyChannelSourceFilter($query, string $chFilter): void
|
||||
{
|
||||
if ($chFilter === '') {
|
||||
return;
|
||||
}
|
||||
$tblFields = Db::name('doctor_appointment')->getTableFields();
|
||||
$cols = \is_array($tblFields) ? $tblFields : [];
|
||||
$hasChannelSource = \in_array('channel_source', $cols, true);
|
||||
$hasChannels = \in_array('channels', $cols, true);
|
||||
if (!$hasChannelSource && !$hasChannels) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query->where(function ($q) use ($chFilter, $hasChannelSource, $hasChannels): void {
|
||||
if ($hasChannelSource && $hasChannels) {
|
||||
$q->where('a.channel_source', '=', $chFilter)
|
||||
->whereOr('a.channels', '=', $chFilter);
|
||||
if (is_numeric($chFilter)) {
|
||||
$q->whereOr('a.channels', '=', (int) $chFilter);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if ($hasChannelSource) {
|
||||
$q->where('a.channel_source', '=', $chFilter);
|
||||
|
||||
return;
|
||||
}
|
||||
$q->where('a.channels', '=', $chFilter);
|
||||
if (is_numeric($chFilter)) {
|
||||
$q->whereOr('a.channels', '=', (int) $chFilter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return array
|
||||
@@ -107,6 +148,9 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
$this->searchWhere[] = ['a.status', '=', $this->params['status']];
|
||||
}
|
||||
|
||||
// 渠道字典 value(命中 channel_source 或 legacy channels)
|
||||
$chFilter = isset($this->params['channel_source']) ? trim((string) $this->params['channel_source']) : '';
|
||||
|
||||
// 处理日期范围搜索
|
||||
if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', 'between', [$this->params['start_date'], $this->params['end_date']]];
|
||||
@@ -147,6 +191,8 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
|
||||
$this->applyAssistantIdFilter($query);
|
||||
|
||||
$this->applyChannelSourceFilter($query, $chFilter);
|
||||
|
||||
// 是否确认诊单:1=已确认 0=未确认
|
||||
if (isset($this->params['diagnosis_confirmed']) && $this->params['diagnosis_confirmed'] !== '') {
|
||||
$confirmed = (int)$this->params['diagnosis_confirmed'];
|
||||
@@ -308,6 +354,7 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
if ($applyStatusFilter && isset($this->params['status']) && $this->params['status'] !== '') {
|
||||
$query->where('a.status', '=', $this->params['status']);
|
||||
}
|
||||
$chFilter = isset($this->params['channel_source']) ? trim((string) $this->params['channel_source']) : '';
|
||||
if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) {
|
||||
$query->whereBetween('a.appointment_date', [$this->params['start_date'], $this->params['end_date']]);
|
||||
} elseif (!empty($this->params['start_date'])) {
|
||||
@@ -326,6 +373,8 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
|
||||
$this->applyAssistantIdFilter($query);
|
||||
|
||||
$this->applyChannelSourceFilter($query, $chFilter);
|
||||
|
||||
if ((int) ($this->params['exclude_cancelled'] ?? 0) === 1) {
|
||||
$sf = $this->params['status'] ?? '';
|
||||
if ($sf === '' || (int) $sf !== 2) {
|
||||
|
||||
@@ -104,6 +104,7 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
$this->applyPatientIdFilter($query);
|
||||
$this->applyExpressCompanyFilter($query);
|
||||
$this->applyExpressKeywordFilter($query);
|
||||
$this->applyServiceChannelFilter($query);
|
||||
$this->applySupplyModeFilter($query);
|
||||
if (!$this->shouldBypassListVisibilityForDiagnosisEdit()) {
|
||||
$this->applyCreatorOrOwnPrescriptionVisibility($query);
|
||||
@@ -200,6 +201,24 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
$query->whereRaw("(($po) OR ($et))");
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务渠道:未指派传 service_channel=0 时命中「空串」或「0」(varchar)
|
||||
*/
|
||||
private function applyServiceChannelFilter(Query $query): void
|
||||
{
|
||||
$raw = $this->params['service_channel'] ?? '';
|
||||
if ($raw === '' || $raw === null) {
|
||||
return;
|
||||
}
|
||||
$v = trim((string) $raw);
|
||||
if ($v === '0') {
|
||||
$query->whereRaw("(TRIM(IFNULL(`service_channel`,'')) = '' OR `service_channel` = '0')");
|
||||
|
||||
return;
|
||||
}
|
||||
$query->where('service_channel', '=', $v);
|
||||
}
|
||||
|
||||
/**
|
||||
* 供货方式:甘草(已上传甘草药方单号)/ 自营(无甘草单号,走药房直发等)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user