123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263 |
- <?php
- namespace app\api\controller;
- use app\common\model\ArticleCommentLike;
- use app\common\model\PlatformDemand;
- use app\common\model\DemandComment;
- use app\common\model\PlatformLike;
- use app\common\model\PlatformSwitch;
- use app\common\model\TopSearch;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserDemand;
- use app\common\model\UserMessage;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use app\common\service\CheckPower;
- use app\common\service\UserSynth;
- use library\tools\Data;
- use think\Db;
- /**
- * @title 需求【也叫项目。。。】
- * @controller Demand
- * @group base
- */
- class Demand extends Base
- {
- // 需要登录的
- protected $need_login = [
- 'demandComment',
- 'demandSecondComment',
- 'demandTags',
- 'commentTags',
- 'demandCollect',
- 'getMyDemandList',
- 'getTagsDemand',
- 'getDemandTrack',
- 'getCollectDemand',
- 'getMyDemandComment',
- 'unreadChange',
- 'commentMyDemand',
- 'praiseMyDemand',
- 'praiseCommentList',
- 'batchesDel',
- 'getReplyComment',
- 'getTagsComment',
- 'getReplyDemand',
- ];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 需求推荐
- * @desc 需求推荐
- * @author qc
- * @method GET
- * @url /api/Demand/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:每页数
- * @param name:is_over type:int default:0 desc:是否解决或开源【0否,1是,2开源】
- * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:内容
- * @return name:cover type:array default:-- desc:封面
- * @return name:money type:float default:-- desc:价格
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:label_name type:array default:-- desc:标签
- * @return name:is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
- * @return name:release_time type:string default:-- desc:上架时间
- *
- *
- */
- public function getRecommendList()
- {
- $user_id = $this->user_id ? $this->user_id : input('rand_user');
- if(!$user_id) $this->error('参数错误');
- $list = UserSynth::getRecommendList($user_id,'demand',$this->page,$this->page_num,['is_over'=>input('is_over',0)]);
- if($list['code'] != 200) $this->error($list['msg']);
- $this->success('ok',$list);
- $search_log = UserSearch::getSearchTitle($this->user_id,5);
- $app_name = sysconf('app_name');
- $app_logo = sysconf('app_logo');
- $search_arr = [];
- $is_over = input('is_over',0);
- $where_str = 'b.id > 0';
- foreach ($search_log as $t){
- $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
- $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- $field = 'a.id,cover,money,user_id,label,title,cover,a.read_num,is_over,content,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_platform_demand';
- $order_by_two = 'a.id';
- $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 WHERE a.is_deleted = 0 AND a.status = 1 AND a.is_over = ".$is_over ." ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
- $sql2 = "SELECT count(a.id) num 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 WHERE a.is_deleted = 0 AND a.status = 1 AND a.is_over = ".$is_over ." ORDER BY is_recommend DESC , $order_by_two desc ";
- $list = Db::query($sql);
- $list = dispose_recommend($list);
- array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
- if(!$v['user_id']){
- $v['app_name'] = $app_name;
- $v['app_logo'] = $app_logo;
- }else{
- $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
- $v['app_name'] = $user_info ? $user_info->name : '';
- $v['app_logo'] = $user_info ? $user_info->headimg : '';
- }
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['cover_arr'] = explode('|',trim($v['cover'],'|'));
- $v['read_num'] = numTransform($v['read_num']);
- });
- $total = Db::query($sql2);
- $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
- }
- /**
- * @title 需求列表【平台】
- * @desc 需求列表【平台】
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:is_over type:int default:-1 desc:是否解决或开源【0待解决,1已解决,2开源】
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:需求
- * @return name:cover type:array default:-- desc:封面
- * @return name:images type:string default:-- desc:图片【多张|隔开】
- * @return name:user_name type:string default:-- desc:名称
- * @return name:headimg type:string default:-- desc:头像
- * @return name:money type:float default:-- desc:金额
- * @return name:is_over type:int default:-- desc:是否解决或开源【0待解决,1已解决,2开源】
- * @param name:company type:string default:0 desc:公司名
- * @param name:company_logo type:string default:0 desc:公司logo
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:release_time type:string default:-- desc:上架时间
- */
- public function getDemandList()
- {
- $title = input('get.title');
- $is_tj = input('get.is_tj',0);
- $is_over = input('get.is_over',-1);
- $sort_type = input('get.sort_type',1);
- $sel_where =[];
- $sel_where[] = ['d.is_deleted','=',0];
- $sel_where[] = ['d.status','=',1];
- if($title) $sel_where[] = ['d.title|d.label','like','%'.$title.'%'];
- if($is_over > -1) $sel_where[] = ['d.is_over','=',$is_over];
- if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,5);
- $where_str = '';
- if($is_tj) {
- $search_log = UserSearch::getSearchTitle($this->user_id,5);
- $search_arr = [];
- foreach ($search_log as $t){
- $search_arr[] = " d.title like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- }
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'asc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- $list = PlatformDemand::where($sel_where)
- ->field('d.*,u.name user_name,u.headimg')
- ->alias('d')
- ->leftJoin('store_member u','u.id = d.user_id')
- ->when($where_str,function ($query)use ($where_str){if($where_str) $query->where($where_str);})
- ->order($order)
- ->limit($this->off_set,$this->page_num)->select()->toArray();
- array_walk($list,function (&$v){
- $auth_info = PlatformDemand::getAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $auth_info['app_name'];
- $v['app_logo'] = $auth_info['app_logo'];
- $v['read_num'] = numTransform($v['read_num']);
- });
- $total_num = PlatformDemand::where($sel_where)->field('d.*,u.name user_name,u.headimg')
- ->alias('d')->leftJoin('store_member u','u.id = d.user_id')
- ->when($where_str,function ($query)use ($where_str){if($where_str) $query->where($where_str);})->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 需求详情【平台】
- * @desc 需求详情【平台】
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandInfo
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:平台发布需求id
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:需求
- * @return name:cover type:array default:-- desc:封面
- * @return name:images type:string default:-- desc:图片【多张|隔开】
- * @return name:user_name type:string default:-- desc:名称
- * @return name:headimg type:string default:-- desc:头像
- * @return name:money type:float default:-- desc:金额
- * @return name:is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
- * @param name:company type:string default:0 desc:公司名
- * @param name:company_logo type:string default:0 desc:公司logo
- * @return name:praise_num type:int default:-- desc:点赞数量
- * @return name:is_praise type:int default:-- desc:是否点赞(0否1是)
- * @return name:is_collect type:int default:-- desc:是否收藏(0否1是)
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:comment_num type:int default:-- desc:评论数量
- * @return name:link type:string default:-- desc:相关链接
- * @return name:datum_id type:int default:-- desc:资料id【系列id】
- * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:create_at type:string default:-- desc:发布时间
- * @return name:transmit_num type:string default:-- desc:转发量
- * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- * @return name:label_name type:array default:-- desc:标签
- * @return name:solve_phone type:string default:-- desc:发布方电话
- * @return name:solve_email type:string default:-- desc:发布方邮箱
- * @return name:release_time type:string default:-- desc:上架时间
- * @return name:solve_qrcode type:string default:-- desc:发布方二维码
- */
- public function getDemandInfo()
- {
- $detail = PlatformDemand::where('id',input('get.id'))->find();
- if(!$detail || $detail->is_deleted == 1 || $detail->status == 0) $this->error('该需求已下架');
- $detail = $detail->toArray();
- $detail['label_name'] = $detail['label'] ? explode(',',trim($detail['label'],',')) : null;
- $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],9);
- $detail['is_praise'] = PlatformLike::checkTags($this->user_id, $detail['id'], 9);
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,10,$detail['id']);
- $detail['collect_num'] = UserCollect::getCollectNum(10,$detail['id']);
- UserTrack::crateTrack($this->user_id,11,input('get.id'),0);
- $detail['read_num'] = numTransform($detail['read_num']);
- $auth_info = PlatformDemand::getAuth($detail['user_id'],APPNAME,APPLOGO);
- $detail['app_name'] = $auth_info['app_name'];
- $detail['app_logo'] = $auth_info['app_logo'];
- $detail['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],12);
- $detail['comment_num'] = DemandComment::getCommentNum($detail['id']);
- PlatformDemand::where('id',input('get.id'))->setInc('read_num');
- if($this->user_id){
- TopSearch::seIncHotNum($detail['id'],$this->request->controller());
- }
- if($this->user_id){
- $General = new General();
- $General->label($detail['label']);
- }
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 获取需求评论列表
- * @desc 获取需求评论列表
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandCommentList
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:需求id
- * @param name:sort_type type:int default:1 desc:排序规则1时间2热点
- * @param name:page type:int default:-- desc:页数
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:内容
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】)
- * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】)
- * @return name:praise_num type:int default:-- desc:点赞数量
- * @return name:is_praise type:int default:-- desc:是否点赞(0否1是)
- * @return name:total_num type:int default:-- desc:总评论数(仅一级)
- */
- public function getDemandCommentList()
- {
- $where = [];
- $where[] = ['c.first_id','=',input('get.id')];
- $where[] = ['c.is_deleted','=',0];
- $where[] = ['c.type','=',1];
- $user_id = $this->user_id;
- $sort_type= input('sort_type',1);
- switch ($sort_type) {
- case 1:
- $order = ['c.is_top'=>'desc','c.id'=>'desc','c.like_times'=>'desc'];
- break;
- case 2:
- $order = ['c.is_top'=>'desc','c.like_times'=>'desc','c.id'=>'asc'];
- break;
- }
- $list =DemandComment::where($where)
- ->alias('c')
- ->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order($order)
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$val,$k)use($user_id){
- $children = DemandComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0])
- ->alias('c')->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order('c.is_top desc,c.id asc')
- ->select()->toArray();
- $val['children'] = $children ? $children : null;
- $val['praise_num'] = PlatformLike::getPraiseNum($val['id'],6);
- $val['is_praise'] = PlatformLike::where(['like_id'=>$val['id'],'user_id'=>$user_id,'type'=>6])->count();
- $parent = DemandComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0])
- ->alias('c')->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->find();
- $val['parent'] = $parent ? $parent->toArray() : null;
- $val['parent_comment'] = $val['parent'] ;
- });
- $total_num = DemandComment::where($where)->alias('c')->count();
- $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 需求评论
- * @desc 需求评论
- * @author qc
- * @method POST
- * @url /api/Demand/demandComment
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:需求id
- * @param name:content type:string default:-- desc:内容
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:内容
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- */
- public function demandComment()
- {
- $id = input('post.id');
- $content = input('post.content',0);
- if(!$content) $this->error('请输入评论内容');
- $info = PlatformDemand::where('id',$id)->find();
- if(!$info->comment_switch) $this->error('评论功能已关闭');
- $send_user =$info->user_id;
- $user_info = $this->userInfo('name');
- if($send_user && $send_user != $this->user_id) UserMessage:: sendUserMessage($send_user,'demand',4,0,$this->user_id,$id,$content);
- $res = DemandComment::create(['user_id'=>$this->user_id,'content'=>$content,'first_id'=>$id,'type'=>1]);
- $detail =DemandComment::where('p.id',$res->id)
- ->alias('p')
- ->field('p.id,p.is_top,p.content,p.create_at,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = p.user_id')
- ->find()->toArray();
- $this->success('评论成功',['detail'=>$detail]);
- }
- /**
- * @title 需求二级评论
- * @desc 需求二级评论
- * @author qc
- * @method POST
- * @url /api/Demand/demandSecondComment
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:评论id
- * @param name:content type:string default:-- desc:内容
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:内容
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- */
- public function demandSecondComment()
- {
- $comment = DemandComment::where('id',input('post.id'))->find()->toArray();
- $info = PlatformDemand::where('id',$comment['first_id'])->find();
- if(!$info->comment_switch) $this->error('评论功能已关闭');
- $user_info = $this->userInfo('name');
- if($comment['user_id'] != $this->user_id)UserMessage:: sendUserMessage($comment['user_id'],'demand',3,0,$this->user_id,$comment['id'],input('post.content'));
- $send_user =$info->user_id;
- //if($send_user && $send_user != $this->user_id) UserMessage::sendUserMessage($send_user,'demand',4,0,$this->user_id,$comment['first_id'],input('post.content'));
- unset($comment['id']);
- unset($comment['create_at']);
- $comment['pid'] = input('post.id');
- $comment['user_id'] = $this->user_id;
- $comment['content'] = input('post.content');
- $comment['lev']++;
- if(!$comment['source_id']) $comment['source_id'] = input('post.id');
- $res = DemandComment::create($comment);
- $detail = DemandComment::where('p.id',$res->id)
- ->alias('p')
- ->field('p.id,p.is_top,p.content,p.create_at,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = p.user_id')
- ->find()->toArray();
- $this->success('评论成功',['detail'=>$detail]);
- }
- /**
- * @title 需求点赞||取消点赞[需求]
- * @desc 评论
- * @author qc
- * @method POST
- * @url /api/Demand/demandTags
- * @header name:Authorization require:1 desc:Token
- * @param name:demand_id type:int default:1 desc:需求id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function demandTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.demand_id'),9);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 评论点赞||取消点赞[评论]
- * @desc 评论
- * @author qc
- * @method POST
- * @url /api/Demand/commentTags
- * @header name:Authorization require:1 desc:Token
- * @param name:comment_id type:int default:1 desc:评论记录id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function commentTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.comment_id'),6);
- if($ret_val == 1){
- DemandComment::where('id',input('post.comment_id'))->setInc('like_times');
- }else{
- DemandComment::where('id',input('post.comment_id'))->setDec('like_times');
- }
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 收藏||取消收藏
- * @desc 用户收藏
- * @author qc
- * @method POST
- * @url /api/Demand/demandCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:需求id
- * @return name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function demandCollect(){
- $coll_status = UserCollect::plateCollect($this->user_id,10,input('post.id',0));
- $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
- }
- /**
- * @title 用户提交||修改需求【用户】
- * @desc 用户提交||修改需求
- * @author qc
- * @method POST
- * @url /api/Demand/commitDemand
- * @param name:id type:int default:-- desc:修改必传[添加不传,或是null或是空]
- * @param name:title type:string default:-- desc:标题
- * @param name:content type:string default:1 desc:内容
- * @param name:money type:float default:0 desc:价格【设计图没有,可以不传】
- * @param name:label type:string default:0 desc:标签【多个逗号隔开】
- * @param name:cover type:string default:0 desc:封面【一张】
- * @param name:images type:string default:0 desc:图片【多张|隔开】
- * @param name:company type:string default:0 desc:公司名
- * @param name:company_logo type:string default:0 desc:公司logo
- */
- /**
- * @title 我的发布
- * @desc 我的发布
- * @author qc
- * @method GET
- * @url /api/Demand/getMyDemandList
- * @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:每页数
- * @return name:id type:int default:-- desc:需求id
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:需求
- * @return name:money type:float default:0 desc:价格【设计图没有,可以不传】
- * @return name:cover type:string default:0 desc:封面【一张】
- * @return name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- * @return name:label_name type:array default:-- desc:标签
- */
- public function getMyDemandList()
- {
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['user_id','=',$this->user_id];
- $title = input('get.title');
- if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
- $list = PlatformDemand::where($sel_where)
- ->field('id,title,status,cover,money,label,is_over,read_num')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$lv){
- $lv['label_name'] = $lv['label'] ? explode(',',trim($lv['label'],',')) : null;
- $lv['is_normal'] = CheckPower::checkModulesPower($lv['id'],0,$this->request->controller());
- }
- $total_num = PlatformDemand::where($sel_where)->order('id desc')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的点赞列表【需求】
- * @desc 我的点赞
- * @author qc
- * @method GET
- * @url /api/Demand/getTagsDemand
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:content type:string default:-- desc:内容
- * @return name:company type:string default:-- desc:公司
- * @return name:company_logo type:string default:-- desc:公司logo
- * @return name:money type:string default:-- desc:价格
- * @return name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:praise_num type:int default:-- desc:点赞数量
- * @return name:is_praise type:int default:-- desc:是否点赞(0否1是)
- * @return name:is_collect type:int default:-- desc:是否收藏(0否1是)
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:comment_num type:int default:-- desc:评论数量
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:transmit_num type:string default:-- desc:转发量
- * @return name:create_at type:string default:-- desc:发布时间
- * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- *
- */
- public function getTagsDemand()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',9];
- $list = PlatformLike::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,i.read_num,i.transmit_num,t.like_id demand_id,i.title,i.cover,i.user_id buid,i.content,company,money,is_over,company_logo,t.user_id,i.comment_switch')
- ->leftJoin('PlatformDemand i','t.like_id = i.id')
- ->order('i.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $v['praise_num'] = PlatformLike::getPraiseNum($v['demand_id'],9);
- $v['is_praise'] = PlatformLike::checkTags($this->user_id, $v['demand_id'], 9);
- $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,10,$v['demand_id']);
- $v['collect_num'] = UserCollect::getCollectNum(10,$v['demand_id']);
- $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['demand_id'],12);
- $v['comment_num'] = DemandComment::getCommentNum($v['demand_id']);
- $v['read_num'] = numTransform($v['read_num']);
- $v['transmit_num'] = numTransform($v['transmit_num']);
- $auth_info = PlatformDemand::getAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $auth_info['app_name'];
- $v['app_logo'] = $auth_info['app_logo'];
- });
- $total_num = PlatformLike::where($sel_where)->alias('t')->leftJoin('PlatformDemand i','t.like_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的浏览历史【需求】
- * @desc 我的浏览历史
- * @author qc
- * @method GET
- * @url /api/Demand/getDemandTrack
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:content type:string default:-- desc:内容
- * @return name:company type:string default:-- desc:公司
- * @return name:company_logo type:string default:-- desc:公司logo
- * @return name:money type:string default:-- desc:价格
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- * @return name:time type:string default:-- desc:时间
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getDemandTrack()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',11];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $list = UserTrack::where($sel_where)
- ->alias('t')
- ->field('t.id,t.update_int,t.first_id demand_id,i.title,i.cover,i.content,company,money,is_over,company_logo,i.user_id,i.read_num')
- ->leftJoin('PlatformDemand 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",$v['update_int']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $auth_info = PlatformDemand::getAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $auth_info['app_name'];
- $v['app_logo'] = $auth_info['app_logo'];
- $v['read_num'] = numTransform($v['read_num']);
- }
- $total_num = UserTrack::where($sel_where)->alias('t')->leftJoin('PlatformDemand i','t.first_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的收藏【需求】
- * @desc 我的收藏
- * @author qc
- * @method GET
- * @url /api/Demand/getCollectDemand
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:content type:string default:-- desc:内容
- * @return name:money type:string default:-- desc:价格
- * @return name:user_id type:string default:-- desc:会员id
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:is_over type:int default:-1 desc:是否解决或开源【0否,1是,2开源】
- * @return name:praise_num type:string default:-- desc:点赞数量
- * @return name:is_praise type:string default:-- desc:是否点赞(0否1是)
- * @return name:collect_num type:string default:-- desc:收藏量
- * @return name:comment_num type:string default:-- desc:评论数量
- * @return name:transmit_num type:string default:-- desc:转发量
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getCollectDemand()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.coll_type','=',10];
- $list = UserCollect::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.coll_id demand_id,i.title,i.cover,i.content,company,money,is_over,company_logo,i.user_id,i.transmit_num,i.read_num')
- ->leftJoin('PlatformDemand i','t.coll_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['read_num'] = numTransform($v['read_num']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $auth_info = PlatformDemand::getAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $auth_info['app_name'];
- $v['app_logo'] = $auth_info['app_logo'];
- $v['praise_num'] = PlatformLike::getPraiseNum($v['demand_id'],9);
- $v['is_praise'] = PlatformLike::checkTags($this->user_id, $v['demand_id'], 9);
- $v['collect_num'] = UserCollect::getCollectNum(10,$v['demand_id']);
- $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['demand_id'],12);
- $v['comment_num'] = DemandComment::getCommentNum($v['demand_id']);
- });
- $total_num = UserCollect::where($sel_where)->alias('t') ->leftJoin('PlatformDemand i','t.coll_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的评论
- * @desc 我的评论
- * @author qc
- * @method GET
- * @url /api/Demand/getMyDemandComment
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:content type:string default:-- desc:评论内容
- * @return name:cover type:string default:-- desc:封面
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:create_at type:string default:-- desc:时间
- * @return name:user_name type:string default:-- desc:用户名【用户自己的】
- * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getMyDemandComment()
- {
- $title = input('get.title');
- $where = [];
- $where[] = ['t.is_deleted','=',0];
- $where[] = ['t.type','=',1];
- $where[] = ['t.user_id','=',$this->user_id];
- $where[] = ['t.pid','=',0];
- if($title) $where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $list = DemandComment::where($where)
- ->alias('t')
- ->field('t.id,t.is_top,t.create_at,t.first_id demand_id,i.is_over,t.content,i.title,i.cover,i.user_id,u.name user_name,u.headimg,i.read_num')
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->leftJoin('store_member u','u.id = t.user_id')
- ->order('t.is_top desc , id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $v['read_num'] = numTransform($v['read_num']);
- $auth_info = PlatformDemand::getAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $auth_info['app_name'];
- $v['app_logo'] = $auth_info['app_logo'];
- });
- $total_num = DemandComment::where($where)
- ->alias('t')->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->leftJoin('store_member u','u.id = t.user_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取角标数量
- * @desc 获取角标数量
- * @author qc
- * @method GET
- * @url /api/Demand/getMarkNum
- * @header name:Authorization require:1 desc:Token
- * @return name:comment_num type:int default:-- desc:评论我的
- * @return name:reply_num type:int default:-- desc:回复我的
- * @return name:praise_demand type:int default:-- desc:点赞我的--需求
- * @return name:praise_num type:int default:-- desc:点赞我的--评论
- * @return name:praise_comment type:int default:-- desc:点赞我的--需求+评论
- * @return name:total_num type:int default:-- desc:总数【comment_num+reply_num】
- */
- public function getMarkNum()
- {
- // 评论我的
- $comment_num = DemandComment::where([['t.is_deleted','=',0],['t.user_id','<>',$this->user_id],['t.pid','=',0],['i.user_id','=',$this->user_id],['is_read','=',0]])
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->alias('t')->count();
- // 回复我的
- $all_comment = DemandComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- $reply_num = DemandComment::where([['t.is_deleted','=',0],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count();
- $total_num = $comment_num + $reply_num ;
- $praise_demand = PlatformLike::where([['p.type', '=', 9],['f.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0],['p.user_id','<>',$this->user_id]])->alias('p') ->leftJoin('PlatformDemand f', 'f.id = p.like_id')->count();
- $praise_comment = PlatformLike::where([['p.type', '=', 6],['c.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0],['p.user_id','<>',$this->user_id]])->alias('p')->leftJoin('DemandComment c', 'c.id = p.like_id')->count();
- $praise_num = $praise_demand + $praise_comment;
- $this->success('ok',compact(['comment_num','reply_num','total_num','praise_num','praise_comment','praise_demand']));
- }
- /**
- * @title 消息已读
- * @desc 消息已读
- * @author qc
- * @method POST
- * @url /api/Demand/unreadChange
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部])
- * @param name:type type:string default:1 desc:消息类型【1评论我的,2回复我的,3点赞我的--需求,4点赞我的--评论】
- * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
- */
- public function unreadChange()
- {
- $type = input('post.type',1);
- $id = input('post.id');
- $is_read = input('post.is_read');
- switch ($type) {
- case 1:
- DemandComment::where([['i.user_id','=',$this->user_id]])
- ->when($id ,function ($query)use ($id){
- if($id) return $query->where('t.id','in',$id);
- })->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->alias('t') ->update(['source_read'=>$is_read,'is_read'=>$is_read]);
- break;
- case 2:
- $all_comment = DemandComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- DemandComment::where([['t.pid','in',implode(',',$all_comment)]])
- ->when($id ,function ($query)use ($id){
- if($id) return $query->where('t.id','in',$id);
- })->alias('t')->update(['is_read'=>$is_read]);
- break;
- case 3:
- $ids = PlatformLike::where([['p.type', '=', 9],['f.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0],['p.user_id','<>',$this->user_id]])->alias('p')->leftJoin('PlatformDemand f', 'f.id = p.like_id')->column('p.id');
- PlatformLike::where('id','in' ,$ids )->update(['is_read'=>1]);
- break;
- case 4:
- $ids2 = PlatformLike::where([['p.type', '=', 6],['c.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0],['p.user_id','<>',$this->user_id]])->alias('p')->leftJoin('DemandComment c', 'c.id = p.like_id')->column('p.id');
- PlatformLike::where('id','in' , $ids2)->update(['is_read'=>1]);
- break;
- }
- $this->success('消息变更成功');
- }
- /**
- * @title 评论我的
- * @desc 评论我的
- * @author qc
- * @method GET
- * @url /api/Demand/commentMyDemand
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:string default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:content type:string default:-- desc:评论内容
- * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:demand_content type:string default:-- desc:需求内容【简介】
- * @return name:create_at type:string default:-- desc:时间
- * @return name:user_name type:string default:-- desc:用户名
- * @return name:headimg type:string default:-- desc:用户头像
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:is_over type:int default:-- desc:是否解决或开源【0待解决,1已解决,2开源】
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- */
- public function commentMyDemand()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['t.to_deleted','=',0];
- $sel_where[] = ['i.user_id','=',$this->user_id];
- $sel_where[] = ['t.user_id','<>',$this->user_id];
- $sel_where[] = ['t.pid','=',0];
- $list = DemandComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.is_top,t.create_at,t.is_read,i.is_over,i.read_num,i.user_id,t.first_id demand_id,t.content,i.title,i.cover,i.content demand_content,u.name user_name,u.headimg')
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->order('t.is_top,t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $v['read_num'] = numTransform($v['read_num']);
- $auth_info = PlatformDemand::getAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $auth_info['app_name'];
- $v['app_logo'] = $auth_info['app_logo'];
- });
- $total_num = DemandComment::where($sel_where)->alias('t') ->leftJoin('PlatformDemand i','t.first_id = i.id')->leftJoin('store_member u','t.user_id = u.id')->count();
- $this->success('ok',['list'=>$list,'user_id'=>$this->user_id,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 点赞我的--需求
- * @desc 点赞我的--需求
- * @author qc
- * @method GET
- * @url /api/Demand/praiseMyDemand
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- * @return name:id type:int default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:create_at type:string default:-- desc:时间
- * @return name:cover type:string default:-- desc:封面
- * @return name:read_num type:int default:-- desc:阅读量
- * @return name:is_over type:int default:-- desc:是否解决或开源【0待解决,1已解决,2开源】
- * @return name:user_name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:详情
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- */
- public function praiseMyDemand()
- {
- $user_info = $this->userInfo('name,headimg');
- $sel_where = [];
- $sel_where[] = ['p.type', '=', 9];
- $sel_where[] = ['f.user_id', '=', $this->user_id];
- $sel_where[] = ['p.to_deleted', '=', 0];
- $list = PlatformLike::where($sel_where)
- ->field('p.*,f.title,u.name user_name,u.headimg,f.images,f.read_num,f.content,f.is_over,f.cover')
- ->alias('p')
- ->leftJoin('PlatformDemand f', 'f.id = p.like_id')
- ->leftJoin('StoreMember u', 'u.id = p.user_id')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list, function (&$v) use ($user_info){
- $v['is_normal'] = CheckPower::checkModulesPower($v['like_id'], 0, $this->request->controller());
- $v['app_name'] = $user_info['name'];
- $v['app_logo'] = $user_info['headimg'];
- $v['read_num'] = numTransform($v['read_num']);
- });
- $total_num = PlatformLike::where($sel_where)->alias('p')->leftJoin('PlatformDemand f', 'f.id = p.like_id')->leftJoin('StoreMember u', 'u.id = p.user_id')->count();
- $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
- }
- /**
- * @title 点赞我的--评论
- * @desc 点赞我的
- * @author qc
- * @method GET
- * @url /api/Demand/praiseCommentList
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- * @return name:id type:int default:-- desc:记录id
- * @return name:demand_id type:int default:-- desc:需求id
- * @return name:title type:string default:-- desc:需求标题
- * @return name:create_at type:string default:-- desc:时间
- * @return name:user_name type:string default:-- desc:会员名称【点赞人的】
- * @return name:headimg type:string default:-- desc:会员头像【点赞人的】
- * @return name:self_name type:string default:-- desc:用户名称【自己的】
- * @return name:content type:string default:-- desc:评论内容
- * @return name:is_over type:int default:-- desc:是否解决或开源【0待解决,1已解决,2开源】
- * @return name:demand_content type:string default:-- desc:需求内容
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:read_num type:int default:-- desc:阅读量
- * @return name:images type:string default:-- desc:图片多张|隔开
- * @return name:images_arr type:array default:-- desc:图片多张[数组]
- * @return name:comment_normal type:int default:-- desc:评论是否正常
- */
- public function praiseCommentList()
- {
- $user_info = $this->userInfo('name,headimg');
- $list = PlatformLike::where([['l.type','=',6],['c.user_id','=',$this->user_id],['l.to_deleted','=',0]])
- ->alias('l')
- ->field('l.id,l.user_id,m.name user_name,m.headimg,c.is_deleted,c.to_deleted,c.source_deleted,l.create_at,v.images,c.first_id demand_id,v.user_id buid,v.title,v.read_num,c.content,v.content demand_content,v.comment_switch,v.is_over,v.cover')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('DemandComment c','c.id = l.like_id')
- ->leftJoin('PlatformDemand v','v.id = c.first_id')
- ->order('l.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v,$k)use ($user_info){
- $info_auth = PlatformDemand::getAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $info_auth['app_name'];
- $v['app_logo'] = $info_auth['app_logo'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $v['read_num'] = numTransform($v['read_num']);
- $v['self_name'] = $user_info['name'];
- $v['comment_normal'] = $v['to_deleted'] || $v['is_deleted'] || $v['source_deleted'] ? 0 : 1;
- });
- $total_num = PlatformLike::where([['l.type','=',6],['c.user_id','=',$this->user_id],['l.to_deleted','=',0]])->alias('l')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('DemandComment c','c.id = l.like_id')
- ->leftJoin('PlatformDemand v','v.id = c.first_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 批量删除||批量取消
- * @desc 删除||取消
- * @author qc
- * @method POST
- * @url /api/Demand/batchesDel
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
- * @param name:type type:string default:1 desc:消息类型【1点赞我的,2我的评论,3回复我的,4评论我的,5我的点赞,6我的收藏,7我的回复】
- */
- public function batchesDel()
- {
- $type = input('post.type',1);
- $id = input('post.id');
- if(!$id) $this->error('请选择要删除的记录');
- $del_where = [];
- $del_where[] = ['id','in',$id];
- if(in_array($type,[1])) PlatformLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
- if(in_array($type,[2])) DemandComment::where($del_where)->where(['user_id'=>$this->user_id])->update(['is_deleted'=>1]);
- if(in_array($type,[3,4])) DemandComment::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
- if(in_array($type,[5])) PlatformLike::where($del_where)->where('user_id',$this->user_id)->delete();
- if(in_array($type,[6])) UserCollect::where($del_where)->where('user_id',$this->user_id)->where('coll_type',10)->delete();
- if(in_array($type,[7])) DemandComment::where($del_where)->where('user_id',$this->user_id)->update(['source_deleted'=>1]);
- $this->success('删除成功');
- }
- /**
- * @title 回复我的【回复我的--回复过我的评论】
- * @desc 回复我的
- * @author qc
- * @method GET
- * @url /api/Demand/getReplyComment
- * @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:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:封面
- * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:self_name type:string default:-- desc:用户名称【自己的】
- * @return name:user_name type:string default:-- desc:用户名【其他会员】
- * @return name:headimg type:string default:-- desc:用户头【其他会员】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:parent_comment type:array default:-- desc:你的评论内容【别人回复的那个评论】
- * @return name:parent_comment.content type:string default:-- desc:内容
- * @return name:parent_comment.name type:string default:-- desc:会员名称
- * @return name:parent_comment.title type:string default:-- desc:标题
- * @return name:parent_comment.demand_id type:string default:-- desc:需求id
- * @return name:parent_comment.app_name type:string default:-- desc:发布方名称
- * @return name:parent_comment.app_logo type:string default:-- desc:发布方头像
- * @return name:parent_comment.read_num type:string default:-- desc:阅读量
- * @return name:parent_comment.is_over type:int default:-- desc:是否解决或开源【0待解决,1已解决,2开源】
- */
- public function getReplyComment()
- {
- $all_comment = DemandComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- if(empty($all_comment)) $this->success('ok',['list'=>null,'total_count'=>0,'page_num'=>$this->page_num]);
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['t.lev','>=',2];
- $sel_where[] = ['t.to_deleted','=',0];
- $sel_where[] = ['t.user_id','<>',$this->user_id];
- $sel_where[] = ['t.pid','in',implode(',',$all_comment)];
- $list = DemandComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.is_top,t.is_read,t.create_at,t.first_id demand_id,t.lev,t.content,t.pid,u.name user_name,u.headimg,i.cover,i.images,i.read_num')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->order('t.is_top desc,t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['self_name'] = $this->user_info['name'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $parent_comment = DemandComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.first_id demand_id,t.is_top,t.content,i.title,i.is_over,i.cover,t.pid,u.name,i.user_id,i.read_num')
- ->alias('t')
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->find()->toArray();
- $v['images_arr'] = $v['images'] ? explode('|', $v['images']) : null;
- $parent_comment['images_arr'] =$v['images_arr'];
- $parent_comment['read_num'] = numTransform($v['read_num']);
- $info_auth = PlatformDemand::getAuth($parent_comment['user_id'],APPNAME,APPLOGO);
- $parent_comment['app_name'] = $info_auth['app_name'];
- $parent_comment['app_logo'] = $info_auth['app_logo'];
- $v['parent_comment'] = $parent_comment;
- }
- $total_num = DemandComment::where($sel_where)->alias('t')->leftJoin('store_member u','t.user_id = u.id')->leftJoin('PlatformDemand i','t.first_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 需求转发(转发数量统计)
- * @desc 转发成功后调用
- * @author qc
- * @method POST
- * @url /api/Demand/demandTransmit
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:需求id
- */
- public function demandTransmit()
- {
- $demand_id = input('post.id',0);
- PlatformDemand::where('id',$demand_id)->setInc('transmit_num');
- $this->success('ok');
- }
- /**
- * @title 我的点赞--评论
- * @desc 评论点赞列表
- * @author qc
- * @method GET
- * @url /api/Demand/getTagsComment
- * @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:create_at type:string default:-- desc:时间
- * @return name:self_name type:string default:-- desc:会员名称【自己的】
- * @return name:self_headimg type:string default:-- desc:会员头像【自己的】
- * @return name:comment_user type:string default:-- desc:会员名称【评论人】
- * @return name:content type:string default:-- desc:评论内容
- * @return name:cover type:string default:-- desc:封面
- * @return name:title type:string default:-- desc:标题
- * @return name:read_num type:string default:-- desc:浏览量
- * @return name:like_id type:int default:-- desc:评论的id
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- */
- public function getTagsComment()
- {
- $list = PlatformLike::field('l.id,l.like_id,c.content,g.read_num,g.cover,u.name comment_user,g.is_over,g.user_id,l.create_at,g.title,g.id demand_id,c.user_id cuid')
- ->alias('l')
- ->where(['l.user_id'=>$this->user_id,'l.type'=>6])
- ->where('c.user_id','<>',$this->user_id)
- ->leftJoin('DemandComment c','l.like_id = c.id')
- ->leftJoin('PlatformDemand g','g.id = c.first_id')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order('l.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- $user_info = $this->userInfo();
- foreach ($list as &$v) {
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $auth_info = PlatformDemand::getAuth($v['user_id'],APPNAME,APPLOGO);
- $user_infos = User::where('id',$v['cuid'])->field('name,headimg')->find();
- $v['app_name'] = $auth_info['app_name'];
- $v['app_logo'] = $auth_info['app_logo'];
- $v['read_num'] = numTransform($v['read_num']);
- // 把self_headimg和self_name 删掉,
- // 返回评论人的headimg和
- $v['user_name'] = $user_infos['name'];
- $v['headimg'] = $user_infos['headimg'];
- }
- $total_num = PlatformLike::where(['l.user_id'=>$this->user_id,'l.type'=>6])
- ->alias('l')
- ->where('c.user_id','<>',$this->user_id)
- ->leftJoin('DemandComment c','l.like_id = c.id')
- ->leftJoin('PlatformDemand g','g.id = c.first_id')
- ->leftJoin('store_member u','u.id = c.user_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的回复【我的回复--我回复过的评论】
- * @desc 我的回复
- * @author qc
- * @method GET
- * @url /api/Demand/getReplyDemand
- * @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:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:demand_id type:int default:-- desc:需求id
- * @return name:cover type:string default:-- desc:封面
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:user_name type:string default:-- desc:用户名【用户自己的】
- * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
- * @return name:parent_comment type:array default:-- desc:上级评论内容【你评论的那个评论】
- * @return name:parent_comment.content type:string default:-- desc:内容
- * @return name:parent_comment.name type:string default:-- desc:会员名称
- * @return name:parent_comment.title type:string default:-- desc:标题
- * @return name:parent_comment.demand_id type:string default:-- desc:需求id
- * @return name:parent_comment.app_name type:string default:-- desc:发布方名称
- * @return name:parent_comment.app_logo type:string default:-- desc:发布方头像
- * @return name:parent_comment.read_num type:string default:-- desc:阅读量
- * @return name:parent_comment.is_over type:int default:-- desc:是否解决或开源【0否,1是,2开源】
- */
- public function getReplyDemand()
- {
- $user_info = $this->userInfo();
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['t.source_deleted','=',0];
- $sel_where[] = ['t.lev','>=',2];
- $sel_where[] = ['t.pid','>',0];
- $list = DemandComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.is_top,t.create_at,t.first_id demand_id,t.lev,t.content,t.pid,i.title,i.cover,read_num,i.is_over')
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->order('t.is_top,t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['user_name'] = $user_info['name'];
- $v['headimg'] = $user_info['headimg'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['demand_id'],0,$this->request->controller());
- $parent_comment = DemandComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.is_top,t.first_id demand_id,t.content,i.title,i.cover,t.pid,u.name,i.read_num,i.user_id,i.is_over')->alias('t')
- ->leftJoin('PlatformDemand i','t.first_id = i.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->find()->toArray();
- $parent_comment['read_num'] = numTransform($v['read_num']);
- $info_auth = PlatformDemand::getAuth($parent_comment['user_id'],APPNAME,APPLOGO);
- $parent_comment['app_name'] = $info_auth['app_name'];
- $parent_comment['app_logo'] = $info_auth['app_logo'];
- $v['parent_comment'] = $parent_comment;
- }
- $total_num = DemandComment::where($sel_where)->alias('t') ->leftJoin('PlatformDemand i','t.first_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- }
|