LiuJ 1 week ago
parent
commit
2fa4be5655
1 changed files with 84 additions and 51 deletions
  1. 84 51
      app/JsonRpc/NewsService.php

+ 84 - 51
app/JsonRpc/NewsService.php

@@ -715,7 +715,7 @@ class NewsService implements NewsServiceInterface
                             if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                                 $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                                 if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
-                                    $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
+                                    $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin . '/' . $category->aLIas_pinyin : null;
                                 }
                             } else {
                                 $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
@@ -723,9 +723,9 @@ class NewsService implements NewsServiceInterface
                             $article->pinyin = $pinyin;
                             return $article;
                         });
-                        if (empty($result)) {
-                            return Result::success([]);
-                        }
+                    if (empty($result)) {
+                        return Result::success([]);
+                    }
                     return Result::success($result);
                 } else {
                     return Result::error("参数错误level=7,id不能为空", 0);
@@ -768,7 +768,7 @@ class NewsService implements NewsServiceInterface
                     if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                         $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                         if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
-                            $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
+                            $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin . '/' . $category->aLIas_pinyin : null;
                         }
                     } else {
                         $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
@@ -2153,11 +2153,17 @@ class NewsService implements NewsServiceInterface
                 ->where('talk_type', 2)
                 ->orderBy('created_at', 'desc')
                 ->limit(5)->get();
-            $count = count($chat) + count($chat_group) + count($apply_articale);
+            //获取5条用户的已审核商品
+            $good = Good::where('status', 2)
+                ->where('user_id', $user_id)
+                ->orderBy('updated_at', 'desc')
+                ->limit(5)->get();
+            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
             $result = [
                 'apply_articale' => $apply_articale,
                 'chat' => $chat,
                 'chat_group' => $chat_group,
+                'good' => $good,
                 'count' => $count,
             ];
         } elseif ($type_id == 2) {
@@ -2177,11 +2183,17 @@ class NewsService implements NewsServiceInterface
                 ->where('talk_type', 2)
                 ->orderBy('created_at', 'desc')
                 ->limit(5)->get();
-            $count = count($chat) + count($chat_group) + count($apply_articale);
+            //获取5条用户的已审核商品
+            $good = Good::where('status', 2)
+                ->where('user_id', $user_id)
+                ->orderBy('updated_at', 'desc')
+                ->limit(5)->get();
+            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
             $result = [
                 'apply_articale' => $apply_articale,
                 'chat' => $chat,
                 'chat_group' => $chat_group,
+                'good' => $good,
                 'count' => $count,
             ];
         } elseif ($type_id == 3) {
@@ -2201,11 +2213,17 @@ class NewsService implements NewsServiceInterface
                 ->where('talk_type', 2)
                 ->orderBy('created_at', 'desc')
                 ->limit(5)->get();
-            $count = count($chat) + count($chat_group) + count($apply_articale);
+            //获取5条用户的已审核商品
+            $good = Good::where('status', 2)
+                ->where('user_id', $user_id)
+                ->orderBy('updated_at', 'desc')
+                ->limit(5)->get();
+            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
             $result = [
                 'apply_articale' => $apply_articale,
                 'chat' => $chat,
                 'chat_group' => $chat_group,
+                'good' => $good,
                 'count' => $count,
             ];
         } elseif ($type_id == 4) {
@@ -2214,9 +2232,17 @@ class NewsService implements NewsServiceInterface
                 ->where('admin_user_id', $user_id)
                 ->limit(5)->get();
 
-            $count = count($apply_articale);
+            //获取5条用户的已审核商品
+            $good = Good::where('status', 2)
+                ->where('user_id', $user_id)
+                ->orderBy('updated_at', 'desc')
+                ->limit(5)->get();
+            $count =  count($apply_articale) + count($good);
             $result = [
                 'apply_articale' => $apply_articale,
+                'chat' => '',
+                'chat_group' => '',
+                'good' => $good,
                 'count' => $count,
             ];
         } elseif ($type_id == 10000) {
@@ -2236,11 +2262,17 @@ class NewsService implements NewsServiceInterface
                 ->where('talk_type', 2)
                 ->orderBy('created_at', 'desc')
                 ->limit(5)->get();
-            $count = count($chat) + count($chat_group) + count($apply_articale);
+            //获取5条用户的已审核商品
+            $good = Good::where('status', 1)
+                // ->where('user_id', $user_id)
+                ->orderBy('updated_at', 'desc')
+                ->limit(5)->get();
+            $count = count($chat) + count($chat_group) + count($apply_articale) + count($good);
             $result = [
                 'apply_articale' => $apply_articale,
                 'chat' => $chat,
                 'chat_group' => $chat_group,
+                'good' => $good,
                 'count' => $count,
             ];
         } elseif ($type_id == 20000) {
@@ -2357,22 +2389,24 @@ class NewsService implements NewsServiceInterface
     {
         // return Result::success($data);
         $user = User::where('user.id', $data['user_id'])
-        ->where('user.status',1)
-        ->leftJoin('user_info', 'user_info.user_id', 'user.id')
-        ->select(
-            'user.type_id', 'user.mobile','user.email',
-            'user_info.business_name',
-            'user_info.company_hy_id',
-            'user_info.company_nature',
-            'user_info.company_size',
-            'user_info.introduction',
-            'user_info.real_name',
-            'user_info.company_url',
-            'user_info.address_arr_id',
-            'user_info.address'
-        )
-        ->first();
-        if(empty($user) || $user['type_id'] != $data['user_type']){
+            ->where('user.status', 1)
+            ->leftJoin('user_info', 'user_info.user_id', 'user.id')
+            ->select(
+                'user.type_id',
+                'user.mobile',
+                'user.email',
+                'user_info.business_name',
+                'user_info.company_hy_id',
+                'user_info.company_nature',
+                'user_info.company_size',
+                'user_info.introduction',
+                'user_info.real_name',
+                'user_info.company_url',
+                'user_info.address_arr_id',
+                'user_info.address'
+            )
+            ->first();
+        if (empty($user) || $user['type_id'] != $data['user_type']) {
             return Result::error("用户不存在", 0);
         }
         $web = Website::where('id', $data['website_id'])->first();
@@ -2430,20 +2464,20 @@ class NewsService implements NewsServiceInterface
             } else {
                 // 企业会员添加企业信息
                 $company = [
-                    'user_id' => $data['user_id']?? null,
-                    'business_name' => $user['business_name']?? null,
-                    'company_hy_id' => $user['company_hy_id']?? null,
-                    'company_size' => $user['company_size']?? null,
-                    'company_nature' => $user['company_nature']?? null,
-                    'introduction' => $user['introduction']?? null,
-                    'real_name' => $user['real_name']?? null,
-                    'mobile' => $user['mobile']?? null,
-                    'company_url' => $user['company_url']?? null,
-                    'address_arr_id' => $user['address_arr_id']?? null,
-                    'address' => $user['address']?? null,
-                    'email' => $user['email']?? null,
-                    'website_id' => $data['website_id']?? null,
-                    'user_type' => $user['type_id']?? null,
+                    'user_id' => $data['user_id'] ?? null,
+                    'business_name' => $user['business_name'] ?? null,
+                    'company_hy_id' => $user['company_hy_id'] ?? null,
+                    'company_size' => $user['company_size'] ?? null,
+                    'company_nature' => $user['company_nature'] ?? null,
+                    'introduction' => $user['introduction'] ?? null,
+                    'real_name' => $user['real_name'] ?? null,
+                    'mobile' => $user['mobile'] ?? null,
+                    'company_url' => $user['company_url'] ?? null,
+                    'address_arr_id' => $user['address_arr_id'] ?? null,
+                    'address' => $user['address'] ?? null,
+                    'email' => $user['email'] ?? null,
+                    'website_id' => $data['website_id'] ?? null,
+                    'user_type' => $user['type_id'] ?? null,
                     'job_id' => $jobId,
                 ];
                 $companyId = JobCompany::insertGetId($company);
@@ -2616,9 +2650,9 @@ class NewsService implements NewsServiceInterface
     public function getJobCompany(array $data): array
     {
         $user = User::where('user.id', $data['user_id'])
-        ->leftJoin('user_info', 'user_info.user_id', 'user.id')
-        ->select('user.user_name','user.mobile','user.email','user.type_id','user_info.*')
-        ->first();
+            ->leftJoin('user_info', 'user_info.user_id', 'user.id')
+            ->select('user.user_name', 'user.mobile', 'user.email', 'user.type_id', 'user_info.*')
+            ->first();
         // return Result::success($user);
         if (empty($user)) {
             return Result::error("用户不存在", 0);
@@ -2655,10 +2689,10 @@ class NewsService implements NewsServiceInterface
     {
         // return Result::success($data);
         $user = User::where('user.id', $data['user_id'])
-        ->where('user.status',1)
-        ->select('user.user_name','user.type_id')
-        ->first();
-        if(empty($user)){
+            ->where('user.status', 1)
+            ->select('user.user_name', 'user.type_id')
+            ->first();
+        if (empty($user)) {
             return Result::error("用户不存在", 0);
         }
         $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
@@ -2673,7 +2707,7 @@ class NewsService implements NewsServiceInterface
             'address_arr_id' => $data['address_arr_id'],     // 企业地址
             'address' => $data['address'],                   // 企业详细地址
         ];
-        if($user['type_id'] == 3){
+        if ($user['type_id'] == 3) {
             Db::beginTransaction();
             try {
                 $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
@@ -2691,10 +2725,9 @@ class NewsService implements NewsServiceInterface
                 Db::commit();
             } catch (\Exception $e) {
                 Db::rollBack();
-                return Result::error($e->getMessage(), 0); 
+                return Result::error($e->getMessage(), 0);
             }
-           
-        }else{
+        } else {
             return Result::error("用户类型错误", 0);
         }
         if (empty($result)) {