shish пре 5 година
родитељ
комит
58ceacd34d

+ 4 - 1
app-hd/controllers/ConsoleController.php

@@ -4,6 +4,7 @@ namespace hd\controllers;
 
 use biz\sj\classes\SjClass;
 use biz\sj\services\MerchantAssetService;
+use bizHd\stat\classes\StatStudentClass;
 use bizHd\stat\services\StatIncomeMonthService;
 use bizHd\stat\services\StatIncomeService;
 use bizHd\stat\services\StatOrderService;
@@ -55,8 +56,10 @@ class ConsoleController extends BaseController
         //今天收入
         $incomeData = StatIncomeService::getTodayNum($this->shopId);
         $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
+        //今天新学员数
+        $newStudent = StatStudentClass::getTodayNum($this->shop);
         //今日概况
-        $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => 1];
+        $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => $newStudent];
 
         $incomeStat = [];
         if (httpUtil::isMiniProgram() == false) {

+ 28 - 17
biz-hd/stat/classes/StatStudentClass.php

@@ -7,21 +7,32 @@ use bizHd\base\classes\BaseClass;
 
 class StatStudentClass extends BaseClass
 {
-	
-	public static $baseFile = '\bizHd\stat\models\StatStudent';
-	
-	public static function addStudent($shop, $date = null)
-	{
-		$shopId = $shop['id'];
-		$date = isset($date) ? $date : date("Ymd");
-		$stat = self::getByCondition(['shopId' => $shopId, 'time' => $date], true);
-		if (empty($stat)) {
-			$stat = self::add(['shopId' => $shopId, 'time' => $date], true);
-		}
-		$stat->riseNum += 1;
-		$stat->totalNum = $shop['totalStudent'] + 1;
-		$stat->save();
-		StatStudentMonthClass::addStudent($shop);
-	}
-	
+
+    public static $baseFile = '\bizHd\stat\models\StatStudent';
+
+    public static function addStudent($shop, $date = null)
+    {
+        $shopId = $shop->id;
+        $sjId = $shop->merchantId;
+        $date = isset($date) ? $date : date("Ymd");
+        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $date], true);
+        if (empty($stat)) {
+            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $date], true);
+        }
+        $stat->riseNum += 1;
+        $stat->totalNum = $shop->totalStudent + 1;
+        $stat->save();
+        StatStudentMonthClass::addStudent($shop);
+    }
+
+    //今天的新学员数 shish 20210524
+    public static function getTodayNum($shop)
+    {
+        $today = date("Ymd");
+        $shopId = $shop->id;
+        $sjId = $shop->merchantId;
+        $new = self::getByCondition(['time' => $today, 'sjId' => $sjId, 'shopId' => $shopId], true);
+        return $new->riseNum ?? 0;
+    }
+
 }

+ 15 - 15
biz-hd/stat/classes/StatStudentMonthClass.php

@@ -8,21 +8,21 @@ use bizHd\base\classes\BaseClass;
 class StatStudentMonthClass extends BaseClass
 {
 
-	public static $baseFile = '\bizHd\stat\models\StatStudentMonth';
+    public static $baseFile = '\bizHd\stat\models\StatStudentMonth';
 
-	//月订单数增加 ssh 2020.5.25
-	public static function addStudent($shop, $month = null)
-	{
-        $sjId = $shop['merchantId'];
-        $shopId = $shop['merchantId'];
-		$month = isset($month) ? $month : date("Ym");
-		$stat = self::getByCondition(['sjId' => $sjId, 'shopId'=>$shopId ,'time' => $month], true);
-		if (empty($stat)) {
-			$stat = self::add(['sjId' => $sjId,  'shopId'=>$shopId,'time' => $month], true);
-		}
-		$stat->riseNum += 1;
-		$stat->totalNum = $shop['totalStudent'] + 1;
-		$stat->save();
-	}
+    //月订单数增加 ssh 2020.5.25
+    public static function addStudent($shop, $month = null)
+    {
+        $sjId = $shop->merchantId;
+        $shopId = $shop->id;
+        $month = isset($month) ? $month : date("Ym");
+        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $month], true);
+        if (empty($stat)) {
+            $stat = self::add(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $month], true);
+        }
+        $stat->riseNum += 1;
+        $stat->totalNum = $shop['totalStudent'] + 1;
+        $stat->save();
+    }
 
 }