findOrEmpty($params['id'])->toArray(); } /** * @notes 查看供需详情 * @param $params * @return array * @author heshihu * @date 2022/2/21 17:54 */ public static function detailCate($params) : array { return SupplyDemandCate::findOrEmpty($params['id'])->toArray(); } /** * @notes 更改服务商状态 * @param array $params * @return bool * @author heshihu * @date 2022/2/21 18:04 */ public static function updateStatus(array $params) { SupplyDemandInfo::update([ 'id' => $params['id'], 'status' => $params['status'], 'audit_time' =>time(), 'remark' => $params['remark'] ]); return true; } /** * @notes 有效用户数据 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 段誉 * @date 2022/10/13 10:53 */ public static function getValidUserData() { $list = User::where(['is_disable' => YesNoEnum::NO]) ->field('id,sn,nickname') ->order([ 'id' => 'desc']) ->select() ->toArray(); return $list; } /** * @notes 添加供应分类 * @param array $params * @author heshihu * @date 2022/2/18 10:17 */ public static function addCate(array $params) { $pid = $params['pid']; $level = 1; $pidInfo = SupplyDemandCate::find($pid); if(!empty($pidInfo)){ $level = $pidInfo['level'] + 1; } SupplyDemandCate::create([ 'name' => $params['name'], 'level' => $level, 'pid' => $pid, 'type' => $params['type'] ?? 1, 'status' => $params['status'] ?? 1, 'sort' => $params['sort'] ?? 0 ]); } public static function editCate(array $params) : bool { try { $pid = $params['pid']; $level = 1; $pidInfo = SupplyDemandCate::find($pid); if(!empty($pidInfo)){ $level = $pidInfo['level'] + 1; } SupplyDemandCate::update([ 'id' => $params['id'], 'name' => $params['name'], 'level' => $level, 'pid' => $pid, 'status' => $params['status'] ?? 1, 'sort' => $params['sort'] ?? 0 ]); return true; } catch (\Exception $e) { self::setError($e->getMessage()); return false; } } public static function updateCateStatus(array $params) { SupplyDemandCate::update([ 'id' => $params['id'], 'status' => $params['status'], ]); return true; } public static function deleteCate(array $params) { SupplyDemandCate::destroy($params['id']); } }