NewsService.php 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. <?php
  2. namespace App\JsonRpc;
  3. use App\Model\Article;
  4. use App\Model\ArticleData;
  5. use App\Model\Category;
  6. use App\Model\Website;
  7. use App\Model\WebsiteCategory;
  8. use App\Model\ArticleSurvey;
  9. use App\Model\District;
  10. use App\Model\Good;
  11. use App\Model\JobRecruiting;
  12. use App\Model\JobIndustry;
  13. use App\Model\JobPosition;
  14. use App\Model\JobNature;
  15. use App\Model\JobEnum;
  16. use App\Model\User;
  17. use App\Model\UserRole;
  18. use App\Model\News;
  19. use App\Model\UserInfo;
  20. use App\Model\WebsiteGroup;
  21. use Hyperf\DbConnection\Db;
  22. use Hyperf\RpcServer\Annotation\RpcService;
  23. use App\Tools\Result;
  24. use Directory;
  25. use Ramsey\Uuid\Uuid;
  26. use Hyperf\Utils\Random;
  27. #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
  28. class NewsService implements NewsServiceInterface
  29. {
  30. /**
  31. * 获取导航池列表
  32. * @param array $data
  33. * @return array
  34. */
  35. public function getCategoryList(array $data): array
  36. {
  37. $where = [];
  38. if (isset($data['name']) && $data['name']) {
  39. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  40. }
  41. if (isset($data['department_id']) && $data['department_id']) {
  42. array_push($where, ['category.department_id', '=', $data['department_id']]);
  43. }
  44. $city_id = '';
  45. if (isset($data['city_id']) && $data['city_id']) {
  46. $city_id = intval($data['city_id']);
  47. }
  48. $rep = Category::where($where)
  49. ->when($city_id, function ($query) use ($city_id) {
  50. if (isset($city_id) && $city_id) {
  51. $query->whereJsonContains("category.city_arr_id", $city_id);
  52. }
  53. })
  54. ->leftJoin('district', 'category.city_id', 'district.id')
  55. ->leftJoin('department', 'category.department_id', 'department.id')
  56. ->select("category.*", "district.name as city_name", "department.name as department_name")
  57. ->limit($data['pageSize'])->orderByDesc('category.updated_at')->offset(($data['page'] - 1) * $data['pageSize'])->get();
  58. $count = Category::where($where)->when($city_id, function ($query) use ($city_id) {
  59. if (isset($city_id) && $city_id) {
  60. $query->whereJsonContains("category.city_arr_id", $city_id);
  61. }
  62. })->count();
  63. $data = [
  64. 'rows' => $rep->toArray(),
  65. 'count' => $count,
  66. ];
  67. if (empty($rep->toArray())) {
  68. return Result::error("没有导航池数据");
  69. }
  70. return Result::success($data);
  71. }
  72. public function myCategoryList(array $data): array
  73. {
  74. $sszq = $data['sszq'] ?? '';
  75. unset($data['sszq']);
  76. //1,2,3 根据这些webid,。从website_category表中取出对应的分类id,然后从category表中取出分类信息
  77. $catorytids = WebsiteCategory::whereIn('website_id', explode(',', $sszq))->get()->pluck('category_id')->toArray();
  78. $where[] = [
  79. 'pid', '=', $data['pid'],
  80. ];
  81. if (isset($data['name'])) {
  82. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  83. }
  84. var_dump($where);
  85. //根据分类id,从category表中取出分类信息
  86. $result = Category::where($where)
  87. ->whereIn('category.id', $catorytids)
  88. ->select('category.*', 'category.id as category_id')->get();
  89. if (empty($result)) {
  90. return Result::error("没有栏目数据");
  91. }
  92. return Result::success($result);
  93. }
  94. /**
  95. * @param array $data
  96. * @return array
  97. */
  98. public function categoryList(array $data): array
  99. {
  100. $where[] = [
  101. 'pid', '=', $data['pid'],
  102. ];
  103. if (isset($data['name'])) {
  104. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  105. }
  106. var_dump($where);
  107. $result = Category::where($where)->select('category.*', 'category.id as category_id')->get();
  108. if (empty($result)) {
  109. return Result::error("没有栏目数据");
  110. }
  111. return Result::success($result);
  112. }
  113. /**
  114. * @param array $data
  115. * @return array
  116. */
  117. public function addCategory(array $data): array
  118. {
  119. $id = Category::insertGetId($data);
  120. if (empty($id)) {
  121. return Result::error("添加失败");
  122. }
  123. return Result::success(['id' => $id]);
  124. }
  125. /**
  126. * @param array $data
  127. * @return array
  128. */
  129. public function delCategory(array $data): array
  130. {
  131. $categoryList = Category::where(['pid' => $data['id']])->get();
  132. var_dump("分类列表:", $data, $categoryList);
  133. if ($categoryList->toArray()) {
  134. return Result::error("分类下面有子分类不能删除");
  135. }
  136. $articleList = Article::where(['catid' => $data['id']])->get();
  137. var_dump("文章列表:", $articleList);
  138. if ($articleList->toArray()) {
  139. return Result::error("分类下面有资讯不能删除");
  140. }
  141. $result = Category::where($data)->delete();
  142. if (!$result) {
  143. return Result::error("删除失败");
  144. }
  145. return Result::success($result);
  146. }
  147. /**
  148. * @param array $data
  149. * @return array
  150. */
  151. public function updateCategory(array $data): array
  152. {
  153. $where = [
  154. 'id' => $data['id'],
  155. ];
  156. $result = Category::where($where)->update($data);
  157. if ($result) {
  158. return Result::success($result);
  159. } else {
  160. return Result::error("更新失败");
  161. }
  162. }
  163. /**
  164. * 获取导航池信息
  165. * @param array $data
  166. * @return array
  167. */
  168. public function getCategoryInfo(array $data): array
  169. {
  170. $where = [
  171. 'id' => $data['id'],
  172. ];
  173. $result = Category::where($where)->first();
  174. if ($result) {
  175. return Result::success($result);
  176. } else {
  177. return Result::error("更新失败");
  178. }
  179. }
  180. /**
  181. * @param array $data
  182. * @return array
  183. */
  184. public function getArticleList(array $data): array
  185. {
  186. //判断是否是管理员'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
  187. $type_id = $data['type_id'];
  188. unset($data['type_id']);
  189. $user_id = $data['user_id'];
  190. unset($data['user_id']);
  191. $where = [];
  192. if (isset($data['title']) && $data['title']) {
  193. array_push($where, ['article.title', 'like', '%' . $data['title'] . '%']);
  194. }
  195. if (isset($data['category_name']) && $data['category_name']) {
  196. array_push($where, ['category.name', 'like', '%' . $data['category_name'] . '%']);
  197. }
  198. if (isset($data['author']) && $data['author']) {
  199. array_push($where, ['article.author', '=', $data['author']]);
  200. }
  201. if (isset($data['islink']) && $data['islink'] !== "") {
  202. array_push($where, ['article.islink', '=', $data['islink']]);
  203. }
  204. if (isset($data['status']) && $data['status'] !== "") {
  205. array_push($where, ['article.status', '=', $data['status']]);
  206. }
  207. //不是管理员展示个人数据;
  208. if ($type_id != 10000) {
  209. $where[] = ['article.admin_user_id', '=', $user_id];
  210. }
  211. $rep = Article::where($where)
  212. ->whereNotIn('article.status', [404])
  213. ->leftJoin('category', 'article.catid', 'category.id')
  214. ->select("article.*", "category.name as category_name")
  215. ->orderBy("article.id", "desc")
  216. ->limit($data['pageSize'])
  217. ->offset(($data['page'] - 1) * $data['pageSize'])->get();
  218. $count = Article::where($where)->whereNotIn('article.status', [404])
  219. ->leftJoin('category', 'article.catid', 'category.id')->count();
  220. $data = [
  221. 'rows' => $rep->toArray(),
  222. 'count' => $count,
  223. ];
  224. if (empty($rep)) {
  225. return Result::error("没有信息数据");
  226. }
  227. return Result::success($data);
  228. }
  229. /**
  230. * @param array $data
  231. * @return array
  232. */
  233. public function addArticle(array $data): array
  234. {
  235. var_dump($data, '----------12-----------1');
  236. var_dump($data, '----------12-----------1');
  237. unset($data['user_type']);
  238. // unset($data['web_site_id']);
  239. unset($data['nav_add_pool_id']);
  240. // $data['cat_arr_id'] = is_string($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  241. Db::beginTransaction();
  242. try {
  243. //处理投票
  244. $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
  245. $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
  246. $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
  247. $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
  248. unset($data['is_survey']);
  249. unset($data['survey_name']);
  250. unset($data['suvey_array']);
  251. unset($data['website_id']);
  252. if ($data['hits'] == '') {
  253. $data['hits'] = 0;
  254. }
  255. if ($data['is_original'] == '') {
  256. $data['is_original'] = 0;
  257. }
  258. if ($data['status'] == '') {
  259. $data['status'] = 0;
  260. }
  261. $articleData = $data;
  262. unset($articleData['content']);
  263. $id = Article::insertGetId($articleData);
  264. $articleDataContent = [
  265. 'article_id' => $id,
  266. 'content' => $data['content'],
  267. ];
  268. ArticleData::insertGetId($articleDataContent);
  269. //处理投票
  270. if ($is_survey == 1) {
  271. //生成年月日时分秒+8位随机数
  272. $uuid = date('YmdHis') . rand(10000000, 99999999);
  273. var_dump($suvey_array, 'suvey_array________');
  274. $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
  275. var_dump($suveys_array, '---------------------1');
  276. var_dump($suvey_array, '---------------------2');
  277. $suvey_data = [];
  278. foreach ($suveys_array as $key => $value) {
  279. if ($value == '') {
  280. continue;
  281. }
  282. if (is_array($value)) {
  283. $suvey_data[] = [
  284. 'sur_id' => $uuid,
  285. 'art_id' => $id,
  286. 'website_id' => $website_id ?? 2,
  287. 'survey_name' => $survey_name,
  288. 'choice_name' => $value[1],
  289. 'is_other' => 1,
  290. 'other_id' => 0,
  291. 'results' => 0,
  292. ];
  293. } else {
  294. $suvey_data[] = [
  295. 'sur_id' => $uuid,
  296. 'art_id' => $id,
  297. 'website_id' => $website_id ?? 2,
  298. 'survey_name' => $survey_name,
  299. 'choice_name' => $value,
  300. 'is_other' => 0,
  301. 'other_id' => 0,
  302. 'results' => 0,
  303. ];
  304. }
  305. if (empty($suvey_data)) {
  306. throw new \Exception("投票数据为空");
  307. }
  308. }
  309. $result = ArticleSurvey::insert($suvey_data);
  310. if (!$result) {
  311. throw new \Exception("投票失败,ArticleSurvey插入失败");
  312. }
  313. $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
  314. if (!$result) {
  315. throw new \Exception("投票失败,更新主表失败");
  316. }
  317. }
  318. Db::commit();
  319. return Result::success(['id' => $id]);
  320. } catch (\Throwable $ex) {
  321. Db::rollBack();
  322. var_dump($ex->getMessage());
  323. return Result::error("创建失败", 0);
  324. }
  325. }
  326. /**
  327. * @param array $data
  328. * @return array
  329. */
  330. public function delArticle(array $data): array
  331. {
  332. $result = Article::where($data)->delete();
  333. //survey投票删除
  334. articleSurvey::where(['art_id' => $data['id']])->delete();
  335. if (!$result) {
  336. return Result::error("删除失败");
  337. }
  338. return Result::success($result);
  339. }
  340. /**
  341. * @param array $data
  342. * @return array
  343. */
  344. public function updateArticle(array $data): array
  345. {
  346. var_dump($data, '----------12-----------1');
  347. Db::beginTransaction();
  348. unset($data['user_type']);
  349. // unset($data['web_site_id']);
  350. unset($data['nav_add_pool_id']);
  351. try {
  352. //处理投票
  353. $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
  354. $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
  355. $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
  356. $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
  357. unset($data['is_survey']);
  358. unset($data['survey_name']);
  359. unset($data['suvey_array']);
  360. unset($data['website_id']);
  361. if ($data['hits'] == '') {
  362. $data['hits'] = 0;
  363. }
  364. if ($data['is_original'] == '') {
  365. $data['is_original'] = 0;
  366. }
  367. if ($data['status'] == '') {
  368. $data['status'] = 0;
  369. }
  370. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  371. $data['tag'] = isset($data['tag']) ? json_encode($data['tag']) : '';
  372. $articleData = $data;
  373. unset($articleData['content']);
  374. unset($articleData['status_name']);
  375. unset($articleData['name']);
  376. unset($articleData['content']);
  377. unset($articleData['pid_arr']);
  378. unset($articleData['pid']);
  379. $id = Article::where(['id' => $data['id']])->update($articleData);
  380. $articleDataContent = [
  381. 'content' => $data['content'],
  382. ];
  383. ArticleData::where(['article_id' => $data['id']])->update($articleDataContent);
  384. //处理投票
  385. $id = $data['id'];
  386. $surveydata = ArticleSurvey::where(['art_id' => $data['id']])->delete();
  387. var_dump($suvey_array, 'suvey_array________delete');
  388. //处理投票
  389. if ($is_survey == 1) {
  390. //生成年月日时分秒+8位随机数
  391. $uuid = date('YmdHis') . rand(10000000, 99999999);
  392. $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
  393. var_dump($suveys_array, '---------------------1');
  394. var_dump($suvey_array, '---------------------2');
  395. $suvey_data = [];
  396. if (is_array($suveys_array)) {
  397. foreach ($suveys_array as $key => $value) {
  398. if ($value == '') {
  399. continue;
  400. }
  401. if (is_array($value)) {
  402. $suvey_data[] = [
  403. 'sur_id' => $uuid,
  404. 'art_id' => $id,
  405. 'website_id' => $website_id ?? 2,
  406. 'survey_name' => $survey_name,
  407. 'choice_name' => $value[1],
  408. 'is_other' => 1,
  409. 'other_id' => 0,
  410. 'results' => 0,
  411. ];
  412. } else {
  413. $suvey_data[] = [
  414. 'sur_id' => $uuid,
  415. 'art_id' => $id,
  416. 'website_id' => $website_id ?? 2,
  417. 'survey_name' => $survey_name,
  418. 'choice_name' => $value,
  419. 'is_other' => 0,
  420. 'other_id' => 0,
  421. 'results' => 0,
  422. ];
  423. }
  424. if (empty($suvey_data)) {
  425. throw new \Exception("投票数据为空");
  426. }
  427. }
  428. }
  429. $result = ArticleSurvey::insert($suvey_data);
  430. if (!$result) {
  431. throw new \Exception("投票失败");
  432. }
  433. $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
  434. if (!$result) {
  435. throw new \Exception("投票失败");
  436. }
  437. } else {
  438. $result = Article::where('id', $id)->update(['survey_id' => '', 'survey_name' => '', 'is_survey' => 0]);
  439. }
  440. Db::commit();
  441. return Result::success([]);
  442. } catch (\Throwable $ex) {
  443. Db::rollBack();
  444. var_dump($ex->getMessage());
  445. return Result::error("更新失败1" . $ex->getMessage(), 0);
  446. }
  447. }
  448. /**
  449. * 更新资讯状态
  450. * @param array $data
  451. * @return array
  452. */
  453. public function upArticleStatus(array $data): array
  454. {
  455. $result = Article::where(['id' => $data['id']])->update($data);
  456. if ($result) {
  457. return Result::success();
  458. } else {
  459. return Result::error("更新状态失败", 0);
  460. }
  461. }
  462. /**
  463. * 获取新闻详情
  464. * @param array $data
  465. * @return array
  466. */
  467. public function getArticleInfo(array $data): array
  468. {
  469. $where = [
  470. 'article.id' => $data['id'],
  471. // 'article.status' => 1,
  472. ];
  473. $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")->first();
  474. $articleSurvey = ArticleSurvey::where(['art_id' => $data['id']])->get()->all();
  475. var_dump($articleSurvey, 'articleSurvey');
  476. $info = $result;
  477. var_dump($info, 'info');
  478. // $info['survey_array'] = $articleSurvey == null ? [] : $info['survey_array'];
  479. if ($result) {
  480. return Result::success($info);
  481. } else {
  482. return Result::error("查询失败", 0);
  483. }
  484. return Result::success($result);
  485. }
  486. /**
  487. * 获取头条新闻
  488. * @param array $data
  489. * @return array
  490. */
  491. public function getWebsiteArticlett(array $data): array
  492. {
  493. $category = WebsiteCategory::where('website_id', $data['website_id'])->select('category_id')->get();
  494. $category = $category->toArray();
  495. $result = [];
  496. if ($category) {
  497. $category_ids = [];
  498. foreach ($category as $val) {
  499. array_push($category_ids, $val['category_id']);
  500. }
  501. if (isset($data['placeid'])) {
  502. $placeid = $data['placeid'] - 1;
  503. $result = Article::where('status', 1)->where('level', $data['level'])->whereIn("catid", $category_ids)->orderBy("updated_at", "desc")->offset($placeid)->limit($data['pageSize'])->get();
  504. } else {
  505. $result = Article::where('status', 1)->where('level', $data['level'])->whereIn("catid", $category_ids)->orderBy("updated_at", "desc")->offset(0)->limit($data['pageSize'])->get();
  506. }
  507. if (empty($result)) {
  508. return Result::error("暂无头条新闻", 0);
  509. }
  510. return Result::success($result);
  511. } else {
  512. return Result::error("本网站下暂无相关栏目", 0);
  513. }
  514. }
  515. /**
  516. * 获取模块新闻
  517. * @param array $data
  518. * @return array
  519. */
  520. public function getWebsiteModelArticles(array $data): array
  521. {
  522. $catid = $data['catid'];
  523. $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->select('category_id')->get();
  524. $category = $category->toArray();
  525. if (!empty($category)) {
  526. $where = [
  527. 'status' => 1,
  528. 'catid' => $catid,
  529. ];
  530. if ($data['level'] == 1) {
  531. $level = [
  532. 0 => '1',
  533. 1 => '4',
  534. 2 => '5',
  535. 3 => '0',
  536. ];
  537. $result = Article::where($where)->whereIn('level', $level)->orderBy("updated_at", "desc")->limit($data['pagesize'])->get();
  538. } elseif ($data['level'] == 2) {
  539. $level = '2';
  540. $result = Article::where($where)->where('level', $level)->orderBy("updated_at", "desc")->limit($data['pagesize'])->get();
  541. } else {
  542. $level = '3';
  543. $result = Article::where($where)->where('level', $level)->orderBy("updated_at", "desc")->limit($data['pagesize'])->get();
  544. }
  545. $result = $result->toArray();
  546. if (!empty($result) && isset($data['placeid']) && !empty($data['placeid'])) {
  547. $placeid = $data['placeid'] - 1;
  548. if ($level == 2 || $level == 3) {
  549. $where = [
  550. 'level' => $level,
  551. ];
  552. $result = Article::where($where)
  553. ->orderBy("updated_at", "desc")
  554. ->offset($placeid)
  555. ->limit($data['pagesize'])->get();
  556. } else {
  557. $result = Article::where($where)
  558. ->whereIn('level', $level)
  559. ->offset($placeid)
  560. ->orderBy("updated_at", "desc")
  561. ->limit($data['pagesize'])->get();
  562. }
  563. }
  564. if (empty($result)) {
  565. return Result::error("此栏目暂无相关新闻", 0);
  566. }
  567. } else {
  568. return Result::error("此网站暂无此栏目", 0);
  569. }
  570. return Result::success($result);
  571. }
  572. /**
  573. *获取新闻列表
  574. * @param array $data
  575. * @return array
  576. */
  577. public function getWebsiteArticleList(array $data): array
  578. {
  579. $where[] = ['status', '=', 1];
  580. if (isset($data['keyword']) && !empty($data['keyword'])) {
  581. array_push($where, ['article.title', 'like', '%' . $data['keyword'] . '%']);
  582. }
  583. if (isset($data['catid']) && !empty($data['catid'])) {
  584. if (is_array($data['catid'])) {
  585. $category = WebsiteCategory::where('website_id', $data['website_id'])->whereIn('category_id', $data['catid'])->pluck('category_id');
  586. array_push($where, ['catid', 'in', $data['catid']]);
  587. } else {
  588. $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
  589. array_push($where, ['catid', '=', $data['catid']]);
  590. }
  591. if (empty($category)) {
  592. return Result::error("此网站暂无此栏目", 0);
  593. }
  594. }
  595. // return Result::success($where);
  596. $rep = Article::where(function ($query) use ($where) {
  597. foreach ($where as $condition) {
  598. if ($condition[1] === 'in') {
  599. $query->whereIn($condition[0], $condition[2]);
  600. } else {
  601. $query->where($condition[0], $condition[1], $condition[2]);
  602. }
  603. }
  604. })
  605. ->orderBy("updated_at", "desc")
  606. ->limit($data['pageSize'])
  607. ->offset(($data['page'] - 1) * $data['pageSize'])
  608. ->get();
  609. $count = Article::where(function ($query) use ($where) {
  610. foreach ($where as $condition) {
  611. if ($condition[1] === 'in') {
  612. $query->whereIn($condition[0], $condition[2]);
  613. } else {
  614. $query->where($condition[0], $condition[1], $condition[2]);
  615. }
  616. }
  617. })->count();
  618. $data = [
  619. 'rows' => $rep->toArray(),
  620. 'count' => $count,
  621. ];
  622. if (empty($rep)) {
  623. return Result::error("没有信息数据");
  624. }
  625. return Result::success($data);
  626. }
  627. /**
  628. * 前端-获取新闻详情
  629. * @param array $data
  630. * @return array
  631. */
  632. public function selectWebsiteArticleInfo(array $data): array
  633. {
  634. $where = [
  635. 'article.id' => $data['id'],
  636. 'article.status' => 1,
  637. ];
  638. $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")->first();
  639. if (empty($result)) {
  640. return Result::error("查询失败", 0);
  641. }
  642. $category = WebsiteCategory::where('website_id', $data['website_id'])->where(['category_id' => $result['catid']])->first();
  643. if (empty($category)) {
  644. return Result::error("查询失败", 0);
  645. }
  646. $result['category_id'] = $category['category_id'];
  647. $result['cat_name'] = $category['name'];
  648. return Result::success($result);
  649. }
  650. /**
  651. * 前端-获取网站调查问卷
  652. * @param array $data
  653. * @return array
  654. */
  655. public function getWebsiteSurvey(array $data): array
  656. {
  657. if (isset($data['website_id']) && !empty($data['website_id'])) {
  658. $website = Website::where('id', $data['website_id'])->first();
  659. if (empty($website)) {
  660. return Result::error("暂无此网站", 0);
  661. }
  662. }
  663. if (isset($data['art_id']) && !empty($data['art_id'])) {
  664. $article = Article::where('id', $data['art_id'])->where('status', 1)->first();
  665. if (empty($article)) {
  666. return Result::error("暂无此文章", 0);
  667. }
  668. // return Result::error($data,0);
  669. $where['art_id'] = $data['art_id'];
  670. // $query = ArticleSurvey::where('art_id',$data['art_id']);
  671. } else {
  672. $survey = ArticleSurvey::where('website_id', $data['website_id'])->orderBy('created_at')->first();
  673. if (empty($survey)) {
  674. return Result::error("暂无调查问卷", 0);
  675. }
  676. $where['sur_id'] = $survey['sur_id'];
  677. // $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
  678. }
  679. $result['survey'] = ArticleSurvey::where($where)->where('is_other', 0)
  680. ->leftJoin('article', 'article_survey.art_id', 'article.id')
  681. ->select('article_survey.*', 'article.survey_type')
  682. ->get()->all();
  683. $result['other'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
  684. $result['others'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->first();
  685. if (empty($result)) {
  686. return Result::error("此文章暂无调查问卷", 0);
  687. }
  688. return Result::success($result);
  689. }
  690. /**
  691. * 前端-添加网站调查问卷选项
  692. * @param array $data
  693. * @return array
  694. */
  695. public function addWebsiteSurveyOption(array $data): array
  696. {
  697. if (isset($data['website_id']) && !empty($data['website_id'])) {
  698. $website = Website::where('id', $data['website_id'])->first();
  699. if (empty($website)) {
  700. return Result::error("暂无此网站", 0);
  701. }
  702. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  703. $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->where('is_other', 1)->where('other_id', 0)->first();
  704. if (empty($survey)) {
  705. return Result::error("此调查问卷不可添加选项", 0);
  706. }
  707. if (isset($data['choice_name']) && !empty($data['choice_name'])) {
  708. $choice = [
  709. 'art_id' => $survey['art_id'],
  710. 'website_id' => $data['website_id'],
  711. 'survey_name' => $survey['survey_name'],
  712. 'choice_name' => $data['choice_name'],
  713. 'sur_id' => $survey['sur_id'],
  714. 'is_other' => 1,
  715. 'other_id' => $survey['id'],
  716. ];
  717. $result = ArticleSurvey::insertGetId($choice);
  718. if (empty($result)) {
  719. return Result::error("添加失败", 0);
  720. }
  721. return Result::success($result);
  722. }
  723. }
  724. return Result::error("添加失败", 0);
  725. }
  726. return Result::error("添加失败", 0);
  727. }
  728. /**
  729. * 前端-调查问卷投票
  730. * @param array $data
  731. * @return array
  732. */
  733. public function addWebsiteSurveyVote(array $data): array
  734. {
  735. if (isset($data['website_id']) && !empty($data['website_id'])) {
  736. $website = Website::where('id', $data['website_id'])->first();
  737. if (empty($website)) {
  738. return Result::error("暂无此网站", 0);
  739. }
  740. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  741. $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->pluck('sur_id');
  742. if (empty($survey)) {
  743. return Result::error("此调查问卷不存在", 0);
  744. }
  745. // return Result::success($survey);
  746. // 调查问卷类型 0:单选 1:多选
  747. $type = Article::where('survey_id', $data['sur_id'])->pluck('survey_type');
  748. // return Result::success($type);
  749. if (empty($type) || ($type[0] != 1 && $type[0] != 0)) {
  750. return Result::error("此调查问卷不可投票", 0);
  751. }
  752. // return Result::success($type[0]);
  753. if (isset($data['choice_id']) && !empty($data['choice_id'])) {
  754. if ($type[0] == 0) {
  755. if (is_array($data['choice_id'])) {
  756. return Result::error("请选择一个选项!", 0);
  757. }
  758. $data['choice_id'] = [$data['choice_id']];
  759. } else {
  760. if (!is_array($data['choice_id'])) {
  761. return Result::error("请传递数组!", 0);
  762. }
  763. }
  764. // return Result::success($data['choice_id']);
  765. $other = ArticleSurvey::whereIn('id', $data['choice_id'])
  766. ->where('website_id', $data['website_id'])
  767. ->where('is_other', 1)
  768. ->where('other_id', 0)
  769. ->first();
  770. if (!empty($other)) {
  771. return Result::error("请选择已有的选项!", 0);
  772. }
  773. $choice['other'] = ArticleSurvey::whereIn('id', $data['choice_id'])
  774. ->where('website_id', $data['website_id'])
  775. ->where('is_other', 1)
  776. ->where('other_id', '!=', 0)
  777. ->first();
  778. // return Result::success($data);
  779. if (!empty($choice['other'])) {
  780. array_push($data['choice_id'], $choice['other']['other_id']);
  781. // return Result::success($data['choice_id']);
  782. }
  783. // return Result::success($data);
  784. $choice = ArticleSurvey::whereIn('id', $data['choice_id'])
  785. ->where('website_id', $data['website_id'])
  786. ->increment('results', 1);
  787. if (empty($choice)) {
  788. return Result::error("请选择已有的选项!", 0);
  789. }
  790. return Result::success($choice);
  791. }
  792. return Result::error("参数必填!");
  793. // if(isset($data['choice_id']) && !empty($data['choice_id'])){
  794. // $choice = ArticleSurvey::whereIn('id',$data['choice_id'])->where('website_id',$data['website_id'])->where('is_other',1)->where('other_id',0)->first();
  795. // }
  796. }
  797. return Result::error("此调查问卷不存在", 0);
  798. }
  799. return Result::error("参数必填!");
  800. }
  801. /**
  802. * 验证导航名称是否重复
  803. * @return void
  804. */
  805. public function checkCategoryName(array $data): array
  806. {
  807. $result = Category::when($data, function ($query) use ($data) {
  808. if (isset($data['name']) && $data['name']) {
  809. $query->where("name", $data['name']);
  810. }
  811. if (isset($data['id']) && $data['id']) {
  812. $query->where("id", "!=", $data['id']);
  813. }
  814. })->first();
  815. if ($result) {
  816. return Result::error("已存在");
  817. } else {
  818. return Result::success();
  819. }
  820. }
  821. //20250226 产品列表
  822. public function getGoodList(array $data): array
  823. {
  824. $where = [];
  825. //类型
  826. if (isset($data['type_id']) && $data['type_id']) {
  827. $where = [
  828. 'type_id' => $data['type_id'],
  829. ];
  830. }
  831. //名称
  832. if (isset($data['name']) && $data['name']) {
  833. $where = [
  834. 'good.name' => $data['name'],
  835. ];
  836. }
  837. $where1 = [];
  838. //website_id
  839. // if (isset($data['website_id']) && $data['website_id']) {
  840. // $where1 = [
  841. // 'good.website_id', 'like', '%' . $data['website_id'] . '%',
  842. // ];
  843. // }
  844. // website_name
  845. if (isset($data['website_name']) && $data['website_name']) {
  846. $where1[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
  847. }
  848. // catid
  849. if (isset($data['category_name']) && $data['category_name']) {
  850. $where1[] = ['category.name', 'like', '%' . $data['category_name'] . '%'];
  851. }
  852. // $result = Good::where($where)
  853. // ->orderBy("updated_at", "desc")->paginate($data['pige_size'], ['*'], 'page', $data['page']);
  854. $result = Good::where($where)
  855. ->when(!empty($where1), function ($query) use ($where1) {
  856. return $query->where($where1);
  857. })
  858. ->leftJoin('district', 'good.city_id', '=', 'district.id')
  859. ->leftJoin('website', 'good.website_id', '=', 'website.id')
  860. ->leftJoin('category', 'good.catid', '=', 'category.id')
  861. ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
  862. ->orderBy("id", "desc")
  863. ->limit($data['page_size'])
  864. ->offset(($data['page'] - 1) * $data['page_size'])
  865. ->get();
  866. $count = Good::where($where)
  867. ->leftJoin('district', 'good.city_id', '=', 'district.id')
  868. ->leftJoin('website', 'good.website_id', '=', 'website.id')
  869. ->leftJoin('category', 'good.catid', '=', 'category.id')
  870. ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
  871. ->orderBy("updated_at", "desc")->count();
  872. $data = [
  873. 'rows' => $result->toArray(),
  874. 'count' => $count,
  875. ];
  876. if (empty($result)) {
  877. return Result::error("此栏目暂无相关产品", 0);
  878. }
  879. return Result::success($data);
  880. }
  881. public function getGoodInfo(array $data): array
  882. {
  883. $result = Good::where('id', $data['id'])->first();
  884. if (empty($result)) {
  885. return Result::error("此产品不存在", 0);
  886. }
  887. return Result::success($result);
  888. }
  889. public function addGood(array $data): array
  890. {
  891. // unset($data['city_arr_id']);
  892. // unset($data['cat_arr_id']);
  893. $data['city_id'] = end($data['city_arr_id']);
  894. $data['catid'] = end($data['cat_arr_id']);
  895. $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
  896. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  897. $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
  898. unset($data['imgUrl']);
  899. $result = Good::insert($data);
  900. if (empty($result)) {
  901. return Result::error("添加失败", 0);
  902. }
  903. return Result::success($result);
  904. }
  905. public function updateGood(array $data): array
  906. {
  907. $data['city_id'] = end($data['city_arr_id']);
  908. $data['catid'] = end($data['cat_arr_id']);
  909. $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
  910. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  911. $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
  912. //设置东八区
  913. date_default_timezone_set('Asia/Shanghai');
  914. $data['updated_at'] = date('Y-m-d H:i:s');
  915. $result = Good::where('id', $data['id'])->update($data);
  916. if (empty($result)) {
  917. return Result::error("更新失败", 0);
  918. }
  919. return Result::success($result);
  920. }
  921. public function delGood(array $data): array
  922. {
  923. $result = Good::where('id', $data['id'])->delete();
  924. if (empty($result)) {
  925. return Result::error("删除失败", 0);
  926. }
  927. return Result::success($result);
  928. }
  929. //20250226 产品列表
  930. /**
  931. * 后端-获取网站调查问卷列表
  932. * @param array $data
  933. * @return array
  934. */
  935. public function getSurveyList(array $data): array
  936. {
  937. $where = [];
  938. if (isset($data['survey_name']) && !empty($data['survey_name'])) {
  939. array_push($where, ['survey_name', 'like', '%' . $data['survey_name'] . '%']);
  940. }
  941. if (isset($data['survey_type']) && $data['survey_type'] != null) {
  942. array_push($where, ['survey_type', '=', $data['survey_type']]);
  943. }
  944. if (isset($data['is_survey']) && $data['is_survey'] != null) {
  945. array_push($where, ['is_survey', '=', $data['is_survey']]);
  946. }
  947. // return Result::success($where);
  948. if (!empty($where)) {
  949. $query = Article::where($where)->whereNotNull('survey_name');
  950. } else {
  951. $query = Article::whereNotNull('survey_name');
  952. }
  953. $count = $query->count();
  954. $survey = $query->orderByDesc('id')
  955. ->limit($data['pageSize'])
  956. ->offset(($data['page'] - 1) * $data['pageSize'])
  957. ->get();
  958. if (empty($survey->toArray())) {
  959. return Result::error("暂无调查问卷!", 0);
  960. }
  961. $result = [
  962. 'rows' => $survey,
  963. 'count' => $count,
  964. ];
  965. return Result::success($result);
  966. }
  967. /**
  968. * 后端-获取网站调查问卷详情
  969. * @param array $data
  970. * @return array
  971. */
  972. public function getSurveyInfo(array $data): array
  973. {
  974. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  975. $where = ['sur_id' => $data['sur_id']];
  976. $choose = ArticleSurvey::where($where)->where('is_other', 0)
  977. ->leftJoin('article', 'article_survey.art_id', 'article.id')
  978. ->select('article_survey.*', 'article.survey_type')
  979. ->get()->all();
  980. if (empty($choose)) {
  981. return Result::error("此调查问卷不存在", 0);
  982. }
  983. $resultsArray = array_column($choose, 'results');
  984. $total = array_sum($resultsArray);
  985. $other = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
  986. $others = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->get()->all();
  987. // $total = 0;
  988. if (!empty($other)) {
  989. $total = $total + $other['results'];
  990. $other['choice_name'] = $other['choice_name'] . '(其他)';
  991. if (!empty($others)) {
  992. $other['hasChildren'] = true;
  993. // array_push($other,['hasChildren','=',true]);
  994. $other['children'] = $others;
  995. $other_choices = [$other->toArray()];
  996. $mer_choice = array_merge($choose, $other_choices);
  997. $value_choice = array_values($mer_choice);
  998. } else {
  999. // return Result::error('1111');
  1000. $other_choices = [$other->toArray()];
  1001. $other_choices = array_merge($choose, $other_choices);
  1002. $value_choice = array_values($other_choices);
  1003. // return Result::success($result);
  1004. }
  1005. } else {
  1006. $value_choice = $choose;
  1007. }
  1008. $result = [
  1009. 'choose' => $value_choice,
  1010. 'total' => $total,
  1011. ];
  1012. }
  1013. return Result::success($result);
  1014. }
  1015. // 20250306 招聘
  1016. /*
  1017. * 招聘列表
  1018. * */
  1019. public function getJobRecruitingList(array $data): array
  1020. {
  1021. $where = [];
  1022. if(isset($data['keyword']) && !empty($data['keyword'])){
  1023. array_push($where, ['job_recruiting.title', 'like', '%'. $data['keyword']. '%']);
  1024. }
  1025. $user = User::where('id', $data['user_id'])->first();
  1026. if(empty($user)){
  1027. return Result::error("用户不存在", 0);
  1028. }
  1029. // 3:企业会员
  1030. if($user['type_id'] == 3){
  1031. array_push($where,['user_id', $data['user_id']]);
  1032. }
  1033. $result = JobRecruiting::where($where)
  1034. ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
  1035. ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
  1036. ->select('job_recruiting.*', 'website.website_name as website_name', 'user.user_name as user_name')
  1037. ->orderBy("updated_at", "desc")
  1038. ->offset(($data['page'] - 1) * $data['page_size'])
  1039. ->limit($data['page_size'])
  1040. ->get()
  1041. ->all();
  1042. if (empty($result)) {
  1043. return Result::error("暂无招聘信息", 0);
  1044. }
  1045. return Result::success($result);
  1046. }
  1047. /*
  1048. * 招聘信息详情
  1049. * */
  1050. public function getJobRecruitingInfo(array $data): array
  1051. {
  1052. $result = JobRecruiting::where('job_recruiting.id', $data['id'])
  1053. ->leftJoin('user_info', 'job_recruiting.user_id', 'user_info.id')
  1054. ->leftJoin('user', 'job_recruiting.user_id', 'user.id')
  1055. ->select(
  1056. 'job_recruiting.*',
  1057. 'user_info.business_name', // 企业名称
  1058. 'user_info.hy_id', // 企业所属行业
  1059. 'user_info.company_size', // 公司规模
  1060. 'user_info.company_nature', // 公司性质
  1061. 'user_info.introduction', // 公司简介
  1062. 'user_info.real_name', // 企业联系人
  1063. 'user.mobile', // 企业联系电话
  1064. 'user_info.company_url', // 企业网址
  1065. 'user_info.address_arr_id', // 企业地址
  1066. 'user_info.address', // 企业地址
  1067. 'user.email', // 企业邮箱
  1068. )
  1069. ->orderBy("updated_at", "desc")
  1070. ->first();
  1071. if (empty($result)) {
  1072. return Result::error("暂无招聘信息", 0);
  1073. }
  1074. return Result::success($result);
  1075. }
  1076. /*
  1077. * 招聘信息添加
  1078. * */
  1079. public function addJobRecruiting(array $data): array
  1080. {
  1081. $user = User::where('id', $data['user_id'])->first();
  1082. if(empty($user)){
  1083. return Result::error("用户不存在", 0);
  1084. }
  1085. // 3:企业会员
  1086. if($user['type_id'] != 3){
  1087. if($data['website_id'] == 0){
  1088. return Result::error("请选择所属网站", 0);
  1089. }
  1090. $website = Website::where('id', $data['website_id'])->first();
  1091. if(empty($website)){
  1092. return Result::error("网站不存在", 0);
  1093. }
  1094. $data['website_id'] = $website['id'];
  1095. }
  1096. $data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
  1097. $data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
  1098. $data['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode($data['cat_arr_id']) : '';
  1099. $data['city_arr_id'] = isset($data['city_arr_id'])? json_encode($data['city_arr_id']) : '';
  1100. $result = JobRecruiting::insertGetId($data);
  1101. if (empty($result)) {
  1102. return Result::error("添加失败", 0);
  1103. }
  1104. return Result::success($result);
  1105. }
  1106. /*
  1107. * 招聘信息更新
  1108. * */
  1109. public function upJobRecruiting(array $data): array
  1110. {
  1111. $job = JobRecruiting::where('id', $data['id'])->first();
  1112. if(empty($job)){
  1113. return Result::error("招聘信息不存在", 0);
  1114. }
  1115. $user = User::where('id', $data['user_id'])->first();
  1116. if(empty($user)){
  1117. return Result::error("用户不存在", 0);
  1118. }
  1119. // 3:企业会员
  1120. if($user['type_id'] != 3){
  1121. if($data['website_id'] == 0){
  1122. return Result::error("请选择所属网站", 0);
  1123. }
  1124. $website = Website::where('id', $data['website_id'])->first();
  1125. if(empty($website)){
  1126. return Result::error("网站不存在", 0);
  1127. }
  1128. $data['website_id'] = $website['id'];
  1129. }
  1130. $data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
  1131. $data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
  1132. $data['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode($data['cat_arr_id']) : '';
  1133. $data['city_arr_id'] = isset($data['city_arr_id'])? json_encode($data['city_arr_id']) : '';
  1134. $result = JobRecruiting::where('id', $data['id'])->update($data);
  1135. if (empty($result)) {
  1136. return Result::error("更新失败", 0);
  1137. }
  1138. return Result::success($data);
  1139. }
  1140. /*
  1141. * 招聘信息删除
  1142. * */
  1143. public function delJobRecruiting(array $data): array
  1144. {
  1145. $job = JobRecruiting::where('id', $data['id'])->first();
  1146. if(empty($job)){
  1147. return Result::error("招聘信息不存在", 0);
  1148. }
  1149. $result = JobRecruiting::where('id',$data['id'])->delete();
  1150. if (empty($result)) {
  1151. return Result::error("删除失败", 0);
  1152. }
  1153. return Result::success($data);
  1154. }
  1155. /*
  1156. * 获取省-市
  1157. * */
  1158. public function getJobRecruitingArea(array $data): array
  1159. {
  1160. if(isset($data['province_id']) && $data['province_id']!=null){
  1161. $result = District::where('pid',$data['pid'])->get()->all();
  1162. }else{
  1163. $result = District::where('level',1)->get()->all();
  1164. }
  1165. if (empty($result)) {
  1166. return Result::error("暂无此省市", 0);
  1167. }
  1168. return Result::success($result);
  1169. }
  1170. /*
  1171. * 获取行业分类
  1172. * */
  1173. public function getIndustry(array $data): array
  1174. {
  1175. $result = JobIndustry::get()->all();
  1176. if (empty($result)) {
  1177. return Result::error("暂无行业分类", 0);
  1178. }
  1179. return Result::success($result);
  1180. }
  1181. /*
  1182. * 获取职位
  1183. * */
  1184. public function getPositionList(array $data): array
  1185. {
  1186. if(isset($data['zwpid']) && $data['zwpid']!=null){
  1187. $result = JobPosition::where('zwpid',$data['zwpid'])->get()->all();
  1188. }else{
  1189. $result = JobPosition::where('zwpid',0)->get()->all();
  1190. }
  1191. if (empty($result)) {
  1192. return Result::error("暂无此职位", 0);
  1193. }
  1194. return Result::success($result);
  1195. }
  1196. /*
  1197. * 获取工作性质-菜单
  1198. * */
  1199. public function getJobNature(array $data): array
  1200. {
  1201. $result = JobEnum::where('egroup','nature')->get()->all();
  1202. if (empty($result)) {
  1203. return Result::error("暂无工作性质", 0);
  1204. }
  1205. return Result::success($result);
  1206. }
  1207. /*
  1208. * 获取工作经验-菜单
  1209. * */
  1210. public function getExperience(array $data): array
  1211. {
  1212. $result = JobEnum::where('egroup','years')->get()->all();
  1213. if (empty($result)) {
  1214. return Result::error("暂无工作经验", 0);
  1215. }
  1216. return Result::success($result);
  1217. }
  1218. /*
  1219. * 获取学历-菜单
  1220. * */
  1221. public function getEducation(array $data): array
  1222. {
  1223. $result = JobEnum::where('egroup','education')->get()->all();
  1224. if (empty($result)) {
  1225. return Result::error("暂无学历", 0);
  1226. }
  1227. return Result::success($result);
  1228. }
  1229. /*
  1230. * 获取薪资-菜单
  1231. * */
  1232. public function getSalary(array $data): array
  1233. {
  1234. $result = JobEnum::where('egroup','income')->get()->all();
  1235. if (empty($result)) {
  1236. return Result::error("暂无薪资", 0);
  1237. }
  1238. return Result::success($result);
  1239. }
  1240. /*
  1241. * 获取语言-菜单
  1242. * */
  1243. public function getLanguage(array $data): array
  1244. {
  1245. $result = JobEnum::where('egroup','language')->get()->all();
  1246. if (empty($result)) {
  1247. return Result::error("暂无语言", 0);
  1248. }
  1249. return Result::success($result);
  1250. }
  1251. /*
  1252. * 获取掌握程度-菜单
  1253. * */
  1254. public function getLevel(array $data): array
  1255. {
  1256. $result = JobEnum::where('egroup','languagetype')->get()->all();
  1257. if (empty($result)) {
  1258. return Result::error("暂无工作性质", 0);
  1259. }
  1260. return Result::success($result);
  1261. }
  1262. // 公司信息
  1263. /*
  1264. * 获取公司性质-菜单
  1265. * */
  1266. public function getCompanyNature(array $data): array
  1267. {
  1268. $result = JobNature::get()->all();
  1269. if (empty($result)) {
  1270. return Result::error("暂无公司性质", 0);
  1271. }
  1272. return Result::success($result);
  1273. }
  1274. /*
  1275. * 获取公司规模-菜单
  1276. * */
  1277. public function getCompanySize(array $data): array
  1278. {
  1279. $result = JobEnum::where('egroup','cosize')->get()->all();
  1280. if (empty($result)) {
  1281. return Result::error("暂无公司规模", 0);
  1282. }
  1283. return Result::success($result);
  1284. }
  1285. // 20250306 招聘
  1286. }