1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace app\dao\work;
- use app\dao\BaseDao;
- use app\model\work\WorkClientFollow;
- use crmeb\traits\SearchDaoTrait;
- class WorkClientFollowDao extends BaseDao
- {
- use SearchDaoTrait;
-
- protected function setModel(): string
- {
- return WorkClientFollow::class;
- }
-
- public function searchWhere(array $where, bool $authWhere = true)
- {
- return $this->search($where)->when(!empty($where['user_name']), function ($query) use ($where) {
- $query->whereIn('client_id', function ($query) use ($where) {
- $query->name('work_client')->where('name', 'LIKE', '%' . $where['user_name'] . '%')->field(['id']);
- });
- })->when(!empty($where['state']), function ($query) use ($where) {
- $query->where('state', $where['state']);
- })->when(!empty($where['userid']), function ($query) use ($where) {
- if (is_array($where['userid'])) {
- $query->whereIn('userid', $where['userid']);
- } else {
- $query->where('userid', $where['userid']);
- }
- });
- }
-
- public function userIdByCilentCount(array $userId, int $codeId)
- {
- return $this->getModel()->whereIn('userid', $userId)->group('userid')->field(['userid', 'count(*) as sum'])->select()->toArray();
- }
-
- public function channelIdByCilentCount(array $channeId)
- {
- return $this->getModel()->whereDay('create_time')->whereIn('state', $channeId)->group('state')->field(['state', 'count(*) as sum'])->select()->toArray();
- }
- }
|