|
|
@@ -32,48 +32,6 @@ class StatVisitService extends BaseService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //将昨天的保存入库
|
|
|
- public static function saveYesterdayNum($shopId)
|
|
|
- {
|
|
|
- $yesTime = date("Ymd", strtotime("-1 day"));
|
|
|
- $resource = self::getByCondition(['shopId' => $shopId, 'time' => $yesTime]);
|
|
|
- //有数据表示已经保存过了
|
|
|
- if (!empty($resource)) {
|
|
|
- return [];
|
|
|
- }
|
|
|
- $wholeSiteView = StatVisitClass::getKeyName($shopId, 'whole_site_view', $yesTime);
|
|
|
- //获取访问次数
|
|
|
- $viewNum = Yii::$app->redis->executeCommand('GET', [$wholeSiteView]);
|
|
|
-
|
|
|
- //获取访问客户数
|
|
|
- $wholeSiteVisit = StatVisitClass::getKeyName($shopId, 'whole_site_visit', $yesTime);
|
|
|
- $visitNum = Yii::$app->redis->executeCommand('SCARD', [$wholeSiteVisit]);
|
|
|
-
|
|
|
- $shop = ShopClass::getById($shopId, true);
|
|
|
- if (empty($shop)) {
|
|
|
- util::fail('没有找到门店');
|
|
|
- }
|
|
|
- $sjId = $shop->sjId ?? 0;
|
|
|
- $currentTotalVisit = $shop->totalVisit;
|
|
|
- $currentTotalView = $shop->totalView;
|
|
|
- $currentTotalVisit = stringUtil::calcAdd($currentTotalVisit, $visitNum);
|
|
|
- $currentTotalView = stringUtil::calcAdd($currentTotalView, $viewNum);
|
|
|
- //保存累计访问量
|
|
|
- $shop->totalVisit = $currentTotalVisit;
|
|
|
- $shop->totalView = $currentTotalView;
|
|
|
- $shop->save();
|
|
|
-
|
|
|
- //保存访客数
|
|
|
- $data = ['time' => $yesTime, 'totalNum' => $currentTotalVisit, 'riseNum' => $visitNum, 'shopId' => $shopId, 'sjId' => $sjId, 'createTime' => date("Y-m-d H:i:s")];
|
|
|
- self::add($data);
|
|
|
-
|
|
|
- //保存访问量
|
|
|
- $data = ['time' => $yesTime, 'totalNum' => $currentTotalView, 'riseNum' => $viewNum, 'shopId' => $shopId, 'sjId' => $sjId, 'addTime' => time()];
|
|
|
- StatViewClass::add($data);
|
|
|
-
|
|
|
- self::clearYesNum($shopId);
|
|
|
- }
|
|
|
-
|
|
|
//清空昨天的缓存
|
|
|
public static function clearYesNum($shopId)
|
|
|
{
|