| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers;
- use app\models\CommonOperation;
- use app\modules\admin\models\AnalysisDataForm;
- use yii\helpers\Json;
- /**
- * 数据面板统计
- * Class DashboardController
- * @package app\modules\admin\controllers
- */
- class DashboardController extends BaseController
- {
- /**
- * 总销售额,商品总数,用户总量,订单总数
- * @return \yii\web\Response
- */
- public function actionData()
- {
- $form = new AnalysisDataForm();
- $form->attributes = post_params();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $form->mch_id = get_mch_id();
- return $this->asJson($form->getData());
- }
- /**
- * 商品订单数据和店铺销售总体排行
- * @return \yii\web\Response
- */
- public function actionOrderData()
- {
- $form = new AnalysisDataForm();
- $form->start_time = get_params('start_time');
- $form->end_time = get_params('end_time');
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $form->mch_id = get_mch_id();
- return $this->asJson($form->getOrderData());
- }
- /**
- * 商品销量数据
- * @return \yii\web\Response
- */
- public function actionGoodsData()
- {
- $form = new AnalysisDataForm();
- $form->store_id = get_store_id();
- $form->mch_id = get_mch_id();
- return $this->asJson($form->GoodsSearch());
- }
- /**
- * 常用操作表
- * @return \yii\web\Response
- */
- public function actionOperations()
- {
- $mch_id = get_mch_id();
- $store_id = get_store_id();
- $text = input_params('text', array());
- $operations = CommonOperation::findOne(['store_id' => $store_id, 'mch_id' => $mch_id]);
- if (\Yii::$app->request->isPost) {
- $form = new AnalysisDataForm();
- $form->store_id = $store_id;
- $form->mch_id = $mch_id;
- $form->text = $text;
- $form->model = $operations ? $operations : new CommonOperation();
- return $this->asJson($form->operations());
- }
- if (!$operations) {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => []
- ]);
- } else {
- if (empty($operations->text)) {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => []
- ]);
- } else {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => Json::decode($operations->text)
- ]);
- }
- }
- }
- }
|