LiuJ 3 days ago
parent
commit
7ecf89a73c
1 changed files with 127 additions and 125 deletions
  1. 127 125
      app/JsonRpc/NewsService.php

+ 127 - 125
app/JsonRpc/NewsService.php

@@ -65,13 +65,14 @@ use Illuminate\Support\Facades\Cache;
 
 use App\Model\Company;
 use Hyperf\Paginator\Paginator;
-use App\Model\Project;    
+use App\Model\Project;
 
 use Hyperf\Context\Context;
 use Hyperf\Context\ApplicationContext as ContextApplicationContext;
 use Hyperf\Amqp\Producer;
 
 use App\Amqp\Producer\MqProducer;
+
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class NewsService implements NewsServiceInterface
 {
@@ -496,12 +497,12 @@ class NewsService implements NewsServiceInterface
         // 截取 100 个字符
         $articleData['introduce'] = mb_substr($content, 0, 100);
       }
-      if($articleData['status']==0){
+      if ($articleData['status'] == 0) {
         $this->sendMessage([
-          'talk_type'=>100,
-          'title'=>$articleData['title'],
-          'content'=>'提交了审核',
-          'messageType'=>2,
+          'talk_type' => 100,
+          'title' => $articleData['title'],
+          'content' => '提交了审核',
+          'messageType' => 2,
         ]);
       }
       $id = Article::insertGetId($articleData);
@@ -686,12 +687,13 @@ class NewsService implements NewsServiceInterface
         // 截取 100 个字符
         $articleData['introduce'] = mb_substr($content, 0, 100);
       }
-      if($articleData['status']==0){
+      if ($articleData['status'] == 0) {
         $this->sendMessage([
-          'talk_type'=>100,
-          'title'=>$articleData['title'],
-          'content'=>'提交了审核',
-          'messageType'=>2,]);
+          'talk_type' => 100,
+          'title' => $articleData['title'],
+          'content' => '提交了审核',
+          'messageType' => 2,
+        ]);
       }
       $id = Article::where(['id' => $data['id']])->update($articleData);
       $articleDataContent = [
@@ -772,22 +774,22 @@ class NewsService implements NewsServiceInterface
   public function upArticleStatus(array $data): array
   {
     $articleData = Article::where(['id' => $data['id']])->first();
-    if($data['status']==1){
+    if ($data['status'] == 1) {
       $this->sendMessage([
-        'talk_type'=>101,
-        'title'=>$articleData['title'],
-        'content'=>'审核通过',
-        'messageType'=>2,
-        'user_id'=>$articleData['admin_user_id'],
+        'talk_type' => 101,
+        'title' => $articleData['title'],
+        'content' => '审核通过',
+        'messageType' => 2,
+        'user_id' => $articleData['admin_user_id'],
       ]);
     }
-    if($data['status']==2){
+    if ($data['status'] == 2) {
       $this->sendMessage([
-        'talk_type'=>101,
-        'title'=>$articleData['title'],
-        'content'=>'审核拒绝',
-        'messageType'=>2,
-        'user_id'=>$articleData['admin_user_id'],
+        'talk_type' => 101,
+        'title' => $articleData['title'],
+        'content' => '审核拒绝',
+        'messageType' => 2,
+        'user_id' => $articleData['admin_user_id'],
       ]);
     }
 
@@ -3661,12 +3663,12 @@ class NewsService implements NewsServiceInterface
       $data['description'] = mb_substr($cleaned, 0, 100, 'UTF-8');
       // $data['description'] = substr(preg_replace('/\s+/', '', strip_tags($data['detail'])), 0, 100);
     }
-    if($data['status']==1){
+    if ($data['status'] == 1) {
       $this->sendMessage([
-        'talk_type'=>200,
-        'title'=>$data['name'],
-        'content'=>'提交了审核',
-        'messageType'=>3,
+        'talk_type' => 200,
+        'title' => $data['name'],
+        'content' => '提交了审核',
+        'messageType' => 3,
       ]);
     }
 
@@ -3714,12 +3716,12 @@ class NewsService implements NewsServiceInterface
       $cleaned = preg_replace('/\s+/', '', strip_tags(html_entity_decode($data['detail'], ENT_QUOTES, 'UTF-8')));
       $data['description'] = mb_substr($cleaned, 0, 100, 'UTF-8');
     }
-    if($data['status']==1){
+    if ($data['status'] == 1) {
       $this->sendMessage([
-        'talk_type'=>200,
-        'title'=>$data['name'],
-        'content'=>'提交了审核',
-        'messageType'=>3,
+        'talk_type' => 200,
+        'title' => $data['name'],
+        'content' => '提交了审核',
+        'messageType' => 3,
       ]);
     }
 
@@ -4007,10 +4009,10 @@ class NewsService implements NewsServiceInterface
     $user_id = json_encode($user_id);
     $data['re_user_ids'] = $user_id;
     $this->sendMessage([
-      'talk_type'=>700,
-      'title'=>$data['title'],
-      'content'=>'提交了审核',
-      'messageType'=>5,
+      'talk_type' => 700,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 5,
     ]);
     $result = Notice::insertGetId($data);
 
@@ -4043,10 +4045,10 @@ class NewsService implements NewsServiceInterface
     $data['re_user_ids'] = $user_id;
     $data['updated_at'] = date('Y-m-d H:i:s');
     $this->sendMessage([
-      'talk_type'=>700,
-      'title'=>$data['title'],
-      'content'=>'提交了审核',
-      'messageType'=>5,
+      'talk_type' => 700,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 5,
     ]);
     $result = Notice::where('id', $data['id'])->update($data);
     return Result::success($result);
@@ -4242,10 +4244,10 @@ class NewsService implements NewsServiceInterface
     $data['created_at'] = date('Y-m-d H:i:s');
     $data['updated_at'] = date('Y-m-d H:i:s');
     $this->sendMessage([
-      'talk_type'=>800,
-      'title'=>$data['title'],
-      'content'=>'提交了审核',
-      'messageType'=>6,
+      'talk_type' => 800,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 6,
     ]);
     $result = Complaint::create($data);
     return Result::success($result);
@@ -4260,10 +4262,10 @@ class NewsService implements NewsServiceInterface
     unset($data['user_id']);
     unset($data['type_id']);
     $this->sendMessage([
-      'talk_type'=>800,
-      'title'=>$data['title'],
-      'content'=>'提交了审核',
-      'messageType'=>6,
+      'talk_type' => 800,
+      'title' => $data['title'],
+      'content' => '提交了审核',
+      'messageType' => 6,
     ]);
     $result = Complaint::where('id', $data['id'])->update($data);
     return Result::success($result);
@@ -4304,56 +4306,56 @@ class NewsService implements NewsServiceInterface
       }
     }
     $complaintInfo = Complaint::where('id', $data['id'])->first();
-    if($data['status']==2 && !isset($data['deal'])){
+    if ($data['status'] == 2 && !isset($data['deal'])) {
       $this->sendMessage([
-        'talk_type'=>801,
-        'title'=>$complaintInfo['title'],
-        'content'=>'审核通过',
-        'messageType'=>6,
-        'user_id'=>$complaintInfo['user_id'],
+        'talk_type' => 801,
+        'title' => $complaintInfo['title'],
+        'content' => '审核通过',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['user_id'],
       ]);
       $this->sendMessage([
-        'talk_type'=>802,
-        'title'=>$complaintInfo['title'],
-        'content'=>'待处理',
-        'messageType'=>6,
-        'user_id'=>$complaintInfo['re_user_ids'],
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '待处理',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
       ]);
     }
-    if($data['status']==3 && !isset($data['deal'])){
+    if ($data['status'] == 3 && !isset($data['deal'])) {
       $this->sendMessage([
-        'talk_type'=>801,
-        'title'=>$complaintInfo['title'],
-        'content'=>'审核拒绝',
-        'messageType'=>6,
-        'user_id'=>$complaintInfo['user_id'],
+        'talk_type' => 801,
+        'title' => $complaintInfo['title'],
+        'content' => '审核拒绝',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['user_id'],
       ]);
     }
-    if($data['status']==2 && isset($data['deal']) && $data['deal']==2){
+    if ($data['status'] == 2 && isset($data['deal']) && $data['deal'] == 2) {
       $this->sendMessage([
-        'talk_type'=>802,
-        'title'=>$complaintInfo['title'],
-        'content'=>'处理中',
-        'messageType'=>6,
-        'user_id'=>$complaintInfo['re_user_ids'],
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '处理中',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
       ]);
     }
-    if($data['status']==2 && isset($data['deal']) && $data['deal']==4){
+    if ($data['status'] == 2 && isset($data['deal']) && $data['deal'] == 4) {
       $this->sendMessage([
-        'talk_type'=>802,
-        'title'=>$complaintInfo['title'],
-        'content'=>'不予处理',
-        'messageType'=>6,
-        'user_id'=>$complaintInfo['re_user_ids'],
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '不予处理',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
       ]);
     }
-    if($data['status']==2 && isset($data['deal']) && $data['deal']==3){
+    if ($data['status'] == 2 && isset($data['deal']) && $data['deal'] == 3) {
       $this->sendMessage([
-        'talk_type'=>802,
-        'title'=>$complaintInfo['title'],
-        'content'=>'已完结',
-        'messageType'=>6,
-        'user_id'=>$complaintInfo['re_user_ids'],
+        'talk_type' => 802,
+        'title' => $complaintInfo['title'],
+        'content' => '已完结',
+        'messageType' => 6,
+        'user_id' => $complaintInfo['re_user_ids'],
       ]);
     }
     $result = complaint::where('id', $data['id'])->update($data);
@@ -4366,22 +4368,22 @@ class NewsService implements NewsServiceInterface
     unset($data['user_id']);
     unset($data['type_id']);
     $goodInfo = Good::where('id', $data['id'])->first();
-    if($data['status']==2){
+    if ($data['status'] == 2) {
       $this->sendMessage([
-        'talk_type'=>201,
-        'title'=>$goodInfo['name'],
-        'content'=>'审核通过',
-        'messageType'=>3,
-        'user_id'=>$goodInfo['user_id'],
+        'talk_type' => 201,
+        'title' => $goodInfo['name'],
+        'content' => '审核通过',
+        'messageType' => 3,
+        'user_id' => $goodInfo['user_id'],
       ]);
     }
-    if($data['status']==3){
+    if ($data['status'] == 3) {
       $this->sendMessage([
-        'talk_type'=>201,
-        'title'=>$goodInfo['name'],
-        'content'=>'审核拒绝',
-        'messageType'=>3,
-        'user_id'=>$goodInfo['user_id'],
+        'talk_type' => 201,
+        'title' => $goodInfo['name'],
+        'content' => '审核拒绝',
+        'messageType' => 3,
+        'user_id' => $goodInfo['user_id'],
       ]);
     }
     $result = Good::where('id', $data['id'])->update($data);
@@ -4472,22 +4474,22 @@ class NewsService implements NewsServiceInterface
     }
     $result = Notice::where('id', $data['id'])->update($data);
     $noticeInfo = Notice::where('id', $data['id'])->first();
-    if($data['status']==2){
+    if ($data['status'] == 2) {
       $this->sendMessage([
-        'talk_type'=>701,
-        'title'=>$noticeInfo['title'],
-        'content'=>'审核通过',
-        'messageType'=>3,
-        'user_id'=>$noticeInfo['user_id'],
+        'talk_type' => 701,
+        'title' => $noticeInfo['title'],
+        'content' => '审核通过',
+        'messageType' => 3,
+        'user_id' => $noticeInfo['user_id'],
       ]);
     }
-    if($data['status']==3){
+    if ($data['status'] == 3) {
       $this->sendMessage([
-        'talk_type'=>701,
-        'title'=>$noticeInfo['title'],
-        'content'=>'审核拒绝',
-        'messageType'=>3,
-        'user_id'=>$noticeInfo['user_id'],
+        'talk_type' => 701,
+        'title' => $noticeInfo['title'],
+        'content' => '审核拒绝',
+        'messageType' => 3,
+        'user_id' => $noticeInfo['user_id'],
       ]);
     }
     return Result::success($result);
@@ -6633,7 +6635,7 @@ class NewsService implements NewsServiceInterface
         // ->limit(5)
         ->get();
       //获取5条用户的求职 2
-      $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
+      $job_recruiting = JobRecruiting::where('job_recruiting.status', 0)
         ->where('job_recruiting.user_id', $user_id)
         ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
         ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
@@ -7255,21 +7257,21 @@ class NewsService implements NewsServiceInterface
     return Result::success($result);
   }
   /**
-     * 发送消息
-     * @param array $messageData
-     * @return void
-  */
-  public function sendMessage($messageData){
-      $msg =[
-        'talk_type'=>$messageData['talk_type'],
-        'title'=>$messageData['title'],
-        'content'=>$messageData['content'],
-        'messageType'=>$messageData['messageType'],
-        'user_id'=>$messageData['user_id']??'',
-      ];
-      $message = new MqProducer($msg);
-      $producer = ContextApplicationContext::getContainer()->get(Producer::class);
-      $producer->produce($message);
-      
+   * 发送消息
+   * @param array $messageData
+   * @return void
+   */
+  public function sendMessage($messageData)
+  {
+    $msg = [
+      'talk_type' => $messageData['talk_type'],
+      'title' => $messageData['title'],
+      'content' => $messageData['content'],
+      'messageType' => $messageData['messageType'],
+      'user_id' => $messageData['user_id'] ?? '',
+    ];
+    $message = new MqProducer($msg);
+    $producer = ContextApplicationContext::getContainer()->get(Producer::class);
+    $producer->produce($message);
   }
 }