首页统计修改
This commit is contained in:
@@ -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())
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user