123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- namespace app\api\controller;
- use app\common\model\GoodsOrder;
- use app\common\model\StoreGoodsItem;
- use app\common\model\UserMessage;
- use library\tools\Data;
- class Message extends Base
- {
- public function initialize()
- {
- parent::initialize();
- parent::checkLogin();
- }
-
- public function getVideoPlatformNews()
- {
- $video = PlatformMessage::where(['type'=>1])->order('id desc')->find();
- if(!$video)$this->success('ok',['detail'=>['content'=>'','is_read'=>0]]);
- $detail = $video->toArray();
- $detail['is_read'] = PlatformReadLog::where(['user_id'=>$this->user_id,'type'=>1,'relation_id'=>$detail['id']])->count();
- $this->success('ok',['detail'=>$detail]);
- }
-
- public function getExpressMessageMenu()
- {
- $where[] = ['user_id','=',$this->user_id];
- $where[] = ['type_id','in','2,3'];
- $detail = UserMessage::where($where)->order('id desc')->find();
- $this->success('ok',['detail'=>$detail ? $detail->toArray():['content'=>'','is_read'=>0]]);
- }
-
- public function getExpressMessageList()
- {
- $where[] = ['user_id','=',$this->user_id];
- $where[] = ['type_id','in','2,3'];
- $list = UserMessage::where($where)
- ->limit($this->off_set,$this->page_num)
- ->order('id desc')
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['goods_list'] = StoreGoodsItem::field('goods_name,cover,goods_spec')->where(['order_id'=>$v['relation_id']])->select()->toArray();
- $v['order_info'] = GoodsOrder::field('id,order_no,express_send_no')->where('id',$v['relation_id'])->find()->toArray();
- }
- $this->success('ok',['list'=>$list]);
- }
-
- public function getActivityNews()
- {
- $detail = PlatformMessage::where(['type'=>2])->order('id desc')->find();
- if(!$detail)$this->success('ok',['detail'=>['content'=>'','is_read'=>0]]);
- $detail = $detail->toArray();
- $detail['is_read'] = PlatformReadLog::where(['user_id'=>$this->user_id,'type'=>2,'relation_id'=>$detail['id']])->count();
- $this->success('ok',['detail'=>$detail]);
- }
-
- public function getActivityNewsList()
- {
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $list = SeckillActivity::where($sel_where)
- ->field('id,title,cover,start_time,end_time')
- ->order('id desc')->limit(0,5)->select()->toArray();
- if(!empty($list)){
- $relation_id = PlatformMessage::where(['type'=>2])->max('id');
- Data::save('PlatformReadLog',['user_id'=>$this->user_id,'type'=>2,'relation_id'=>$relation_id,'create_at'=>date('Y-m-d H:i:s')],'user_id',['user_id'=>$this->user_id,'type'=>2,'relation_id'=>$relation_id]);
- }
- foreach ($list as &$v){
- $v['goods_list'] = SeckillGoods::field('g.id,g.name,g.cover')
- ->alias('s')
- ->leftJoin('StoreGoods g','g.id = s.goods_id')
- ->order('s.id desc')
- ->limit(0,3)
- ->select()->toArray();
- }
- $this->success('ok',['list'=>$list]);
- }
- }
|