StatStudentClass.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace bizHd\stat\classes;
  3. use Yii;
  4. use bizHd\base\classes\BaseClass;
  5. class StatStudentClass extends BaseClass
  6. {
  7. public static $baseFile = '\bizHd\stat\models\StatStudent';
  8. public static function addStudent($shop, $date = null)
  9. {
  10. $shopId = $shop->id;
  11. $sjId = $shop->sjId;
  12. $date = isset($date) ? $date : date("Ymd");
  13. $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $date], true);
  14. if (empty($stat)) {
  15. $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $date], true);
  16. }
  17. $stat->riseNum += 1;
  18. $stat->totalNum = $shop->totalStudent + 1;
  19. $stat->save();
  20. StatStudentMonthClass::addStudent($shop);
  21. }
  22. //今天的新学员数 ssh 20210524
  23. public static function getTodayNum($shop)
  24. {
  25. $today = date("Ymd");
  26. $shopId = $shop->id;
  27. $sjId = $shop->sjId;
  28. $new = self::getByCondition(['time' => $today, 'sjId' => $sjId, 'shopId' => $shopId], true);
  29. return $new->riseNum ?? 0;
  30. }
  31. }