diff --git a/application/plugins/petscms/Petsadmin.php b/application/plugins/petscms/Petsadmin.php index 55e5a4f8cd8806002968fc8c831ad2345b76c4d7..8b419b770f2c4b75cfd94e25b0a9d455c5432dac 100644 --- a/application/plugins/petscms/Petsadmin.php +++ b/application/plugins/petscms/Petsadmin.php @@ -49,7 +49,7 @@ class PetsAdmin extends Controller 'total' => $total, 'where' => $params, 'page' => isset($params['page']) ? intval($params['page']) : 1, - 'url' => PluginsHomeUrl('petscms', 'pets', 'index'), + 'url' => PluginsAdminUrl('petscms', 'petsadmin', 'index'), ); $page = new \base\Page($page_params); $this->assign('page_html', $page->GetPageHtml()); @@ -152,7 +152,45 @@ class PetsAdmin extends Controller } // 用户 - return Service::PestSave($params); + return Service::PetsSave($params); + } + + /** + * 宠物解绑 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-15T11:03:30+0800 + */ + public function untying($params = []) + { + // 是否ajax + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始操作 + return Service::PetsUntying($params); + } + + /** + * 宠物删除 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-15T11:03:30+0800 + */ + public function delete($params = []) + { + // 是否ajax + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始操作 + return Service::PetsDelete($params); } /** @@ -188,7 +226,7 @@ class PetsAdmin extends Controller 'total' => $total, 'where' => $params, 'page' => isset($params['page']) ? intval($params['page']) : 1, - 'url' => PluginsHomeUrl('petscms', 'pets', 'index'), + 'url' => PluginsAdminUrl('petscms', 'petsadmin', 'index'), ); $page = new \base\Page($page_params); $this->assign('page_html', $page->GetPageHtml()); @@ -200,7 +238,9 @@ class PetsAdmin extends Controller 'where' => $where, ); $data = Service::HelpList($data_params); + unset($params['pets_id']); $this->assign('data_list', $data['data']); + $this->assign('params', $params); return $this->fetch('../../../plugins/view/petscms/petsadmin/help'); } diff --git a/application/plugins/petscms/Service.php b/application/plugins/petscms/Service.php index bab7de3f256b6ac44885fa1f13698920061c4adb..a4607e320a4e98fb389c37f3efbb80293c6fe865 100644 --- a/application/plugins/petscms/Service.php +++ b/application/plugins/petscms/Service.php @@ -64,7 +64,7 @@ class Service $where = empty($params['where']) ? [] : $params['where']; $m = isset($params['m']) ? intval($params['m']) : 0; $n = isset($params['n']) ? intval($params['n']) : 10; - $order_by = empty($params['order_by']) ? 'id desc' : $params['order_by']; + $order_by = empty($params['order_by']) ? 'status asc, id desc' : $params['order_by']; // 获取数据列表 $data = Db::name('PluginsPetscmsPets')->where($where)->limit($m, $n)->order($order_by)->select(); @@ -76,13 +76,13 @@ class Service $v['type_name'] = empty($v['type']) ? '' : self::$pets_attribute_type_list[$v['type']]['name']; // 性别 - $v['gender_name'] = self::$pets_attribute_gender_list[$v['gender']]['name']; + $v['gender_name'] = ($v['gender'] == -1) ? '' : self::$pets_attribute_gender_list[$v['gender']]['name']; // 是否绝育 - $v['sterilization_name'] = self::$pets_attribute_is_text_list[$v['sterilization']]['name']; + $v['sterilization_name'] = ($v['sterilization'] == -1) ? '' : self::$pets_attribute_is_text_list[$v['sterilization']]['name']; // 是否疫苗 - $v['vaccine_name'] = self::$pets_attribute_is_text_list[$v['vaccine']]['name']; + $v['vaccine_name'] = ($v['vaccine'] == -1) ? '' : self::$pets_attribute_is_text_list[$v['vaccine']]['name']; // 状态 $v['status_name'] = self::$pets_attribute_status_list[$v['status']]['name']; @@ -102,7 +102,7 @@ class Service $v['content'] = ResourcesService::ContentStaticReplace($v['content'], 'get'); // 相册 - $v['photo'] = empty($v['photo']) ? null : self::GetPestPhotoHandle($v['photo']); + $v['photo'] = empty($v['photo']) ? null : self::GetPetsPhotoHandle($v['photo']); // 丢失时间 $v['lose_time_name'] = empty($v['lose_time']) ? '' : date('Y-m-d', $v['lose_time']); @@ -138,7 +138,7 @@ class Service * @datetime 2019-04-11T22:56:49+0800 * @param [array] $photo [相册数据] */ - private static function GetPestPhotoHandle($photo) + private static function GetPetsPhotoHandle($photo) { $result = []; if(!empty($photo)) @@ -241,7 +241,7 @@ class Service * @desc description * @param [array] $params [输入参数] */ - public static function PestSave($params = []) + public static function PetsSave($params = []) { // 请求参数 $p = [ @@ -359,9 +359,9 @@ class Service 'birthday' => empty($params['birthday']) ? 0 : strtotime($params['birthday']), 'type' => isset($params['type']) ? $params['type'] : '', 'varieties' => isset($params['varieties']) ? $params['varieties'] : '', - 'gender' => isset($params['gender']) ? intval($params['gender']) : 0, - 'sterilization' => isset($params['sterilization']) ? intval($params['sterilization']) : 0, - 'vaccine' => isset($params['vaccine']) ? intval($params['vaccine']) : 0, + 'gender' => isset($params['gender']) ? $params['gender'] : -1, + 'sterilization' => isset($params['sterilization']) ? $params['sterilization'] : -1, + 'vaccine' => isset($params['vaccine']) ? $params['vaccine'] : -1, 'photo' => empty($photo['data']) ? '' : json_encode($photo['data']), 'content' => $content, 'person_name' => isset($params['person_name']) ? $params['person_name'] : '', @@ -586,5 +586,73 @@ class Service { return (int) Db::name('PluginsPetscmsHelp')->where($where)->count(); } + + /** + * 宠物解绑 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function PetsUntying($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 解绑操作 + if(Db::name('PluginsPetscmsPets')->where(['id'=>$params['id']])->update(['user_id'=>0, 'upd_time'=>time()])) + { + return DataReturn('解绑成功'); + } + + return DataReturn('解绑失败或资源不存在', -100); + } + + /** + * 宠物删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function PetsDelete($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 删除操作 + if(Db::name('PluginsPetscmsPets')->where(['id'=>$params['id']])->delete()) + { + return DataReturn('删除成功'); + } + + return DataReturn('删除失败或资源不存在', -100); + } } ?> \ No newline at end of file diff --git a/application/plugins/view/petscms/pets/index.html b/application/plugins/view/petscms/pets/index.html index 0894a9567b13c014be42b2912733c1ff5ba36261..0a70dffb4ea42e937cbed302cfb98046e34f5efa 100644 --- a/application/plugins/view/petscms/pets/index.html +++ b/application/plugins/view/petscms/pets/index.html @@ -114,7 +114,7 @@