大屏数据

This commit is contained in:
2025-01-02 16:16:40 +08:00
parent 89a8ef6662
commit b1dec5d35b

View File

@@ -22,7 +22,7 @@ class DataController extends BaseAdminController
* 获取首页统计数据
* @return array
*/
public function actionCount()
public function actionCount(): array
{
// 诊所
$storeCount = Store::find()->where(['is_delete' => 0]);
@@ -56,9 +56,8 @@ class DataController extends BaseAdminController
/**
* 获取销售量Top10的药品
* @return array|ActiveRecord[]
* @throws Exception
*/
public function actionTopDrugs()
public function actionTopDrugs(): array
{
// 通过yii_reconciliation表统计出前10的药品
$query = Reconciliation::find()
@@ -78,18 +77,22 @@ class DataController extends BaseAdminController
return $list;
}
public function actionTrend()
/**
* 获取趋势图数据
* @return array
*/
public function actionTrend(): array
{
// 根据$month列表的月份统计数据
$query = Reconciliation::find()->where(['between', 'created_at', strtotime(date('Y-01-01')), strtotime(date('Y-m-d 23:59:59'))])->select([
$query = Reconciliation::find()->where(['between', 'created_at', strtotime(date('Y-01-01'), '-11 month'), strtotime(date('Y-m-d 23:59:59'))])->select([
'drug_type',
'total_price',
'status',
'created_at',
])->all();
$month = $this->getMonthsList(strtotime(date('Y-01-01')), strtotime(date('Y-m-d')));
$month = $this->getMonthsList(strtotime(date('Y-01-01'), '-11 month'), strtotime(date('Y-m-d')));
$saleMoney = [];
$refundMoney = [];
$drugSaleMoney = [
@@ -152,7 +155,11 @@ class DataController extends BaseAdminController
];
}
public function actionStoreNumber()
/**
* 获取门店数量
* @return array
*/
public function actionStoreNumber(): array
{
$provinceId = 14;
$storeCount = Store::find()
@@ -186,7 +193,7 @@ class DataController extends BaseAdminController
* @param $endTime
* @return array
*/
public function getMonthsList($startTime, $endTime)
public function getMonthsList($startTime, $endTime): array
{
$monthList = [];
$currentTime = $startTime;
@@ -202,7 +209,7 @@ class DataController extends BaseAdminController
* @param $originalArray
* @return array
*/
public function getArrValues($originalArray)
public function getArrValues($originalArray): array
{
$newArr = [];
foreach ($originalArray as $v) {