Răsfoiți Sursa

1. 花掌柜(app-hd) console/profile 接口更新
2. app-hd: 新增今日访客接口 custom/get-visit
3. 分别给批发与零售创建 StatVisitClass

shizhongqi 10 luni în urmă
părinte
comite
bfcfc1c132

+ 2 - 1
app-ghs/controllers/ConsoleController.php

@@ -9,7 +9,8 @@ use bizGhs\shop\classes\ShopAdminClass;
 use bizGhs\stat\classes\StatKdClass;
 use bizGhs\stat\classes\StatSaleClass;
 use bizHd\purchase\classes\PurchaseClass;
-use bizHd\stat\classes\StatVisitClass;
+//use bizHd\stat\classes\StatVisitClass;
+use bizGhs\stat\classes\StatVisitClass;
 use common\components\dict;
 use common\components\util;
 use Yii;

+ 2 - 2
app-ghs/controllers/CustomController.php

@@ -9,13 +9,13 @@ use biz\sj\classes\SjClass;
 use biz\wx\classes\WxMessageClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\custom\services\CustomService;
-use bizGhs\merchant\classes\WlClass;
 use common\components\qrCodeUtil;
 use bizGhs\order\classes\OrderClass;
 use bizHd\saas\classes\ApplyClass;
 use bizHd\saas\services\ApplyService;
 use bizHd\shop\classes\ShopClass;
-use bizHd\stat\classes\StatVisitClass;
+//use bizHd\stat\classes\StatVisitClass;
+use bizGhs\stat\classes\StatVisitClass;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\orderSn;

+ 98 - 32
app-hd/controllers/ConsoleController.php

@@ -5,9 +5,9 @@ namespace hd\controllers;
 use bizHd\custom\classes\CustomClass;
 use bizHd\goods\classes\GoodsClass;
 use bizHd\order\classes\OrderClass;
-use bizHd\stat\classes\StatOrderClass;
 use bizHd\stat\classes\StatVisitClass;
 use bizGhs\item\classes\ItemClass;
+use common\components\dateUtil;
 use common\components\dict;
 use common\components\util;
 
@@ -78,33 +78,105 @@ class ConsoleController extends BaseController
 		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;
+        //查看财务的权限
+        $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
+
+        $lsIncome = 0;
+        $orderCount = 0;
+        $yesterdayIncome = 0;
+
+        if ($lookMoney == 1) {
+            $mainId = $this->mainId;
+            $todayStr = date('Y-m-d');
+
+            // 今天零售订单总数与收入
+            $cacheKey = 'hd_console_profile:' . 'today_'.$todayStr.'_income_' . $this->shopId;
+            $cache = \Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+            if ($cache) {
+                $cacheData = json_decode($cache, true);
+                $lsIncome = $cacheData['lsIncome'];
+                $orderCount = $cacheData['orderCount'];
+            } else {
+                $period = dateUtil::formatTime('today', '', '', true);
+                $start = $period['startTime'];
+                $end = $period['endTime'];
+                $currentStartDate = date('Y-m-d', strtotime($start));
+                $currentEndDate = date('Y-m-d', strtotime($end));
+                $currentStartTime = $currentStartDate . ' 00:00:00';
+                $currentEndTime = $currentEndDate . ' 23:59:59';
+
+                $where['time'] = ['between', [$start, $end]];
+                $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
+                $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
+                $orderCount = OrderClass::getCount($where);
+
+                $lsIncome = 0;
+                $hdOrderList = OrderClass::getAllByCondition($where, null, 'mainPay, forward, cash');
+                foreach ($hdOrderList as $hdKey => $hdOrder) {
+                    $actPrice = $hdOrder['mainPay'] ?? 0;
+                    $forward = $hdOrder['forward'] ?? 0;
+
+                    if ($forward == 1) { //零售售后付款
+                        // $lsAfterSale = bcadd($lsAfterSale, $actPrice, 2);
+                    } else {
+                        $cash = $hdOrder['cash'] ?? 0;
+                        $lsIncome = bcadd($actPrice, $lsIncome, 2);
+                        $lsIncome = bcadd($lsIncome, $cash, 2);
+                    }
                 }
-                $todaySale = bcadd($todaySale, $item['amount'], 2);
+                $cacheData = [
+                    'lsIncome' => $lsIncome,
+                    'orderCount' => $orderCount,
+                ];
+                \Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 1800, json_encode($cacheData, JSON_UNESCAPED_UNICODE)]);
             }
-        }
 
-        $orderNum = $respond['totalOrderNum'] ?? 0;
+            // 昨天零售收入
+            $cacheKey = 'hd_console_profile:' . 'yesterday_'.$todayStr.'_income_' . $this->shopId;
+            $cache = \Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+            if ($cache) {
+                $cacheData = json_decode($cache, true);
+                $yesterdayIncome = $cacheData['yesterdayIncome'];
+            } else {
+                $period = dateUtil::formatTime('yesterday', '', '', true);
+                $start = $period['startTime'];
+                $end = $period['endTime'];
+                $currentStartDate = date('Y-m-d', strtotime($start));
+                $currentEndDate = date('Y-m-d', strtotime($end));
+                $currentStartTime = $currentStartDate . ' 00:00:00';
+                $currentEndTime = $currentEndDate . ' 23:59:59';
+                $where['time'] = ['between', [$start, $end]];
+                $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
+                $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
+                $yesterdayIncome = 0;
+                $hdOrderList = OrderClass::getAllByCondition($where, null, 'mainPay, forward, cash');
+                foreach ($hdOrderList as $hdKey => $hdOrder) {
+                    $actPrice = $hdOrder['mainPay'] ?? 0;
+                    $forward = $hdOrder['forward'] ?? 0;
 
-        //访客数
-        $visitCustom = StatVisitClass::getVisitNum($this->mainId);
-        $wastage = \bizGhs\order\classes\StockWastageOrderClass::getTodayWaste($this->mainId);
+                    if ($forward == 1) { //零售售后付款
+                        // $lsAfterSale = bcadd($lsAfterSale, $actPrice, 2);
+                    } else {
+                        $cash = $hdOrder['cash'] ?? 0;
+                        $yesterdayIncome = bcadd($actPrice, $yesterdayIncome, 2);
+                        $yesterdayIncome = bcadd($yesterdayIncome, $cash, 2);
+                    }
+                }
+                $cacheData = [
+                    'yesterdayIncome' => $yesterdayIncome,
+                ];
+                \Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 86400, json_encode($cacheData, JSON_UNESCAPED_UNICODE)]);
+            }
+        }
 
-        $hsReturn = StatOrderClass::statHsNum($this->mainId);
-        $hsNum = $hsReturn['num'] ?? 0;
+        //访客数
+        $visitCustom = StatVisitClass::getVisitNum($this->shopId);
+        // $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,],
@@ -120,24 +192,18 @@ class ConsoleController extends BaseController
             ["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
+                'income' => $lsIncome, //$todaySale,
+                'order' => $orderCount, //$orderNum,
+                // 'wastage' => $wastage,
+                // 'bouquet' => $hsNum
             ],
-            'incomeStat' => [],
+            'yesterdayIncome' => $yesterdayIncome,
             'menu' => $menu,
             'lookMoney' => $lookMoney,
         ]);

+ 16 - 0
app-hd/controllers/CustomController.php

@@ -10,6 +10,7 @@ use biz\sj\services\MerchantAssetService;
 use biz\sj\services\MerchantRemarkService;
 use bizHd\member\classes\MemberWealClass;
 use bizHd\order\classes\OrderClass;
+use bizHd\stat\classes\StatVisitClass;
 use bizHd\user\services\UserAssetService;
 use bizHd\user\services\UserGrowthService;
 use bizHd\user\services\UserService;
@@ -675,4 +676,19 @@ class CustomController extends BaseController
         util::success($respond);
     }
 
+    //今日访客
+    public function actionGetVisit()
+    {
+        $userIds = StatVisitClass::getVisitCustomIds($this->shopId);
+        if (empty($userIds)) {
+            util::success(['list' => []]);
+        }
+        $sort = 'visitTime DESC';
+        $where = [
+            'shopId' => $this->shopId,
+            'userId' => ['in', $userIds]
+        ];
+        $list = CustomService::getCustomList($where, $sort);
+        util::success($list);
+    }
 }

+ 1 - 1
app-hd/controllers/GhsController.php

@@ -11,7 +11,7 @@ use bizGhs\merchant\classes\WlClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\shop\classes\ShopExtClass;
 use bizHd\shop\models\ShopExt;
-use bizHd\stat\classes\StatVisitClass;
+use bizGhs\stat\classes\StatVisitClass;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\qrCodeUtil;

+ 4 - 0
app-mall/controllers/BaseController.php

@@ -40,6 +40,8 @@ class BaseController extends PublicController
             }
         }
         $this->user = $user;
+
+
         $shopId = Yii::$app->request->get('account'); // 从 $_GET 中取
         $shopId = empty($shopId) ? Yii::$app->request->post('account') : $shopId; // 从 $_POST 中取
         $shopId = intval($shopId);
@@ -52,6 +54,8 @@ class BaseController extends PublicController
                 $main = MainClass::getById($mainId, true);
                 $this->main = $main;
                 $this->mainId = $mainId;
+
+
                 $hdId = Yii::$app->request->get('hdId', 0);
                 if (empty($hdId)) {
                     //兼容早期代码,勿删,扫码付款页也用到,只写POST方式

+ 2 - 4
app-mall/controllers/CategoryController.php

@@ -3,9 +3,7 @@
 namespace mall\controllers;
 
 use bizHd\custom\classes\CustomClass;
-use bizHd\goods\classes\GoodsCategoryClass;
 use bizMall\goods\services\CategoryService;
-use bizMall\goods\services\GoodsCategoryService;
 use Yii;
 use common\components\util;
 
@@ -56,8 +54,8 @@ class CategoryController extends BaseController
         $shop = $this->shop;
         $custom = $this->custom;
         $params = [];
-        //调用花店端的方法,后面再分离
-        $data = GoodsCategoryClass::getGoodsList($get, $shop, $custom, $params);
+        //调用花店端的方法,后面再分离 (为了代码维护可以不分离,免得一处改了,另一处没修改到。--- 所以分离好后,又还原了)
+        $data = \bizHd\goods\classes\GoodsCategoryClass::getGoodsList($get, $shop, $custom, $params);
         util::success($data);
     }
 

+ 3 - 0
app-mall/controllers/ShopController.php

@@ -2,6 +2,7 @@
 
 namespace mall\controllers;
 
+use bizHd\stat\classes\StatVisitClass;
 use bizHd\custom\classes\CustomClass;
 use bizHd\custom\classes\HdClass;
 use bizMall\invite\services\InviteService;
@@ -52,6 +53,8 @@ class ShopController extends BaseController
             }
         }
 
+        StatVisitClass::addHdCustomVisit($shop->id, $user->id);
+
         util::success(['info' => $info, 'hd' => $hd, 'custom' => $custom]);
     }
 

+ 0 - 2
biz-ghs/stat/classes/StatSaleClass.php

@@ -2,7 +2,6 @@
 
 namespace bizGhs\stat\classes;
 
-use biz\stat\classes\StatCgClass;
 use biz\stat\classes\StatStockInClass;
 use biz\stat\classes\StatStockOutClass;
 use bizGhs\cg\classes\CgRefundClass;
@@ -24,7 +23,6 @@ use bizHd\refund\classes\HdRefundClass;
 use common\components\arrayUtil;
 use common\components\dateUtil;
 use common\components\dict;
-use common\components\noticeUtil;
 use common\components\util;
 use Yii;
 use bizGhs\base\classes\BaseClass;

+ 124 - 0
biz-ghs/stat/classes/StatVisitClass.php

@@ -0,0 +1,124 @@
+<?php
+
+namespace bizGhs\stat\classes;
+
+use common\components\util;
+use bizGhs\base\classes\BaseClass;
+use Yii;
+
+/**
+ * 批发端 -- 浏览记录与浏览统计
+ * Class StatVisitClass
+ * @package bizGhs\stat\classes
+ */
+class StatVisitClass extends BaseClass
+{
+    public static $baseFile = '\bizGhs\stat\models\StatVisit';
+
+    //$time 日期
+    public static function getKeyName($sjId, $class, $time = null)
+    {
+        //全站每天的访问量 //全站每天的访问ip量
+        if (in_array($class, ['whole_site_view', 'whole_site_visit',]) == false) {
+            util::fail('无效键名');
+        }
+        $time = isset($time) == false ? date("Ymd") : $time;
+        return $class . '_' . $sjId . '_' . $time;
+    }
+
+    //增加供货商(批发)的访客
+    public static function addGhsCustomVisit($ghs, $custom, $date = null)
+    {
+        $date = isset($date) == false ? date("Ymd") : $date;
+        $customId = $custom->id ?? 0;
+        $ghsMainId = $ghs->mainId ?? 0;
+        $cacheKey = 'ghs_mall_visit_' . $ghsMainId . '_' . $date;
+        $exists = Yii::$app->redis->executeCommand('SISMEMBER', [$cacheKey, $customId]);
+        if (empty($exists)) {
+            Yii::$app->redis->executeCommand('SADD', [$cacheKey, $customId]);
+            $custom->visitTime = date("Y-m-d H:i:s");
+            $custom->save();
+        }
+    }
+
+    //批发保存访客数
+    public static function saveVisit($shop, $visitNum, $date = null)
+    {
+        $sjId = $shop->sjId ?? 0;
+        $shopId = $shop->id ?? 0;
+        $totalNum = $shop->totalVisit ?? 0;
+
+        $date = isset($date) == false ? date("Ymd") : $date;
+        $resource = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $date], true);
+        //已经存过
+        if (!empty($resource)) {
+            return false;
+        }
+
+        $data = [
+            'time' => $date,
+            'riseNum' => 0,
+            'totalNum' => 0,
+            'shopId' => $shopId,
+            'sjId' => $sjId,
+            'createTime' => date("Y-m-d H:i:s")
+        ];
+        $resource = self::add($data, true);
+
+        $nowNum = bcadd($resource->riseNum, $visitNum, 2);
+        $resource->riseNum = $nowNum;
+        $resource->totalNum = $totalNum;
+        $resource->save();
+
+        //每月
+        if ($date == null) {
+            $time = date('Ym');
+            $year = date('Y');
+            $month = date('m');
+        } else {
+            $timestamp = strtotime($date);
+            $time = date('Ym', $timestamp);
+            $year = date('Y', $timestamp);
+            $month = date('m', $timestamp);
+        }
+        $stat = StatVisitMonthClass::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        if (empty($stat)) {
+            $stat = StatVisitMonthClass::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month, 'createTime' => date("Y-m-d H:i:s")], true);
+        }
+        $currentNum = bcadd($stat->riseNum, $visitNum);
+        $stat->riseNum = $currentNum;
+        $stat->totalNum = $totalNum;
+        $stat->save();
+
+        self::clearVisit($shop, $date);
+    }
+
+    //批发清空访客
+    public static function clearVisit($shop, $date = null)
+    {
+        $mainId = $shop->mainId ?? 0;
+        $date = isset($date) == false ? date("Ymd") : $date;
+        $cacheKey = 'ghs_mall_visit_' . $mainId . '_' . $date;
+        Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
+    }
+
+    //批发端获取访客数 ssh 2020.2.2
+    public static function getVisitNum($mainId, $date = null)
+    {
+        $date = isset($date) == false ? date("Ymd") : $date;
+        $cacheKey = 'ghs_mall_visit_' . $mainId . '_' . $date;
+        $num = Yii::$app->redis->executeCommand('SCARD', [$cacheKey]);
+        return !empty($num) ? $num : 0;
+    }
+
+    //批发端获取访客ID
+    public static function getVisitCustomIds($shop, $date = null)
+    {
+        $mainId = $shop->mainId ?? 0;
+        $date = isset($date) == false ? date("Ymd") : $date;
+        $cacheKey = 'ghs_mall_visit_' . $mainId . '_' . $date;
+        $ids = Yii::$app->redis->executeCommand('SMEMBERS', [$cacheKey]);
+        return $ids;
+    }
+
+}

+ 11 - 0
biz-ghs/stat/models/StatVisit.php

@@ -0,0 +1,11 @@
+<?php
+namespace bizGhs\stat\models;
+use bizGhs\base\models\Base;
+
+class StatVisit extends Base
+{
+	public static function tableName()
+	{
+		return 'xhStatVisit';
+	}
+}

+ 0 - 1
biz-hd/custom/services/CustomService.php

@@ -4,7 +4,6 @@ namespace bizHd\custom\services;
 
 use bizHd\base\services\BaseService;
 use bizHd\custom\classes\CustomClass;
-use Yii;
 
 class CustomService extends BaseService
 {

+ 0 - 2
biz-hd/goods/classes/GoodsCategoryClass.php

@@ -3,9 +3,7 @@
 namespace bizHd\goods\classes;
 
 use bizHd\goods\models\GoodsCategory;
-use common\components\business;
 use common\components\util;
-use Yii;
 use bizHd\base\classes\BaseClass;
 
 class GoodsCategoryClass extends BaseClass

+ 0 - 3
biz-hd/goods/classes/GoodsSettingClass.php

@@ -2,9 +2,6 @@
 
 namespace bizHd\goods\classes;
 
-use bizHd\saas\classes\FestClass;
-use bizHd\saas\classes\FestRiseClass;
-use common\components\util;
 use bizHd\base\classes\BaseClass;
 
 class GoodsSettingClass extends BaseClass

+ 26 - 88
biz-hd/stat/classes/StatVisitClass.php

@@ -2,119 +2,57 @@
 
 namespace bizHd\stat\classes;
 
-use common\components\util;
 use Yii;
 use bizHd\base\classes\BaseClass;
 
+/**
+ * 零售端 -- 浏览记录与浏览统计
+ * Class StatVisitClass
+ * @package bizHd\stat\classes
+ */
 class StatVisitClass extends BaseClass
 {
+    //public static $baseFile = '\bizHd\stat\models\StatVisit';
 
-    public static $baseFile = '\bizHd\stat\models\StatVisit';
-
-    //$time 日期
-    public static function getKeyName($sjId, $class, $time = null)
-    {
-        //全站每天的访问量 //全站每天的访问ip量
-        if (in_array($class, ['whole_site_view', 'whole_site_visit',]) == false) {
-            util::fail('无效键名');
-        }
-        $time = isset($time) == false ? date("Ymd") : $time;
-        return $class . '_' . $sjId . '_' . $time;
-    }
-
-    //增加供货商的访客
-    public static function addGhsCustomVisit($ghs, $custom, $date = null)
+    //零售记录访客
+    public static function addHdCustomVisit($shopId, $userId, $date = null)
     {
         $date = isset($date) == false ? date("Ymd") : $date;
-        $customId = $custom->id ?? 0;
-        $ghsMainId = $ghs->mainId ?? 0;
-        $cacheKey = 'ghs_mall_visit_' . $ghsMainId . '_' . $date;
-        $exists = Yii::$app->redis->executeCommand('SISMEMBER', [$cacheKey, $customId]);
+        $cacheKey = 'hd_visit:' . $shopId . '_' . $date;
+        $exists = Yii::$app->redis->executeCommand('SISMEMBER', [$cacheKey, $userId]);
         if (empty($exists)) {
-            Yii::$app->redis->executeCommand('SADD', [$cacheKey, $customId]);
-            $custom->visitTime = date("Y-m-d H:i:s");
-            $custom->save();
+            Yii::$app->redis->executeCommand('SADD', [$cacheKey, $userId]);
         }
+
+		// 只缓存1天:若未设置过期时间则设置为 86400 秒
+		$ttl = (int)Yii::$app->redis->executeCommand('TTL', [$cacheKey]);
+		if ($ttl === -1) {
+			Yii::$app->redis->executeCommand('EXPIRE', [$cacheKey, 86400]);
+		}
     }
 
     //保存访客数
     public static function saveVisit($shop, $visitNum, $date = null)
     {
-        $sjId = $shop->sjId ?? 0;
-        $shopId = $shop->id ?? 0;
-        $totalNum = $shop->totalVisit ?? 0;
-
-        $date = isset($date) == false ? date("Ymd") : $date;
-        $resource = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $date], true);
-        //已经存过
-        if (!empty($resource)) {
-            return false;
-        }
-
-        $data = [
-            'time' => $date,
-            'riseNum' => 0,
-            'totalNum' => 0,
-            'shopId' => $shopId,
-            'sjId' => $sjId,
-            'createTime' => date("Y-m-d H:i:s")
-        ];
-        $resource = self::add($data, true);
 
-        $nowNum = bcadd($resource->riseNum, $visitNum, 2);
-        $resource->riseNum = $nowNum;
-        $resource->totalNum = $totalNum;
-        $resource->save();
-
-        //每月
-        if ($date == null) {
-            $time = date('Ym');
-            $year = date('Y');
-            $month = date('m');
-        } else {
-            $timestamp = strtotime($date);
-            $time = date('Ym', $timestamp);
-            $year = date('Y', $timestamp);
-            $month = date('m', $timestamp);
-        }
-        $stat = StatVisitMonthClass::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
-        if (empty($stat)) {
-            $stat = StatVisitMonthClass::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month, 'createTime' => date("Y-m-d H:i:s")], true);
-        }
-        $currentNum = bcadd($stat->riseNum, $visitNum);
-        $stat->riseNum = $currentNum;
-        $stat->totalNum = $totalNum;
-        $stat->save();
-
-        self::clearVisit($shop, $date);
     }
 
-    //清空访客
-    public static function clearVisit($shop, $date = null)
+    //获取访客数
+    public static function getVisitNum($shopId, $date = null)
     {
-        $mainId = $shop->mainId ?? 0;
         $date = isset($date) == false ? date("Ymd") : $date;
-        $cacheKey = 'ghs_mall_visit_' . $mainId . '_' . $date;
-        Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
-    }
-
-    //获取访客数 ssh 2020.2.2
-    public static function getVisitNum($mainId, $date = null)
-    {
-        $date = isset($date) == false ? date("Ymd") : $date;
-        $cacheKey = 'ghs_mall_visit_' . $mainId . '_' . $date;
+        $cacheKey = 'hd_visit:' . $shopId . '_' . $date;
         $num = Yii::$app->redis->executeCommand('SCARD', [$cacheKey]);
-        return !empty($num) ? $num : 0;
+        return intval($num);
     }
 
     //获取访客ID
-    public static function getVisitCustomIds($shop, $date = null)
+    public static function getVisitCustomIds($shopId, $date = null)
     {
-        $mainId = $shop->mainId ?? 0;
-        $date = isset($date) == false ? date("Ymd") : $date;
-        $cacheKey = 'ghs_mall_visit_' . $mainId . '_' . $date;
-        $ids = Yii::$app->redis->executeCommand('SMEMBERS', [$cacheKey]);
-        return $ids;
+        $date = isset($date) ? $date :  date("Ymd");
+        $cacheKey = 'hd_visit:' . $shopId . '_' . $date;
+        $userIds = Yii::$app->redis->executeCommand('SMEMBERS', [$cacheKey]);
+        return $userIds;
     }
 
 }

+ 0 - 2
biz-hd/stat/models/StatVisit.php

@@ -4,10 +4,8 @@ use bizHd\base\models\Base;
 
 class StatVisit extends Base
 {
-
 	public static function tableName()
 	{
 		return 'xhStatVisit';
 	}
-
 }

+ 3 - 4
biz-hd/stat/services/StatVisitService.php

@@ -4,11 +4,10 @@ namespace bizHd\stat\services;
 
 use biz\shop\classes\ShopClass;
 use bizHd\base\services\BaseService;
-use bizHd\stat\classes\StatViewClass;
-use bizHd\stat\classes\StatVisitClass;
-use common\components\util;
-use Yii;
+//use bizHd\stat\classes\StatVisitClass;
+use bizGhs\stat\classes\StatVisitClass;
 use common\components\stringUtil;
+use Yii;
 
 class StatVisitService extends BaseService
 {

+ 0 - 3
biz-mall/custom/classes/CustomClass.php

@@ -2,12 +2,9 @@
 
 namespace bizMall\custom\classes;
 
-use Yii;
 use bizMall\base\classes\BaseClass;
 
 class CustomClass extends BaseClass
 {
-
     public static $baseFile = '\bizMall\custom\models\Custom';
-
 }

+ 0 - 1
biz-mall/goods/classes/GoodsClass.php

@@ -94,5 +94,4 @@ class GoodsClass extends BaseClass
         self::updateById($id, ['status' => $status]);
         GoodsCategoryClass::updateByCondition(['gId' => $id], ['status' => $status]);
     }
-
 }

+ 0 - 2
biz-mall/goods/classes/GoodsSettingClass.php

@@ -2,8 +2,6 @@
 
 namespace bizMall\goods\classes;
 
-use bizMall\saas\classes\FestClass;
-use bizMall\saas\classes\FestRiseClass;
 use common\components\util;
 use bizMall\base\classes\BaseClass;
 

+ 0 - 2
biz-mall/goods/models/GoodsSetting.php

@@ -4,10 +4,8 @@ use bizMall\base\models\Base;
 
 class GoodsSetting extends Base
 {
-	
 	public static function tableName()
 	{
 		return 'xhGoodsSetting';
 	}
-
 }

+ 2 - 9
console/controllers/GlobalController.php

@@ -2,17 +2,13 @@
 
 namespace console\controllers;
 
-use biz\ghs\classes\GhsClass;
-use biz\market\classes\TjFlClass;
 use biz\shop\classes\ShopClass;
-use biz\sj\classes\SjClass;
 use biz\stat\classes\StatItemClass;
-use bizGhs\custom\classes\CustomClass;
-use bizGhs\custom\services\CustomService;
 use bizGhs\order\classes\OrderClass;
 use bizGhs\order\classes\OrderItemClass;
 use bizGhs\product\classes\ProductClass;
-use bizHd\stat\classes\StatVisitClass;
+//use bizHd\stat\classes\StatVisitClass;
+use bizGhs\stat\classes\StatVisitClass;
 use common\components\dict;
 use Yii;
 use yii\console\Controller;
@@ -22,7 +18,6 @@ use yii\console\Controller;
  */
 class GlobalController extends Controller
 {
-
     // ./yii global/run
     public function actionRun()
     {
@@ -93,7 +88,6 @@ class GlobalController extends Controller
                     }
                 }
             }
-
         }
 
         //每天凌晨00:10保存昨天访客数
@@ -114,7 +108,6 @@ class GlobalController extends Controller
                 }
             }
         }
-
     }
 
 }