['title','mobile','address'], '=' => ['type'] ]; } /** * @notes 自定查询条件 * @return array * @author 段誉 * @date 2022/10/25 16:53 */ public function queryWhere() { $where[] = ['status', '=', 2]; // $where[] = ['expiration_time', '>=', time()]; // if (!empty($this->params['cate_id'])) { // // $where[] = ['cate_id', 'like', '%' . ',' .$this->params['cate_id'].',' . '%']; // } // // if (!empty($this->params['area_id'])) { // // $where[] = ['area_id', 'like', '%' . ',' .$this->params['area_id'].',' . '%']; // } return $where; } /** * @notes 获取供需列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 段誉 * @date 2022/9/16 18:55 */ public function lists(): array { $orderRaw = 'id desc'; $field = 'id,user_id,title,type,mobile,images,address,number,content,status,remark,create_time'; $result = SupplyDemandInfo::field($field) ->where($this->queryWhere()) ->where($this->searchWhere) ->orderRaw($orderRaw) ->append(['type_desc','status_desc','images','user']) ->limit($this->limitOffset, $this->limitLength) ->select()->toArray(); return $result; } /** * @notes 获取服务商数量 * @return int * @author 段誉 * @date 2022/9/16 18:55 */ public function count(): int { return SupplyDemandInfo::where($this->searchWhere) ->where($this->queryWhere()) ->count(); } }