getOne("select cat_sub_id from bjshop_video v where id=$id $where"); if($cat_sub_id){ $arr = explode(',',$cat_sub_id); $cat_id = $arr[0]; } } if($is_cache){ //缓存数据 if($id){ $file = 'caches/video-'.$id.'.html'; }elseif($cat_id){ $file = 'caches/category-'.$cat_id.'.html'; } if(is_file_cache($file,'8') && empty($_GET['mt'])){ //有缓存 echo $content = file_get_contents($file); //判断数据完整性 exit; } } //查找所有视频的导航 $class = get_video_class($where); //查找需要展示的视频相关信息 if($id){ $sql ="select id,cat_id,cat_sub_id,location,vd_url,vd_code,vd_name,vd_img,vd_desc,show_ids,sort,from_unixtime(update_time,'%Y年%m月%d日 %H:%i') as update_time from bjshop_video v where id=$id $where "; }elseif($cat_id){ $sql ="select id,cat_id,cat_sub_id,location,vd_url,vd_code,vd_name,vd_img,vd_desc,show_ids,sort,from_unixtime(update_time,'%Y年%m月%d日 %H:%i') as update_time from bjshop_video v where concat(',',cat_sub_id,',') like '%,".$cat_id.",%' $where union select v.id,g.classid as cat_id,g.cat_id as cat_sub_id,location,vd_url,vd_code,vd_name,vd_img,vd_desc,show_ids,v.sort,from_unixtime(update_time,'%Y年%m月%d日 %H:%i') as update_time from bjshop_video v left join bjshop_video_goods g on v.id=g.vd_id where g.cat_id=$cat_id $where order by sort desc limit 1"; }else{ $sql ="select id,cat_id,cat_sub_id,location,vd_url,vd_code,vd_name,vd_img,vd_desc,show_ids,from_unixtime(update_time,'%Y年%m月%d日 %H:%i') as update_time from bjshop_video v where cat_id>0 $where order by sort desc, click_count desc limit 1"; } $video = $db->getRow($sql); if($video){ $classid = $video['cat_id']; //科组 if($video['cat_sub_id']) $arr = explode(',',$video['cat_sub_id']); $cat_id = $cat_id ? $cat_id : ($arr[0] ? $arr[0] : ''); //病种id $id = $video['id']; if (strpos($video['vd_img'], '//') === false) { $video['vd_img'] = '//imgcdn.baiji.com.cn/data/afficheimg/mv_'.$video['vd_img']; } $whereid = " and v.enabled=1 and v.vd_show in(0,1) and v.id<>$id"; } //读取科组和病种 foreach($class as $val){ if($val['cat_id']==$classid)$class_name = $val['cat_name']; foreach($val['dis'] as $v){ if($v['cat_id']==$cat_id)$cat_name = $v['cat_name']; } } //根据病种和科组生成tdk if($cat_id){ if($cat_id=='322') $cat_name = '腰椎间盘突出'; if($cat_id=='294') $cat_name = '手足口病'; if($cat_id=='282') $cat_name = '脑梗死'; if($cat_id=='283') $cat_name = '心肌梗死'; if($cat_id=='326' || $cat_id=='327') $cat_name = '糖尿病'; $tdk = array($video['vd_name']."-专业全面的".$cat_name."科普视频-康德乐大药房网上药店",$video['vd_name']."-".$video['vd_desc'],"健康讲堂,".$cat_name."视频介绍,".$cat_name."怎么治,".$cat_name."怎么用药,健康视频哪里看"); }elseif($classid){ $tdk = array($video['vd_name']."-专业全面的".$class_name."科普视频-康德乐大药房网上药店",$video['vd_name']."-".$video['vd_desc'],"健康讲堂,".$class_name."视频介绍,".$class_name."怎么治,".$class_name."怎么用药,健康视频哪里看"); } if($cat_id){ //相关病种视频 $sql ="select id,vd_img,vd_name,sort,from_unixtime(update_time,'%Y-%m-%d') as update_time from bjshop_video v where concat(',',cat_sub_id,',') like '%,".$cat_id.",%' $whereid union select v.id,vd_img,vd_name,v.sort,from_unixtime(update_time,'%Y-%m-%d') as update_time from bjshop_video v left join bjshop_video_goods g on v.id=g.vd_id where g.classid=$cat_id $whereid order by sort desc limit 6"; $dis_video = $db->getAll($sql); if($dis_video){ foreach($dis_video as $key=>$row){ if (strpos($row['vd_img'], '//') === false) { $dis_video[$key]['vd_img'] = '//imgcdn.baiji.com.cn/data/afficheimg/mv_'. $row['vd_img']; } } } } if($classid){ $cat_sub_id = $db->getOne("select cat_sub_id from bjshop_video where cat_id='$classid' and cat_sub_id<>'$cat_id' order by update_time desc limit 1"); if(!$cat_sub_id)$cat_sub_id = $db->getOne("select cat_sub_id from bjshop_video where cat_id='$classid' order by update_time desc limit 1"); $arr = explode(",",$cat_sub_id); if($cat_sub_id){ //相关科组最新病种视频 $sql ="select id,vd_img,vd_name,sort,from_unixtime(update_time,'%Y-%m-%d') as update_time from bjshop_video v where concat(',',cat_sub_id,',') like '%,".$arr[0].",%' $whereid union select v.id,vd_img,vd_name,v.sort,from_unixtime(update_time,'%Y-%m-%d') as update_time from bjshop_video v left join bjshop_video_goods g on v.id=g.vd_id where g.classid=".$arr[0]." $whereid order by sort desc limit 6"; $class_video = $db->getAll($sql); if($class_video){ foreach($class_video as $key=>$row){ if (strpos($row['vd_img'], '//') === false) { $class_video[$key]['vd_img'] = '//imgcdn.baiji.com.cn/data/afficheimg/mv_'. $row['vd_img']; } } } } } //相关产品 if($video && $video['show_ids']){ $sql ="select concat('//m.baiji.com.cn/goods-',goods_id,'.html')as url,goods_name,goods_img,shop_price,attr_value_122,goods_changjia from bjshop_goods where goods_id in($video[show_ids]) limit 5"; $goods_list = $db->getAll($sql); }elseif($cat_id || $classid){ if($cat_id){ $sql="select * from(select concat('//m.baiji.com.cn/goods-',goods_id,'.html')as url,sale_record,goods_name,seller_note,shop_price,goods_changjia,attr_value_122,goods_img,is_special_price,promote_price,promote_start_date, promote_end_date from bjshop_goods g where cat_id = $cat_id and is_delete=0 and goods_img <> '' and is_on_sale=1 and is_alone_sale = 1 and goods_number>0 order by g.sale_record desc) a group by goods_name order by sale_record desc limit 5"; $goods_list=$GLOBALS['db']->getAll($sql); } if($goods_list) $num = 5-count($goods_list); else $num = 5; if((!$goods_list || $num>0) && $classid){ $sql="select * from(select concat('//m.baiji.com.cn/goods-',goods_id,'.html')as url,sale_record,goods_name,seller_note,shop_price,goods_changjia,attr_value_122,goods_img,is_special_price,promote_price,promote_start_date, promote_end_date from bjshop_goods g where(cat_id = '$classid' or classid = '$classid') and cat_id <>'$cat_id' and is_delete=0 and goods_img <> '' and is_on_sale=1 and is_alone_sale = 1 and goods_number>0 order by g.sale_record desc) a group by goods_name order by sale_record desc limit $num"; $res=$GLOBALS['db']->getAll($sql); if($goods_list) $goods_list = array_merge($goods_list,$res); } } if($goods_list){ foreach($goods_list as $key=>$goods){ $goods_list[$key]['name'] = (isset($goods['attr_value_122']) && $goods['attr_value_122']!=$goods['goods_name']) ? $goods['goods_name'].'('.$goods['attr_value_122'].')' : $goods['goods_name']; if(isset($goods['is_special_price']) && $goods['is_special_price']==1){ $goods_list[$key]['shop_price'] = '特价中'; }else{ $goods_list[$key]['shop_price'] = '¥'.$goods['shop_price']; } if ($goods['is_promote'] && $goods['promote_price'] && $time >= $goods['promote_start_date'] && $time <= $goods['promote_end_date']) { $goods_list[$key]['shop_price'] = '¥'.$goods['promote_price']; } $goods_list[$key]['goods_img'] = $goods['goods_img'] ? '//imgcdn.baiji.com.cn/'.$goods['goods_img'] : '//imgcdn.baiji.com.cn/images/no_picture.gif'; } } //热门视频 $video_list = get_hot_video($where,6); if($is_cache){ ob_start();//打开输出缓冲区 } include('template/list.html'); if($is_cache){ //缓存视频页面 $content = ob_get_contents(); //返回内部缓冲区的内容。 ob_end_clean(); //删除内部缓冲区的内容,并且关闭内部缓冲区 echo $content; if(strpos($content,'')){//完整 file_put_contents($file,$content); } } }