['name', 'status'] ]; } /** * @notes 资产信息列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author ljj * @date 2022/2/16 3:18 下午 */ public function lists(): array { $lists = (new AssetInfo())->field('id,name,address,images,contacts,mobile,area,content,status,lease_status,lease_expiration_time,create_time,sort') ->append(['status_desc','lease_status_desc']) ->where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->Order('sort desc') ->select() ->toArray(); return $lists; } /** * @notes 资产信息数量 * @return int * @author ljj * @date 2022/2/16 3:18 下午 */ public function count(): int { return (new AssetInfo())->where($this->searchWhere)->count(); } /** * @notes 添加资产 * @param array $params * @author heshihu * @date 2022/2/22 9:57 */ public static function add(array $params) { AssetInfo::create([ 'name' => $params['name'], 'images' => $params['images'] ?? '', 'address' => $params['address'] ?? '', 'contacts' => $params['contacts']?? '', // 联系人 'mobile' => $params['mobile'] ?? '', 'area' => $params['area'] ?? '', 'content' => $params['content'] ?? '', // 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', 'status' => $params['status'] ?? 1, 'sort' => $params['sort'] ?? 0, // 排序 ]); } /** * @notes 编辑资产 * @param array $params * @return bool * @author heshihu * @date 2022/2/22 10:12 */ public static function edit(array $params) : bool { try { AssetInfo::update([ 'id' => $params['id'], 'name' => $params['name'], 'images' => $params['images'], 'address' => $params['address'], 'contacts' => $params['contacts'], 'mobile' => $params['mobile'], 'area' => $params['area'] ?? '', 'content' => $params['content'] ?? '', 'status' => $params['status'] ?? 1, 'sort' => $params['sort'] ?? 0, 'content' => $params['content'] ?? '', ]); return true; } catch (\Exception $e) { self::setError($e->getMessage()); return false; } } /** * @notes 删除资产 * @param array $params * @author heshihu * @date 2022/2/22 10:17 */ public static function delete(array $params) { AssetInfo::destroy($params['id']); } /** * @notes 查看资产详情 * @param $params * @return array * @author heshihu * @date 2022/2/22 10:15 */ public static function detail($params) : array { return AssetInfo::findOrEmpty($params['id'])->append(['status_desc','lease_status_desc'])->toArray(); } public static function getRentAssetList($params) : array { $where = [] ; if(!empty($params)){ $where[]=['name','like','%'.$params['name'].'%']; } $where[]=['status','=',1]; $where[]=['lease_status','in',[1,3]]; $assetList = AssetInfo::where($where)->field('id,name,area')->select()->toArray(); return $assetList; } }