正在显示
1 个修改的文件
包含
21 行增加
和
17 行删除
| @@ -32,24 +32,28 @@ class APublicModel extends Base | @@ -32,24 +32,28 @@ class APublicModel extends Base | ||
| 32 | */ | 32 | */ |
| 33 | public static function getNumByProjectId($project_id){ | 33 | public static function getNumByProjectId($project_id){ |
| 34 | ProjectServer::useProject($project_id); | 34 | ProjectServer::useProject($project_id); |
| 35 | - $data = Cache::get('product_blog_news_'.$project_id); | ||
| 36 | - if(!$data){ | ||
| 37 | - $productNumber = DB::connection('custom_mysql')->table('gl_product') | ||
| 38 | - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 39 | - $blogNumber = DB::connection('custom_mysql')->table('gl_blog') | ||
| 40 | - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 41 | - $newsNumber = DB::connection('custom_mysql')->table('gl_news') | ||
| 42 | - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 43 | - $keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword') | ||
| 44 | - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 45 | - //获取项目的询盘数量 | ||
| 46 | - $inquiryNumber = 0; | ||
| 47 | - $countInfo = DB::table('gl_count')->where('project_id', $project_id)->orderBy('id', 'desc')->first(); | ||
| 48 | - if(!empty($countInfo)){ | ||
| 49 | - $inquiryNumber = $countInfo->inquiry_num ?? 0; | 35 | + try { |
| 36 | + $data = Cache::get('product_blog_news_'.$project_id); | ||
| 37 | + if(!$data){ | ||
| 38 | + $productNumber = DB::connection('custom_mysql')->table('gl_product') | ||
| 39 | + ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 40 | + $blogNumber = DB::connection('custom_mysql')->table('gl_blog') | ||
| 41 | + ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 42 | + $newsNumber = DB::connection('custom_mysql')->table('gl_news') | ||
| 43 | + ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 44 | + $keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword') | ||
| 45 | + ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 46 | + //获取项目的询盘数量 | ||
| 47 | + $inquiryNumber = 0; | ||
| 48 | + $countInfo = DB::table('gl_count')->where('project_id', $project_id)->orderBy('id', 'desc')->first(); | ||
| 49 | + if(!empty($countInfo)){ | ||
| 50 | + $inquiryNumber = $countInfo->inquiry_num ?? 0; | ||
| 51 | + } | ||
| 52 | + $data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber]; | ||
| 53 | + Cache::add('product_blog_news_'.$project_id,$data,30 * 60); | ||
| 50 | } | 54 | } |
| 51 | - $data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber]; | ||
| 52 | - Cache::add('product_blog_news_'.$project_id,$data,30 * 60); | 55 | + }catch (\Exception $e){ |
| 56 | + return []; | ||
| 53 | } | 57 | } |
| 54 | DB::disconnect('custom_mysql'); | 58 | DB::disconnect('custom_mysql'); |
| 55 | return $data; | 59 | return $data; |
-
请 注册 或 登录 后发表评论