瀏覽代碼

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/news_producer

LiuJ 1 周之前
父節點
當前提交
52d745f219
共有 2 個文件被更改,包括 111 次插入94 次删除
  1. 76 73
      app/JsonRpc/NewsService.php
  2. 35 21
      config/autoload/logger.php

+ 76 - 73
app/JsonRpc/NewsService.php

@@ -681,6 +681,7 @@ class NewsService implements NewsServiceInterface
      */
      */
     public function getWebsiteArticlett(array $data): array
     public function getWebsiteArticlett(array $data): array
     {
     {
+        // return Result::success($data['website_id']);
         $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
         $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
         $category = array_values(array_unique($category->toArray()));
         $category = array_values(array_unique($category->toArray()));
         $result = [];
         $result = [];
@@ -711,17 +712,20 @@ class NewsService implements NewsServiceInterface
                             $catid = $article->catid;
                             $catid = $article->catid;
                             $pinyin = '';
                             $pinyin = '';
                             $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
                             $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
-                            $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
-                            if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
+                            if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                                 $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                                 $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
-                                $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin . '/' . $category->aLIas_pinyin : null;
+                                if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
+                                    $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
+                                }
+                            } else {
+                                $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
                             }
                             }
                             $article->pinyin = $pinyin;
                             $article->pinyin = $pinyin;
                             return $article;
                             return $article;
                         });
                         });
-                    if (empty($result)) {
-                        return Result::success([]);
-                    }
+                        if (empty($result)) {
+                            return Result::success([]);
+                        }
                     return Result::success($result);
                     return Result::success($result);
                 } else {
                 } else {
                     return Result::error("参数错误level=7,id不能为空", 0);
                     return Result::error("参数错误level=7,id不能为空", 0);
@@ -760,17 +764,15 @@ class NewsService implements NewsServiceInterface
                 ->map(function ($article) use ($data) {
                 ->map(function ($article) use ($data) {
                     $catid = $article->catid;
                     $catid = $article->catid;
                     $pinyin = '';
                     $pinyin = '';
-                    // $category = WebsiteCategory::whereIn('category_id', $catArrId)->where('website_category.website_id', $data['website_id'])->get()->all();
-                    // if ($catArrId) {
-                    // foreach ($catArrId as $categoryId) {
                     $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
                     $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
-                    $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
-                    if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
+                    if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
                         $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
                         $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
-                        $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin . '/' . $category->aLIas_pinyin : null;
+                        if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
+                            $pinyin = $childCategory->aLIas_pinyin ?  $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
+                        }
+                    } else {
+                        $pinyin = $category->aLIas_pinyin ?  $category->aLIas_pinyin : null;
                     }
                     }
-                    // }
-                    // }
                     $article->pinyin = $pinyin;
                     $article->pinyin = $pinyin;
                     return $article;
                     return $article;
                 });
                 });
@@ -2355,24 +2357,22 @@ class NewsService implements NewsServiceInterface
     {
     {
         // return Result::success($data);
         // return Result::success($data);
         $user = User::where('user.id', $data['user_id'])
         $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.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);
             return Result::error("用户不存在", 0);
         }
         }
         $web = Website::where('id', $data['website_id'])->first();
         $web = Website::where('id', $data['website_id'])->first();
@@ -2430,20 +2430,20 @@ class NewsService implements NewsServiceInterface
             } else {
             } else {
                 // 企业会员添加企业信息
                 // 企业会员添加企业信息
                 $company = [
                 $company = [
-                    'user_id' => $data['user_id'] ?? null,
-                    'business_name' => $user['business_name'] ?? null,
-                    'company_hy_id' => $user['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,
                     'job_id' => $jobId,
                 ];
                 ];
                 $companyId = JobCompany::insertGetId($company);
                 $companyId = JobCompany::insertGetId($company);
@@ -2616,9 +2616,9 @@ class NewsService implements NewsServiceInterface
     public function getJobCompany(array $data): array
     public function getJobCompany(array $data): array
     {
     {
         $user = User::where('user.id', $data['user_id'])
         $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);
         // return Result::success($user);
         if (empty($user)) {
         if (empty($user)) {
             return Result::error("用户不存在", 0);
             return Result::error("用户不存在", 0);
@@ -2655,11 +2655,10 @@ class NewsService implements NewsServiceInterface
     {
     {
         // return Result::success($data);
         // return Result::success($data);
         $user = User::where('user.id', $data['user_id'])
         $user = User::where('user.id', $data['user_id'])
-            ->where('user.status', 1)
-            ->leftJoin('user_info', 'user_info.user_id', 'user.id')
-            ->select('user.user_name', 'user.type_id', 'user_info.*')
-            ->first();
-        if (empty($user)) {
+        ->where('user.status',1)
+        ->select('user.user_name','user.type_id')
+        ->first();
+        if(empty($user)){
             return Result::error("用户不存在", 0);
             return Result::error("用户不存在", 0);
         }
         }
         $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
         $data['address_arr_id'] = isset($data['address_arr_id']) ? json_encode(array_map('intval', $data['address_arr_id'])) : '';
@@ -2669,29 +2668,33 @@ class NewsService implements NewsServiceInterface
             'company_nature' => $data['company_nature'],     // 公司性质
             'company_nature' => $data['company_nature'],     // 公司性质
             'company_size' => $data['company_size'],         // 公司规模
             'company_size' => $data['company_size'],         // 公司规模
             'introduction' => $data['introduction'],         // 公司简介
             'introduction' => $data['introduction'],         // 公司简介
-            'real_name' => $data['real_name'],               // 企业联系人
+            // 'real_name' => $data['real_name'],               // 企业联系人
             'company_url' => $data['company_url'],           // 企业网址
             'company_url' => $data['company_url'],           // 企业网址
             'address_arr_id' => $data['address_arr_id'],     // 企业地址
             'address_arr_id' => $data['address_arr_id'],     // 企业地址
             'address' => $data['address'],                   // 企业详细地址
             'address' => $data['address'],                   // 企业详细地址
         ];
         ];
-        if ($user['type_id'] == 3) {
-            $result['user'] = User::where('user.id', $data['user_id'])->update([
-                'mobile' => $data['mobile'],                     // 企业联系电话
-                'email' => $data['email'],                       // 企业邮箱
-            ]);
-            $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
-                'business_name' => $data['business_name'],       // 企业名称
-                'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
-                'company_nature' => $data['company_nature'],     // 公司性质
-                'company_size' => $data['company_size'],         // 公司规模
-                'introduction' => $data['introduction'],         // 公司简介
-                'real_name' => $data['real_name'],               // 企业联系人
-                'company_url' => $data['company_url'],           // 企业网址
-                'address_arr_id' => $data['address_arr_id'],     // 企业地址
-                'address' => $data['address'],                   // 企业详细地址
-            ]);
-            $result = JobCompany::where('user_id', $data['user_id'])->update($company);
-        } else {
+        if($user['type_id'] == 3){
+            Db::beginTransaction();
+            try {
+                $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
+                    'business_name' => $data['business_name'],       // 企业名称
+                    'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
+                    'company_nature' => $data['company_nature'],     // 公司性质
+                    'company_size' => $data['company_size'],         // 公司规模
+                    'introduction' => $data['introduction'],         // 公司简介
+                    // 'real_name' => $data['real_name'],               // 企业联系人
+                    'company_url' => $data['company_url'],           // 企业网址
+                    'address_arr_id' => $data['address_arr_id'],     // 企业地址
+                    'address' => $data['address'],                   // 企业详细地址
+                ]);
+                $result['job_company'] = JobCompany::where('user_id', $data['user_id'])->update($company);
+                Db::commit();
+            } catch (\Exception $e) {
+                Db::rollBack();
+                return Result::error($e->getMessage(), 0); 
+            }
+           
+        }else{
             return Result::error("用户类型错误", 0);
             return Result::error("用户类型错误", 0);
         }
         }
         if (empty($result)) {
         if (empty($result)) {

+ 35 - 21
config/autoload/logger.php

@@ -1,21 +1,35 @@
-<?php
-
-return [
-    'default' => [
-        'handler' => [
-            'class' => \Monolog\Handler\StreamHandler::class,
-            'constructor' => [
-                'stream' => BASE_PATH . '/runtime/logs/hyperf.log',
-                'level' => \Monolog\Logger::DEBUG,
-            ],
-        ],
-        'formatter' => [
-            'class' => \Monolog\Formatter\LineFormatter::class,
-            'constructor' => [
-                'format' => null,
-                'dateFormat' => null,
-                'allowInlineLineBreaks' => true,
-            ]
-        ],
-    ],
-];
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://hyperf.wiki
+ * @contact  group@hyperf.io
+ * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
+ */
+return [
+    'default' => [
+        'handler' => [
+            'class' => Monolog\Handler\RotatingFileHandler::class,
+            'constructor' => [
+                'filename' => BASE_PATH . '/runtime/logs/hyperf.log',
+                'maxFiles' => 30, // 保留最近30天的日志文件
+                'level' => Monolog\Logger::DEBUG,
+                'bubble' => true,
+                'filePermission' => null,
+                'useLocking' => false,
+                'dateFormat' => 'Y-m-d', // 按天分割日志文件
+            ],
+        ],
+        'formatter' => [
+            'class' => Monolog\Formatter\LineFormatter::class,
+            'constructor' => [
+                'format' => null,
+                'dateFormat' => 'Y-m-d H:i:s',
+                'allowInlineLineBreaks' => true,
+            ],
+        ],
+    ],
+];