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]); } /** * @title 获取交易物流消息(菜单) * @desc 获取交易物流消息 * @author qc * @url /api/Message/getExpressMessageMenu * @method GET * @header name:Authorization require:1 desc:Token * @return name:create_at type:string default:-- desc:时间 * @return name:content type:string default:-- desc:内容 * @return name:is_read type:int default:-- desc:是否已读(0否) */ 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]]); } /** * @title 获取交易物流消息(内页列表) * @desc 获取交易物流消息(内页列表) * @author qc * @url /api/Message/getExpressMessageList * @method GET * @header name:Authorization require:1 desc:Token * @param name:page type:int default:1 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:create_at type:string default:-- desc:时间 * @return name:content type:string default:-- desc:内容 * @return name:type_id type:int default:-- desc:类型[2发货通知,3收货通知] * @return name:order_info type:array default:-- desc:订单信息 * @return name:order_info.id type:int default:-- desc:订单id * @return name:order_info.express_send_no type:string default:-- desc:发货单号 * @return name:order_info.order_no type:string default:-- desc:订单号 * @return name:goods_list type:array default:-- desc:商品列表 * @return name:goods_list.goods_name type:string default:-- desc:商品名 * @return name:goods_list.cover type:string default:-- desc:商品图 * @return name:goods_list.goods_spec type:string default:-- desc:商品规格 */ 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]); } /** * @title 获取活动平台消息(菜单) * @desc 获取活动平台消息(菜单) * @author qc * @url /api/Message/getActivityNews * @method GET * @return name:content type:string default:-- desc:标题 * @return name:is_read type:string default:-- desc:是否已读(0否) */ 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]); } /** * @title 获取活动平台消息(内页) * @desc 获取活动平台消息(内页) * @author qc * @url /api/Message/getActivityNewsList * @method GET * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:start_time type:string default:-- desc:活动开始时间 * @return name:end_time type:string default:-- desc:活动结束时间 * @return name:goods_list type:array default:-- desc:商品列表(最多查3个) * @return name:goods_list.name type:string default:-- desc:商品名 * @return name:goods_list.cover type:string default:-- desc:商品图 */ 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]); } }