更新
This commit is contained in:
@@ -75,6 +75,8 @@ class FirstVisitConversionLogic
|
||||
'end_date' => $endDate,
|
||||
'include_filters' => 0,
|
||||
'include_members' => 0,
|
||||
'exclude_cancelled_appointments' => 1,
|
||||
'order_metric_mode' => 'performance',
|
||||
'page_no' => 1,
|
||||
'page_size' => 100,
|
||||
];
|
||||
@@ -138,6 +140,8 @@ class FirstVisitConversionLogic
|
||||
'selected_dept_name' => $selectedDeptName,
|
||||
'selected_assistant_name' => $selectedAssistantName,
|
||||
'open_count_source' => '个人业绩录入',
|
||||
'appointment_rule' => '按预约日期统计,归属优先挂号医助、再回退诊单医助;仅含已预约、已完成和已过号',
|
||||
'performance_rule' => '按业务订单创建时间和创建人统计,排除取消、拒收、退款及已发生退款的订单',
|
||||
],
|
||||
'filters' => [
|
||||
'departments' => DeptLogic::getAllDataScoped($adminId, $adminInfo),
|
||||
@@ -318,6 +322,51 @@ class FirstVisitConversionLogic
|
||||
foreach ($deptRows as $deptRow) {
|
||||
$adminDeptMap[(int) $deptRow['admin_id']][] = (int) $deptRow['dept_id'];
|
||||
}
|
||||
$deptMetaRows = Db::name('dept')
|
||||
->whereNull('delete_time')
|
||||
->field('id, pid, sort')
|
||||
->select()
|
||||
->toArray();
|
||||
$deptMeta = [];
|
||||
foreach ($deptMetaRows as $deptMetaRow) {
|
||||
$deptId = (int) ($deptMetaRow['id'] ?? 0);
|
||||
if ($deptId > 0) {
|
||||
$deptMeta[$deptId] = [
|
||||
'pid' => (int) ($deptMetaRow['pid'] ?? 0),
|
||||
'sort' => (int) ($deptMetaRow['sort'] ?? 0),
|
||||
];
|
||||
}
|
||||
}
|
||||
$depthCache = [];
|
||||
$depthOf = static function (int $deptId) use (&$depthOf, &$depthCache, $deptMeta): int {
|
||||
if ($deptId <= 0 || !isset($deptMeta[$deptId])) {
|
||||
return 0;
|
||||
}
|
||||
if (isset($depthCache[$deptId])) {
|
||||
return $depthCache[$deptId];
|
||||
}
|
||||
$parentId = (int) ($deptMeta[$deptId]['pid'] ?? 0);
|
||||
if ($parentId <= 0 || $parentId === $deptId || !isset($deptMeta[$parentId])) {
|
||||
return $depthCache[$deptId] = 0;
|
||||
}
|
||||
|
||||
return $depthCache[$deptId] = $depthOf($parentId) + 1;
|
||||
};
|
||||
foreach ($adminDeptMap as &$deptIds) {
|
||||
usort($deptIds, static function (int $left, int $right) use ($depthOf, $deptMeta): int {
|
||||
$depthCompare = $depthOf($right) <=> $depthOf($left);
|
||||
if ($depthCompare !== 0) {
|
||||
return $depthCompare;
|
||||
}
|
||||
$sortCompare = (int) ($deptMeta[$right]['sort'] ?? 0) <=> (int) ($deptMeta[$left]['sort'] ?? 0);
|
||||
if ($sortCompare !== 0) {
|
||||
return $sortCompare;
|
||||
}
|
||||
|
||||
return $left <=> $right;
|
||||
});
|
||||
}
|
||||
unset($deptIds);
|
||||
|
||||
$direct = [];
|
||||
foreach ($rows as $row) {
|
||||
@@ -449,17 +498,14 @@ class FirstVisitConversionLogic
|
||||
if ($effectiveAdminIds !== []) {
|
||||
$actualQuery = Db::name('tcm_prescription_order')
|
||||
->alias('po')
|
||||
->leftJoin('tcm_prescription rx', 'rx.id = po.prescription_id')
|
||||
->whereNull('po.delete_time')
|
||||
->where('po.prescription_audit_status', 1)
|
||||
->where('po.payment_slip_audit_status', 1)
|
||||
->where('po.create_time', 'between', [
|
||||
strtotime($year . '-01-01 00:00:00'),
|
||||
strtotime($year . '-12-31 23:59:59'),
|
||||
]);
|
||||
YejiStatsLogic::applyPrescriptionOrderEffectiveAmountQuery($actualQuery, 'po');
|
||||
if ($effectiveAdminIds !== null) {
|
||||
$actualQuery->whereIn('rx.assistant_id', $effectiveAdminIds);
|
||||
$actualQuery->whereIn('po.creator_id', $effectiveAdminIds);
|
||||
}
|
||||
$actualRows = $actualQuery
|
||||
->fieldRaw("DATE_FORMAT(FROM_UNIXTIME(po.create_time), '%m') AS month_no, SUM(po.amount) AS actual_amount")
|
||||
|
||||
Reference in New Issue
Block a user