| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- namespace hd\controllers;
- use biz\sj\classes\SjClass;
- use biz\sj\services\MerchantAssetService;
- use bizHd\stat\classes\StatStudentClass;
- 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;
- use Yii;
- class ConsoleController extends BaseController
- {
- public $guestAccess = ['init', 'profile'];
- //概况 ssh 2019.12.19
- public function actionProfile()
- {
- $get = Yii::$app->request->get();
- $isMini = $get['isMini'] ?? 0;
- //试用期到期时间
- $notice = [];
- $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
- $deadline = $sj['deadline'] ?? 0;
- $current = time();
- $remain = strtotime($deadline) - $current;
- if ($remain <= 1296000) {
- //是否有充值免费续期权限
- $hasRight = SjClass::hasRechargeRenewRight($sj, $this->sjExtend);
- if ($hasRight) {
- $title = '您的试用期已结束,点此免费续期';
- 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/renewal']]);
- }
- }
- //引导关注公众号
- $admin = $this->admin;
- $subscribe = $admin['subscribe'] ?? 0;
- if ($subscribe == 0) {
- //$notice = array_merge($notice, [['title' => '开启提醒,批发店花材做特价及时通知您', 'action' => '开启', 'page' => '/pagesClient/official/warn']]);
- }
- if ($isMini == 1 && !empty($admin)) {
- $miniOpenId = $admin['miniOpenId'] ?? '';
- if (empty($miniOpenId)) {
- $notice = [['title' => '帐号绑定微信,下次自动登录后台', 'action' => '去绑定', 'page' => '/admin/staff/miniAutoLogin']];
- }
- }
- if (isset($this->shop) && !empty($this->shop)) {
- //今天访客
- $todayVisit = 0;
- //今天开单
- $orderData = StatOrderService::getTodayNum($this->shopId);
- $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
- //今天收入
- $incomeData = StatIncomeService::getTodayNum($this->shopId);
- $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
- //今天新学员数
- $newStudent = StatStudentClass::getTodayNum($this->shop);
- //今日概况
- } else {
- $todayVisit = 0;
- $todayIncome = 0.00;
- $todayOrder = 0;
- $newStudent = 0;
- }
- $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => $newStudent];
- $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],
- ];
- $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
- util::success([
- 'asset' => $shop,
- 'notice' => $notice,
- 'todayData' => $todayData,
- 'visitStat' => $visitStat,
- 'incomeStat' => $incomeStat,
- ]);
- }
- //常用初始化
- public function actionInit()
- {
- $dict = dict::get();
- $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
- util::success(['dict' => $dict, 'shop' => $shop]);
- }
- }
|