更新
This commit is contained in:
@@ -65,9 +65,18 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
$effectiveAmountQuery = clone $query;
|
||||
YejiStatsLogic::applyPrescriptionOrderEffectiveAmountQuery($effectiveAmountQuery, 'po');
|
||||
|
||||
// 拒收指标保留关键词、审核和日期条件,但不受当前履约状态按钮影响,
|
||||
// 避免点击“拒收订单”后分母被收窄为拒收状态而固定显示 100%。
|
||||
$rejectionScopeQuery = $this->buildQuery(true);
|
||||
$rejectionScopeOrderCount = (int) (clone $rejectionScopeQuery)->count('po.id');
|
||||
$rejectedCount = (int) (clone $rejectionScopeQuery)
|
||||
->where('po.fulfillment_status', 9)
|
||||
->count('po.id');
|
||||
$orderCount = (int) (clone $query)->count('po.id');
|
||||
|
||||
return [
|
||||
'summary' => [
|
||||
'orders' => (int) (clone $query)->count('po.id'),
|
||||
'orders' => $orderCount,
|
||||
'amount' => round((float) $effectiveAmountQuery->sum('po.amount'), 2),
|
||||
'pending' => (int) $pendingQuery
|
||||
->where(function ($q) {
|
||||
@@ -76,12 +85,16 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
})
|
||||
->count('po.id'),
|
||||
'completed' => (int) (clone $query)->whereIn('po.fulfillment_status', [3, 6])->count('po.id'),
|
||||
'rejected' => $rejectedCount,
|
||||
'rejection_rate' => $rejectionScopeOrderCount > 0
|
||||
? round($rejectedCount / $rejectionScopeOrderCount * 100, 2)
|
||||
: 0.0,
|
||||
],
|
||||
'scope' => MyPatientLogic::scopeMeta($this->adminId, $this->adminInfo),
|
||||
];
|
||||
}
|
||||
|
||||
private function buildQuery(): Query
|
||||
private function buildQuery(bool $ignoreFulfillmentStatus = false): Query
|
||||
{
|
||||
$query = PrescriptionOrder::alias('po')
|
||||
->join('tcm_diagnosis d', 'po.diagnosis_id = d.id')
|
||||
@@ -91,7 +104,7 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
|
||||
MyPatientLogic::applyScope($query, $this->adminId, $this->adminInfo);
|
||||
$this->applyKeyword($query);
|
||||
$this->applyStatusFilters($query);
|
||||
$this->applyStatusFilters($query, $ignoreFulfillmentStatus);
|
||||
$this->applyDateFilter($query);
|
||||
|
||||
return $query;
|
||||
@@ -122,9 +135,12 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
});
|
||||
}
|
||||
|
||||
private function applyStatusFilters(Query $query): void
|
||||
private function applyStatusFilters(Query $query, bool $ignoreFulfillmentStatus = false): void
|
||||
{
|
||||
foreach (['prescription_audit_status', 'payment_slip_audit_status', 'fulfillment_status'] as $field) {
|
||||
if ($ignoreFulfillmentStatus && $field === 'fulfillment_status') {
|
||||
continue;
|
||||
}
|
||||
$raw = $this->params[$field] ?? '';
|
||||
if ($raw === '' || $raw === null) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user