|
...
|
...
|
@@ -32,24 +32,28 @@ class APublicModel extends Base |
|
|
|
*/
|
|
|
|
public static function getNumByProjectId($project_id){
|
|
|
|
ProjectServer::useProject($project_id);
|
|
|
|
$data = Cache::get('product_blog_news_'.$project_id);
|
|
|
|
if(!$data){
|
|
|
|
$productNumber = DB::connection('custom_mysql')->table('gl_product')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
$blogNumber = DB::connection('custom_mysql')->table('gl_blog')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
$newsNumber = DB::connection('custom_mysql')->table('gl_news')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
$keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
//获取项目的询盘数量
|
|
|
|
$inquiryNumber = 0;
|
|
|
|
$countInfo = DB::table('gl_count')->where('project_id', $project_id)->orderBy('id', 'desc')->first();
|
|
|
|
if(!empty($countInfo)){
|
|
|
|
$inquiryNumber = $countInfo->inquiry_num ?? 0;
|
|
|
|
try {
|
|
|
|
$data = Cache::get('product_blog_news_'.$project_id);
|
|
|
|
if(!$data){
|
|
|
|
$productNumber = DB::connection('custom_mysql')->table('gl_product')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
$blogNumber = DB::connection('custom_mysql')->table('gl_blog')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
$newsNumber = DB::connection('custom_mysql')->table('gl_news')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
$keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword')
|
|
|
|
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
|
|
|
|
//获取项目的询盘数量
|
|
|
|
$inquiryNumber = 0;
|
|
|
|
$countInfo = DB::table('gl_count')->where('project_id', $project_id)->orderBy('id', 'desc')->first();
|
|
|
|
if(!empty($countInfo)){
|
|
|
|
$inquiryNumber = $countInfo->inquiry_num ?? 0;
|
|
|
|
}
|
|
|
|
$data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber];
|
|
|
|
Cache::add('product_blog_news_'.$project_id,$data,30 * 60);
|
|
|
|
}
|
|
|
|
$data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber];
|
|
|
|
Cache::add('product_blog_news_'.$project_id,$data,30 * 60);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
return $data;
|
...
|
...
|
|