| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace ghs\controllers;
- use biz\stat\classes\StatStockOutClass;
- use biz\stat\services\StatOutService;
- use bizHd\stat\classes\StatViewClass;
- use bizHd\stat\services\StatIncomeMonthService;
- use bizHd\stat\services\StatIncomeService;
- use bizHd\stat\services\StatUserService;
- use common\components\dict;
- use common\components\httpUtil;
- use Yii;
- use common\components\util;
- class ConsoleController extends BaseController
- {
- public $guestAccess = ['init', 'profile'];
- //概况 ssh 2019.12.19
- public function actionProfile()
- {
- $notice = [
- //['title' => '您的试用期还有7天,点击免费续期1年 ', 'action' => '查看', 'page' => '/admin/recharge/renew'],
- ];
- //今天客户与粉丝数
- $userData = StatUserService::getTodayNum($this->shopId);
- $customNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
- //今天总收入-出库收入= 营业收入
- $incomeData = StatIncomeService::getTodayNum($this->shopId);
- $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0.00;
- $stockOutAmount = StatStockOutClass::getTodayAmount($this->shop);
- $todayIncome = bcsub($todayIncome, $stockOutAmount, 2);
- //2021.4.14 linqh 今日支出
- $outData = StatOutService::getTodayNum($this->shopId);
- $todayOut = $outData['amount'] ?? '0.00';
- //今天开单数
- $statOrder = \bizHd\stat\classes\StatOrderClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
- $orderNum = $statOrder['riseNum'] ?? 0;
- $view = StatViewClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
- $viewNum = $view['riseNum'] ?? 0;
- $todayData = ['income' => $todayIncome, 'order' => $orderNum, 'custom' => $customNum, 'expend' => $todayOut, 'view' => $viewNum];
- $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,
- ];
- }
- $asset = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
- util::success([
- 'asset' => $asset,
- 'notice' => $notice,
- 'todayData' => $todayData,
- 'incomeStat' => $incomeStat,
- ]);
- }
- //常用初始化
- public function actionInit()
- {
- $dict = dict::get();
- $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
- util::success(['dict' => $dict, 'shop' => $shop]);
- }
- }
|