123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <?php
- namespace app\api\controller;
- use app\common\model\GoodsOrderItem;
- use app\common\model\PlatformMessage;
- use app\common\model\StoreBanner;
- use app\common\model\UserCollect;
- use app\common\model\VideoCate;
- use app\common\model\VideoGoods;
- use app\common\model\VideoIntro;
- use library\tools\Data;
- class Video extends Base
- {
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
-
- public function getCateTree()
- {
- $list = VideoCate::where(['is_deleted'=>0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
-
- public function getBanner()
- {
- $num = input('get.num',5);
- $list = StoreBanner::where(['place'=>3,'is_deleted'=>0])
- ->field('id,cover,link')
- ->limit(0,$num)
- ->order('sort desc ,id desc')
- ->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
-
- public function getVideoList()
- {
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $title = input('get.title');
- $first_classify = input('get.first_classify');
- if($title) $sel_where[] = ['title','like','%'.$title.'%'];
- if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
- $list = VideoIntro::where($sel_where)
- ->order('is_top desc,sort desc ,id desc')
- ->limit($this->off_set,$this->page)->select()->toArray();
- array_walk($list,function ($v,$k){
- $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$v['id']);
- });
- $this->success('ok',['list'=>$list]);
- }
-
- public function getNewVideo()
- {
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $list = VideoIntro::where($sel_where)
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function ($v,$k){
- $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$v['id']);
- });
- if(!empty($list) && $this->user_id){
- $relation_id = PlatformMessage::where(['type'=>1])->max('id');
-
- Data::save('PlatformReadLog',['user_id'=>$this->user_id,'type'=>1,'relation_id'=>$relation_id,'create_at'=>date('Y-m-d H:i:s')],'user_id',['user_id'=>$this->user_id,'type'=>1,'relation_id'=>$relation_id]);
- }
- $this->success('ok',['list'=>$list]);
- }
-
- public function getVideoDetail()
- {
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['id','=',input('get.id')];
- $detail = VideoIntro::where($sel_where)
- ->order('is_top desc,sort desc ,id desc')->find();
- if(!$detail)$this->error('该视频已下线');
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail->id);
- $this->success('ok',['detail'=>$detail]);
- }
-
- public function getVideoGoods()
- {
- $id = input('get.id');
- if($id){
- $list = VideoGoods::with('goodsSet')->limit($this->off_set,$this->page_num)->select()->toArray();
- }else{
- $list = VideoGoods::with('goodsSet')->where(['video_id'=>$id])->limit($this->off_set,$this->page_num)->select()->toArray();
- }
- array_walk($list,function (&$v,$k){
- $v['line_price'] = GoodsOrderItem::where('goods_id',$v['goods_id'])->max('original_price');
- });
- $this->success('ok',['list'=>$list]);
- }
- }
|