$this->mainId, 'debt' => 1]; // 重新赋值 $pfDebt = OrderClass::sum($where, 'remainDebtPrice'); // 总欠款 $pfDebt = $pfDebt === null ? 0 : $pfDebt; $lsDebt = \bizHd\order\classes\OrderClass::sum(['mainId' => $this->mainId, 'debt' => 1], 'remainDebtPrice'); $lsDebt = $lsDebt === null ? 0 : $lsDebt; $totalDebt = bcadd($pfDebt, $lsDebt, 2); $itemList = ItemClass::getAllByCondition(['mainId' => $this->mainId], null, 'id,stock,cost', null, true); $totalItemNum = 0; $totalCost = 0; if (!empty($itemList)) { foreach ($itemList as $item) { $stock = $item->stock ?? 0; $cost = $item->cost ?? 0; $totalItemNum = bcadd($stock, $totalItemNum, 2); $currentCost = bcmul($stock, $cost, 2); $totalCost = bcadd($currentCost, $totalCost, 2); } } $totalItemNum = floor($totalItemNum); $main = $this->main; $totalCustom = $main->totalUser ?? 0; $totalVisit = $main->totalVisit ?? 0; $totalOrder = $main->finishOrder ?? 0; $overview = [ ['name' => "库存(扎)", "url" => '/admin/stat/stock', 'value' => $totalItemNum, 'type' => 1], ['name' => "库存(元)", "url" => '/admin/stat/stock', 'value' => $totalCost, 'type' => 1], ['name' => "总欠款", "url" => '/admin/home/member', 'value' => $totalDebt, 'type' => 4], ['name' => "总客户", "url" => '/admin/home/member', 'value' => $totalCustom, 'type' => 4], ['name' => "总访客", "url" => '/admin/home/member', 'value' => $totalVisit, 'type' => 4], ['name' => "总订单", "url" => '/admin/home/order', 'value' => $totalOrder, 'type' => 4], ]; util::success(['overview' => $overview]); } //概况 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']]; } } $mainId = $this->mainId; $respond = \bizGhs\stat\classes\StatSaleClass::profile($mainId); $incomeList = $respond['income'] ?? []; $todaySale = 0; if (!empty($incomeList)) { foreach ($incomeList as $item) { $todaySale = bcadd($todaySale, $item['amount'], 2); } } $expendList = $respond['expend'] ?? []; $todayOut = 0; if (!empty($expendList)) { foreach ($expendList as $item) { $todayOut = bcadd($todayOut, $item['amount'], 2); } } $orderNum = $respond['totalOrderNum'] ?? 0; //访客数 $visitCustom = StatVisitClass::getVisitNum($this->mainId); util::success([ 'asset' => $this->main, 'notice' => $notice, 'todayData' => ['visit' => $visitCustom, 'income' => $todaySale, 'order' => $orderNum, 'out' => $todayOut], 'incomeStat' => [], ]); } //常用初始化 public function actionInit() { $dict = dict::get(); $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : []; util::success(['dict' => $dict, 'shop' => $shop]); } }