shish 4 年之前
父节点
当前提交
81bb8252ea
共有 1 个文件被更改,包括 34 次插入91 次删除
  1. 34 91
      app-ghs/controllers/ConsoleController.php

+ 34 - 91
app-ghs/controllers/ConsoleController.php

@@ -5,6 +5,7 @@ namespace ghs\controllers;
 use biz\stat\classes\StatSaleClass;
 use biz\stat\services\StatOutService;
 use bizGhs\clear\classes\ClearClass;
+use bizGhs\item\classes\ItemClass;
 use bizGhs\order\classes\OrderClass;
 use bizHd\order\classes\OrderClass as HdOrderClass;
 use bizHd\stat\classes\StatVisitClass;
@@ -17,109 +18,51 @@ class ConsoleController extends BaseController
 
     public $guestAccess = ['init', 'profile'];
 
-    //今日实收统计和欠款统计等
+    //总览
     public function actionStat()
     {
-        $todayDate = date('Y-m-d');
-        $todayStartTime = $todayDate . ' 00:00:00';
-        $todayEndTime = $todayDate . ' 23:59:59';
-        $where = ['shopId' => $this->shopId, 'debt' => 0, 'debtPrice' => '0.00'];
-        $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]];
-        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
-        $todayActIncome = OrderClass::sum($where, 'actPrice'); // 今日实收
-        $todayActIncome = $todayActIncome === null ? 0 : $todayActIncome;
-
-        $where = ['shopId' => $this->shopId, 'debt' => 1]; // 查询条件重新赋值
-        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
-        $todayDebt = OrderClass::sum($where, 'remainDebtPrice'); // 今日欠款
-        $todayDebt = $todayDebt === null ? 0 : $todayDebt;
-
         $where = ['shopId' => $this->shopId, 'debt' => 1]; // 重新赋值
         $totalDebt = OrderClass::sum($where, 'remainDebtPrice'); // 总欠款
         $totalDebt = $totalDebt === null ? 0 : $totalDebt;
 
-        util::success(['todayActIncome' => $todayActIncome, 'todayDebt' => $todayDebt, 'totalDebt' => $totalDebt]);
+        $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);
+            }
+        }
+        $shop = $this->shop;
+        $totalCustom = $shop->totalUser ?? 0;
+        $totalVisit = $shop->totalVisit ?? 0;
+        $totalOrder = $shop->finishOrder ?? 0;
+        $overview = [
+            ['name' => "库存(扎)", "url" => '/admin/home/member', 'value' => $totalItemNum, 'type' => 4],
+            ['name' => "库存(元)", "url" => '/admin/home/member', 'value' => $totalCost, 'type' => 4],
+            ['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/member', 'value' => $totalOrder, 'type' => 4],
+        ];
+
+        util::success(['overview' => $overview]);
     }
 
     //今日笔数和总金额
     public function actionStrokeCount()
     {
-        $todayDate = date('Y-m-d');
-        $todayStartTime = $todayDate . ' 00:00:00';
-        $todayEndTime = $todayDate . ' 23:59:59';
-
-        //线上收入 180笔  12000元
-        //xhGhsOrder actPrice 字段,条件:debtPrice=0 and status in (2,3,4)  and payWay in (0,1)
-        //xhOrder    actPrice 字段,条件 status in (2,3,4)  and payWay in (0,1)
-        $where = ['shopId' => $this->shopId, 'debt' => 0, 'debtPrice' => '0.00'];
-        $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]];
-        $where['payWay'] = ['in', [0, 1]];
-        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
-        $ghsOnlineCount = OrderClass::getCount($where); // 批发今日收入总笔数
-        $ghsActIncome = OrderClass::sum($where, 'actPrice'); // 批发今日实收总数
-        Yii::info('批发今日收入总笔数:' . $ghsOnlineCount . ', 批发今日实收总数:' . $ghsActIncome);
-
-        $where['shopId'] = $this->shop['lsShopId'];
-        $where['onlinePay'] = 2; // 花店 xhOrder 表的 onlinePay 字段是指:钱是否进入公司的帐户 --  1不是 2是
-        unset($where['debt']);
-        unset($where['debtPrice']);
-        $hdActualCount = HdOrderClass::getCount($where); // 花店今日收入总笔数
-        $hdActualIncome = HdOrderClass::sum($where, 'actPrice'); // 花店今日收入金额总数
-        Yii::info('花店今日收入总笔数:' . $hdActualCount . ', 花店今日收入金额总数:' . $hdActualIncome);
-        $systemCount = $ghsOnlineCount + $hdActualCount;
-        $systemIncome = floatval(bcadd($ghsActIncome, $hdActualIncome, 2)); // 扫码收入
-
-        //现金收入 23笔  5980元
-        //xhGhsOrder actPrice 字段,条件:debtPrice=0 and status in (2,3,4)  and payWay=4
-        //xhOrder    actPrice 字段,条件 status in (2,3,4)  and payWay=4
-        $where = ['shopId' => $this->shopId, 'debt' => 0, 'debtPrice' => '0.00'];
-        $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]];
-        $where['payWay'] = 4;
-        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
-        $ghsCashCount = OrderClass::getCount($where); // 批发今日现金总笔数
-        $ghsCashIncome = OrderClass::sum($where, 'actPrice'); // 批发今日现金金额总数
-        Yii::info('批发今日现金总笔数:' . $ghsCashCount . ', 批发今日现金金额总数:' . $ghsCashIncome);
-
-        $where['shopId'] = $this->shop['lsShopId'];
-        unset($where['debt']);
-        unset($where['debtPrice']);
-        $hdCashCount = HdOrderClass::getCount($where); // 花店今日现金总笔数
-        $hdCashIncome = HdOrderClass::sum($where, 'actPrice'); // 花店今日现金金额总数
-        Yii::info('花店今日现金总笔数:' . $hdCashCount . ', 花店今日现金金额总数:' . $hdCashIncome);
-        $cashCount = $ghsCashCount + $hdCashCount;
-        $cashIncome = floatval(bcadd($ghsCashIncome, $hdCashIncome, 2)); // 现金收入
-
-        //批发欠款 39笔 13980元
-        $where = ['shopId' => $this->shopId, 'debt' => 1];
-        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
-        $debtCount = OrderClass::getCount($where); // 批发今日欠款总笔数
-        $debtAmount = OrderClass::sum($where, 'remainDebtPrice'); // 欠款 // 批发今日总欠款
-        $debtAmount = floatval($debtAmount);
-
-        //结帐收入
-        $where = ['ghsShopId' => $this->shopId];
-        $where['status'] = 2;
-        $where['onlinePay'] = 2;
-        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
-        $clearCount = ClearClass::getCount($where);
-        $clearIncome = ClearClass::sum($where, 'actPrice');
-        $clearIncome = empty($clearIncome) ? 0 : floatval($clearIncome);
-
-        $actTotalCount = $cashCount + $systemCount + $clearCount;
-        $actTotalIncome = bcadd($cashIncome, $systemIncome, 2);
-        $actTotalIncome = floatval(bcadd($actTotalIncome, $clearIncome, 2)); // 收入合计 = 扫码收入 + 现金收入 + 结帐收入
-
         util::success([
-            'systemCount' => $systemCount,
-            'systemIncome' => $systemIncome, // 扫码收入
-            'cashCount' => $cashCount,
-            'cashIncome' => $cashIncome, // 现金收入
-            'clearCount' => $clearCount,
-            'clearIncome' => $clearIncome, // 结帐收入
-            'actTotalCount' => $actTotalCount,
-            'actTotalIncome' => $actTotalIncome, // 收入合计
-            'debtCount' => $debtCount,
-            'debtAmount' => $debtAmount, // 欠款
+            'systemIncome' => 0,
+            'systemCount' => 0,
+            'debtCount' => 0,
+            'debtIncome' => 0,
+            'kfWxCount' => 0,
+            'kfWxIncome' => 0,
         ]);
     }