NewsService.php 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796
  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\WebsiteCategory;
  7. use App\Model\ArticleSurvey;
  8. use App\Model\jobHunting;
  9. use App\Model\JobEnum;
  10. use App\Model\JobIndustry;
  11. use App\Model\JobPosition;
  12. use App\Model\JobRecruiting;
  13. use App\Model\Good;
  14. use App\Model\JobNature;
  15. use App\Model\Website;
  16. use Hyperf\DbConnection\Db;
  17. use Hyperf\RpcServer\Annotation\RpcService;
  18. use App\Tools\Result;
  19. use Ramsey\Uuid\Uuid;
  20. use Hyperf\Utils\Random;
  21. use Fukuball\Jieba\Jieba;
  22. use Fukuball\Jieba\Finalseg;
  23. use App\Model\ChatRecords;
  24. use Hyperf\Utils\Collection;
  25. #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
  26. class NewsService implements NewsServiceInterface
  27. {
  28. /**
  29. * 获取导航池列表
  30. * @param array $data
  31. * @return array
  32. */
  33. public function getCategoryList(array $data): array
  34. {
  35. $page = (int) $data['page'] ?? 1;
  36. $perPage = (int) $data['pageSize'] ?? 10;
  37. $search = $data['name'] ?? '';
  38. // 查找所有匹配的分类
  39. $matchedCategories = $this->findMatchedCategories($search);
  40. // 查找所有匹配分类的父级分类
  41. $allRequiredCategories = $this->findAllParents($matchedCategories);
  42. // 提取一级分类
  43. $topLevelCategories = [];
  44. foreach ($allRequiredCategories as $category) {
  45. if ($category->pid === 0) {
  46. $topLevelCategories[] = $category;
  47. }
  48. }
  49. // 分页处理
  50. $offset = ($page - 1) * $perPage;
  51. $paginatedTopLevelCategories = array_slice($topLevelCategories, $offset, $perPage);
  52. $categoryTree = [];
  53. foreach ($paginatedTopLevelCategories as $category) {
  54. $categoryTree[] = $this->buildCategoryTree($category, $allRequiredCategories);
  55. }
  56. $return = [
  57. 'rows' => $categoryTree,
  58. 'total' => count($topLevelCategories),
  59. ];
  60. return Result::success($return);
  61. }
  62. private function findMatchedCategories($search)
  63. {
  64. if ($search) {
  65. return Category::where('name', 'like', "%{$search}%")
  66. ->orderBy('updated_at', 'desc')
  67. ->get();
  68. }
  69. return Category::orderBy('updated_at', 'desc') // 按 updated_at 字段倒序排序
  70. ->get();
  71. }
  72. private function findAllParents($categories)
  73. {
  74. $allCategories = [];
  75. foreach ($categories as $category) {
  76. $parentId = $category->pid;
  77. while ($parentId > 0) {
  78. $parent = Category::find($parentId);
  79. if ($parent) {
  80. $allCategories[$parent->id] = $parent;
  81. $parentId = $parent->pid;
  82. } else {
  83. break;
  84. }
  85. }
  86. $allCategories[$category->id] = $category;
  87. }
  88. return array_values($allCategories);
  89. }
  90. private function buildCategoryTree($category, $allRequiredCategories)
  91. {
  92. $categoryData = $category->toArray();
  93. $children = [];
  94. foreach ($allRequiredCategories as $c) {
  95. if ($c->pid === $category->id) {
  96. $children[] = $this->buildCategoryTree($c, $allRequiredCategories);
  97. }
  98. }
  99. if (!empty($children)) {
  100. $categoryData['children'] = $children;
  101. }
  102. return $categoryData;
  103. }
  104. public function myCategoryList(array $data): array
  105. {
  106. $sszq = $data['sszq'] ?? '';
  107. unset($data['sszq']);
  108. //1,2,3 根据这些webid,。从website_category表中取出对应的分类id,然后从category表中取出分类信息
  109. $catorytids = WebsiteCategory::whereIn('website_id', explode(',', $sszq))->get()->pluck('category_id')->toArray();
  110. $where[] = [
  111. 'pid', '=', $data['pid'],
  112. ];
  113. if (isset($data['name'])) {
  114. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  115. }
  116. var_dump($where);
  117. //根据分类id,从category表中取出分类信息
  118. $result = Category::where($where)
  119. ->whereIn('category.id', $catorytids)
  120. ->select('category.*', 'category.id as category_id')->get();
  121. if (empty($result)) {
  122. return Result::error("没有栏目数据");
  123. }
  124. return Result::success($result);
  125. }
  126. /**
  127. * @param array $data
  128. * @return array
  129. */
  130. public function categoryList(array $data): array
  131. {
  132. $where[] = [
  133. 'pid', '=', $data['pid'],
  134. ];
  135. if (isset($data['name'])) {
  136. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  137. }
  138. var_dump($where);
  139. $result = Category::where($where)->select('category.*', 'category.id as category_id')->get();
  140. if (empty($result)) {
  141. return Result::error("没有栏目数据");
  142. }
  143. return Result::success($result);
  144. }
  145. /**
  146. * @param array $data
  147. * @return array
  148. */
  149. public function addCategory(array $data): array
  150. {
  151. if (isset($data['id'])) {
  152. unset($data['id']);
  153. }
  154. $id = Category::insertGetId($data);
  155. if (empty($id)) {
  156. return Result::error("添加失败");
  157. }
  158. return Result::success(['id' => $id]);
  159. }
  160. /**
  161. * @param array $data
  162. * @return array
  163. */
  164. public function delCategory(array $data): array
  165. {
  166. $categoryList = Category::where(['pid' => $data['id']])->get();
  167. var_dump("分类列表:", $data, $categoryList);
  168. if ($categoryList->toArray()) {
  169. return Result::error("分类下面有子分类不能删除");
  170. }
  171. $articleList = Article::where(['catid' => $data['id']])->get();
  172. var_dump("文章列表:", $articleList);
  173. if ($articleList->toArray()) {
  174. return Result::error("分类下面有资讯不能删除");
  175. }
  176. $result = Category::where($data)->delete();
  177. if (!$result) {
  178. return Result::error("删除失败");
  179. }
  180. return Result::success($result);
  181. }
  182. /**
  183. * @param array $data
  184. * @return array
  185. */
  186. public function updateCategory(array $data): array
  187. {
  188. $where = [
  189. 'id' => $data['id'],
  190. ];
  191. $result = Category::where($where)->update($data);
  192. if ($result) {
  193. return Result::success($result);
  194. } else {
  195. return Result::error("更新失败");
  196. }
  197. }
  198. /**
  199. * 获取导航池信息
  200. * @param array $data
  201. * @return array
  202. */
  203. public function getCategoryInfo(array $data): array
  204. {
  205. $where = [
  206. 'id' => $data['id'],
  207. ];
  208. $result = Category::where($where)->first();
  209. if ($result) {
  210. return Result::success($result);
  211. } else {
  212. return Result::error("更新失败");
  213. }
  214. }
  215. /**
  216. * @param array $data
  217. * @return array
  218. */
  219. public function getArticleList(array $data): array
  220. {
  221. //判断是否是管理员'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
  222. $type_id = $data['type_id'];
  223. unset($data['type_id']);
  224. $user_id = $data['user_id'];
  225. unset($data['user_id']);
  226. $where = [];
  227. $status1 = [];
  228. if (isset($data['id']) && $data['id']) {
  229. array_push($where, ['article.id', '=', $data['id']]);
  230. }
  231. if (isset($data['title']) && $data['title']) {
  232. array_push($where, ['article.title', 'like', '%' . $data['title'] . '%']);
  233. }
  234. if (isset($data['category_name']) && $data['category_name']) {
  235. array_push($where, ['category.name', 'like', '%' . $data['category_name'] . '%']);
  236. }
  237. if (isset($data['author']) && $data['author']) {
  238. array_push($where, ['article.author', '=', $data['author']]);
  239. }
  240. if (isset($data['islink']) && $data['islink'] !== "") {
  241. array_push($where, ['article.islink', '=', $data['islink']]);
  242. }
  243. if (isset($data['status']) && $data['status'] !== "") {
  244. array_push($where, ['article.status', '=', $data['status']]);
  245. }
  246. if (isset($data['status1'])) {
  247. $status1 = json_decode(($data['status1']));
  248. }
  249. //不是管理员展示个人数据;
  250. if ($type_id != 10000) {
  251. $where[] = ['article.admin_user_id', '=', $user_id];
  252. }
  253. $rep = Article::where($where)
  254. ->whereNotIn('article.status', [404])
  255. ->when($status1, function ($query) use ($status1) {
  256. if (isset($status1) && $status1) {
  257. $query->whereIn('article.status', $status1);
  258. }
  259. })
  260. ->leftJoin('category', 'article.catid', 'category.id')
  261. ->select("article.*", "category.name as category_name")
  262. ->orderBy("article.updated_at", "desc")
  263. ->limit($data['pageSize'])
  264. ->offset(($data['page'] - 1) * $data['pageSize'])->get();
  265. $count = Article::where($where)->whereNotIn('article.status', [404])
  266. ->when($status1, function ($query) use ($status1) {
  267. if (isset($status1) && $status1) {
  268. $query->whereIn('article.status', $status1);
  269. }
  270. })
  271. ->leftJoin('category', 'article.catid', 'category.id')->count();
  272. $data = [
  273. 'rows' => $rep->toArray(),
  274. 'count' => $count,
  275. ];
  276. if (empty($rep)) {
  277. return Result::error("没有信息数据");
  278. }
  279. return Result::success($data);
  280. }
  281. /**
  282. * @param array $data
  283. * @return array
  284. */
  285. public function addArticle(array $data): array
  286. {
  287. var_dump($data, '----------12-----------1');
  288. unset($data['user_type']);
  289. unset($data['nav_add_pool_id']);
  290. // $data['cat_arr_id'] = is_string($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  291. Db::beginTransaction();
  292. try {
  293. //处理投票
  294. $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
  295. $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
  296. $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
  297. $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
  298. unset($data['is_survey']);
  299. unset($data['survey_name']);
  300. unset($data['suvey_array']);
  301. // unset($data['website_id']);
  302. // unset($data['web_site_id']);
  303. // $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
  304. if ($data['hits'] == '') {
  305. $data['hits'] = 0;
  306. }
  307. if ($data['is_original'] == '') {
  308. $data['is_original'] = 0;
  309. }
  310. if ($data['status'] == '') {
  311. $data['status'] = 0;
  312. }
  313. $articleData = $data;
  314. unset($articleData['content']);
  315. //自动处理缩略图、关键字、描述
  316. if ($articleData['imgurl'] == '') {
  317. //如果没有图,设置level=0
  318. $levelArr = json_decode($articleData['level'], true);
  319. var_dump($levelArr, '----------levelArr-----------1');
  320. //content中提取图片第一个图,正则提取
  321. $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
  322. preg_match_all($reg, $data['content'], $matches);
  323. if (isset($matches[1][0])) {
  324. //截取varchar240
  325. $articleData['imgurl'] = substr($matches[1][0], 0, 240);
  326. //如果有图,设置level=3
  327. if (!in_array(3, $levelArr)) {$levelArr[] = 3;}
  328. $articleData['level'] = json_encode($levelArr);
  329. } else {
  330. if (!in_array(0, $levelArr)) {
  331. $levelArr[] = 0;
  332. }
  333. $articleData['level'] = json_encode($levelArr);
  334. }
  335. }
  336. var_dump($articleData['level'], '----------$articleData[level]----------1');
  337. if ($articleData['keyword'] == '') {
  338. //提取标题+内容中的关键词
  339. $articleData['keyword'] = $data['title'];
  340. // . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
  341. Jieba::init(); // 初始化 jieba-php
  342. Finalseg::init();
  343. $segList = Jieba::cut($articleData['keyword']);
  344. $segList1 = array_slice($segList, 0, 8);
  345. $articleData['keyword'] = implode(',', $segList1);
  346. }
  347. if ($articleData['introduce'] == '') {
  348. //提取内容中的描述
  349. $articleData['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
  350. }
  351. $id = Article::insertGetId($articleData);
  352. $articleDataContent = [
  353. 'article_id' => $id,
  354. 'content' => $data['content'],
  355. ];
  356. ArticleData::insertGetId($articleDataContent);
  357. //处理投票
  358. if ($is_survey == 1) {
  359. //生成年月日时分秒+8位随机数
  360. $uuid = date('YmdHis') . rand(10000000, 99999999);
  361. var_dump($suvey_array, 'suvey_array________');
  362. $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
  363. var_dump($suveys_array, '---------------------1');
  364. var_dump($suvey_array, '---------------------2');
  365. $suvey_data = [];
  366. foreach ($suveys_array as $key => $value) {
  367. if ($value == '') {
  368. continue;
  369. }
  370. if (is_array($value)) {
  371. $suvey_data[] = [
  372. 'sur_id' => $uuid,
  373. 'art_id' => $id,
  374. 'website_id' => $website_id ?? 2,
  375. 'survey_name' => $survey_name,
  376. 'choice_name' => $value[1],
  377. 'is_other' => 1,
  378. 'other_id' => 0,
  379. 'results' => 0,
  380. ];
  381. } else {
  382. $suvey_data[] = [
  383. 'sur_id' => $uuid,
  384. 'art_id' => $id,
  385. 'website_id' => $website_id ?? 2,
  386. 'survey_name' => $survey_name,
  387. 'choice_name' => $value,
  388. 'is_other' => 0,
  389. 'other_id' => 0,
  390. 'results' => 0,
  391. ];
  392. }
  393. if (empty($suvey_data)) {
  394. throw new \Exception("投票数据为空");
  395. }
  396. }
  397. $result = ArticleSurvey::insert($suvey_data);
  398. if (!$result) {
  399. throw new \Exception("投票失败,ArticleSurvey插入失败");
  400. }
  401. $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
  402. if (!$result) {
  403. throw new \Exception("投票失败,更新主表失败");
  404. }
  405. }
  406. Db::commit();
  407. return Result::success(['id' => $id]);
  408. } catch (\Throwable $ex) {
  409. Db::rollBack();
  410. var_dump($ex->getMessage());
  411. return Result::error("创建失败", 0);
  412. }
  413. }
  414. /**
  415. * @param array $data
  416. * @return array
  417. */
  418. public function delArticle(array $data): array
  419. {
  420. $result = Article::where($data)->delete();
  421. //survey投票删除
  422. articleSurvey::where(['art_id' => $data['id']])->delete();
  423. if (!$result) {
  424. return Result::error("删除失败");
  425. }
  426. return Result::success($result);
  427. }
  428. /**
  429. * @param array $data
  430. * @return array
  431. */
  432. public function updateArticle(array $data): array
  433. {
  434. var_dump($data, '----------12-----------1');
  435. Db::beginTransaction();
  436. unset($data['user_type']);
  437. // unset($data['web_site_id']);
  438. unset($data['nav_add_pool_id']);
  439. try {
  440. //处理投票
  441. $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
  442. $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
  443. $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
  444. $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
  445. unset($data['is_survey']);
  446. unset($data['survey_name']);
  447. unset($data['suvey_array']);
  448. unset($data['website_id']);
  449. $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
  450. if ($data['hits'] == '') {
  451. $data['hits'] = 0;
  452. }
  453. if ($data['is_original'] == '') {
  454. $data['is_original'] = 0;
  455. }
  456. if ($data['status'] == '') {
  457. $data['status'] = 0;
  458. }
  459. $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : $data['cat_arr_id'];
  460. $data['tag'] = isset($data['tag']) ? json_encode($data['tag']) : '';
  461. $articleData = $data;
  462. unset($articleData['content']);
  463. unset($articleData['status_name']);
  464. unset($articleData['name']);
  465. unset($articleData['content']);
  466. unset($articleData['pid_arr']);
  467. unset($articleData['pid']);
  468. //自动处理缩略图、关键字、描述
  469. if ($articleData['imgurl'] == '') {
  470. //如果没有图,设置level=0
  471. $levelArr = json_decode($articleData['level'], true);
  472. var_dump($levelArr, '----------levelArr-----------1');
  473. //content中提取图片第一个图,正则提取
  474. $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
  475. preg_match_all($reg, $data['content'], $matches);
  476. if (isset($matches[1][0])) {
  477. //截取varchar240
  478. // 截取到第一个<
  479. $articleData['imgurl'] = $matches[1][0];
  480. var_dump($articleData['imgurl'], '----------imgurl-----------1');
  481. $pos = strpos($articleData['imgurl'], '"');
  482. if ($pos !== false) {
  483. $articleData['imgurl'] = substr($articleData['imgurl'], 0, $pos);
  484. }
  485. //$articleData['imgurl'] = substr($matches[1][0], 0, 240);
  486. //如果有图,设置level=3
  487. if (!in_array(3, $levelArr)) {$levelArr[] = 3;}
  488. $articleData['level'] = json_encode($levelArr);
  489. } else {
  490. if (!in_array(0, $levelArr)) {
  491. $levelArr[] = 0;
  492. }
  493. $articleData['level'] = json_encode($levelArr);
  494. }
  495. }
  496. var_dump($articleData['level'], '----------$articleData[level]----------1');
  497. if ($articleData['keyword'] == '') {
  498. //提取标题+内容中的关键词
  499. $articleData['keyword'] = $data['title'];
  500. // . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
  501. Jieba::init(); // 初始化 jieba-php
  502. Finalseg::init();
  503. $segList = Jieba::cut($articleData['keyword']);
  504. $segList1 = array_slice($segList, 0, 8);
  505. $articleData['keyword'] = implode(',', $segList1);
  506. }
  507. if ($articleData['introduce'] == '') {
  508. //提取内容中的描述
  509. $articleData['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
  510. }
  511. $id = Article::where(['id' => $data['id']])->update($articleData);
  512. $articleDataContent = [
  513. 'content' => $data['content'],
  514. ];
  515. ArticleData::where(['article_id' => $data['id']])->update($articleDataContent);
  516. //处理投票
  517. $id = $data['id'];
  518. $surveydata = ArticleSurvey::where(['art_id' => $data['id']])->delete();
  519. var_dump($suvey_array, 'suvey_array________delete');
  520. //处理投票
  521. if ($is_survey == 1) {
  522. //生成年月日时分秒+8位随机数
  523. $uuid = date('YmdHis') . rand(10000000, 99999999);
  524. $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
  525. var_dump($suveys_array, '---------------------1');
  526. $suvey_data = [];
  527. if (is_array($suveys_array)) {
  528. foreach ($suveys_array as $key => $value) {
  529. if ($value == '') {
  530. continue;
  531. }
  532. if (is_array($value)) {
  533. $suvey_data[] = [
  534. 'sur_id' => $uuid,
  535. 'art_id' => $id,
  536. 'website_id' => $website_id ?? 2,
  537. 'survey_name' => $survey_name,
  538. 'choice_name' => $value[1],
  539. 'is_other' => 1,
  540. 'other_id' => 0,
  541. 'results' => 0,
  542. ];
  543. } else {
  544. $suvey_data[] = [
  545. 'sur_id' => $uuid,
  546. 'art_id' => $id,
  547. 'website_id' => $website_id ?? 2,
  548. 'survey_name' => $survey_name,
  549. 'choice_name' => $value,
  550. 'is_other' => 0,
  551. 'other_id' => 0,
  552. 'results' => 0,
  553. ];
  554. }
  555. if (empty($suvey_data)) {
  556. throw new \Exception("投票数据为空");
  557. }
  558. }
  559. }
  560. $result = ArticleSurvey::insert($suvey_data);
  561. if (!$result) {
  562. throw new \Exception("投票失败");
  563. }
  564. $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
  565. if (!$result) {
  566. throw new \Exception("投票失败");
  567. }
  568. } else {
  569. $result = Article::where('id', $id)->update(['survey_id' => '', 'survey_name' => '', 'is_survey' => 0]);
  570. }
  571. Db::commit();
  572. return Result::success([]);
  573. } catch (\Throwable $ex) {
  574. Db::rollBack();
  575. var_dump($ex->getMessage());
  576. return Result::error("更新失败" . $ex->getMessage(), 0);
  577. }
  578. }
  579. /**
  580. * 更新资讯状态
  581. * @param array $data
  582. * @return array
  583. */
  584. public function upArticleStatus(array $data): array
  585. {
  586. $result = Article::where(['id' => $data['id']])->update($data);
  587. if ($result) {
  588. return Result::success();
  589. } else {
  590. return Result::error("更新状态失败", 0);
  591. }
  592. }
  593. /**
  594. * @param array $data
  595. * @return array
  596. */
  597. public function getArticleInfo(array $data): array
  598. {
  599. $where = [
  600. 'article.id' => $data['id'],
  601. // 'article.status' => 1,
  602. ];
  603. $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")->first();
  604. $articleSurvey = ArticleSurvey::where(['art_id' => $data['id']])->get();
  605. $info = $result;
  606. // var_dump($info, 'info');
  607. $info['survey_array'] = $articleSurvey;
  608. if ($result) {
  609. return Result::success($info);
  610. } else {
  611. return Result::error("查询失败", 0);
  612. }
  613. }
  614. /**
  615. * 获取新闻
  616. * @param array $data
  617. * @return array
  618. */
  619. public function getWebsiteArticlett(array $data): array
  620. {
  621. $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
  622. $result = [];
  623. if ($category) {
  624. $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
  625. $where = [
  626. 'status' => 1,
  627. ];
  628. var_dump($data, 'data-----------------');
  629. // level=7 根据文章key来匹配文章
  630. if (isset($data['level']) && $data['level'] == 7) {
  631. // 根据文章id获取key
  632. // $data['id'] = 50142;
  633. if (isset($data['id']) && !empty($data['id'])) {
  634. $keyword = Article::where('id', $data['id'])->value('keyword');
  635. $keywordArray = explode(',', $keyword);
  636. $whereL7 = [];
  637. foreach ($keywordArray as $k => $v) {
  638. $whereL7[] = ['keyword', 'like', '%' . $v . '%'];
  639. }
  640. $result = Article::where($whereL7)
  641. ->offset($placeid)
  642. ->limit($data['pageSize'])
  643. ->orderBy('updated_at', 'desc')
  644. ->get();
  645. if (empty($result)) {
  646. return Result::success([]);
  647. }
  648. return Result::success($result);
  649. } else {
  650. return Result::error("参数错误level=7,id不能为空", 0);
  651. }
  652. }
  653. //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
  654. // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
  655. var_dump($where, 'where-----------------');
  656. $result = Article::where($where)
  657. ->whereIn("catid", $category)
  658. ->where(function ($query) use ($data) {
  659. $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
  660. ->orWhereNull("ignore_ids");
  661. })
  662. //$data['level'] == 4 || $data['level'] == 5 查询随机
  663. ->when($data['level'] == 5, function ($query) {
  664. $query->inRandomOrder()
  665. //updated_at最近三十天;
  666. ->where('updated_at', '>', date("Y-m-d H:i:s", strtotime("-30 day")));
  667. })
  668. ->when($data['level'] == 4, function ($query) {
  669. $query->orderBy("updated_at", "desc");
  670. })
  671. ->when(!empty($data['level']), function ($query) use ($data) {
  672. if ($data['level'] != 4 && $data['level'] != 5) {
  673. $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
  674. ->orderBy("updated_at", "desc");
  675. }
  676. })
  677. ->offset($placeid)
  678. ->limit($data['pageSize'])
  679. ->get();
  680. if (empty($result)) {
  681. return Result::error("暂无头条新闻", 0);
  682. }
  683. return Result::success($result);
  684. } else {
  685. return Result::error("本网站下暂无相关栏目", 0);
  686. }
  687. }
  688. /**
  689. * 获取模块新闻
  690. * @param array $data
  691. * @return array
  692. */
  693. public function getWebsiteModelArticles(array $data): array
  694. {
  695. $catid = $data['catid'];
  696. $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->select('category_id')->get();
  697. $category = $category->toArray();
  698. if (!empty($category)) {
  699. $where = [
  700. 'status' => 1,
  701. 'catid' => $catid,
  702. ];
  703. $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
  704. // 1:文字新闻;2:轮播图;3:图文;
  705. // 级别:0:未分类
  706. // 3:推荐图片
  707. if ($data['level'] == 1) {
  708. $data['level'] = 0;
  709. }
  710. $result = Article::where($where)
  711. ->where(function ($query) use ($data) {
  712. $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
  713. ->orWhereNull("level")
  714. ->orWhereRaw("level = '[]'");
  715. })
  716. ->where(function ($query) use ($data) {
  717. $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
  718. ->orWhereNull("ignore_ids");
  719. })
  720. ->orderBy("updated_at", "desc")
  721. ->offset($placeid)
  722. ->limit($data['pagesize'])
  723. ->get();
  724. if (empty($result)) {
  725. return Result::error("此栏目暂无相关新闻", 0);
  726. }
  727. } else {
  728. return Result::error("此网站暂无此栏目", 0);
  729. }
  730. return Result::success($result);
  731. }
  732. /**
  733. *获取新闻列表
  734. * @param array $data
  735. * @return array
  736. */
  737. public function getWebsiteArticleList(array $data): array
  738. {
  739. $where[] = ['status', '=', 1];
  740. if (isset($data['keyword']) && !empty($data['keyword'])) {
  741. array_push($where, ['article.title', 'like', '%' . $data['keyword'] . '%']);
  742. }
  743. if (isset($data['catid']) && !empty($data['catid'])) {
  744. if (is_array($data['catid'])) {
  745. $category = WebsiteCategory::where('website_id', $data['website_id'])->whereIn('category_id', $data['catid'])->pluck('category_id');
  746. array_push($where, ['catid', 'in', $data['catid']]);
  747. } else {
  748. $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
  749. array_push($where, ['catid', '=', $data['catid']]);
  750. }
  751. if (empty($category)) {
  752. return Result::error("此网站暂无此栏目", 0);
  753. }
  754. }
  755. // return Result::success($where);
  756. $rep = Article::where(function ($query) use ($where) {
  757. foreach ($where as $condition) {
  758. if ($condition[1] === 'in') {
  759. $query->whereIn($condition[0], $condition[2]);
  760. } else {
  761. $query->where($condition[0], $condition[1], $condition[2]);
  762. }
  763. }
  764. })
  765. ->where(function ($query) use ($data) {
  766. $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
  767. ->orWhereNull("ignore_ids");
  768. })
  769. ->orderBy("updated_at", "desc")
  770. ->limit($data['pageSize'])
  771. ->offset(($data['page'] - 1) * $data['pageSize'])
  772. ->get();
  773. $count = Article::where(function ($query) use ($where) {
  774. foreach ($where as $condition) {
  775. if ($condition[1] === 'in') {
  776. $query->whereIn($condition[0], $condition[2]);
  777. } else {
  778. $query->where($condition[0], $condition[1], $condition[2]);
  779. }
  780. }
  781. })->count();
  782. $data = [
  783. 'rows' => $rep->toArray(),
  784. 'count' => $count,
  785. ];
  786. if (empty($rep)) {
  787. return Result::error("没有信息数据");
  788. }
  789. return Result::success($data);
  790. }
  791. /**
  792. * 前端-获取新闻详情
  793. * @param array $data
  794. * @return array
  795. */
  796. public function selectWebsiteArticleInfo(array $data): array
  797. {
  798. $where = [
  799. 'article.id' => $data['id'],
  800. 'article.status' => 1,
  801. ];
  802. $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")
  803. ->where(function ($query) use ($data) {
  804. $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
  805. ->orWhereNull("ignore_ids");
  806. })
  807. ->first();
  808. if (empty($result)) {
  809. return Result::error("暂无此新闻!", 0);
  810. }
  811. $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
  812. ->select('website_category.*', 'website.website_name', 'website.suffix')
  813. ->where('website_category.website_id', $data['website_id'])
  814. ->where(['website_category.category_id' => $result['catid']])
  815. ->first();
  816. if (empty($category)) {
  817. return Result::error("查询失败", 0);
  818. }
  819. //手动推荐文章
  820. $commend_ids = $result['commend_id'] ? json_decode($result['commend_id']) : [];
  821. $commendArticle = Article::whereIn('id', $commend_ids)
  822. ->where('status', 1)
  823. ->select('id', 'title', 'catid', 'imgurl', 'hits', 'created_at')
  824. ->orderBy('updated_at', 'desc')
  825. ->limit(5)
  826. ->get();
  827. $result['category_id'] = $category['category_id'];
  828. $result['cat_name'] = $category['alias'];
  829. $result['website_name'] = $category['website_name'] ?? "";
  830. $result['suffix'] = $category['suffix'] ?? "";
  831. $result['commendArticle'] = $commendArticle;
  832. return Result::success($result);
  833. }
  834. /**
  835. * 前端-获取网站调查问卷
  836. * @param array $data
  837. * @return array
  838. */
  839. public function getWebsiteSurvey(array $data): array
  840. {
  841. if (isset($data['website_id']) && !empty($data['website_id'])) {
  842. $website = Website::where('id', $data['website_id'])->first();
  843. if (empty($website)) {
  844. return Result::error("暂无此网站", 0);
  845. }
  846. }
  847. if (isset($data['art_id']) && !empty($data['art_id'])) {
  848. $article = Article::where('id', $data['art_id'])->where('status', 1)->first();
  849. if (empty($article)) {
  850. return Result::error("暂无此文章", 0);
  851. }
  852. // return Result::error($data,0);
  853. $where['art_id'] = $data['art_id'];
  854. // $query = ArticleSurvey::where('art_id',$data['art_id']);
  855. } else {
  856. $survey = Article::where(function ($query) {
  857. $query->whereRaw("JSON_CONTAINS(cat_arr_id, '28')")
  858. ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '\"28\"')");
  859. })
  860. ->where('status', 1)
  861. ->where('is_survey', 1)
  862. ->select('survey_id')
  863. ->orderBy('updated_at', 'desc')
  864. ->first();
  865. if (empty($survey)) {
  866. return Result::error("暂无调查问卷", 0);
  867. }
  868. $where['sur_id'] = $survey['survey_id'];
  869. // $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
  870. }
  871. // return Result::success($where);
  872. $result = ArticleSurvey::where($where)
  873. ->where(function ($query) {
  874. $query->where('is_other', 0)
  875. ->orWhere(function ($subQuery) {
  876. $subQuery->where('is_other', 1)
  877. ->where('other_id', 0);
  878. });
  879. })
  880. ->leftJoin('article', 'article_survey.art_id', 'article.id')
  881. ->select('article_survey.*', 'article.survey_type')
  882. ->get()->all();
  883. if (empty($result)) {
  884. return Result::error("此文章暂无调查问卷", 0);
  885. }
  886. return Result::success($result);
  887. }
  888. /**
  889. * 前端-添加网站调查问卷选项
  890. * @param array $data
  891. * @return array
  892. */
  893. public function addWebsiteSurveyOption(array $data): array
  894. {
  895. if (isset($data['website_id']) && !empty($data['website_id'])) {
  896. $website = Website::where('id', $data['website_id'])->first();
  897. if (empty($website)) {
  898. return Result::error("暂无此网站", 0);
  899. }
  900. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  901. $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->where('is_other', 1)->where('other_id', 0)->first();
  902. if (empty($survey)) {
  903. return Result::error("此调查问卷不可添加选项", 0);
  904. }
  905. if (isset($data['choice_name']) && !empty($data['choice_name'])) {
  906. $choice = [
  907. 'art_id' => $survey['art_id'],
  908. 'website_id' => $data['website_id'],
  909. 'survey_name' => $survey['survey_name'],
  910. 'choice_name' => $data['choice_name'],
  911. 'sur_id' => $survey['sur_id'],
  912. 'is_other' => 1,
  913. 'other_id' => $survey['id'],
  914. ];
  915. $result = ArticleSurvey::insertGetId($choice);
  916. if (empty($result)) {
  917. return Result::error("添加失败", 0);
  918. }
  919. return Result::success($result);
  920. }
  921. }
  922. return Result::error("添加失败", 0);
  923. }
  924. return Result::error("添加失败", 0);
  925. }
  926. /**
  927. * 前端-调查问卷投票
  928. * @param array $data
  929. * @return array
  930. */
  931. public function addWebsiteSurveyVote(array $data): array
  932. {
  933. // return Result::success($data);
  934. if (isset($data['website_id']) && !empty($data['website_id'])) {
  935. $website = Website::where('id', $data['website_id'])->first();
  936. if (empty($website)) {
  937. return Result::error("暂无此网站", 0);
  938. }
  939. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  940. $is_survey = ArticleSurvey::where('sur_id', $data['sur_id'])->first();
  941. // return Result::success($survey);
  942. if (empty($is_survey)) {
  943. return Result::error("此调查问卷不存在", 0);
  944. }
  945. // return Result::success($survey);
  946. // 调查问卷类型
  947. if (isset($data['choice_id']) && !empty($data['choice_id'])) {
  948. //多选 若是json型则转化成数组类型
  949. if (strpos($data['choice_id'], '[') === 0) {
  950. $data['choice_id'] = json_decode($data['choice_id'], true);
  951. } else {
  952. // 单选 也转换成数组
  953. $data['choice_id'] = [$data['choice_id']];
  954. }
  955. $data['choice_id'] = array_map('intval', $data['choice_id']);
  956. $other = ArticleSurvey::whereIn('id', $data['choice_id'])
  957. ->where('website_id', $data['website_id'])
  958. ->where('is_other', 1)
  959. ->where('other_id', 0)
  960. ->first();
  961. if (!empty($other)) {
  962. return Result::error("请选择已有的选项!", 0);
  963. }
  964. $choice['other'] = ArticleSurvey::whereIn('id', $data['choice_id'])
  965. ->where('website_id', $data['website_id'])
  966. ->where('is_other', 1)
  967. ->where('other_id', '!=', 0)
  968. ->first();
  969. // return Result::success($choice['other']);
  970. $choice_id = $data['choice_id'];
  971. if (!empty($choice['other'])) {
  972. // array_push($data['choice_id'],$choice['other']['other_id']);
  973. if (!empty($choice_id)) {
  974. $key = array_search($choice['other']['id'], $choice_id);
  975. if ($key !== false) {
  976. unset($choice_id[$key]);
  977. $choice_id = array_values($choice_id);
  978. }
  979. array_push($choice_id, $choice['other']['other_id']);
  980. } else {
  981. $choice_id[0] = $choice['other']['other_id'];
  982. }
  983. array_push($data['choice_id'], $choice['other']['other_id']);
  984. }
  985. // return Result::success($data);
  986. $choice = ArticleSurvey::whereIn('id', $data['choice_id'])
  987. ->where('website_id', $data['website_id'])
  988. ->increment('results', 1);
  989. if (empty($choice)) {
  990. return Result::error("请选择已有的选项!", 0);
  991. }
  992. $survey['data'] = ArticleSurvey::where('sur_id', $data['sur_id'])
  993. ->where('website_id', $data['website_id'])
  994. ->where('other_id', 0)
  995. ->get();
  996. $survey['choice'] = $choice_id;
  997. return Result::success($survey);
  998. }
  999. return Result::error("参数必填!");
  1000. }
  1001. return Result::error("此调查问卷不存在", 0);
  1002. }
  1003. return Result::error("参数必填!");
  1004. }
  1005. /**
  1006. * 后端-获取网站调查问卷列表
  1007. * @param array $data
  1008. * @return array
  1009. */
  1010. public function getSurveyList(array $data): array
  1011. {
  1012. $where = [];
  1013. if (isset($data['survey_name']) && !empty($data['survey_name'])) {
  1014. array_push($where, ['survey_name', 'like', '%' . $data['survey_name'] . '%']);
  1015. }
  1016. if (isset($data['survey_type']) && $data['survey_type'] != null) {
  1017. array_push($where, ['survey_type', '=', $data['survey_type']]);
  1018. }
  1019. if (isset($data['is_survey']) && $data['is_survey'] != null) {
  1020. array_push($where, ['is_survey', '=', $data['is_survey']]);
  1021. }
  1022. // return Result::success($where);
  1023. if (!empty($where)) {
  1024. $query = Article::where($where)->where(function ($q) {
  1025. $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
  1026. });
  1027. } else {
  1028. $query = Article::where(function ($q) {
  1029. $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
  1030. });
  1031. }
  1032. $count = $query->count();
  1033. $survey = $query->orderByDesc('id')
  1034. ->limit($data['pageSize'])
  1035. ->offset(($data['page'] - 1) * $data['pageSize'])
  1036. ->get();
  1037. if (empty($survey->toArray())) {
  1038. return Result::error("暂无调查问卷!", 0);
  1039. }
  1040. $result = [
  1041. 'rows' => $survey,
  1042. 'count' => $count,
  1043. ];
  1044. return Result::success($result);
  1045. }
  1046. /**
  1047. * 后端-获取网站调查问卷详情
  1048. * @param array $data
  1049. * @return array
  1050. */
  1051. public function getSurveyInfo(array $data): array
  1052. {
  1053. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  1054. $where = ['sur_id' => $data['sur_id']];
  1055. $choose = ArticleSurvey::where($where)->where('is_other', 0)
  1056. ->leftJoin('article', 'article_survey.art_id', 'article.id')
  1057. ->select('article_survey.*', 'article.survey_type')
  1058. ->get()->all();
  1059. if (empty($choose)) {
  1060. return Result::error("此调查问卷不存在", 0);
  1061. }
  1062. $resultsArray = array_column($choose, 'results');
  1063. $total = array_sum($resultsArray);
  1064. $other = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
  1065. $others = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->get()->all();
  1066. // $total = 0;
  1067. if (!empty($other)) {
  1068. $total = $total + $other['results'];
  1069. $other['choice_name'] = '(其他)';
  1070. if (!empty($others)) {
  1071. $other['hasChildren'] = true;
  1072. // array_push($other,['hasChildren','=',true]);
  1073. $other['children'] = $others;
  1074. $other_choices = [$other->toArray()];
  1075. $mer_choice = array_merge($choose, $other_choices);
  1076. $value_choice = array_values($mer_choice);
  1077. } else {
  1078. // return Result::error('1111');
  1079. $other_choices = [$other->toArray()];
  1080. $other_choices = array_merge($choose, $other_choices);
  1081. $value_choice = array_values($other_choices);
  1082. // return Result::success($result);
  1083. }
  1084. } else {
  1085. $value_choice = $choose;
  1086. }
  1087. $result = [
  1088. 'choose' => $value_choice,
  1089. 'total' => $total,
  1090. ];
  1091. }
  1092. return Result::success($result);
  1093. }
  1094. /**
  1095. * 前端-搜索新闻列表
  1096. * @param array $data
  1097. * @return array
  1098. */
  1099. public function selectWebsiteArticle(array $data): array
  1100. {
  1101. $where = [];
  1102. // 初始化查询构造器
  1103. $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
  1104. $query = Article::where('status', 1)
  1105. ->whereIn('catid', $category)
  1106. ->where(function ($query) use ($data) {
  1107. $query->where(function ($subQuery) use ($data) {
  1108. $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
  1109. })->orWhereNull("ignore_ids");
  1110. });
  1111. // return Result::success($all_articles);
  1112. // 检查是否存在 cityid 参数
  1113. if (isset($data['cityid']) && !empty($data['cityid'])) {
  1114. $query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
  1115. }
  1116. // 检查是否存在 department_id 参数
  1117. if (isset($data['department_id']) && !empty($data['department_id'])) {
  1118. $query->whereRaw("JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "')");
  1119. }
  1120. // 检查是否存在 keyword 参数
  1121. if (isset($data['keyword']) && !empty($data['keyword'])) {
  1122. $query->where('title', 'like', '%' . $data['keyword'] . '%');
  1123. }
  1124. // 计算总数
  1125. $count = $query->count();
  1126. // 分页查询
  1127. $articles = $query->orderBy("updated_at", "desc")
  1128. ->limit($data['pageSize'])
  1129. ->offset(($data['page'] - 1) * $data['pageSize'])
  1130. ->get()->all();
  1131. if (empty($articles)) {
  1132. return Result::error("没有符合条件的资讯数据");
  1133. }
  1134. $data = [
  1135. 'rows' => $articles,
  1136. 'count' => $count,
  1137. ];
  1138. return Result::success($data);
  1139. }
  1140. /**
  1141. * 模块新闻加强版
  1142. * @param array $data
  1143. * @return array
  1144. */
  1145. public function getWebsiteCatidArticle(array $data): array
  1146. {
  1147. // return Result::success($data);
  1148. $where = [
  1149. // 'category.status' => 1,
  1150. 'website_category.category_id' => $data['catid'],
  1151. 'website_category.website_id' => $data['website_id'],
  1152. // 'article.status' => 1,
  1153. ];
  1154. // $category = WebsiteCategory::where($where);
  1155. if (isset($data['child_catnum']) && !empty($data['child_catnum'])) {
  1156. $child_catnum = $data['child_catnum'] ?? 1;
  1157. $category['child'] = WebsiteCategory::where('pid', $data['catid'])->where('website_id', $data['website_id'])->select('category_id', 'alias')->limit($child_catnum)->get()->toArray();
  1158. $childCategoryIds = array_column($category['child'], 'category_id');
  1159. if (empty($childCategoryIds)) {
  1160. return Result::error("暂无子栏目", 0);
  1161. }
  1162. $imgArticles = [];
  1163. $textArticles = [];
  1164. // return Result::success($childCategoryIds);
  1165. if (isset($data['child_imgnum']) && !empty($data['child_imgnum']) && $data['child_imgnum'] != 0) {
  1166. // 初始化子分类图片新闻和文字新闻数组
  1167. // 查询所有子级栏目的图文新闻
  1168. $imgArticles = Article::where('catid', $childCategoryIds[0])
  1169. ->where('status', 1)
  1170. ->where('imgurl', '!=', '')
  1171. ->select('*')
  1172. ->orderBy('updated_at', 'desc')
  1173. ->limit($data['child_imgnum'])
  1174. ->get();
  1175. }
  1176. if (isset($data['child_textnum']) && !empty($data['child_textnum']) && $data['child_textnum'] != 0) {
  1177. // 查询所有子级栏目的文字新闻
  1178. $textArticles = Article::where('catid', $childCategoryIds[0])
  1179. ->where('status', 1)
  1180. // ->where(function ($query) {
  1181. // $query->whereNull('imgurl')
  1182. // ->orWhere('imgurl', '');
  1183. // })
  1184. ->select('*')
  1185. ->orderBy('updated_at', 'desc')
  1186. ->limit($data['child_textnum'])
  1187. ->get();
  1188. }
  1189. // 遍历子分类,将图文新闻和文字新闻分别添加到子分类中
  1190. $category['child'] = array_map(function ($child) use ($imgArticles, $textArticles) {
  1191. $child['img'] = $imgArticles ? $imgArticles->where('catid', $child['category_id']) : [];
  1192. $child['text'] = $textArticles ? $textArticles->where('catid', $child['category_id']) : [];
  1193. return $child;
  1194. }, $category['child']);
  1195. }
  1196. // }
  1197. if (isset($data['img_num']) && !empty($data['img_num'])) {
  1198. $category['img'] = WebsiteCategory::where($where)
  1199. ->leftJoin('article', 'article.catid', 'website_category.category_id')
  1200. ->where('article.status', 1)
  1201. ->where('article.imgurl', '!=', '')
  1202. ->select('article.*', 'website_category.category_id', 'website_category.alias')
  1203. ->orderBy('article.updated_at', 'desc')
  1204. ->limit($data['img_num'])
  1205. ->get();
  1206. }
  1207. if (isset($data['text_num']) && !empty($data['text_num'])) {
  1208. $category['text'] = WebsiteCategory::where($where)
  1209. ->leftJoin('article', 'article.catid', 'website_category.category_id')
  1210. ->where('article.status', 1)
  1211. // ->where(function ($query) {
  1212. // $query->whereNull('article.imgurl')
  1213. // ->orWhere('article.imgurl', '');
  1214. // })
  1215. ->select('article.*', 'website_category.category_id', 'website_category.alias')
  1216. ->orderBy('article.updated_at', 'desc')
  1217. ->limit($data['text_num'])
  1218. ->get();
  1219. }
  1220. // $category = $category->get();
  1221. if (empty($category)) {
  1222. return Result::error("查询失败", 0);
  1223. }
  1224. return Result::success($category);
  1225. }
  1226. /**
  1227. * 模块新闻加强plus版
  1228. * @param array $data
  1229. * @return array
  1230. */
  1231. public function getWebsiteAllArticle(array $data): array
  1232. {
  1233. // 修正传入的字符串,将单引号替换为双引号
  1234. $input['id'] = $data['id'];
  1235. $input['website_id'] = $data['website_id'];
  1236. // 将 JSON 字符串转换为 PHP 数组
  1237. $data = json_decode($input['id'], true);
  1238. // 使用 array_map 处理每个元素
  1239. $result = array_map(function ($item) use ($input) {
  1240. list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
  1241. $website = [
  1242. 'website_id' => $input['website_id'],
  1243. ];
  1244. // 查询栏目名称
  1245. $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id']);
  1246. // 查询图片新闻
  1247. $imgArticles = Article::where('catid', $parentCatId)
  1248. ->where('imgurl', '!=', '')
  1249. // ->where($website)
  1250. ->limit($parentImgNum)
  1251. ->get();
  1252. // 查询文字新闻
  1253. $textArticles = Article::where('catid', $parentCatId)
  1254. // ->where($website)
  1255. ->limit($parentTextNum)
  1256. ->get();
  1257. $resultItem = [
  1258. 'alias' => $category ? $category->alias : null,
  1259. 'category_id' => $parentCatId,
  1260. 'imgnum' => $imgArticles->toArray(),
  1261. 'textnum' => $textArticles->toArray()
  1262. ];
  1263. if (!empty($item['child']) && $item['child'] != "") {
  1264. // 查询第一个pid等于parent中第一个参数的category来获取child的category_id
  1265. $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)->first();
  1266. if ($childCategory) {
  1267. list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
  1268. // 查询子栏目名称
  1269. $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)->first(['alias', 'category_id']);
  1270. // 查询子栏目图片新闻
  1271. $childImgArticles = Article::where('catid', $childCatId)
  1272. ->where('imgurl', '!=', '')
  1273. // ->where($website)
  1274. ->limit($childImgNum)
  1275. ->get();
  1276. // 查询子栏目文字新闻
  1277. $childTextArticles = Article::where('catid', $childCatId)
  1278. // ->where($website)
  1279. ->limit($childTextNum)
  1280. ->get();
  1281. $resultItem['child'] = [
  1282. 'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
  1283. 'category_id' => $childCatId,
  1284. 'imgnum' => $childImgArticles->toArray(),
  1285. 'textnum' => $childTextArticles->toArray()
  1286. ];
  1287. }
  1288. }
  1289. return $resultItem;
  1290. }, $data);
  1291. return Result::success($result);
  1292. // return Result::success($data);
  1293. }
  1294. /**
  1295. * 验证导航名称是否重复
  1296. * @return void
  1297. */
  1298. public function checkCategoryName(array $data): array
  1299. {
  1300. $result = Category::when($data, function ($query) use ($data) {
  1301. if (isset($data['name']) && $data['name']) {
  1302. $query->where("name", $data['name']);
  1303. }
  1304. if (isset($data['id']) && $data['id']) {
  1305. $query->where("id", "!=", $data['id']);
  1306. }
  1307. })->first();
  1308. if ($result) {
  1309. return Result::error("已存在");
  1310. } else {
  1311. return Result::success();
  1312. }
  1313. }
  1314. //20250226 产品列表
  1315. public function getGoodList(array $data): array
  1316. {
  1317. $type_id = isset($data['type_id']) ? $data['type_id'] : '';
  1318. unset($data['type_id']);
  1319. $user_id = isset($data['user_id']) ? $data['user_id'] : '';
  1320. $where = [];
  1321. if ($type_id != '10000') {
  1322. $where = [
  1323. 'good.user_id' => $user_id,
  1324. ];
  1325. }
  1326. //类型
  1327. if (isset($data['type_id']) && $data['type_id']) {
  1328. $where = [
  1329. 'type_id' => $data['type_id'],
  1330. ];
  1331. }
  1332. //名称
  1333. if (isset($data['name']) && $data['name']) {
  1334. $where = [
  1335. 'good.name' => $data['name'],
  1336. ];
  1337. }
  1338. $where1 = [];
  1339. //website_id
  1340. // if (isset($data['website_id']) && $data['website_id']) {
  1341. // $where1 = [
  1342. // 'good.website_id', 'like', '%' . $data['website_id'] . '%',
  1343. // ];
  1344. // }
  1345. // website_name
  1346. if (isset($data['website_name']) && $data['website_name']) {
  1347. $where1[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
  1348. }
  1349. // catid
  1350. if (isset($data['category_name']) && $data['category_name']) {
  1351. $where1[] = ['category.name', 'like', '%' . $data['category_name'] . '%'];
  1352. }
  1353. // $result = Good::where($where)
  1354. // ->orderBy("updated_at", "desc")->paginate($data['pige_size'], ['*'], 'page', $data['page']);
  1355. $result = Good::where($where)
  1356. ->when(!empty($where1), function ($query) use ($where1) {
  1357. return $query->where($where1);
  1358. })
  1359. ->leftJoin('district', 'good.city_id', '=', 'district.id')
  1360. ->leftJoin('website', 'good.website_id', '=', 'website.id')
  1361. ->leftJoin('category', 'good.catid', '=', 'category.id')
  1362. ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
  1363. ->orderBy("id", "desc")
  1364. ->limit($data['page_size'])
  1365. ->offset(($data['page'] - 1) * $data['page_size'])
  1366. ->get();
  1367. $count = Good::where($where)
  1368. ->leftJoin('district', 'good.city_id', '=', 'district.id')
  1369. ->leftJoin('website', 'good.website_id', '=', 'website.id')
  1370. ->leftJoin('category', 'good.catid', '=', 'category.id')
  1371. ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
  1372. ->orderBy("updated_at", "desc")->count();
  1373. $data = [
  1374. 'rows' => $result->toArray(),
  1375. 'count' => $count,
  1376. ];
  1377. if (empty($result)) {
  1378. return Result::error("此栏目暂无相关产品", 0);
  1379. }
  1380. return Result::success($data);
  1381. }
  1382. public function getGoodInfo(array $data): array
  1383. {
  1384. $result = Good::where('id', $data['id'])->first();
  1385. if (empty($result)) {
  1386. return Result::error("此产品不存在", 0);
  1387. }
  1388. return Result::success($result);
  1389. }
  1390. public function addGood(array $data): array
  1391. {
  1392. // unset($data['city_arr_id']);
  1393. // unset($data['cat_arr_id']);
  1394. $data['city_id'] = end($data['city_arr_id']);
  1395. $data['catid'] = end($data['cat_arr_id']);
  1396. $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
  1397. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  1398. $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
  1399. unset($data['imgUrl']);
  1400. $result = Good::insert($data);
  1401. if (empty($result)) {
  1402. return Result::error("添加失败", 0);
  1403. }
  1404. return Result::success($result);
  1405. }
  1406. public function updateGood(array $data): array
  1407. {
  1408. $data['city_id'] = end($data['city_arr_id']);
  1409. $data['catid'] = end($data['cat_arr_id']);
  1410. $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
  1411. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  1412. $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
  1413. //设置东八区
  1414. date_default_timezone_set('Asia/Shanghai');
  1415. $data['updated_at'] = date('Y-m-d H:i:s');
  1416. $result = Good::where('id', $data['id'])->update($data);
  1417. if (empty($result)) {
  1418. return Result::error("更新失败", 0);
  1419. }
  1420. return Result::success($result);
  1421. }
  1422. public function delGood(array $data): array
  1423. {
  1424. $result = Good::where('id', $data['id'])->delete();
  1425. if (empty($result)) {
  1426. return Result::error("删除失败", 0);
  1427. }
  1428. return Result::success($result);
  1429. }
  1430. //20250226 产品列表
  1431. //20250306 求职信息
  1432. public function getJobHuntingList(array $data): array
  1433. {
  1434. $where = [];
  1435. if (isset($data['username']) && !empty($data['username'])) {
  1436. $where[] = ['user.user_name', 'like', '%' . $data['username'] . '%'];
  1437. }
  1438. $type_id = isset($data['type_id']) ? $data['type_id'] : '';
  1439. $user_id = isset($data['user_id']) ? $data['user_id'] : '';
  1440. unset($data['type_id']);
  1441. if ($type_id != '10000') {
  1442. $where[] = ['job_hunting.user_id', '=', $user_id];
  1443. }
  1444. $result = JobHunting::where($where)
  1445. ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
  1446. ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
  1447. ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as username', 'website.website_name as website_name')
  1448. ->orderBy("id", "desc")
  1449. ->limit($data['page_size'])
  1450. ->offset(($data['page'] - 1) * $data['page_size'])
  1451. ->get();
  1452. if (empty($result)) {
  1453. return Result::error("查询失败", 0);
  1454. }
  1455. $count = JobHunting::where($where)
  1456. ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
  1457. ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
  1458. ->count();
  1459. $data = [
  1460. 'rows' => $result->toArray(),
  1461. 'count' => $count,
  1462. ];
  1463. return Result::success($data);
  1464. }
  1465. public function addJobHunting(array $data): array
  1466. {
  1467. date_default_timezone_set('Asia/Shanghai');
  1468. unset($data['company_name']);
  1469. unset($data['job_industry']);
  1470. unset($data['job_name']);
  1471. unset($data['department']);
  1472. unset($data['job_timeList']);
  1473. unset($data['job_content']);
  1474. $data['created_at'] = date('Y-m-d H:i:s');
  1475. $data['updated_at'] = date('Y-m-d H:i:s');
  1476. var_dump($data, '-----------------test---------');
  1477. $result = JobHunting::create($data);
  1478. if (empty($result)) {
  1479. return Result::error("添加失败", 0);
  1480. }
  1481. return Result::success($result);
  1482. }
  1483. public function delJobHunting(array $data): array
  1484. {
  1485. $result = JobHunting::where('id', $data['id'])->delete();
  1486. if (empty($result)) {
  1487. return Result::error("删除失败", 0);
  1488. }
  1489. return Result::success($result);
  1490. }
  1491. public function updateJobHunting(array $data): array
  1492. {
  1493. //设置东八区
  1494. date_default_timezone_set('Asia/Shanghai');
  1495. unset($data['company_name']);
  1496. unset($data['job_industry']);
  1497. unset($data['job_name']);
  1498. unset($data['department']);
  1499. unset($data['job_timeList']);
  1500. unset($data['job_content']);
  1501. $data['created_at'] = date('Y-m-d H:i:s');
  1502. $data['updated_at'] = date('Y-m-d H:i:s');
  1503. $result = JobHunting::where('id', $data['id'])->update($data);
  1504. if (empty($result)) {
  1505. return Result::error("更新失败", 0);
  1506. }
  1507. return Result::success($result);
  1508. }
  1509. public function getJobHuntingInfo(array $data): array
  1510. {
  1511. $result = JobHunting::where('id', $data['id'])->first();
  1512. if (empty($result)) {
  1513. return Result::error("查询失败", 0);
  1514. }
  1515. return Result::success($result);
  1516. }
  1517. public function getJobHuntingData(array $data): array
  1518. {
  1519. $jobEnum = JobEnum::get();
  1520. $jobIndustry = JobIndustry::get();
  1521. $jobNature = JobNature::get();
  1522. $jobPosition = JobPosition::get();
  1523. $data = [
  1524. 'jobEnum' => $jobEnum,
  1525. 'jobIndustry' => $jobIndustry,
  1526. 'jobNature' => $jobNature,
  1527. 'jobPosition' => $jobPosition,
  1528. ];
  1529. return Result::success($data);
  1530. }
  1531. public function delJobHuntingInfo(array $data): array
  1532. {
  1533. $result = JobHunting::where('id', $data['id'])->delete();
  1534. return Result::success();
  1535. }
  1536. //20250324 通知,公告,消息
  1537. public function delNotice(array $data): array
  1538. {
  1539. return Result::success();
  1540. }
  1541. public function getNoticeInfo(array $data): array
  1542. {
  1543. $result = Notice::where('id', $data['id'])->first();
  1544. if (empty($result)) {
  1545. return Result::error("查询失败", 0);
  1546. }
  1547. return Result::success($result);
  1548. }
  1549. public function addNotice(array $data): array
  1550. {
  1551. $result = Notice::create($data);
  1552. return Result::success($result);
  1553. }
  1554. public function updateNotice(array $data): array
  1555. {
  1556. $result = Notice::where('id', $data['id'])->update($data);
  1557. return Result::success($result);
  1558. }
  1559. public function getNoticeList(array $data): array
  1560. {
  1561. $result = Notice::where('status', 1)->get();
  1562. return Result::success($result);
  1563. }
  1564. public function getNoticeDetail(array $data): array
  1565. {
  1566. $result = Notice::where('id', $data['id'])->first();
  1567. if (empty($result)) {
  1568. return Result::error("查询失败", 0);
  1569. }
  1570. return Result::success($result);
  1571. }
  1572. public function deleteNotice(array $data): array
  1573. {
  1574. $result = Notice::where('id', $data['id'])->delete();
  1575. return Result::success($result);
  1576. }
  1577. public function getMSG(array $data): array
  1578. {
  1579. $type_id = isset($data['type_id']) ? $data['type_id'] : 1;
  1580. // '1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
  1581. $user_id = isset($data['user_id']) ? $data['user_id'] : 0; //用户id
  1582. $result = [];
  1583. if ($type_id == 1) {
  1584. //最近的5篇已审的文章
  1585. $apply_articale = Article::where('status', 1)
  1586. ->orderBy('updated_at', 'desc')
  1587. ->limit(5)->get();
  1588. //获取5条单聊未读聊天消息
  1589. $chat = ChatRecords::where('is_read', 0)
  1590. ->where('user_id', $user_id)
  1591. ->where('talk_type', 1)
  1592. ->orderBy('created_at', 'desc')
  1593. ->limit(5)->get();
  1594. //获取5条未读群聊信息
  1595. $chat_group = ChatRecords::where('is_read', 0)
  1596. ->where('user_id', $user_id)
  1597. ->where('talk_type', 2)
  1598. ->orderBy('created_at', 'desc')
  1599. ->limit(5)->get();
  1600. $count = count($chat) + count($chat_group) + count($apply_articale);
  1601. $result = [
  1602. 'apply_articale' => $apply_articale,
  1603. 'chat' => $chat,
  1604. 'chat_group' => $chat_group,
  1605. 'count' => $count,
  1606. ];
  1607. } elseif ($type_id == 2) {
  1608. //最近的5篇已审的文章
  1609. $apply_articale = Article::where('status', 1)->limit(5)->get();
  1610. //获取5条单聊未读聊天消息
  1611. $chat = ChatRecords::where('is_read', 0)
  1612. ->where('user_id', $user_id)
  1613. ->where('talk_type', 1)
  1614. ->orderBy('created_at', 'desc')
  1615. ->limit(5)->get();
  1616. //获取5条未读群聊信息
  1617. $chat_group = ChatRecords::where('is_read', 0)
  1618. ->where('user_id', $user_id)
  1619. ->where('talk_type', 2)
  1620. ->orderBy('created_at', 'desc')
  1621. ->limit(5)->get();
  1622. $count = count($chat) + count($chat_group) + count($apply_articale);
  1623. $result = [
  1624. 'apply_articale' => $apply_articale,
  1625. 'chat' => $chat,
  1626. 'chat_group' => $chat_group,
  1627. 'count' => $count,
  1628. ];
  1629. } elseif ($type_id == 3) {
  1630. //最近的5篇已审的文章
  1631. $apply_articale = Article::where('status', 1)->limit(5)->get();
  1632. //获取5条单聊未读聊天消息
  1633. $chat = ChatRecords::where('is_read', 0)
  1634. ->where('user_id', $user_id)
  1635. ->where('talk_type', 1)
  1636. ->orderBy('created_at', 'desc')
  1637. ->limit(5)->get();
  1638. //获取5条未读群聊信息
  1639. $chat_group = ChatRecords::where('is_read', 0)
  1640. ->where('user_id', $user_id)
  1641. ->where('talk_type', 2)
  1642. ->orderBy('created_at', 'desc')
  1643. ->limit(5)->get();
  1644. $count = count($chat) + count($chat_group) + count($apply_articale);
  1645. $result = [
  1646. 'apply_articale' => $apply_articale,
  1647. 'chat' => $chat,
  1648. 'chat_group' => $chat_group,
  1649. 'count' => $count,
  1650. ];
  1651. } elseif ($type_id == 4) {
  1652. //最近的5篇已审的文章
  1653. $apply_articale = Article::where('status', 1)->limit(5)->get();
  1654. $count = count($apply_articale);
  1655. $result = [
  1656. 'count' => $count,
  1657. ];
  1658. } elseif ($type_id == 10000) {
  1659. //获取未审核的5篇文章
  1660. $apply_articale = Article::where('status', 0)
  1661. ->orderBy('updated_at', 'desc')
  1662. ->limit(5)->get();
  1663. //获取5条单聊未读聊天消息
  1664. $chat = ChatRecords::where('is_read', 0)
  1665. ->where('user_id', $user_id)
  1666. ->where('talk_type', 1)
  1667. ->orderBy('created_at', 'desc')
  1668. ->limit(5)->get();
  1669. //获取5条未读群聊信息
  1670. $chat_group = ChatRecords::where('is_read', 0)
  1671. ->where('user_id', $user_id)
  1672. ->where('talk_type', 2)
  1673. ->orderBy('created_at', 'desc')
  1674. ->limit(5)->get();
  1675. $count = count($chat) + count($chat_group) + count($apply_articale);
  1676. $result = [
  1677. 'apply_articale' => $apply_articale,
  1678. 'chat' => $chat,
  1679. 'chat_group' => $chat_group,
  1680. 'count' => $count,
  1681. ];
  1682. } elseif ($type_id == 20000) {
  1683. }
  1684. var_dump($type_id, '-----------------test---------');
  1685. return Result::success($result);
  1686. }
  1687. public function getComplaintList(array $data): array
  1688. {
  1689. $result = Notice::where('status', 1)->get();
  1690. return Result::success($result);
  1691. }
  1692. public function getComplaintInfo(array $data): array
  1693. {
  1694. $result = Notice::where('id', $data['id'])->first();
  1695. if (empty($result)) {
  1696. return Result::error("查询失败", 0);
  1697. }
  1698. return Result::success($result);
  1699. }
  1700. public function addComplaint(array $data): array
  1701. {
  1702. $result = Notice::create($data);
  1703. return Result::success($result);
  1704. }
  1705. public function updateComplaint(array $data): array
  1706. {
  1707. $result = Notice::where('id', $data['id'])->update($data);
  1708. return Result::success($result);
  1709. }
  1710. public function deleteComplaint(array $data): array
  1711. {
  1712. $result = Notice::where('id', $data['id'])->delete();
  1713. return Result::success($result);
  1714. }
  1715. public function getComplainInfo(array $data): array
  1716. {
  1717. $result = Notice::where('id', $data['id'])->first();
  1718. if (empty($result)) {
  1719. return Result::error("查询失败", 0);
  1720. }
  1721. return Result::success($result);
  1722. }
  1723. //20250324 通知,公告,消息
  1724. }