| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace ghs\controllers;
- use biz\stat\classes\StatSaleClass;
- use biz\stat\services\StatOutService;
- use bizHd\stat\classes\StatViewClass;
- use bizHd\stat\classes\StatVisitClass;
- use bizHd\stat\services\StatIncomeMonthService;
- use bizHd\stat\services\StatIncomeService;
- use bizHd\stat\services\StatUserService;
- 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 = [];
- $admin = $this->admin;
- if ($isMini == 1 && !empty($admin)) {
- $miniOpenId = $admin['miniOpenId'] ?? '';
- if (empty($miniOpenId)) {
- $notice = [['title' => '绑定微信,下次自动登录后台', 'action' => '去绑定', 'page' => '/admin/staff/miniAutoLogin']];
- }
- }
- //今天客户与粉丝数
- $userData = StatUserService::getTodayNum($this->shopId);
- $customNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
- //今天销售
- $sale = StatSaleClass::getByCondition(['shopId' => $this->shopId, 'time' => date('Ymd')]);
- $todaySale = $sale['amount'] ?? 0;
- $orderNum = $sale['num'] ?? 0;
- //2021.4.14 linqh 今日支出
- $outData = StatOutService::getTodayNum($this->shopId);
- $todayOut = $outData['amount'] ?? '0.00';
- //访客数
- $visitCustom = StatVisitClass::getVisitNum($this->shop);
- $todayData = ['income' => $todaySale, 'order' => $orderNum, 'custom' => $customNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom];
- $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,
- ];
- }
- $shopInfo = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
- $menu = [
- ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"],
- ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"],
- ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"],
- ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
- ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/pagesStorehouse/stockWarn/manage"],
- ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
- ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
- ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"]
- ];
- $agent = $shopInfo['agentLevel'] ?? 0;
- if ($agent == 1) {
- //代理商显示邀请开店按钮
- $menu = [
- ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"],
- ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"],
- ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"],
- ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
- ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/pagesStorehouse/stockWarn/manage"],
- ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
- ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
- ["name" => "邀请开店", "img" => "ghs/home/yqyl.png", "url" => "/pagesInvite/list"]
- ];
- }
- util::success([
- 'asset' => $shopInfo,
- 'notice' => $notice,
- 'todayData' => $todayData,
- 'incomeStat' => $incomeStat,
- 'menu' => $menu,
- ]);
- }
- //常用初始化
- public function actionInit()
- {
- $dict = dict::get();
- $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
- util::success(['dict' => $dict, 'shop' => $shop]);
- }
- }
|