|
|
@@ -1,209 +1 @@
|
|
|
-<?php
|
|
|
|
|
|
-namespace hd\controllers;
|
|
|
-
|
|
|
-use bizGhs\stat\classes\StatSaleClass;
|
|
|
-use bizHd\custom\classes\CustomClass;
|
|
|
-use bizHd\goods\classes\GoodsClass;
|
|
|
-use bizHd\order\classes\OrderClass;
|
|
|
-use bizHd\shop\classes\ShopExtClass;
|
|
|
-use bizHd\stat\classes\StatVisitClass;
|
|
|
-use bizGhs\item\classes\ItemClass;
|
|
|
-use common\components\dict;
|
|
|
-use common\components\util;
|
|
|
-use bizHd\stat\classes\StatOrderClass;
|
|
|
-
|
|
|
-class ConsoleController extends BaseController
|
|
|
-{
|
|
|
- public $guestAccess = ['init', 'profile'];
|
|
|
-
|
|
|
- //总览
|
|
|
- public function actionStat()
|
|
|
- {
|
|
|
- //不要用缓存!!!
|
|
|
-
|
|
|
- $itemList = ItemClass::getAllByCondition(['mainId' => $this->mainId], null, 'id,stock,avCost,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->avCost ?? 0;
|
|
|
- $totalItemNum = bcadd($stock, $totalItemNum, 2);
|
|
|
- $currentCost = bcmul($stock, $cost, 2);
|
|
|
- $totalCost = bcadd($currentCost, $totalCost, 2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $totalItemNum = floor($totalItemNum);
|
|
|
- $goodsCount = GoodsClass::getCount(['mainId'=>$this->mainId]);
|
|
|
- $customCount = CustomClass::getCount(['shopId'=>$this->shopId]);
|
|
|
- $orderCount = OrderClass::getCount(['mainId'=>$this->mainId, 'status'=>4]);
|
|
|
- $debtCount = OrderClass::debtCount($this->mainId);
|
|
|
- $overview = [
|
|
|
- ['name' => "花材数", "url" => '/admin/stat/stock', 'value' => $totalItemNum, 'type' => 1],
|
|
|
- ['name' => "花材值", "url" => '/admin/stat/stock', 'value' => $totalCost, 'type' => 1],
|
|
|
- ['name' => "花束", "url" => '/admin/goods/list', 'value' => $goodsCount, 'type' => 1],
|
|
|
- ['name' => "总客户", "url" => '/admin/home/member', 'value' => $customCount, 'type' => 1],
|
|
|
- ['name' => "总订单", "url" => '/admin/home/order', 'value' => $orderCount, 'type' => 4],
|
|
|
- ['name' => "总挂账", "url" => '/admin/home/order', 'value' => $debtCount, 'type' => 4],
|
|
|
- ];
|
|
|
- util::success(['overview' => $overview]);
|
|
|
- }
|
|
|
-
|
|
|
- //概况 ssh 2019.12.19
|
|
|
- public function actionProfile()
|
|
|
- {
|
|
|
- $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->shopId);
|
|
|
- $wastage = \bizGhs\order\classes\StockWastageOrderClass::getTodayWaste($this->mainId);
|
|
|
-
|
|
|
- $hsReturn = StatOrderClass::statHsNum($this->mainId);
|
|
|
- $hsNum = $hsReturn['num'] ?? 0;
|
|
|
- $mainId = $this->mainId;
|
|
|
- $_GET['searchTime'] = 'yesterday'; // 必须要有的,让其获取昨天的收入
|
|
|
- $respond = StatSaleClass::profile($mainId);
|
|
|
- $incomeList = $respond['income'] ?? [];
|
|
|
- $yesterdayIncome = 0;
|
|
|
- if (!empty($incomeList)) {
|
|
|
- //这里有二个地方同时要修改,请搜索关键词:index_show_income
|
|
|
- foreach ($incomeList as $item) {
|
|
|
- if (isset($item['id']) && $item['id'] == 'allot') {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $yesterdayIncome = bcadd($yesterdayIncome, $item['amount'], 2);
|
|
|
- }
|
|
|
- }
|
|
|
- $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 = '';
|
|
|
- $warningUrl = '';
|
|
|
- $warning = '【必看】结账功能重大调整 点击查看 >';
|
|
|
- $warningUrl = '/admin/notice/warning';
|
|
|
-
|
|
|
- util::success([
|
|
|
- 'asset' => $this->main,
|
|
|
- 'notice' => [],
|
|
|
- 'warning' => $warning,
|
|
|
- 'warningUrl' => $warningUrl,
|
|
|
- 'todayData' => [
|
|
|
- 'visit' => $visitCustom,
|
|
|
- 'income' => $todaySale,
|
|
|
- 'order' => $orderNum,
|
|
|
- 'wastage' => $wastage,
|
|
|
- 'bouquet' => $hsNum
|
|
|
- ],
|
|
|
- 'incomeStat' => [],
|
|
|
- 'yesterdayIncome' => $yesterdayIncome,
|
|
|
- 'menu' => $menu,
|
|
|
- 'lookMoney' => $lookMoney,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- //常用初始化
|
|
|
- public function actionInit()
|
|
|
- {
|
|
|
- $dict = dict::get($this->mainId);
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $this->shop->id], false, false, 'reachVip');
|
|
|
- $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
|
|
|
- $shop['reachVip'] = $shopExt['reachVip'];
|
|
|
- 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,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
-}
|