$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' => 10, 'type' => 1], ['name' => "花材", "url" => '/admin/stat/stock', 'value' => $totalItemNum, 'type' => 1], ['name' => "库存值", "url" => '/admin/stat/stock', 'value' => $totalItemNum, 'type' => 1], ['name' => "总欠款", "url" => '/admin/home/member', 'value' => $totalDebt, 'type' => 4], ['name' => "总客户", "url" => '/admin/home/member', 'value' => $totalCustom, '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(); $notice = []; $mainId = $this->mainId; $respond = \bizGhs\stat\classes\StatSaleClass::profile($mainId); $incomeList = $respond['income'] ?? []; $todaySale = 0; if (!empty($incomeList)) { //这里有二个地方同时要修改,请搜索关键词:index_show_income foreach ($incomeList as $item) { if (isset($item['id']) && $item['id'] == 'allot') { continue; } $todaySale = bcadd($todaySale, $item['amount'], 2); } } $orderNum = $respond['totalOrderNum'] ?? 0; //访客数 $visitCustom = StatVisitClass::getVisitNum($this->mainId); $wastage = \bizGhs\order\classes\StockWastageOrderClass::getTodayWaste($this->mainId); $hsReturn = StatOrderClass::statHsNum($this->mainId); $hsNum = $hsReturn['num'] ?? 0; $menu = [ ["name" => "商城", "img" => "ghs/home/shop2.png", "url" => "/admin/cg/mall", 'pf' => 1,], ["name" => "改价", "img" => "ghs/home/gj2.png", "url" => "/admin/changePrice/list2", 'pf' => 1,], ["name" => "花材", "img" => "ghs/home/hcgl2.png", "url" => "/admin/item/list2", 'pf' => 1,], ["name" => "接花束", "img" => "ghs/home/shop2.png", "url" => "/admin/order/workOrder", 'pf' => 1,], ["name" => "拆散", "img" => "ghs/home/kcyjs2.png", "url" => "/admin/part/list", 'pf' => 1,], ["name" => "损耗", "img" => "ghs/home/kcyjs2.png", "url" => "/admin/breakage/list", 'pf' => 1,], ["name" => "任务", "img" => "ghs/home/kcyjs2.png", "url" => "/admin/work/list", 'pf' => 1,], ["name" => "买花", "img" => "ghs/home/shop2.png", "url" => "/pagesPurchase/order", 'pf' => 1,], ["name" => "买花记录", "img" => "ghs/home/shop2.png", "url" => "/pagesPurchase/shopping", 'pf' => 1,], ["name" => "花束", "img" => "ghs/home/kcyjs2.png", "url" => "/admin/goods/list", 'pf' => 1,], ["name" => "客户充值", "img" => "ghs/home/kcyjs2.png", "url" => "/admin/recharge/rechargeCode", 'pf' => 1,], ]; //查看财务的权限 $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop); $warning = ''; //$warning = '本月4号凌晨4点~5点系统升级,暂停使用'; util::success([ 'asset' => $this->main, 'notice' => $notice, 'warning'=> $warning, 'todayData' => ['visit' => $visitCustom, 'income' => $todaySale, 'order' => $orderNum, 'wastage' => $wastage, 'bouquet' => $hsNum], 'incomeStat' => [], 'menu' => $menu, 'lookMoney' => $lookMoney, ]); } //常用初始化 public function actionInit() { $dict = dict::get($this->mainId); $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : []; util::success(['dict' => $dict, 'shop' => $shop]); } //系统收入、客服收入、欠款 public function actionStrokeCount() { if (empty($this->mainId)) { util::success([ 'systemIncome' => 0, 'systemCount' => 0, 'debtCount' => 0, 'debtIncome' => 0, 'kfWxCount' => 0, 'kfWxIncome' => 0, 'cashCount' => 0, 'cashIncome' => 0, ]); } $return = \bizGhs\stat\classes\StatKdClass::eachChannelIncome($this->mainId, $this->shop); $incomeList = $return['incomeList']; $systemIncome1 = $incomeList['system']['category']['ls']['amount'] ?? 0; $systemCount1 = $incomeList['system']['category']['ls']['num'] ?? 0; $systemIncome2 = $incomeList['system']['category']['pf']['amount'] ?? 0; $systemCount2 = $incomeList['system']['category']['pf']['num'] ?? 0; $systemCount = bcadd($systemCount1, $systemCount2); $systemIncome = bcadd($systemIncome1, $systemIncome2, 2); $debtIncome1 = $incomeList['debt']['category']['ls']['amount'] ?? 0; $debtCount1 = $incomeList['debt']['category']['ls']['num'] ?? 0; $debtIncome2 = $incomeList['debt']['category']['pf']['amount'] ?? 0; $debtCount2 = $incomeList['debt']['category']['pf']['num'] ?? 0; $debtIncome = bcadd($debtIncome1, $debtIncome2, 2); $debtCount = bcadd($debtCount1, $debtCount2); $kfWxIncome1 = $incomeList['kfWx']['category']['ls']['amount'] ?? 0; $kfWxCount1 = $incomeList['kfWx']['category']['ls']['num'] ?? 0; $kfWxIncome2 = $incomeList['kfWx']['category']['pf']['amount'] ?? 0; $kfWxCount2 = $incomeList['kfWx']['category']['pf']['num'] ?? 0; $kfWxIncome = bcadd($kfWxIncome1, $kfWxIncome2, 2); $kfWxCount = bcadd($kfWxCount1, $kfWxCount2); $cashIncome1 = $incomeList['cash']['category']['ls']['amount'] ?? 0; $cashCount1 = $incomeList['cash']['category']['ls']['num'] ?? 0; $cashIncome2 = $incomeList['cash']['category']['pf']['amount'] ?? 0; $cashCount2 = $incomeList['cash']['category']['pf']['num'] ?? 0; $cashIncome = bcadd($cashIncome1, $cashIncome2, 2); $cashCount = bcadd($cashCount1, $cashCount2); util::success([ 'systemIncome' => $systemIncome, 'systemCount' => $systemCount, 'debtCount' => $debtCount, 'debtIncome' => $debtIncome, 'kfWxCount' => $kfWxCount, 'kfWxIncome' => $kfWxIncome, 'cashCount' => $cashCount, 'cashIncome' => $cashIncome, ]); } }