| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- *
- * @copyright ©2020 点小铺
- * @author hanj
- * @link: https://dyuit.com
- * Created by VSCode
- */
- namespace app\store\controller\statistics;
- use app\store\controller\Controller;
- use app\store\service\statistics\Data as StatisticsDataService;
- /**
- * 数据概况
- * Class Data
- * @package app\store\controller\statistics
- */
- class Data extends Controller
- {
- /* @var $statisticsDataService StatisticsDataService 数据概况服务类 */
- private $statisticsDataService;
- /**
- * 构造方法
- * @throws \app\common\exception\BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function _initialize()
- {
- parent::_initialize();
- $this->statisticsDataService = new StatisticsDataService;
- }
- /**
- * 数据统计主页
- * @return mixed
- * @throws \think\Exception
- */
- public function index()
- {
- return $this->fetch('index', [
- // 数据概况
- 'survey' => $this->statisticsDataService->getSurveyData(),
- // 近七日交易走势
- 'echarts7days' => $this->statisticsDataService->getTransactionTrend(),
- // 商品销售榜
- 'goodsRanking' => $this->statisticsDataService->getGoodsRanking(),
- // 用户消费榜
- 'userExpendRanking' => $this->statisticsDataService->geUserExpendRanking(),
- ]);
- }
- /**
- * 数据概况API
- * @param null $startDate
- * @param null $endDate
- * @return array
- * @throws \think\Exception
- */
- public function survey($startDate = null, $endDate = null)
- {
- return $this->renderSuccess('', '',
- $this->statisticsDataService->getSurveyData($startDate, $endDate));
- }
- }
|