123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- <?php
- namespace App\JsonRpc;
- use App\Model\Department;
- use App\Model\District;
- use App\Model\LetterOfComplaint;
- use App\Model\LetterType;
- use App\Model\LevelUser;
- use App\Model\UserLevel;
- use App\Tools\Result;
- use Hyperf\RpcServer\Annotation\RpcService;
- use App\Service\MinioService;
- #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
- class PublicRpcService implements PublicRpcServiceInterface
- {
- /**
- * @param array $data
- * @return array
- */
- public function getDistrictList(array $data): array
- {
- $where = [];
- if(isset($data['keyWord'])){
- $where = [
- ['name','like','%'.$data['keyWord'].'%']
- ];
- }
- $result = [];
- if(isset($data['pageSize'])){
- $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("code","asc")->get();
- $count = District::where($where)->count();
- $result = [
- 'rows'=>$rep,
- 'count'=>$count
- ];
- }else{
- $result = District::where($data)->orderBy("code","asc")->get();
- }
- return $result?Result::success($result):Result::error("没有查到数据");
- }
- /**
- * @param array $data
- * @return array
- */
- public function getUserLevelList(array $data): array
- {
- $where = [];
- if (isset($data['keyWord'])) {
- $where = [
- ['name', 'like', '%' . $data['keyWord'] . '%'],
- ];
- }
- $result = [];
- if (isset($data['pageSize'])) {
- $rep = UserLevel::where($where)->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("id", "asc")->get();
- $count = UserLevel::where($where)->count();
- $result = [
- 'rows' => $rep,
- 'count' => $count,
- ];
- } else {
- $result = UserLevel::orderBy("id", "asc")->get();
- }
- return $result ? Result::success($result) : Result::error("没有查到数据");
- }
- /**
- * 添加用户等级
- * @param array $data
- * @return array
- */
- public function addUserLevel(array $data): array
- {
- LevelUser::insertGetId($data);
- return Result::success([]);
- }
- /**
- * 更新等级
- * @param array $data
- * @return array
- */
- public function updateUserLevel(array $data): array
- {
- $result = LevelUser::where(['id' => $data['id']])->update($data);
- if ($result) {
- return Result::success($result);
- }
- return Result::error("更新失败");
- }
- /**
- * 删除等级
- * @param array $data
- * @return array
- */
- public function delUserLevel(array $data): array
- {
- $result = LevelUser::where(['id' => $data['id']])->delete();
- if ($result) {
- return Result::success($result);
- }
- return Result::error("删除失败");
- }
- /**
- * 查询投诉举报信息
- * @param array $data
- * @return array
- */
- public function getLetterOfComplaint(array $data = []): array
- {
- var_dump("====");
- $where = [];
- if (isset($data['user_id']) && !empty($data['user_id'])) {
- array_push($where, ['letter_of_complaint.user_id', '=', $data['user_id']]);
- }
- if (isset($data['nature']) && !empty($data['nature'])) {
- array_push($where, ['letter_of_complaint.nature', '=', $data['nature']]);
- }
- if (isset($data['nature_level0']) && !empty($data['nature_level0'])) {
- array_push($where, ['letter_of_complaint.nature_level0', '=', $data['nature_level0']]);
- }
- if (isset($data['status']) && !empty($data['status'])) {
- array_push($where, ['letter_of_complaint.status', '=', $data['status']]);
- }
- $result = [];
- if (isset($data['pageSize'])) {
- $rep = LetterOfComplaint::where($where)
- ->leftJoin("letter_type as type_a", "letter_of_complaint.nature", "type_a.id")
- ->leftJoin("letter_type as type_c", "letter_of_complaint.nature_level0", "type_c.id")
- ->leftJoin("letter_type as type_b", "letter_of_complaint.nature_level1", "type_b.id")
- ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
- ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
- ->select("letter_of_complaint.*",
- "type_a.type_name as nature_name",
- "type_b.type_name as nature_name1",
- "type_c.type_name as nature_name0",
- "type_d.type_name as status_name",
- "type_e.type_name as nature_name3")
- ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("letter_of_complaint.id", "desc")->get();
- $count = LetterOfComplaint::where($where)->count();
- if ($rep) {
- foreach ($rep as $val) {
- if ($val['judgment']) {
- $val['judgment'] = json_decode($val['judgment']);
- }
- if ($val['audio_and_video']) {
- $val['audio_and_video'] = json_decode($val['audio_and_video']);
- }
- if ($val['contract']) {
- $val['contract'] = json_decode($val['contract']);
- }
- if ($val['qualifications']) {
- $val['qualifications'] = json_decode($val['qualifications']);
- }
- }
- }
- $result = [
- 'rows' => $rep,
- 'count' => $count,
- ];
- } else {
- $result = LetterOfComplaint::where($where)
- ->leftJoin("letter_type as type_a", "letter_of_complaint.nature", "type_a.id")
- ->leftJoin("letter_type as type_c", "letter_of_complaint.nature_level0", "type_c.id")
- ->leftJoin("letter_type as type_b", "letter_of_complaint.nature_level1", "type_b.id")
- ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
- ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
- ->select("letter_of_complaint.*",
- "type_a.type_name as nature_name",
- "type_b.type_name as nature_name1",
- "type_c.type_name as nature_name0",
- "type_d.type_name as status_name",
- "type_e.type_name as nature_name3")
- ->orderBy("letter_of_complaint.id", "desc")->get();
- }
- return $result ? Result::success($result) : Result::error("没有查到数据");
- }
- /**
- * 添加投诉举报信息
- * @param array $data
- * @return array
- */
- public function addLetterOfComplaint(array $data): array
- {
- $data['judgment'] = $data['judgment'] ? json_encode($data['judgment']) : '';
- $data['audio_and_video'] = $data['audio_and_video'] ? json_encode($data['audio_and_video']) : '';
- $data['contract'] = $data['contract'] ? json_encode($data['contract']) : '';
- $data['qualifications'] = $data['qualifications'] ? json_encode($data['qualifications']) : '';
- unset($data['id']);
- $result = LetterOfComplaint::insertGetId($data);
- if (empty($result)) {
- return Result::error("创建失败", 0);
- } else {
- return Result::success(["id" => $result]);
- }
- }
- /**
- * 用户端更新投诉举报
- * @param array $data
- * @return array
- */
- public function userUpLetterOfComplaint(array $data): array
- {
- $data['judgment'] = $data['judgment'] ? json_encode($data['judgment']) : '';
- $data['audio_and_video'] = $data['audio_and_video'] ? json_encode($data['audio_and_video']) : '';
- $data['contract'] = $data['contract'] ? json_encode($data['contract']) : '';
- $data['qualifications'] = $data['qualifications'] ? json_encode($data['qualifications']) : '';
- $result = LetterOfComplaint::where(['id' => $data['id']])->update($data);
- if (empty($result)) {
- return Result::error("创建失败", 0);
- } else {
- return Result::success(["id" => $result]);
- }
- }
- /**
- * 管理后台更新投诉举报信息
- * @param array $data
- * @return array
- */
- public function upLetterOfComplaint(array $data): array
- {
- var_dump("admin:", $data);
- $where = [
- 'id' => $data['id'],
- ];
- $filtered_array = array_filter($data, function ($value) {
- return $value !== "" && $value !== null && $value !== false && !is_array($value) || !empty($value);
- });
- $filtered_array['judgment'] = isset($filtered_array['judgment']) ? json_encode($filtered_array['judgment']) : '';
- $filtered_array['audio_and_video'] = isset($filtered_array['audio_and_video']) ? json_encode($filtered_array['audio_and_video']) : '';
- $filtered_array['contract'] = isset($filtered_array['contract']) ? json_encode($filtered_array['contract']) : '';
- $filtered_array['qualifications'] = isset($filtered_array['qualifications']) ? json_encode($filtered_array['qualifications']) : '';
- unset($filtered_array['nature_name']);
- unset($filtered_array['type_name']);
- unset($filtered_array['nature_level_name']);
- unset($filtered_array['status_name']);
- unset($filtered_array['is_admin']);
- unset($filtered_array['type_level_name']);
- $result = LetterOfComplaint::where($where)->update($filtered_array);
- if ($result) {
- return Result::success($result);
- }
- return Result::error("更新失败", 0);
- }
- /**
- * 查询投诉举报记录
- * @param array $data
- * @return array
- */
- public function getLetterOfComplaintInfo(array $data): array
- {
- $where = [
- 'letter_of_complaint.id' => $data['id'],
- ];
- if (isset($data['user_id']) && !empty($data['user_id'])) {
- array_push($where, ['letter_of_complaint.user_id', '=', $data['user_id']]);
- }
- $result = LetterOfComplaint::where($where)
- ->leftJoin("letter_type as type_a", "letter_of_complaint.nature", "type_a.id")
- ->leftJoin("letter_type as type_c", "letter_of_complaint.nature_level0", "type_c.id")
- ->leftJoin("letter_type as type_b", "letter_of_complaint.nature_level1", "type_b.id")
- ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
- ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
- ->select("letter_of_complaint.*",
- "type_a.type_name as nature_name",
- "type_b.type_name as nature_name1",
- "type_c.type_name as nature_name0",
- "type_d.type_name as status_name",
- "type_e.type_name as nature_name3")
- ->first();
- return Result::success($result);
- }
- /**
- * 删除投诉举报信息
- * @param array $data
- * @return array
- */
- public function delLetterOfComplaint(array $data): array
- {
- $result = LetterOfComplaint::when($data,function ($query) use ($data){
- if(isset($data['id']) && !empty($data['id'])){
- $query->where(['id'=>$data['id']]);
- }
- if(isset($data['user_id']) && !empty($data['user_id'])){
- $query->where(['user_id'=>$data['user_id']]);
- }
- })->delete();
- if (empty($result)) {
- return Result::error("删除失败", 0);
- } else {
- return Result::success();
- }
- }
- /**
- * 获取举报信息类型
- * @param array $data
- * @return array
- */
- public function getLetterType(array $data): array
- {
- $where = [];
- if (isset($data['type'])) {
- array_push($where, ['type', '=', $data['type']]);
- }
- if (isset($data['pid']) && $data['pid']>0) {
- array_push($where, ['pid', '=', $data['pid']]);
- }
- $result = LetterType::where($where)->orderBy('sort','asc')->get();
- return $result ? Result::success($result) : Result::error("没有查到数据");
- }
- /**
- * 更新举报类型
- * @param array $data
- * @return array
- */
- public function upLetterType(array $data): array
- {
- return [];
- }
- /**
- * 添加举报类型
- * @param array $data
- * @return array
- */
- public function addLetterType(array $data): array
- {
- $result = LetterType::insertGetId($data);
- if (empty($result)) {
- return Result::error("创建失败", 0);
- } else {
- return Result::success(["id" => $result]);
- }
- }
- /**
- * 删除举报类型
- * @param array $data
- * @return array
- */
- public function delLetterType(array $data): array
- {
- $result = LetterType::where('id', $data['id'])->delete();
- if (empty($result)) {
- return Result::error("删除失败", 0);
- } else {
- return Result::success();
- }
- }
- /**
- * 检测是否已经被接案
- * @param array $data
- * @return array
- */
- public function checkMeasure(array $data): array
- {
- $where = [
- 'id' => $data['id'],
- ];
- $letterOfComplaintInfo = LetterOfComplaint::where($where)->first();
- var_dump("查询数据:", $letterOfComplaintInfo['admin_id'], $data['user_id']);
- //操作人和当前登陆用户id 相等说明是当前人接收的案件
- if (($letterOfComplaintInfo['admin_id'] == $data['user_id']) || empty($letterOfComplaintInfo['admin_id'])) {
- return Result::success();
- } else {
- return Result::error("您不能处理其他人已经接过的案件", 0);
- }
- }
- /**
- * 后台获取职能部门
- * @param array $data
- * @return array
- */
- public function getZhinengbumenList(array $data): array
- {
- // 获取分页参数,默认每页 10 条记录
- $page = isset($data['page']) ? (int) $data['page'] : 1;
- $perPage = isset($data['pagesize']) ? (int) $data['pagesize'] : 10;
- // 查询数据并分页
- $query = Department::query();
- // 可以在这里添加更多的查询条件
- if (isset($data['search'])) {
- $query->where('name', 'like', '%' . $data['search'] . '%');
- }
- // 执行分页查询
- $result = $query->paginate($perPage, ['*'], 'page', $page);
- // 返回分页结果
- return Result::success([
- 'count' => $result->total(),
- 'current_page' => $result->currentPage(),
- 'last_page' => $result->lastPage(),
- 'pagesize' => $result->perPage(),
- 'rows' => $result->items(),
- ]);
- }
- /**
- * 添加获取职能部门
- * @param array $data
- * @return array
- */
- public function addZhinengbumen(array $data): array
- {
- $result = Department::insertGetId($data);
- if (empty($result)) {
- return Result::error("创建失败", 0);
- } else {
- return Result::success(["id" => $result]);
- }
- }
- public function delZhinengbumen(array $data): array
- {
- $result = Department::where('id', $data['id'])->delete();
- if (empty($result)) {
- return Result::error("删除失败", 0);
- } else {
- return Result::success();
- }
- }
- public function getZhinengbumen(array $data): array
- {
- $result = Department::where('id', $data['id'])->first();
- return Result::success($result);
- }
- public function getPidZhinengbumen(array $data): array
- {
- if (empty($data['pid'])) {
- $data['pid'] = 0;
- }
- $result = Department::where('pid', $data['pid'])->get();
- return Result::success($result);
- }
- public function modZhinengbumen(array $data): array
- {
- $result = Department::where('id', $data['id'])->update($data);
- if (empty($result)) {
- return Result::error("修改失败", 0);
- } else {
- return Result::success();
- }
- }
- /**
- * 查询职能列表
- * @param array $data
- * @return array
- */
- public function getDepartment(array $data) :array
- {
- $where = [];
- if(isset($data['pid'])){
- $where = [
- 'pid'=>$data['pid']??0
- ];
- }
- $result = Department::when(!empty($where),function ($query) use ($where){
- $query->where($where);
- })->orderBy("sort","desc")->get();
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }else{
- return Result::success($result);
- }
- }
- /**
- * 获取所有的buckets
- * @param array $data
- * @return array
- */
- public function getBuckets(array $data) :array
- {
- $result = new MinioService();
- // 调用服务层的方法获取存储桶列表
- $bucketsResponse =$result->listBuckets();
- // 直接返回服务层生成的响应
- return Result::success($bucketsResponse['data']);
- }
- /**
- * 上传文件
- * @param array $data
- * @return array
- */
- public function uploadFile(array $data) :array
- {
- $result = new MinioService();
- $rep = $result->uploadFile($data);
- if($rep['code']==200){
- return Result::success($rep['data']);
- }else{
- return Result::error("上传失败!");
- }
- }
- }
|