123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618 |
- <?php
- namespace app\api\controller;
- use app\common\model\PlatformLike;
- use app\common\model\PressComment;
- use app\common\model\SupplierCate;
- use app\common\model\UserCollect;
- use app\common\model\UserSearch;
- use app\common\model\SupplierGoods;
- use app\common\model\UserTrack;
- use library\tools\Data;
- use think\Db;
- /**
- * @title 供应商
- * @controller Supplier
- * @group base
- */
- class Supplier extends Base
- {
- // 需要登录的
- protected $need_login = ['','',''];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 供应商接口说明
- * @desc 供应商接口说明
- * @author qc
- * @url /api/Supplier/classIntro
- * @method GET
- * @return name:1 type:string default:-- desc:--
- */
- public function classIntro(){}
- /**
- * @title 获取供应商分类
- * @desc 两级分类
- * @author qc
- * @url /api/Supplier/getSupplierCate
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:分类id
- * @return name:title type:string default:0 desc:分类名称
- * @return name:children type:array default:0 desc:下级分类
- */
- public function getSupplierCate()
- {
- $list = SupplierCate::where(['is_deleted'=>0])->field('id,title,pid')->order('sort desc')->select()->toArray();
- $list = make_tree($list);
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 联系我们(详情内部)【两个二维码】
- * @desc 联系我们
- * @author qc
- * @method GET
- * @url /api/Supplier/getSupplierContact
- * @header name:Authorization require:1 desc:Token
- * @param name:supplier_id type:int default:-- desc:供应商id
- * @return name:phone type:string default:-- desc:供应商电话
- * @return name:email type:string default:-- desc:供应商email
- * @return name:qr_code type:int default:-- desc:供应商二维码
- * @return name:contact_qrcode type:string default:-- desc:平台二维码
- * @return name:contact_phone type:string default:-- desc:平台电话
- * @return name:contact_email type:string default:-- desc:平台邮箱
- */
- public function getSupplierContact()
- {
- $sel_where[] = ['id','=',input('get.supplier_id')];
- $detail = \app\common\model\Supplier::field('id,phone,email,qr_code')->where($sel_where)->find()->toArray();
- $contact = Db::name('contact')->where('tag','supplier')->field('qrcode contact_qrcode,phone contact_phone,email contact_email')->find();
- $contact['phone'] = $detail['phone'];
- $contact['email'] = $detail['email'];
- $contact['qr_code'] = $detail['qr_code'];;
- $this->success('ok',$contact);
- }
- /**
- * @title 获取供应商列表
- * @desc 获取供应商列表
- * @author qc
- * @method GET
- * @url /api/Supplier/getSupplierList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- * @param name:first_classify type:int default:0 desc:一级分类id
- * @param name:second_classify type:int default:0 desc:二级分类id
- *
- * @return name:title type:string default:-- desc:名称
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:phone type:string default:-- desc:电话
- * @return name:email type:string default:-- desc:email
- * @return name:label_name type:array default:-- desc:标签
- * @return name:content type:string default:-- desc:供应商详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:build_time type:string default:-- desc:成立时间
- * @return name:work_place type:string default:-- desc:办公地点
- * @return name:business type:string default:-- desc:业务范围
- *
- */
- public function getSupplierList(){
- $title = input('get.title');
- $sort_type = input('get.sort_type',1);
- $first_classify = input('get.first_classify');
- $second_classify = input('get.second_classify');
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'desc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
- if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
- if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,9);
- $list = \app\common\model\Supplier::where($sel_where)
- ->when($title,function ($query)use($title){
- if($title) $query->where('title|label','like','%'.$title.'%');
- })->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v) {
- $v['cover'] =$v['logo'] ;
- $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
- $v['business_arr'] = $v['business'] ? explode(',',trim($v['business'],',')) : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取供应商详情
- * @desc 获取供应商详情
- * @author qc
- * @method GET
- * @url /api/Supplier/getSupplierDetail
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:供应商记录id
- * @return name:title type:string default:-- desc:名称
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:phone type:string default:-- desc:电话
- * @return name:email type:string default:-- desc:email
- * @return name:label_name type:array default:-- desc:标签
- * @return name:content type:string default:-- desc:供应商详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:build_time type:string default:-- desc:成立时间
- * @return name:work_place type:string default:-- desc:办公地点
- * @return name:business type:string default:-- desc:业务范围
- */
- public function getSupplierDetail()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Supplier::where($sel_where)->find()->toArray();
- $detail['label_name'] =$detail['label'] ? explode(',',trim($detail['label'],',')):null;
- $detail['business_arr'] = $detail['business'] ? explode(',',trim($detail['business'],',')) : null;
- UserTrack::crateTrack($this->user_id,9,input('get.id'),0);
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 供应商商品推荐
- * @desc 供应商商品推荐
- * @author qc
- * @method GET
- * @url /api/Supplier/getRecommendList
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:id type:int default:-- desc:供应商商品d
- * @return name:name type:string default:-- desc:商品名称
- * @return name:cover_arr type:array default:-- desc:封面
- * @return name:label_name type:array default:-- desc:标签
- * @return name:label type:string default:-- desc:标签
- * @return name:supplier_name type:float default:-- desc:供应商名称
- * @return name:supplier_logo type:string default:-- desc供应商logo
- * @return name:read_num type:int default:-- desc:阅读量
- *
- */
- public function getRecommendList()
- {
- $search_log = UserSearch::getSearchTitle($this->user_id,10);
- $search_arr = [];
- $where_str = 'b.id > 0';
- foreach ($search_log as $t){
- $search_arr[] = " b.name like '".'%'.$t."%'" .' ';
- $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- $field = 'a.id,a.supplier_id,a.name,a.label,a.cover,a.read_num,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_supplier_goods';
- $order_by_two = 'read_num';
- $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id LEFT JOIN dd_supplier as k ON a.supplier_id = k.id WHERE a.is_deleted = 0 AND a.status = 1 AND k.status =1 AND k.is_deleted = 0 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
- $list = Db::query($sql);
- array_walk($list,function (&$v,$k){
- $supplier_info =\app\common\model\Supplier::where('id',$v['supplier_id'])->find()->toArray();
- $v['supplier_name']=$supplier_info['title'];
- $v['supplier_logo'] =$supplier_info['logo'];
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
- });
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 供应商商品列表【产品集合】
- * @desc 供应商商品列表
- * @author qc
- * @method GET
- * @url /api/Supplier/getSupplierGoodsList
- * @header name:Authorization require:1 desc:Token
- * @param name:supplier_id type:int default:-- desc:供应商记录id
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- *
- * @return name:name type:string default:-- desc:名称
- * @return name:supplier_name type:string default:-- desc:供应商名称
- * @return name:supplier_logo type:string default:-- desc供应商logo
- * @return name:cover type:string default:-- desc:图片【多张|隔开】
- * @return name:cover_arr type:array default:-- desc:图片数组
- * @return name:label_name type:array default:-- desc:标签
- * @return name:content type:string default:-- desc:详情
- * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
- * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
- * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
- * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
- * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
- * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
- * @return name:total_num type:array default:-- desc:总数
- *
- */
- public function getSupplierGoodsList()
- {
- $supplier_id = input('get.supplier_id');
- $sort_type = input('get.sort_type',1);
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'desc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['supplier_id','=',$supplier_id];
- $list = SupplierGoods::where($sel_where)
- ->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
- $supplier_info = \app\common\model\Supplier::where('id',$supplier_id)->find()->toArray();
- foreach ($list as &$v) {
- $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
- $v['cover_arr'] =$v['cover'] ? explode('|',trim($v['cover'])):null;
- $v['supplier_name'] =$supplier_info['title'];
- $v['supplier_logo'] =$supplier_info['logo'];
- }
- $total_num = SupplierGoods::where($sel_where)->count();
- $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
- }
- /**
- * @title 供应商产品详情
- * @desc 供应商产品详情
- * @author qc
- * @method GET
- * @url /api/Supplier/getSupplierGoodsDetail
- * @header name:Authorization require:1 desc:Token
- * @param name:goods_id type:int default:-- desc:供应商产品id
- * @return name:name type:string default:-- desc:名称
- * @return name:cover type:string default:-- desc:图片【多张逗号隔开】
- * @return name:cover_arr type:array default:-- desc:图片数组
- * @return name:label_name type:array default:-- desc:标签
- * @return name:content type:string default:-- desc:详情
- * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
- * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
- * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
- * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
- * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
- * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
- * @return name:is_collect type:int default:-- desc:是否收藏
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:praise_num type:int default:-- desc:点赞量
- * @return name:is_praise type:int default:-- desc:是否点赞
- * @return name:transmit_num type:int default:-- desc:转发量
- *
- * @return name:supplier_info type:array default:-- desc:供应商详情
- * @return name:supplier_info.title type:string default:-- desc:名称
- * @return name:supplier_info.cover type:string default:-- desc:公司logo
- * @return name:supplier_info.phone type:string default:-- desc:电话
- * @return name:supplier_info.email type:string default:-- desc:email
- * @return name:supplier_info.label_name type:array default:-- desc:标签
- * @return name:supplier_info.content type:string default:-- desc:供应商详情
- * @return name:supplier_info.create_at type:string default:-- desc:时间
- * @return name:supplier_info.build_time type:string default:-- desc:成立时间
- * @return name:supplier_info.work_place type:string default:-- desc:办公地点
- * @return name:supplier_info.business type:string default:-- desc:业务范围
- */
- public function getSupplierGoodsDetail()
- {
- $goods_id = input('get.goods_id');
- $detail = SupplierGoods::where('id',$goods_id)->find()->toArray();
- $detail['label_name'] =$detail['label'] ? explode(',',trim($detail['label'],',')):null;
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,9,$detail['id']);
- $detail['collect_num'] = UserCollect::getCollectNum(9,$detail['id']);
- $detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],7);
- $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],7);
- $supplier_info = \app\common\model\Supplier::where('id',$detail['supplier_id'])->find()->toArray();
- $supplier_info['label_name'] =$supplier_info['label'] ? explode(',',trim($supplier_info['label'],',')):null;
- $supplier_info['business_arr'] = $supplier_info['business'] ? explode(',',trim($supplier_info['business'],',')) : null;
- $supplier_info['cover'] = $supplier_info['logo'] ;
- UserTrack::crateTrack($this->user_id,10,$goods_id,0);
- SupplierGoods::where('id',$goods_id)->setInc('read_num');
- $this->success('ok',['detail'=>$detail,'supplier_info'=>$supplier_info]);
- }
- /**
- * @title 供应商搜索列表
- * @desc 供应商搜索列表
- * @author qc
- * @method GET
- * @url /api/Supplier/searchGoods
- * @header name:Authorization require:1 desc:Token
- * @param name:search_name type:int default:-- desc:搜索名称
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- *
- * @return name:name type:string default:-- desc:名称
- * @return name:supplier_name type:string default:-- desc:供应商名称
- * @return name:cover type:string default:-- desc:图片【多张逗号隔开】
- * @return name:cover_arr type:array default:-- desc:图片数组
- * @return name:label_name type:array default:-- desc:标签
- * @return name:content type:string default:-- desc:详情
- * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
- * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
- * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
- * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
- * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
- * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
- * @return name:total_num type:array default:-- desc:总数
- *
- */
- public function searchGoods()
- {
- $search_name = input('get.search_name');
- $sort_type = input('get.sort_type',1);
- switch ($sort_type) {
- case 1:
- $order = ['g.sort'=>'desc','g.id'=>'desc'];
- break;
- case 2:
- $order = ['g.id'=>'asc','g.sort'=>'desc'];
- break;
- case 3:
- $order = ['g.id'=>'g.desc','g.sort'=>'desc'];
- break;
- }
- $sel_where = [];
- $sel_where[] = ['g.is_deleted','=',0];
- $sel_where[] = ['g.status','=',1];
- if($search_name && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$search_name,10);
- $list = SupplierGoods::where($sel_where)
- ->field('g.id,g.supplier_id,g.name,g.label,g.cover,s.title supplier_name')
- ->when($search_name,function ($query)use($search_name){
- if($search_name) $query->where('g.name|g.label','like','%'.$search_name.'%');
- })->alias('g')
- ->leftJoin('Supplier s','g.supplier_id = s.id')
- ->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v) {
- $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
- $v['cover_arr'] =$v['cover'] ? explode('|',trim($v['cover'])):null;
- }
- $total_num = SupplierGoods::where($sel_where)->alias('g')->when($search_name,function ($query)use($search_name){
- if($search_name) $query->where('g.name|g.label','like','%'.$search_name.'%');
- })->count();
- $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
- }
- /**
- * @title 以下接口调用验证登录【需要header传Authorization】
- * @desc 以下接口调用验证登录
- * @author qc
- * @method
- * @url /api/Supplier/needLogin()
- */
- public function needLogin(){}
- /**
- * @title 供应商商品点赞||取消点赞
- * @desc 点赞||取消点赞
- * @author qc
- * @method POST
- * @url /api/Supplier/supplierGoodsTags
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:供应商商品记录id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function supplierGoodsTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.id'),7);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 供应商商品收藏||取消收藏
- * @desc 用户收藏
- * @author qc
- * @method POST
- * @url /api/Supplier/supplierGoodsCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:供应商商品记录id
- * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function supplierGoodsCollect(){
- $coll_status = UserCollect::plateCollect($this->user_id,9,input('post.id',0));
- $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
- }
- /**
- * @title 转发(转发数量统计【供应商】)
- * @desc 转发成功后调用
- * @author qc
- * @method POST
- * @url /api/Supplier/supplierTransmit
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:供应商记录id
- */
- public function supplierTransmit()
- {
- $id = input('post.id',0);
- \app\common\model\Supplier::where('id',$id)->setInc('transmit_num');
- $this->success('ok');
- }
- /**
- * @title 转发(转发数量统计【供应商商品】)
- * @desc 转发成功后调用
- * @author qc
- * @method POST
- * @url /api/Supplier/supplierGoodsTransmit
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:供应商商品记录id
- */
- public function supplierGoodsTransmit()
- {
- $id = input('post.id',0);
- SupplierGoods::where('id',$id)->setInc('transmit_num');
- $this->success('ok');
- }
- /**
- * @title 我的浏览历史【供应商商品】
- * @desc 我的浏览历史
- * @author qc
- * @method GET
- * @url /api/Supplier/getSupplierGoodsTrack
- * @header name:Authorization require:1 desc:Token
- * @param name:name type:string default:-- desc:商品名称
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- * @return name:id type:string default:-- desc:浏览记录id
- * @return name:goods_id type:string default:-- desc:商品id
- * @return name:name type:string default:-- desc:名称
- * @return name:cover type:string default:-- desc:封面(多张|隔开)
- * @return name:cover_arr type:array default:-- desc:封面
- * @return name:label_name type:array default:-- desc:标签
- * @return name:supplier_name type:array default:-- desc:供应商名称
- * @return name:time type:string default:-- desc:时间
- */
- public function getSupplierGoodsTrack()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',10];
- $name = input('get.name');
- if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
- $list = UserTrack::where($sel_where)
- ->alias('t')
- ->field('t.id,t.update_int,t.first_id goods_id,i.name,i.cover,i.label,supplier_id')
- ->leftJoin('SupplierGoods i','t.first_id = i.id')
- ->order('update_int desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
- $v['cover_arr'] = $v['cover']? explode('|',$v['cover']) : null;
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['supplier_name'] = \app\common\model\Supplier::where('id',$v['supplier_id'])->value('title');
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的点赞【供应商商品点赞列表】
- * @desc 供应商商品点赞列表
- * @author qc
- * @method GET
- * @url /api/Supplier/getTagsSupplierGoods
- * @header name:Authorization require:1 desc:Token
- * @param name:name type:string default:-- desc:商品名称
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- * @return name:id type:string default:-- desc:浏览记录id
- * @return name:goods_id type:string default:-- desc:商品id
- * @return name:name type:string default:-- desc:名称
- * @return name:cover type:string default:-- desc:封面(多张|隔开)
- * @return name:cover_arr type:array default:-- desc:封面
- * @return name:label_name type:array default:-- desc:标签
- * @return name:supplier_name type:array default:-- desc:供应商名称
- * @return name:create_at type:string default:-- desc:时间
- */
- public function getTagsSupplierGoods()
- {
- $sel_where = [];
- $name = input('get.name');
- if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',7];
- $list = PlatformLike::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.like_id goods_id,i.name,i.cover,i.label,supplier_id')
- ->leftJoin('SupplierGoods i','t.like_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['cover_arr'] = explode('|',$v['cover']);
- $v['label_name'] = explode(',',$v['label']);
- $v['supplier_name'] = \app\common\model\Supplier::where('id',$v['supplier_id'])->value('title');
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的收藏【供应商商品收藏列表】
- * @desc 供应商商品收藏列表
- * @author qc
- * @method GET
- * @url /api/Supplier/getCollectSupplierGoods
- * @header name:Authorization require:1 desc:Token
- * @param name:name type:string default:-- desc:商品名称
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:id type:string default:-- desc:浏览记录id
- * @return name:goods_id type:string default:-- desc:商品id
- * @return name:name type:string default:-- desc:名称
- * @return name:cover type:string default:-- desc:封面(多张|隔开)
- * @return name:cover_arr type:array default:-- desc:封面
- * @return name:label_name type:array default:-- desc:标签
- * @return name:supplier_name type:array default:-- desc:供应商名称
- * @return name:create_at type:string default:-- desc:时间
- */
- public function getCollectSupplierGoods()
- {
- $sel_where = [];
- $name = input('get.name');
- if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.coll_type','=',9];
- $list = UserCollect::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.coll_id goods_id,i.name,i.cover,i.label,supplier_id')
- ->leftJoin('SupplierGoods i','t.coll_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['cover_arr'] = explode('|',$v['cover']);
- $v['label_name'] = explode(',',$v['label']);
- $v['supplier_name'] = \app\common\model\Supplier::where('id',$v['supplier_id'])->value('title');
- }
- $this->success('ok',['list'=>$list]);
- }
- }
|