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.

WorkClientFollowDao.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\dao\work;
  3. use app\dao\BaseDao;
  4. use app\model\work\WorkClientFollow;
  5. use crmeb\traits\SearchDaoTrait;
  6. /**
  7. * 企业微信客户跟踪
  8. * Class WorkClientFollowDao
  9. * @package app\dao\wechat\work
  10. */
  11. class WorkClientFollowDao extends BaseDao
  12. {
  13. use SearchDaoTrait;
  14. /**
  15. * @return string
  16. */
  17. protected function setModel(): string
  18. {
  19. return WorkClientFollow::class;
  20. }
  21. /**
  22. * 搜索
  23. * @param array $where
  24. * @param bool $authWhere
  25. */
  26. public function searchWhere(array $where, bool $authWhere = true)
  27. {
  28. return $this->getModel()->when(!empty($where['user_name']), function ($query) use ($where) {
  29. $query->whereIn('client_id', function ($query) use ($where) {
  30. $query->name('work_client')->where('name', 'LIKE', '%' . $where['user_name'] . '%')->field(['id']);
  31. });
  32. })->when(!empty($where['state']), function ($query) use ($where) {
  33. $query->where('state', $where['state']);
  34. })->when(!empty($where['userid']), function ($query) use ($where) {
  35. if (is_array($where['userid'])) {
  36. $query->whereIn('userid', $where['userid']);
  37. } else {
  38. $query->where('userid', $where['userid']);
  39. }
  40. });
  41. }
  42. /**
  43. * 根据员工userid获取今日添加客户总数
  44. * @param array $userId
  45. * @param int $codeId
  46. * @return mixed
  47. */
  48. public function userIdByCilentCount(array $userId, int $codeId)
  49. {
  50. return $this->getModel()->whereIn('userid', $userId)->group('userid')->field(['userid', 'count(*) as sum'])->select()->toArray();
  51. }
  52. /**
  53. * 获取二维码添加客户数量
  54. * @param array $channeId
  55. * @return mixed
  56. */
  57. public function channelIdByCilentCount(array $channeId)
  58. {
  59. return $this->getModel()->whereDay('create_time')->whereIn('state', $channeId)->group('state')->field(['state', 'count(*) as sum'])->select()->toArray();
  60. }
  61. }