Favorite.php 918 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\shop\model\user;
  3. use app\common\model\user\Favorite as FavoriteModel;
  4. /**
  5. * 收藏模型
  6. */
  7. class Favorite extends FavoriteModel
  8. {
  9. /**
  10. * 获取用户统计数量
  11. */
  12. public function getFavData($startDate = null, $endDate = null, $type)
  13. {
  14. $model = $this;
  15. if(!is_null($startDate)){
  16. $model = $model->where('create_time', '>=', strtotime($startDate));
  17. }
  18. if(is_null($endDate)){
  19. $model = $model->where('create_time', '<', strtotime($startDate) + 86400);
  20. }else{
  21. $model = $model->where('create_time', '<', strtotime($endDate) + 86400);
  22. }
  23. if($type == 'product'){
  24. return $model->where('type', '=', 20)->count();
  25. }else if($type == 'supplier'){
  26. return $model->where('type', '=', 10)->count();
  27. }
  28. return 0;
  29. }
  30. }