LiuJ 3 dagar sedan
förälder
incheckning
86a9f792b1
1 ändrade filer med 65 tillägg och 11 borttagningar
  1. 65 11
      app/JsonRpc/NewsService.php

+ 65 - 11
app/JsonRpc/NewsService.php

@@ -726,6 +726,23 @@ class NewsService implements NewsServiceInterface
   public function upArticleStatus(array $data): array
   {
     $result = Article::where(['id' => $data['id']])->update($data);
+    if (isset($data['ignore_ids']) && !empty($data['ignore_ids'])) {
+      //article_ignore  表插入数据  db操作
+      //转成数组
+      //删掉数据重新写入
+      DB::table('article_ignore')->where('article_id', $data['id'])->delete();
+
+      $website_ids = is_array($data['ignore_ids']) ? $data['ignore_ids'] : json_decode($data['ignore_ids'], true);
+      $insert_data = [];
+      foreach ($website_ids as $key => $value) {
+        $insert_data[] = [
+          'article_id' => $data['id'],
+          'website_id' => $value,
+        ];
+      }
+      DB::table('article_ignore')->insert($insert_data);
+    }
+
     if ($result) {
       return Result::success();
     } else {
@@ -3188,8 +3205,9 @@ class NewsService implements NewsServiceInterface
 
   public function getGoodList(array $data): array
   {
-    $type_id = isset($data['type_id']) ? $data['type_id'] : '';
-    unset($data['type_id']);
+    var_dump($data, '---------1-2--');
+    $type_id = isset($data['user_type_id']) ? $data['user_type_id'] : '';
+    unset($data['user_type_id']);
     $user_id = isset($data['user_id']) ? $data['user_id'] : '';
     $where = [];
     if ($type_id != '10000') {
@@ -3199,21 +3217,16 @@ class NewsService implements NewsServiceInterface
     }
     //类型
     if (isset($data['type_id']) && $data['type_id']) {
-      $where = [
-        'type_id' => $data['type_id'],
-      ];
+
+      $where['good.type_id'] = $data['type_id'];
     }
     //名称
     if (isset($data['name']) && $data['name']) {
-      $where = [
-        'good.name' => $data['name'],
-      ];
+      $where['good.name'] = $data['name'];
     }
     //status
     if (isset($data['status']) && $data['status'] != '') {
-      $where = [
-        'good.status' => $data['status'],
-      ];
+      $where['good.status'] = $data['status'];
     }
     //status1
     // if (isset($data['status1']) && $data['status1'] == 1) {
@@ -3238,6 +3251,7 @@ class NewsService implements NewsServiceInterface
 
     // $result = Good::where($where)
     // ->orderBy("updated_at", "desc")->paginate($data['pige_size'], ['*'], 'page', $data['page']);
+    var_dump($where, '---------1---');
     $result = Good::where($where)
       ->when(!empty($where1), function ($query) use ($where1) {
         return $query->where($where1);
@@ -3605,6 +3619,26 @@ class NewsService implements NewsServiceInterface
     if (empty($result)) {
       return Result::error("查询失败", 0);
     }
+    //判断$requireData['user_id'] ; 是不是在 re_user_ids 中,如果在,就写入read_id,存成数组的json
+    $re_user_ids = json_decode($result['re_user_ids'], true);
+    if (is_array($re_user_ids) && in_array($data['user_id'], $re_user_ids)) {
+      //如果已经存在,就不再添加
+      if (isset($result['read_id']) && !empty($result['read_id'])) {
+        $read_id = json_decode($result['read_id'], true);
+        if (!is_array($read_id)) {
+          $read_id = [];
+        }
+        if (!in_array($data['user_id'], $read_id)) {
+          $read_id[] = $data['user_id'];
+          $result['read_id'] = json_encode($read_id);
+          Notice::where('id', $data['id'])->update(['read_id' => json_encode($read_id)]);
+        }
+      } else {
+        //如果不存在,就添加
+        // $result['read_id'] = json_encode([$data['user_id']]);
+        // Notice::where('id', $data['id'])->update(['read_id' => json_encode([$data['user_id']])]);
+      }
+    }
     return Result::success($result);
   }
   public function addNotice(array $data): array
@@ -4149,6 +4183,26 @@ class NewsService implements NewsServiceInterface
     if (empty($result)) {
       return Result::error("查询失败", 0);
     }
+    //判断$requireData['user_id'] ; 是不是在 re_user_ids 中,如果在,就写入read_id,存成数组的json
+    $re_user_ids = json_decode($result['re_user_ids'], true);
+    if (is_array($re_user_ids) && in_array($data['user_id'], $re_user_ids)) {
+      //如果已经存在,就不再添加
+      if (isset($result['read_id']) && !empty($result['read_id'])) {
+        $read_id = json_decode($result['read_id'], true);
+        if (!is_array($read_id)) {
+          $read_id = [];
+        }
+        if (!in_array($data['user_id'], $read_id)) {
+          $read_id[] = $data['user_id'];
+          $result['read_id'] = json_encode($read_id);
+          Complaint::where('id', $data['id'])->update(['read_id' => json_encode($read_id)]);
+        }
+      } else {
+        //如果不存在,就添加
+        // $result['read_id'] = json_encode([$data['user_id']]);
+        // Complaint::where('id', $data['id'])->update(['read_id' => json_encode([$data['user_id']])]);
+      }
+    }
     return Result::success($result);
   }
   public function addComplaint(array $data): array