$this->shopId, '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,virtualStock,delStatus', null, true); $totalItemNum = 0; $totalCost = 0; if (!empty($itemList)) { foreach ($itemList as $item) { if ($item->virtualStock == 0 && $item->delStatus == 0) { $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/shop/debtChange', 'value' => $totalDebt, 'type' => 1], ['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]); } //系统收入、客服收入、欠款 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 = 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, ]); } //获取昨天的收入 ssh 20240830 public function actionGetYesterdayIncome() { $mainId = $this->mainId; $respond = StatSaleClass::profile($mainId); $incomeList = $respond['income'] ?? []; $sale = 0; if (!empty($incomeList)) { //这里有二个地方同时要修改,请搜索关键词:index_show_income foreach ($incomeList as $item) { if (isset($item['id']) && $item['id'] == 'allot') { continue; } $sale = bcadd($sale, $item['amount'], 2); } } util::success(['income' => $sale]); } //今日概况 ssh 20220723 public function actionProfile() { $get = Yii::$app->request->get(); $version = $get['version'] ?? 1; $notice = []; $shop = $this->shop; if (!empty($shop)) { //到期前10天提醒 $deadline = $shop->deadline; $currentTime = time(); $currentTime = $currentTime + 864000; $deadTime = strtotime($deadline); if ($currentTime > $deadTime) { if (time() > $deadTime) { $notice[] = ['title' => '系统已到期', 'action' => '查看', 'page' => '/admin/shop/renew']; } else { $notice[] = ['title' => '系统即将到期,请及时续费', 'action' => '查看', 'page' => '/admin/shop/renew']; } } } //$notice[] = ['title' => '节日期间官方技术服务电话2号:17189513228', 'action' => '', 'page' => '']; //$notice[] = ['title' => '今天11:30~12:00订单可能会漏打小票,请复查', 'action' => '', 'page' => '']; $mainId = $this->mainId; $respond = 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); } } $expendList = $respond['expend'] ?? []; $todayOut = 0; if (!empty($expendList)) { foreach ($expendList as $item) { $todayOut = bcadd($todayOut, $item['amount'], 2); } } $orderNum = $respond['totalOrderNum'] ?? 0; $wastage = StockWastageOrderClass::getTodayWaste($this->mainId); $visitCustom = StatVisitClass::getVisitNum($this->mainId); $cgNum = PurchaseClass::getCount(['mainId' => $this->mainId, 'status' => ['in', [3]]]); $menu = [ ["name" => "商城", "img" => "ghs/home/shop3.png", "url" => "/admin/home/mall"], ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"], ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"], ["name" => "花材(简)", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/simple"], ["name" => "改库存", "img" => "ghs/home/kcyjs.png", "url" => "/admin/changePrice/changeStock"], ["name" => "供货商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"], ["name" => "采购记录", "img" => "ghs/home/icon_caigou.png", "url" => "/pagesPurchase/order"], ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"], ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"], ["name" => "买花", "img" => "ghs/home/icon_buy_item.png", "url" => "buyGhs"], ["name" => "买花记录", "img" => "ghs/home/icon_buy_record.png", "url" => "buyRecord", 'remindNum' => $cgNum], ["name" => "库存总览", "img" => "ghs/home/kcyjs.png", "url" => "/admin/stat/stock"], ["name" => "支出", "img" => "ghs/home/kcyjs.png", "url" => "/admin/expend/list"], ["name" => "员工", "img" => "ghs/home/yggl.png", "url" => "/admin/staff/list"], ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/admin/item/list?warning=1"], ["name" => "盘点", "img" => "ghs/home/pandian.png", "url" => "/pagesStorehouse/inventory/list"], ["name" => "损耗", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"], ]; if ($version == 2) { $menu = [ ["name" => "商城", "img" => "ghs/home/shop3.png", "url" => "/admin/home/mall"], ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list2"], ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list2"], ["name" => "预订客户", "img" => "ghs/home/yggl.png", "url" => "/admin/book/custom"], ["name" => "改库存", "img" => "ghs/home/kcyjs.png", "url" => "/admin/changePrice/changeStock2"], ["name" => "供货商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"], ["name" => "采购记录", "img" => "ghs/home/icon_caigou.png", "url" => "/pagesPurchase/order"], ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"], ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"], ["name" => "买花", "img" => "ghs/home/icon_buy_item.png", "url" => "buyGhs"], ["name" => "买花记录", "img" => "ghs/home/icon_buy_record.png", "url" => "buyRecord", 'remindNum' => $cgNum], ["name" => "库存总览", "img" => "ghs/home/kcyjs.png", "url" => "/admin/stat/stock"], ["name" => "支出", "img" => "ghs/home/kcyjs.png", "url" => "/admin/expend/list"], ["name" => "员工", "img" => "ghs/home/yggl.png", "url" => "/admin/staff/list"], ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/admin/item/list?warning=1"], ["name" => "盘点", "img" => "ghs/home/pandian.png", "url" => "/pagesStorehouse/inventory/list"], ["name" => "损耗", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"], ["name" => "预订明细", "img" => "ghs/home/yggl.png", "url" => "/admin/book/itemCustom"], ["name" => "新增预订", "img" => "ghs/home/yggl.png", "url" => "/admin/custom/selectCustom?style=1&book=1&getAll=1"], ["name" => "拆散", "img" => "ghs/home/kcyjs.png", "url" => "/admin/part/list"], ]; } //用于审核,不展示全部完整的功能,批发的功能不展示出来,否则要申请B2B类目!!!!!!!! if ($this->adminId == 17) { $menu = [ ["name" => "商城", "img" => "ghs/home/shop3.png", "url" => "/admin/home/mall"], ["name" => "改库存", "img" => "ghs/home/kcyjs.png", "url" => "/admin/changePrice/changeStock2"], ["name" => "采购记录", "img" => "ghs/home/icon_caigou.png", "url" => "/pagesPurchase/order"], ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"], ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"], ["name" => "买花", "img" => "ghs/home/icon_buy_item.png", "url" => "buyGhs"], ["name" => "买花记录", "img" => "ghs/home/icon_buy_record.png", "url" => "buyRecord", 'remindNum' => $cgNum], ["name" => "库存总览", "img" => "ghs/home/kcyjs.png", "url" => "/admin/stat/stock"], ["name" => "支出", "img" => "ghs/home/kcyjs.png", "url" => "/admin/expend/list"], ["name" => "员工", "img" => "ghs/home/yggl.png", "url" => "/admin/staff/list"], ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/admin/item/list?warning=1"], ["name" => "盘点", "img" => "ghs/home/pandian.png", "url" => "/pagesStorehouse/inventory/list"], ["name" => "损耗", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"], ["name" => "拆散", "img" => "ghs/home/kcyjs.png", "url" => "/admin/part/list"], ]; } //查看财务的权限 $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop); $warning = ''; $warningUrl = ''; //$warning = '因网络原因,今天11:30~12:00的订单可能会漏打小票,请复查,避免漏发货'; //$warningUrl = '/admin/notice/warning'; util::success([ 'asset' => $this->main, 'notice' => $notice, 'warning' => $warning, 'warningUrl' => $warningUrl, 'todayData' => [ 'income' => $todaySale, 'order' => $orderNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom, 'wastage' => $wastage ], 'menu' => $menu, 'lookMoney' => $lookMoney, ]); } //常用初始化 public function actionInit() { $dict = dict::get(); $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : []; util::success(['dict' => $dict, 'shop' => $shop]); } }