作者 李宇航

合并分支 'develop' 到 'master'

gx



查看合并请求 !499
@@ -138,6 +138,7 @@ class OptimizeController extends BaseController @@ -138,6 +138,7 @@ class OptimizeController extends BaseController
138 } 138 }
139 $item['product_num'] = $data['product'] ?? 0; 139 $item['product_num'] = $data['product'] ?? 0;
140 $item['keyword_num'] = $item['key'] ?? 0; 140 $item['keyword_num'] = $item['key'] ?? 0;
  141 + $item['inquiry_num'] = $data['inquiry'] ?? 0;
141 $item['autologin_code'] = getAutoLoginCode($item['id']); 142 $item['autologin_code'] = getAutoLoginCode($item['id']);
142 return $item; 143 return $item;
143 } 144 }
@@ -10,9 +10,11 @@ @@ -10,9 +10,11 @@
10 namespace App\Models\ASide; 10 namespace App\Models\ASide;
11 11
12 use App\Helper\AyrShare as AyrShareHelper; 12 use App\Helper\AyrShare as AyrShareHelper;
  13 +use App\Helper\FormGlobalsoApi;
13 use App\Models\AyrShare\AyrShare as AyrShareModel; 14 use App\Models\AyrShare\AyrShare as AyrShareModel;
14 use App\Models\Base; 15 use App\Models\Base;
15 use App\Services\ProjectServer; 16 use App\Services\ProjectServer;
  17 +use Illuminate\Support\Facades\Cache;
16 use Illuminate\Support\Facades\DB; 18 use Illuminate\Support\Facades\DB;
17 19
18 class APublicModel extends Base 20 class APublicModel extends Base
@@ -30,16 +32,28 @@ class APublicModel extends Base @@ -30,16 +32,28 @@ class APublicModel extends Base
30 */ 32 */
31 public static function getNumByProjectId($project_id){ 33 public static function getNumByProjectId($project_id){
32 ProjectServer::useProject($project_id); 34 ProjectServer::useProject($project_id);
33 - $productNumber = DB::connection('custom_mysql')->table('gl_product')  
34 - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();  
35 - $blogNumber = DB::connection('custom_mysql')->table('gl_blog')  
36 - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();  
37 - $newsNumber = DB::connection('custom_mysql')->table('gl_news')  
38 - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();  
39 - $keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword')  
40 - ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); 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')
  48 + ->first()->toArray();
  49 + if(!empty($countInfo)){
  50 + $inquiryNumber = $countInfo['inquiry_num'];
  51 + }
  52 + $data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber];
  53 + Cache::add('product_blog_news_'.$project_id,$data,30 * 60);
  54 + }
41 DB::disconnect('custom_mysql'); 55 DB::disconnect('custom_mysql');
42 - return ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber]; 56 + return $data;
43 } 57 }
44 58
45 } 59 }