You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserStoreOrderServices.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\services\user;
  4. use app\services\BaseServices;
  5. use app\dao\user\UserStoreOrderDao;
  6. /**
  7. *
  8. * Class UserStoreOrderServices
  9. * @package app\services\user
  10. */
  11. class UserStoreOrderServices extends BaseServices
  12. {
  13. /**
  14. * UserStoreOrderServices constructor.
  15. * @param UserStoreOrderDao $dao
  16. */
  17. public function __construct(UserStoreOrderDao $dao)
  18. {
  19. $this->dao = $dao;
  20. }
  21. public function getUserSpreadCountList($uid, $orderBy = '', $keyword = '', $time = [])
  22. {
  23. if ($orderBy === '') {
  24. $orderBy = 'u.add_time desc';
  25. }
  26. $where = [];
  27. $where[] = ['u.uid', 'IN', $uid];
  28. if (strlen(trim($keyword))) {
  29. $where[] = ['u.nickname|u.phone', 'LIKE', "%$keyword%"];
  30. }
  31. if ($time[0] || $time[1]) {
  32. $where[] = ['spread_time', 'between', $time];
  33. }
  34. [$page, $limit] = $this->getPageValue();
  35. $field = "u.uid,u.nickname,u.avatar,from_unixtime(u.add_time,'%Y/%m/%d') as time,u.spread_time,u.spread_count as childCount,p.orderCount,p.numberCount";
  36. $list = $this->dao->getUserSpreadCountList($where, $field, $orderBy, $page, $limit);
  37. /** @var UserServices $userServices */
  38. $userServices = app()->make(UserServices::class);
  39. foreach ($list as &$item) {
  40. $item['childCount'] = count($userServices->getUserSpredadUids($item['uid'], 1)) ?? 0;
  41. }
  42. return $list;
  43. }
  44. }