123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- namespace app\controller\admin\v1\statistic;
- use app\controller\admin\AuthController;
- use app\services\statistic\UserStatisticServices;
- use think\facade\App;
- class UserStatistic extends AuthController
- {
-
- public function __construct(App $app, UserStatisticServices $services)
- {
- parent::__construct($app);
- $this->services = $services;
- }
-
- public function getBasic()
- {
- $where = $this->request->getMore([
- ['channel_type', ''],
- ['data', '', '', 'time']
- ]);
- $where['time'] = $this->getDay($where['time']);
- return $this->success($this->services->getBasic($where));
- }
-
- public function getTrend()
- {
- $where = $this->request->getMore([
- ['channel_type', ''],
- ['data', '', '', 'time']
- ]);
- $where['time'] = $this->getDay($where['time']);
- return $this->success($this->services->getTrend($where));
- }
-
- public function getWechat()
- {
- $where = $this->request->getMore([
- ['channel_type', ''],
- ['data', '', '', 'time']
- ]);
- $where['time'] = $this->getDay($where['time']);
- return $this->success($this->services->getWechat($where));
- }
-
- public function getWechatTrend()
- {
- $where = $this->request->getMore([
- ['channel_type', ''],
- ['data', '', '', 'time']
- ]);
- $where['time'] = $this->getDay($where['time']);
- return $this->success($this->services->getWechatTrend($where));
- }
-
- public function getRegion()
- {
- $where = $this->request->getMore([
- ['channel_type', ''],
- ['data', '', '', 'time'],
- ['sort', 'allNum']
- ]);
- $where['time'] = $this->getDay($where['time']);
- return $this->success($this->services->getRegionV1($where));
- }
-
- public function getSex()
- {
- $where = $this->request->getMore([
- ['channel_type', ''],
- ['data', '', '', 'time']
- ]);
- $where['time'] = $this->getDay($where['time']);
- return $this->success($this->services->getSex($where));
- }
-
- public function getExcel()
- {
- $where = $this->request->getMore([
- ['channel_type', ''],
- ['data', '', '', 'time']
- ]);
- $where['time'] = $this->getDay($where['time']);
- return $this->success($this->services->getTrend($where, true));
- }
-
- public function getDay($time)
- {
- if (strstr($time, '-') !== false) {
- [$startTime, $endTime] = explode('-', $time);
- if (!$startTime && !$endTime) {
- return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
- } else {
- return $startTime . '-' . $endTime;
- }
- } else {
- return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
- }
- }
- }
|