['mw.sn', 'mw.real_name', 'mw.account', 'mw.password', 'mw.mobile', 'mw.sex', 'mw.channel', 'mw.is_disable', 'mw.is_new_user', 'mw.create_time', 'mw.update_time'], ]; } public function queryWhere(){ $where = []; // 用户昵称 if (isset($this->params['nickname']) && !empty($this->params['nickname'])) { $where[] = ['mw.nickname|mw.worker_number', 'like','%' .$this->params['nickname'] . '%']; } if (isset($this->params['worker_number']) && !empty($this->params['worker_number'])) { $where[] = ['mw.worker_number', 'like','%' .$this->params['worker_number'] . '%']; } if (isset($this->params['worker_exp_type']) && !empty($this->params['worker_exp_type'])) { $where[] = ['mwr.maintain_exp_type', '=', $this->params['worker_exp_type']]; } if(isset($this->params['min_work_number']) && is_numeric($this->params['min_work_number'])){ $where[] =[ 'mw.work_total','>=',$this->params['min_work_number']]; } if(isset($this->params['max_work_number']) && is_numeric($this->params['max_work_number'])){ $where[] =[ 'mw.work_total','<= ',$this->params['max_work_number']]; } $goods_category_id = 0; if(isset($this->params['order_id']) && $this->params['order_id']){ $lon_lat = (ServiceWork::where('id',$this->params['order_id'])->column("lon,lat,goods_category_id"))[0]; $this->lon = $lon_lat['lon']; $this->lat = $lon_lat['lat']; $goods_category_id = $lon_lat['goods_category_id']; } $ids = DistributeLeafletsService::getIntersection($this->lon, $this->lat,$goods_category_id); $where[] = [ 'mw.id','IN',$ids]; Log::debug('MasterWorker-where:'.json_encode($where)); return $where; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/07/10 18:17 */ public function lists(): array { $list = MasterWorker::alias('mw') ->join('master_worker_register mwr', 'mwr.worker_id = mw.id') ->where($this->searchWhere) ->where($this->queryWhere()) ->field([ 'mw.*', 'mwr.maintain_exp_type', 'mwr.other_exp_type', ]) ->limit($this->limitOffset, $this->limitLength) ->order(['mw.id' => 'desc']) ->select() ->toArray(); $distances = DistributeLeafletsService::locationIds($this->lon, $this->lat,0,array_keys(array_column($list, 'distance','id'))); foreach ($list as &$item){ $item['user_distance'] = $distances[$item['id']]??0; } return $list; } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2024/07/10 18:17 */ public function count(): int { return MasterWorker::alias('mw') ->join('master_worker_register mwr', 'mwr.worker_id = mw.id') ->field([ 'mw.*']) ->where($this->searchWhere)->where($this->queryWhere()) ->count(); //return $this->count; } }