From 64ce01bb917be862c4ea8988975d4e22be337b82 Mon Sep 17 00:00:00 2001 From: lq Date: Tue, 12 Nov 2024 10:51:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/controllers/base/HomeController.php | 34 +++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/admin/controllers/base/HomeController.php b/admin/controllers/base/HomeController.php index 1057542..cbf360e 100644 --- a/admin/controllers/base/HomeController.php +++ b/admin/controllers/base/HomeController.php @@ -12,9 +12,11 @@ use common\models\Drug; use common\models\DrugStoreDrug; use common\models\DrugStoreRelations; use common\models\PrescripOrderRefund; +use common\models\Prescription; use common\models\ProductOrder; use common\models\ProductOrderRefund; use common\models\Reconciliation; +use common\models\Register; use common\models\Store; use common\services\PlatformService; use linslin\yii2\curl\Curl; @@ -38,14 +40,22 @@ class HomeController extends BaseAdminController $drugCount = Drug::find(); $inventoryWarning = DrugStoreDrug::find()->where(['<', 'stock', 100]); $inventoryWarningByStore = DrugStoreRelations::find()->where(['<', 'stock', 100]); + // 处方订单 + $prescriptionCount = Prescription::find()->where(['status' => 1]); + // 挂号人数 + $registerCount = Register::find()->where(['in', 'status', [2,3]]); return [ 'store' => intval($storeCount->count()), 'user' => intval($userCount->count()), 'order' => intval($orderCount->count()), 'drug' => intval($drugCount->count()), - 'total_price' => intval($totalPrice->sum('total_price')), + 'total_price' => round($totalPrice->sum('total_price'), 2), 'inventory_warning' => intval($inventoryWarning->count()), - 'inventory_warning_store' => intval($inventoryWarningByStore->count()) + 'inventory_warning_store' => intval($inventoryWarningByStore->count()), + 'register' => intval($registerCount->count()), + 'prescription' => intval($prescriptionCount->count()), + 'prescription_china' => intval($prescriptionCount->andWhere(['prescription_type' => 1])->count()), + 'prescription_west' => intval($prescriptionCount->andWhere(['prescription_type' => 2])->count()) ]; } @@ -61,7 +71,10 @@ class HomeController extends BaseAdminController $totalPrice = Reconciliation::find()->where(['status' => 1]); $inventoryWarning = DrugStoreRelations::find()->where(['<', 'stock', 100]); $drug = DrugStoreRelations::find(); - + // 处方订单 + $prescriptionCount = Prescription::find()->where(['status' => 1]); + // 挂号人数 + $registerCount = Register::find()->where(['in', 'status', [2,3]]); switch ($admin->role) { case UserRoleEnum::STORE_ADMIN: // 门店 @@ -96,12 +109,23 @@ class HomeController extends BaseAdminController $totalPrice->andWhere($where); $inventoryWarning->andWhere($where); $drug->where($where); + $registerCount->andWhere($where); + $prescriptionCount->andWhere($where); + } + $totalPriceArr = 0; + $totalPriceSum = $totalPrice->select(['total_price'])->asArray()->all(); + foreach ($totalPriceSum as $item) { + $totalPriceArr = bcadd($totalPriceArr, $item['total_price'], 2); } return [ 'order' => intval($orderCount->count()), - 'total_price' => intval($totalPrice->sum('total_price')), + 'total_price' => round($totalPriceArr, 2), 'inventory_warning' => intval($inventoryWarning->count()), - 'drug' => intval($drug->count()) + 'drug' => intval($drug->count()), + 'register' => intval($registerCount->count()), + 'prescription' => intval($prescriptionCount->count()), + 'prescription_china' => intval($prescriptionCount->andWhere(['prescription_type' => 1])->count()), + 'prescription_west' => intval($prescriptionCount->andWhere(['prescription_type' => 2])->count()) ]; }