| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace hd\controllers;
- use biz\sj\classes\SjClass;
- use biz\sj\services\MerchantAssetService;
- use bizHd\stat\services\StatIncomeMonthService;
- use bizHd\stat\services\StatIncomeService;
- use bizHd\stat\services\StatOrderService;
- use bizHd\stat\services\StatUserService;
- use bizHd\stat\services\StatVisitService;
- use common\components\dict;
- use common\components\httpUtil;
- use common\components\util;
- class ConsoleController extends BaseController
- {
- public $guestAccess = ['init'];
- //概况 ssh 2019.12.19
- public function actionProfile()
- {
- $asset = MerchantAssetService::getByMerchantId($this->sjId);
- //试用期到期时间
- $notice = [];
- $sj = $this->sj;
- $deadline = $sj['deadline'] ?? 0;
- $current = time();
- $remain = strtotime($deadline) - $current;
- if ($remain <= 1296000) {
- //是否有充值免费续期权限
- $hasRight = SjClass::hasRechargeRenewRight($this->sj, $this->sjExtend);
- if ($hasRight) {
- $title = '您的试用期已到,点击免费续期1年';
- if ($remain > 0) {
- $num = ceil($remain / 86400);
- $title = "您的试用期还有{$num}天,点击免费续期";
- }
- $notice = array_merge($notice, [['title' => $title, 'action' => '查看', 'page' => '/admin/recharge/renew']]);
- } else {
- $title = '您的试用期已到,请及时续费';
- if ($remain > 0) {
- $num = ceil($remain / 86400);
- $title = "您的试用期还有{$num}天,请及时续费";
- }
- $notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/pagesClient/official/index']]);
- }
- }
- //今天访客数
- $todayVisit = StatVisitService::getTodayVisitNum($this->sjId);
- //今天客户与粉丝数
- $userData = StatUserService::getTodayNum($this->sjId);
- $todayFansNum = isset($userData['riseFansNum']) ? $userData['riseFansNum'] : 0;
- $todayUserNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
- //今天订单数
- $orderData = StatOrderService::getTodayNum($this->sjId);
- $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
- //今天收入
- $incomeData = StatIncomeService::getTodayNum($this->sjId);
- $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
- $todayData = ['visit' => $todayVisit, 'fans' => $todayFansNum, 'user' => $todayUserNum, 'income' => $todayIncome, 'order' => $todayOrder];
- $incomeStat = [];
- if (httpUtil::isMiniProgram() == false) {
- //当月的收入
- $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
- //上个月收入
- $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
- //最近7天收入变化趋势
- $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
- $incomeStat = [
- 'month' => $currentMonthIncome,
- 'week' => 999,
- 'previousMonth' => $previousMonthIncome,
- 'list' => $latestIncome,
- ];
- }
- $visitStat = [
- 'month' => 1999,
- 'week' => 999,
- 'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
- ];
- util::success([
- 'asset' => $asset,
- 'notice' => $notice,
- 'todayData' => $todayData,
- 'visitStat' => $visitStat,
- 'incomeStat' => $incomeStat,
- ]);
- }
- //常用初始化
- public function actionInit()
- {
- $dict = dict::get();
- $shop = $this->shop;
- util::success(['dict' => $dict, 'shop' => $shop]);
- }
- }
|