Article.php 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\ArticleCate;
  4. use app\common\model\ArticleComment;
  5. use app\common\model\ArticleCommentLike;
  6. use app\common\model\ArticleIntro;
  7. use app\common\model\ArticleItem;
  8. use app\common\model\ArticleLike;
  9. use app\common\model\DatumUrl;
  10. use app\common\model\PlatformSwitch;
  11. use app\common\model\SeriesArticleCate;
  12. use app\common\model\TopSearch;
  13. use app\common\model\User;
  14. use app\common\model\UserCollect;
  15. use app\common\model\UserArticle;
  16. use app\common\model\UserLearn;
  17. use app\common\model\UserLevelRank;
  18. use app\common\model\UserMessage;
  19. use app\common\model\UserSearch;
  20. use app\common\model\UserTag;
  21. use app\common\model\UserTrack;
  22. use app\common\model\VideoUrl;
  23. use app\common\service\CheckPower;
  24. use app\common\service\UserSynth;
  25. use library\tools\Data;
  26. use think\Db;
  27. use think\db\Query;
  28. /**
  29. * @title 图文
  30. * @controller Article
  31. * @group base
  32. */
  33. class Article extends Base
  34. {
  35. // 需要登录的
  36. protected $need_login = [
  37. 'articleTransmit',
  38. 'articleRead',
  39. 'articleTags',
  40. 'articleComment',
  41. 'delComment',
  42. 'secondCommend',
  43. 'commentTags',
  44. 'articleCollect',
  45. 'userReferArticle',
  46. 'getMyArticleList',
  47. 'getUserArticleDetail',
  48. 'delUserArticle',
  49. 'delComment',
  50. 'getLearnHistory',
  51. 'getArticleCollect',
  52. 'getCommentArticle',
  53. 'commentMyArticle',
  54. 'getPurchaseArticle',
  55. 'getReplyArticle',
  56. 'getReplyComment',
  57. 'getTagsArticle',
  58. 'getBoundList',
  59. 'getFollowUpList',
  60. 'getFollowUpMessage',
  61. 'getTagsComment',
  62. 'getMarkNum',
  63. 'unreadChange',
  64. 'batchesDel',
  65. 'getArticleDetail', //1.5新增
  66. 'getArticleDetail2', //1.5新增
  67. 'getArticleItemInfo' //1.5新增
  68. ];
  69. public function initialize()
  70. {
  71. parent::initialize();
  72. parent::setUid();
  73. $this->source_type= $this->request->header('source-type',1);
  74. }
  75. /**
  76. * @title 图文接口说明
  77. * @desc 图文接口说明
  78. * @author qc
  79. * @url /api/Article/classIntro
  80. * @method GET
  81. * @return name:1 type:string default:-- desc:图片(images字段)多图片都用竖线(|)隔开,会员上传多张也用(|)隔开
  82. * @return name:2 type:string default:-- desc:cover字段值是images的第一个路径【非多张】
  83. * @return name:3 type:string default:-- desc:单一图文与系列图文区别,type值(1是单一,2是系列),数据:item_list二维数组数据数量不一样(单一的只有一个,系列的可以是多个)【可以将单一图文看做只有一条记录的系列图文!!!!】
  84. * @return name:4 type:string default:-- desc:单一图文详情的字段(cover,images,is_vip,title)与item_list数组的第一个同字段名的值相同
  85. * @return name:5 type:string default:-- desc:系列图文详情的字段(cover,images)与item_list的其中一个相同
  86. * @return name:6 type:string default:-- desc:关于是否的字段(0否,1是)
  87. * @return name:7 type:string default:-- desc:item_id是数组item_list下的id
  88. */
  89. public function classIntro(){}
  90. /**
  91. * @title 获取图文分类
  92. * @desc 获取图文分类
  93. * @author qc
  94. * @url /api/Article/getArticleCate
  95. * @method GET
  96. * @header name:Authorization require:1 desc:Token
  97. * @param name:type type:int default:2 desc:类型2系列
  98. * @return name:id type:int default:-- desc:分类id
  99. * @return name:logo type:string default:-- desc:图标
  100. * @return name:title type:string default:0 desc:分类名称
  101. * @return name:children type:array default:0 desc:下级分类
  102. */
  103. public function getArticleCate()
  104. {
  105. $type = input('type',2);
  106. if($type == 1) {
  107. $list = ArticleCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc')->select()->toArray();
  108. }else{
  109. $list = SeriesArticleCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc')->select()->toArray();
  110. }
  111. $list = make_tree($list);
  112. foreach ($list as &$v) {
  113. if(empty($v['children']))$v['children'] = null;
  114. }
  115. $this->success('ok',['list'=>$list]);
  116. }
  117. /**
  118. * @title 图文推荐
  119. * @desc 图文推荐
  120. * @author qc
  121. * @method GET
  122. * @url /api/Article/getRecommendList
  123. * @header name:Authorization require:1 desc:Token
  124. * @param name:page type:int default:0 desc:页数
  125. * @param name:page_num type:int default:20 desc:每页数
  126. * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
  127. * @return name:id type:string default:-- desc:图文item_id
  128. * @return name:title type:string default:-- desc:标题
  129. * @return name:create_at type:string default:-- desc:时间
  130. * @return name:article_id type:string default:-- desc:系列id
  131. * @return name:cover type:string default:-- desc:封面
  132. * @return name:images_arr type:string default:-- desc:图片
  133. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  134. * @return name:read_num type:int default:-- desc:阅读量
  135. * @return name:app_name type:string default:-- desc:发布者名称
  136. * @return name:app_logo type:string default:-- desc:发布者头像
  137. * @return name:author type:string default:-- desc:原创作者
  138. * @return name:content_type type:int default:1 desc:1富文本2pdf
  139. * @return name:pdf type:string default:-- desc:pdf文件路径
  140. * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
  141. * @return name:release_time type:string default:-- desc:上架时间
  142. * @return name:desc type:string default:-- desc:简介
  143. * @return name:like_num type:int default:-- desc:点赞量
  144. * @return name:is_like type:int default:-- desc:是否点赞
  145. * @return name:collect_num type:int default:-- desc:收藏量
  146. * @return name:is_collect type:int default:-- desc:是否收藏
  147. */
  148. public function getRecommendList()
  149. {
  150. $user_id = $this->user_id ? $this->user_id : input('rand_user');
  151. if(!$user_id) $this->error('参数错误');
  152. $list = UserSynth::getRecommendList($user_id,'article',$this->page,$this->page_num);
  153. if($list['code'] != 200) $this->error($list['msg']);
  154. $this->success('ok',$list);
  155. $search_log = UserSearch::getSearchTitle($this->user_id,2);
  156. $search_arr = [];
  157. $where_str = 'b.id > 0';
  158. foreach ($search_log as $t){
  159. $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
  160. $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
  161. }
  162. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  163. $field = ' a.id,a.title,a.cover,a.content_type,a.pdf,a.images,a.create_at,a.user_id,a.is_vip,a.read_num,a.article_id ,a.author,IFNULL(is_recommend,0) is_recommend ';
  164. $table = 'dd_article_item';
  165. $order_by_two = 'a.read_num';
  166. $time_str = date("Y-m-d H:i:s");
  167. $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_article_intro as k ON k.id = a.article_id WHERE a.is_deleted = 0 AND a.release_time < '". $time_str ."' 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}";
  168. $list = Db::query($sql);
  169. $list = dispose_recommend($list);
  170. array_walk($list,function (&$v,$k){
  171. $v['read_num'] = numTransform($v['read_num']);
  172. $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
  173. $v['app_name'] = $article_auth['app_name'];
  174. $v['app_logo'] = $article_auth['app_logo'];
  175. $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
  176. $v['create_at'] = substr($v['create_at'],0,10);
  177. $v['is_release'] = UserLearn::checkRelease($this->user_id,3,$v['id']);
  178. });
  179. $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 LEFT JOIN dd_article_intro as k ON k.id = a.article_id WHERE a.is_deleted = 0 AND a.release_time < '". $time_str ."' AND a.status =1 AND k.status = 1 AND k.is_deleted = 0 ";
  180. $total = Db::query($sql2);
  181. $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
  182. }
  183. /**
  184. * @title 获取图文列表(平台发布)
  185. * @desc 获取图文列表
  186. * @author qc
  187. * @method GET
  188. * @url /api/Article/getArticleList
  189. * @header name:Authorization require:1 desc:Token
  190. * @param name:title type:string default:-- desc:标题
  191. * @param name:page type:int default:0 desc:页数
  192. * @param name:page_num type:int default:20 desc:每页数
  193. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  194. * @param name:first_classify type:int default:0 desc:一级分类
  195. * @param name:second_classify type:int default:0 desc:二级分类
  196. * @return name:id type:string default:-- desc:ID[请求/api/Article/getArticleDetail用]
  197. * @return name:title type:string default:-- desc:标题
  198. * @return name:type type:int default:0 desc:类型1单个2系列
  199. * @return name:cover type:string default:-- desc:封面()
  200. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  201. * @return name:is_over type:int default:-- desc:是否完结(0否,1是)
  202. * @return name:read_num type:int default:-- desc:阅读量
  203. * @return name:label type:string default:-- desc:标签
  204. * @return name:recently_title type:string default:-- desc:上次观看标题
  205. * @return name:item_list type:array default:-- desc:图文
  206. * @return name:item_list.title type:string default:-- desc:图文标题
  207. * @return name:item_list.is_vip type:int default:-- desc:是否是vip
  208. * @return name:item_list.cover type:string default:-- desc:图文封面
  209. * @return name:item_list.images type:string default:-- desc:图片(多张用|隔开)
  210. * @return name:item_list.content type:string default:-- desc:内容
  211. * @return name:item_list.app_name type:string default:-- desc:发布方名称
  212. * @return name:item_list.app_logo type:string default:-- desc:发布方头像
  213. * @return name:item_list.content_type type:int default:1 desc:1富文本2pdf
  214. * @return name:item_list.pdf type:string default:-- desc:pdf文件路径【加密】
  215. * @return name:item_list.pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
  216. */
  217. public function getArticleList()
  218. {
  219. $sel_where = [];
  220. $title = input('get.title');
  221. $type = input('get.type',2);
  222. $is_tj = input('get.is_tj',0);
  223. $sort_type = input('get.sort_type',1);
  224. $first_classify = input('get.first_classify');
  225. $second_classify = input('get.second_classify');
  226. $sel_where[] = ['is_deleted','=',0];
  227. $sel_where[] = ['status','=',1];
  228. $sel_where[] = ['item_num','>',0];
  229. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  230. if($type) $sel_where[] = ['type','=',$type];
  231. if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
  232. if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
  233. switch ($sort_type) {
  234. case 1:
  235. $order = ['sort'=>'desc','read_num'=>'desc'];
  236. break;
  237. case 2:
  238. $order = ['id'=>'asc','sort'=>'desc'];
  239. break;
  240. case 3:
  241. $order = ['id'=>'desc','sort'=>'desc'];
  242. break;
  243. }
  244. if($title && $this->user_id)UserSearch::saveSearchTitle($this->user_id,$title,2);
  245. $where_str = 'id > 0';
  246. $list = ArticleIntro::where($sel_where)->with('itemList2')
  247. ->limit($this->off_set,$this->page_num)
  248. ->where($where_str)
  249. ->order($order)
  250. ->select()->toArray();
  251. array_walk($list,function (&$v,$k){
  252. $v['item_list'] = $v['item_list2'];
  253. $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$v['id']);
  254. $v['recently_title'] = ArticleItem::where('id',$recently_id)->value('title');
  255. unset($v['item_list2']);
  256. $v['read_num']= array_sum(array_column($v['item_list'],'read_num'));
  257. $v['read_num'] = numTransform($v['read_num']);
  258. $v['cate'] = SeriesArticleCate::where('id',$v['second_classify'])->value('title');
  259. unset($v['content']);
  260. foreach ($v['item_list'] as &$iv) {
  261. //unset($iv['content']);
  262. if(in_array($this->source_type,[1])) unset($iv['pdf_clear']);
  263. $iv['read_num'] = numTransform($iv['read_num']);
  264. $article_auth = ArticleItem::getArticleAuth($iv['user_id'],APPNAME,APPLOGO);
  265. $iv['app_name'] = $article_auth['app_name'];
  266. $iv['app_logo'] = $article_auth['app_logo'];
  267. }
  268. });
  269. $total_num = ArticleIntro::where($sel_where) ->where($where_str)->count();
  270. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  271. }
  272. /**
  273. * @title 获取系列列表
  274. * @desc 获取系列列表
  275. * @author qc
  276. * @method GET
  277. * @url /api/Article/getSeriesList
  278. * @header name:Authorization require:1 desc:Token
  279. * @param name:first_classify type:int default:0 desc:一级分类
  280. * @param name:second_classify type:int default:0 desc:二级分类
  281. * @return name:second_classify type:int default:-- desc:二级分类
  282. * @return name:title type:int default:-- desc:二级分类名称
  283. * @return name:series_list type:array default:-- desc:系列列表
  284. * @return name:series_list.id type:string default:-- desc:系列id
  285. * @return name:series_list.title type:string default:-- desc:标题
  286. * @return name:series_list.cover type:string default:-- desc:封面
  287. * @return name:series_list.is_vip type:int default:-- desc:是否是vip(0否,1是)
  288. * @return name:series_list.is_over type:int default:-- desc:是否完结(0否,1是)
  289. */
  290. public function getSeriesList()
  291. {
  292. $type = input('get.type',2);
  293. $first_classify = input('get.first_classify');
  294. $second_classify = input('get.second_classify');
  295. $list = SeriesArticleCate::where(['is_deleted'=>0,'status'=>1])
  296. ->field('id second_classify,title')->where('pid',$first_classify)
  297. ->when($second_classify,function ($query)use ($second_classify){if($second_classify){$query->where('id',$second_classify);}})
  298. ->order('sort desc,id asc')->select()->toArray();
  299. foreach ($list as &$v) {
  300. $v['series_list'] = ArticleIntro::field('id,title,cover,is_vip,is_over,create_at')
  301. ->where('second_classify',$v['second_classify'])
  302. ->where('type',$type)
  303. ->where('status',1)
  304. ->where('is_deleted',0)
  305. ->where('item_num','>',0)
  306. ->limit($this->off_set,100)
  307. ->order('sort desc,id desc')->select()->toArray();
  308. }
  309. $this->success('ok',['list'=>$list]);
  310. }
  311. /**
  312. * @title 获取图文系列详情(【系列的合集列表,含富文本】)
  313. * @desc 获取图文系列详情
  314. * @author qc
  315. * @method GET
  316. * @url /api/Article/getArticleDetail
  317. * @header name:Authorization require:1 desc:Token
  318. * @param name:id type:int default:0 desc:图文id
  319. * @param name:sort_type type:int default:1 desc:排序1默认2时间升序3时间降序
  320. * @return name:title type:string default:-- desc:系列标题
  321. * @return name:cover type:string default:-- desc:封面
  322. * @return name:images type:string default:-- desc:图片
  323. * @return name:is_vip type:string default:-- desc:是否VIP
  324. * @return name:user_level type:int default:-- desc:会员等级id
  325. * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
  326. * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
  327. * @return name:item_list type:array default:-- desc:图文
  328. * @return name:item_list.id type:string default:-- desc:[请求/api/Article/getArticleItemInfo用,请求图文模块其他接口参数:item_id]
  329. * @return name:item_list.title type:string default:-- desc:图文标题
  330. * @return name:item_list.switch_open type:int default:-- desc:通知开关【0关闭1开启】
  331. * @return name:item_list.is_vip type:int default:-- desc:是否是vip
  332. * @return name:item_list.cover type:string default:-- desc:封面
  333. * @return name:item_list.images type:int default:-- desc:图片
  334. * @return name:item_list.content type:int default:-- desc:内容
  335. * @return name:item_list.transmit_num type:int default:-- desc:转发量
  336. * @return name:item_list.read_num type:int default:-- desc:阅读量
  337. * @return name:item_list.comment_num type:int default:-- desc:评论量
  338. * @return name:item_list.desc type:int default:-- desc:简介
  339. * @return name:item_list.desc_text type:int default:-- desc:文本
  340. * @return name:item_list.collect_num type:int default:-- desc:收藏量
  341. * @return name:item_list.is_collect type:int default:-- desc:是否收藏
  342. * @return name:item_list.video_id type:int default:-- desc:关联视频id【系列id】
  343. * @return name:item_list.video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  344. * @return name:item_list.datum_id type:int default:-- desc:资料id【系列id】
  345. * @return name:item_list.datum_item type:int default:-- desc:资料详情id【url_arr.id】
  346. * @return name:item_list.goods_id type:int default:-- desc:供应商商品id
  347. * @return name:item_list.video_jump type:int default:-- desc:关联视频是否能跳转【0不能跳转,1能跳转,验证是否vip】
  348. * @return name:item_list.datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
  349. *
  350. * @return name:item_list.author type:string default:-- desc:原创作者
  351. * @return name:item_list.content_type type:int default:1 desc:1富文本2pdf
  352. * @return name:item_list.pdf type:string default:-- desc:pdf文件路径【加密】
  353. * @return name:item_list.pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
  354. * @return name:item_list.is_recently type:int default:-- desc:是否最近观看【0否1是】
  355. * @return name:item_list.like_num type:int default:-- desc:点赞量
  356. * @return name:item_list.is_like type:int default:-- desc:是否点赞
  357. * @return name:item_list.app_name type:string default:-- desc:发布者
  358. * @return name:item_list.app_logo type:string default:-- desc:发布者头像
  359. * @return name:item_list.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  360. * @return name:item_list.release_time type:string default:-- desc:上架时间
  361. *
  362. *
  363. */
  364. public function getArticleDetail()
  365. {
  366. $form = input('get.from','H5');
  367. $sel_where = [];
  368. $sel_where[] = ['id','=',input('get.id')];
  369. $sort_type = input('get.sort_type',1);
  370. $is_release = UserLearn::checkRelease($this->user_id,3,input('get.id'));
  371. $detail = ArticleIntro::where($sel_where)->with(['itemList3'=>function($query)use($sort_type,$is_release){
  372. switch ($sort_type) {
  373. case 1:
  374. $order = ['sort'=>'desc','id'=>'asc'];
  375. break;
  376. case 2:
  377. $order = ['id'=>'asc','sort'=>'desc'];
  378. break;
  379. case 3:
  380. $order = ['id'=>'desc','sort'=>'desc'];
  381. break;
  382. }
  383. //->force('item')
  384. return $is_release ? $query->field('id,article_id,create_at,is_vip,read_num,title,sort,user_id,status,release_time')->order($order) : $query->field('id,article_id,create_at,is_vip,read_num,title,sort,user_id,status,release_time')->where('status',1)->order($order);
  385. }])->find()->toArray();
  386. $detail['item_list'] = $detail['item_list3'];
  387. unset($detail['item_list3']);
  388. $detail['is_release'] = $is_release;
  389. if($is_release && $detail['is_deleted'] )$this->error('该图文已下线');
  390. if(!$detail['is_release'] && ($detail['is_deleted'] == 1 || $detail['status'] == 0))$this->error('该图文已下线');
  391. if(in_array($this->source_type,[1])) $detail['content'] = openssl_encrypt($detail['content'],'DES-ECB',123456,0);
  392. $detail['read_num'] = array_sum(array_column($detail['item_list'],'read_num'));
  393. $detail['read_num'] = numTransform($detail['read_num']);
  394. $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],3);
  395. $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$detail['id']);
  396. $level_id = UserLevelRank::getUserVip($this->user_id);
  397. $detail['user_level'] = $level_id;
  398. foreach ($detail['item_list'] as &$dv) {
  399. if(in_array($this->source_type,[1])) unset($dv['pdf_clear']);
  400. if(in_array($this->source_type,[1])) $dv['content'] = openssl_encrypt($dv['content'],'DES-ECB',123456,0);
  401. $dv['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$dv['id'],8);
  402. $dv['comment_num'] = ArticleComment::getArticleCommentNum($dv['id']);
  403. $dv['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
  404. $dv['collect_num'] = numTransform($dv['collect_num']);
  405. $dv['transmit_num'] = numTransform($dv['transmit_num']);
  406. $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['id'],$dv['id']);
  407. $dv['read_num'] = numTransform($dv['read_num']);
  408. $dv['is_recently'] = $dv['id'] == $recently_id ? 1 : 0;
  409. $dv['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
  410. $dv['like_num'] = ArticleLike::where(['article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
  411. $article_auth = ArticleItem::getArticleAuth($dv['user_id'],APPNAME,APPLOGO);
  412. $dv['app_name'] = $article_auth['app_name'];
  413. $dv['app_logo'] = $article_auth['app_logo'];
  414. $dv['video_jump'] = VideoUrl::checkVip($dv['video_item'],$this->user_id);
  415. $dv['datum_jump'] = DatumUrl::checkVip($dv['datum_item'],$this->user_id);
  416. }
  417. if($this->user_id){
  418. $General = new General();
  419. $General->label($detail['label']);
  420. }
  421. $this->success('ok',['detail'=>$detail]);
  422. }
  423. /**
  424. * @title 获取图文系列详情(【系列的合集列表,不含富文本】)
  425. * @desc 获取图文系列详情
  426. * @author qc
  427. * @method GET
  428. * @url /api/Article/getArticleDetail2
  429. * @header name:Authorization require:1 desc:Token
  430. * @param name:id type:int default:0 desc:图文id
  431. * @param name:sort_type type:int default:1 desc:排序1默认2时间升序3时间降序
  432. * @return name:title type:string default:-- desc:系列标题
  433. * @return name:cover type:string default:-- desc:封面
  434. * @return name:images type:string default:-- desc:图片
  435. * @return name:is_vip type:string default:-- desc:是否VIP
  436. * @return name:user_level type:int default:-- desc:会员等级id
  437. * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
  438. * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
  439. * @return name:item_list type:array default:-- desc:图文
  440. * @return name:item_list.id type:string default:-- desc:[请求/api/Article/getArticleItemInfo用,请求图文模块其他接口参数:item_id]
  441. * @return name:item_list.title type:string default:-- desc:图文标题
  442. * @return name:item_list.switch_open type:int default:-- desc:通知开关【0关闭1开启】
  443. * @return name:item_list.is_vip type:int default:-- desc:是否是vip
  444. * @return name:item_list.cover type:string default:-- desc:封面
  445. * @return name:item_list.images type:int default:-- desc:图片
  446. * @return name:item_list.content type:int default:-- desc:内容
  447. * @return name:item_list.transmit_num type:int default:-- desc:转发量
  448. * @return name:item_list.read_num type:int default:-- desc:阅读量
  449. * @return name:item_list.comment_num type:int default:-- desc:评论量
  450. * @return name:item_list.desc type:int default:-- desc:简介
  451. * @return name:item_list.desc_text type:int default:-- desc:文本
  452. * @return name:item_list.collect_num type:int default:-- desc:收藏量
  453. * @return name:item_list.is_collect type:int default:-- desc:是否收藏
  454. * @return name:item_list.video_id type:int default:-- desc:关联视频id【系列id】
  455. * @return name:item_list.video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  456. * @return name:item_list.datum_id type:int default:-- desc:资料id【系列id】
  457. * @return name:item_list.datum_item type:int default:-- desc:资料详情id【url_arr.id】
  458. * @return name:item_list.goods_id type:int default:-- desc:供应商商品id
  459. * @return name:item_list.video_jump type:int default:-- desc:关联视频是否能跳转【0不能跳转,1能跳转,验证是否vip】
  460. * @return name:item_list.datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
  461. * @return name:item_list.release_time type:string default:-- desc:上架时间
  462. * @return name:item_list.author type:string default:-- desc:原创作者
  463. * @return name:item_list.content_type type:int default:1 desc:1富文本2pdf
  464. * @return name:item_list.pdf type:string default:-- desc:pdf文件路径【加密】
  465. * @return name:item_list.pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
  466. * @return name:item_list.is_recently type:int default:-- desc:是否最近观看【0否1是】
  467. * @return name:item_list.like_num type:int default:-- desc:点赞量
  468. * @return name:item_list.is_like type:int default:-- desc:是否点赞
  469. * @return name:item_list.app_name type:string default:-- desc:发布者
  470. * @return name:item_list.app_logo type:string default:-- desc:发布者头像
  471. * @return name:item_list.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  472. */
  473. public function getArticleDetail2()
  474. {
  475. $form = input('get.from','H5');
  476. $sel_where = [];
  477. $sel_where[] = ['id','=',input('get.id')];
  478. $sort_type = input('get.sort_type',1);
  479. $is_release = UserLearn::checkRelease($this->user_id,3,input('get.id'));
  480. $detail = ArticleIntro::where($sel_where)->with(['itemList2'=>function($query)use($sort_type,$is_release){
  481. switch ($sort_type) {
  482. case 1:
  483. $order = ['sort'=>'desc','id'=>'asc'];
  484. break;
  485. case 2:
  486. $order = ['id'=>'asc','sort'=>'desc'];
  487. break;
  488. case 3:
  489. $order = ['id'=>'desc','sort'=>'desc'];
  490. break;
  491. }
  492. return $is_release ? $query->order($order) : $query->where('status',1)->order($order);
  493. }])->find()->toArray();
  494. $detail['item_list'] = $detail['item_list2'];
  495. unset($detail['item_list2']);
  496. $detail['is_release'] = $is_release;
  497. if($is_release && $detail['is_deleted'] )$this->error('该图文已下线');
  498. if(!$detail['is_release'] && ($detail['is_deleted'] == 1 || $detail['status'] == 0))$this->error('该图文已下线');
  499. $detail['read_num'] = array_sum(array_column($detail['item_list'],'read_num'));
  500. $detail['read_num'] = numTransform($detail['read_num']);
  501. $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],3);
  502. $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$detail['id']);
  503. $level_id = UserLevelRank::getUserVip($this->user_id);
  504. $detail['user_level'] = $level_id;
  505. foreach ($detail['item_list'] as &$dv) {
  506. if(in_array($this->source_type,[1])) unset($dv['pdf_clear']);
  507. $dv['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$dv['id'],8);
  508. $dv['comment_num'] = ArticleComment::getArticleCommentNum($dv['id']);
  509. $dv['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
  510. $dv['collect_num'] = numTransform($dv['collect_num']);
  511. $dv['transmit_num'] = numTransform($dv['transmit_num']);
  512. $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['id'],$dv['id']);
  513. $dv['read_num'] = numTransform($dv['read_num']);
  514. $dv['is_recently'] = $dv['id'] == $recently_id ? 1 : 0;
  515. $dv['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
  516. $dv['like_num'] = ArticleLike::where(['article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
  517. $article_auth = ArticleItem::getArticleAuth($dv['user_id'],APPNAME,APPLOGO);
  518. $dv['app_name'] = $article_auth['app_name'];
  519. $dv['app_logo'] = $article_auth['app_logo'];
  520. $dv['video_jump'] = VideoUrl::checkVip($dv['video_item'],$this->user_id);
  521. $dv['datum_jump'] = DatumUrl::checkVip($dv['datum_item'],$this->user_id);
  522. }
  523. if($this->user_id){
  524. $General = new General();
  525. $General->label($detail['label']);
  526. }
  527. $this->success('ok',['detail'=>$detail]);
  528. }
  529. /**
  530. * @title 获取图文ITEM详情(平台)
  531. * @desc 获取图文ITEM详情
  532. * @author qc
  533. * @method GET
  534. * @url /api/Article/getArticleItemInfo
  535. * @header name:Authorization require:1 desc:Token
  536. * @param name:item_id type:int default:0 desc:item_list
  537. * @return name:title type:string default:-- desc:图文标题
  538. * @return name:is_vip type:int default:-- desc:是否是vip
  539. * @return name:cover type:string default:-- desc:封面
  540. * @return name:images type:int default:-- desc:图片
  541. * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
  542. * @return name:content type:int default:-- desc:内容
  543. * @return name:transmit_num type:int default:-- desc:转发量
  544. * @return name:read_num type:int default:-- desc:阅读量
  545. * @return name:comment_num type:int default:-- desc:评论量
  546. * @return name:collect_num type:int default:-- desc:收藏量
  547. * @return name:is_collect type:int default:-- desc:是否收藏
  548. * @return name:like_num type:int default:-- desc:点赞量
  549. * @return name:is_like type:int default:-- desc:是否点赞
  550. * @return name:desc type:int default:-- desc:简介
  551. * @return name:desc_text type:int default:-- desc:文本
  552. * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
  553. * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  554. * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
  555. * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
  556. * @return name:author type:string default:-- desc:原创作者
  557. * @return name:content_type type:int default:1 desc:1富文本2pdf
  558. * @return name:pdf type:string default:-- desc:pdf文件路径[加密]
  559. * @return name:pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
  560. * @return name:app_name type:string default:-- desc:发布者
  561. * @return name:app_logo type:string default:-- desc:发布者头像
  562. * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
  563. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  564. * @return name:article_title type:string default:-- desc:系列标题
  565. * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  566. * @return name:release_time type:string default:-- desc:上架时间
  567. */
  568. public function getArticleItemInfo()
  569. {
  570. $item_id = input('get.item_id');
  571. $form = input('get.from','H5');
  572. $detail = ArticleItem::field('a.*,t.is_deleted td,t.status tus,t.title article_title')->where('a.id',$item_id)->alias('a')->leftJoin('ArticleIntro t','t.id= a.article_id')->find()->toArray();
  573. $is_release = UserLearn::checkRelease($this->user_id,3,$detail['article_id']);
  574. if($is_release && ($detail['is_deleted'] == 1 || $detail['td'] == 1))$this->error('图文已下架');
  575. if(!$is_release && ($detail['is_deleted'] == 1 || $detail['status'] == 0 || $detail['td'] == 1 || $detail['tus']==0) ) $this->error('图文已下架');
  576. $detail['series_title'] = $detail['article_title'];
  577. if(in_array($this->source_type,[1])) unset($detail['pdf_clear']);
  578. $detail['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['article_id'],'children_id'=>$detail['id']])->count();
  579. $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['article_id'],$detail['id']);
  580. $detail['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count();
  581. if(in_array($this->source_type,[1])) $detail['content'] = openssl_encrypt($detail['content'],'DES-ECB',123456,0);
  582. $detail['like_num'] = ArticleLike::where(['article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count();
  583. $detail['like_num'] = numTransform($detail['like_num']);
  584. $detail['read_num'] = numTransform($detail['read_num']);
  585. $detail['comment_num'] =ArticleComment::getArticleCommentNum($detail['id']);
  586. $detail['collect_num'] = numTransform($detail['collect_num']);
  587. $detail['transmit_num'] = numTransform($detail['transmit_num']);
  588. $detail['is_release'] = $is_release;
  589. UserTrack::crateTrack($this->user_id,3,$detail['article_id'],$item_id);
  590. $article_auth = ArticleItem::getArticleAuth($detail['user_id'],APPNAME,APPLOGO);
  591. $detail['app_name'] = $article_auth['app_name'];
  592. $detail['app_logo'] = $article_auth['app_logo'];
  593. $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['article_id'],3);
  594. $detail['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],8);
  595. //var_dump($this->user_id,3,$detail['article_id'],$item_id);
  596. ArticleItem::where('id',$item_id)->setInc('read_num');
  597. ArticleIntro::where('id',$detail['article_id'])->setInc('read_num');
  598. if($this->user_id){
  599. TopSearch::seIncHotNum($item_id,$this->request->controller());
  600. }
  601. $this->success('ok',['detail'=>$detail]);
  602. }
  603. /**
  604. * @title 获取图文评论列表
  605. * @desc 获取图文评论列表
  606. * @author qc
  607. * @method GET
  608. * @url /api/Article/getArticleCommentList
  609. * @header name:Authorization require:1 desc:Token
  610. * @param name:article_id type:int default:-- desc:图文id
  611. * @param name:item_id type:int default:-- desc:item_id
  612. * @param name:sort_type type:int default:1 desc:排序1最新2最热
  613. * @param name:page type:int default:-- desc:页数
  614. * @return name:name type:string default:-- desc:会员名称
  615. * @return name:headimg type:string default:-- desc:会员头像
  616. * @return name:content type:string default:-- desc:内容
  617. * @return name:is_deleted type:int default:-- desc:是否删除(大于0为删除状态)
  618. * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】)
  619. * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】)
  620. * @return name:like_num type:int default:-- desc:点赞数量
  621. * @return name:is_like type:int default:-- desc:是否点赞(0否1是)
  622. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  623. * @return name:can_delete type:int default:-- desc:是否可以删除(0否1是)
  624. * @return name:total_num type:int default:-- desc:总评论数(仅一级)
  625. */
  626. public function getArticleCommentList()
  627. {
  628. $where = [];
  629. $where[] = ['c.article_id','=',input('get.article_id')];
  630. $where[] = ['c.is_deleted','=',0];
  631. $user_id = $this->user_id;
  632. $sort_type= input('sort_type',1);
  633. if(input('get.item_id')) $where[] = ['c.item_id','=',input('get.item_id')];
  634. switch ($sort_type) {
  635. case 1:
  636. $order = ['is_top'=>'desc','id'=>'desc'];
  637. break;
  638. default:
  639. $order = ['is_top'=>'desc','like_times'=>'desc'];
  640. break;
  641. }
  642. $list =ArticleComment::where($where)
  643. ->alias('c')
  644. ->field('c.*,u.name,u.headimg')
  645. ->leftJoin('store_member u','u.id = c.user_id')
  646. ->order($order)
  647. ->limit($this->off_set,$this->page_num)
  648. ->select()->toArray();
  649. array_walk($list,function (&$val,$k)use($user_id){
  650. $children = ArticleComment::where(['c.pid'=>$val['id']])
  651. ->alias('c')->field('c.*,u.name,u.headimg')
  652. ->leftJoin('store_member u','u.id = c.user_id')
  653. ->order('c.is_top desc,c.id asc')
  654. ->select()->toArray();
  655. $val['children'] = $children;
  656. $val['like_num'] = ArticleCommentLike::where('like_id',$val['id'])->count();
  657. $val['like_num'] = numTransform($val['like_num']);
  658. $val['is_like'] = ArticleCommentLike::where(['like_id'=>$val['id'],'user_id'=>$user_id])->count();
  659. $parent = ArticleComment::where(['c.id'=>$val['pid']])
  660. ->alias('c')->field('c.*,u.name,u.headimg')
  661. ->leftJoin('store_member u','u.id = c.user_id')
  662. ->find();
  663. $val['parent'] = $parent ? $parent->toArray() : null;
  664. $val['parent_comment'] = $val['parent'] ;
  665. $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0;
  666. });
  667. $total_num = ArticleComment::where($where)->alias('c') ->leftJoin('store_member u','u.id = c.user_id')->count();
  668. $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  669. }
  670. /**
  671. * @title 以下接口调用验证登录【需要header传Authorization】
  672. * @desc 转发成功后调用
  673. * @author qc
  674. * @method
  675. * @url /api/Article/needLogin()
  676. */
  677. public function needLogin(){}
  678. /**
  679. * @title 图文转发(转发数量统计)
  680. * @desc 转发成功后调用
  681. * @author qc
  682. * @method POST
  683. * @url /api/Article/articleTransmit
  684. * @header name:Authorization require:1 desc:Token
  685. * @param name:item_id type:int default:-- desc:item_list的id
  686. */
  687. public function articleTransmit()
  688. {
  689. $item_id = input('post.item_id',0);
  690. ArticleItem::where('id',$item_id)->setInc('transmit_num');
  691. $this->success('ok');
  692. }
  693. /**
  694. * @title 图文阅读(阅读数量统计)
  695. * @desc 图文阅读
  696. * @author qc
  697. * @method POST
  698. * @url /api/Article/articleRead
  699. * @header name:Authorization require:1 desc:Token
  700. * @param name:item_id type:int default:-- desc:item_list的id
  701. */
  702. public function articleRead()
  703. {
  704. $item_id = input('post.item_id',0);
  705. $article_id = ArticleItem::where('id',$item_id)->value('article_id');
  706. ArticleItem::where('id',$item_id)->setInc('read_num');
  707. ArticleIntro::where('id',$article_id)->setInc('read_num');
  708. if($this->user_id){
  709. TopSearch::seIncHotNum($item_id,$this->request->controller());
  710. }
  711. $this->success('ok');
  712. }
  713. /**
  714. * @title 图文点赞||取消点赞
  715. * @desc 点赞||取消点赞
  716. * @author qc
  717. * @method POST
  718. * @url /api/Article/articleTags
  719. * @header name:Authorization require:1 desc:Token
  720. * @param name:item_id type:int default:1 desc:item_id(多个逗号隔开)
  721. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  722. */
  723. public function articleTags()
  724. {
  725. $ids = input('post.item_id');
  726. $ret_val = 0;
  727. foreach (explode(',',$ids) as $item_id) {
  728. $article_id = ArticleItem::where('id',$item_id)->value('article_id');
  729. $check_tags = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id])->value('id');
  730. if($check_tags) {
  731. ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id])->delete();
  732. }else{
  733. $p_user_id = ArticleItem::where('id',$item_id)->value('user_id');
  734. $is_read = $p_user_id == $this->user_id ? 1 : 0;
  735. Data::save('ArticleLike',
  736. ['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id,'is_read'=>$is_read],'user_id',
  737. ['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id]);
  738. $ret_val = 1;
  739. }
  740. }
  741. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  742. }
  743. /**
  744. * @title 图文评论
  745. * @desc 图文评论
  746. * @author qc
  747. * @method POST
  748. * @url /api/Article/articleComment
  749. * @header name:Authorization require:1 desc:Token
  750. * @param name:article_id type:int default:1 desc:图文id
  751. * @param name:item_id type:int default:1 desc:item_id
  752. * @param name:content type:string default:-- desc:内容
  753. * @return name:name type:string default:-- desc:会员名称
  754. * @return name:headimg type:string default:-- desc:会员头像
  755. * @return name:content type:string default:-- desc:内容
  756. */
  757. public function articleComment()
  758. {
  759. $article_id = input('post.article_id');
  760. $item_id = input('post.item_id');
  761. $content = input('post.content',0);
  762. if(!$content) $this->error('请输入评论内容');
  763. $comment_switch = ArticleItem::where('id',$item_id)->value('comment_switch');
  764. $send_user = ArticleItem::where('id',$item_id)->value('user_id');
  765. if(!$comment_switch) $this->error('评论功能已关闭');
  766. $res = ArticleComment::create([
  767. 'user_id'=>$this->user_id,
  768. 'content'=>$content
  769. ,'article_id'=>$article_id,
  770. 'item_id'=>$item_id,
  771. 'is_read' => $send_user == $this->user_id ? 1 : 0,
  772. 'source_read' => $send_user == $this->user_id ? 1 : 0,
  773. ]);
  774. $detail =ArticleComment::where('c.id',$res->id)
  775. ->alias('c')
  776. ->field('c.id,c.content,c.create_at,u.name,u.headimg')
  777. ->leftJoin('store_member u','u.id = c.user_id')
  778. ->find()->toArray();
  779. $user_info = $this->userInfo('name');
  780. if($send_user != $this->user_id) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$item_id,$content,$item_id,$article_id);
  781. $this->success('评论成功',['detail'=>$detail]);
  782. }
  783. /**
  784. * @title 删除评论
  785. * @desc 删除评论
  786. * @author qc
  787. * @method POST
  788. * @url /api/Article/delComment
  789. * @header name:Authorization require:1 desc:Token
  790. * @param name:id type:int default:1 desc:评论id
  791. */
  792. public function delComment(){
  793. ArticleComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]);
  794. $this->success('删除成功');
  795. }
  796. /**
  797. * @title 图文二级评论
  798. * @desc 图文二级评论
  799. * @author qc
  800. * @method POST
  801. * @url /api/Article/secondCommend
  802. * @header name:Authorization require:1 desc:Token
  803. * @param name:id type:int default:1 desc:评论id
  804. * @param name:content type:string default:-- desc:内容
  805. * @return name:name type:string default:-- desc:会员名称
  806. * @return name:headimg type:string default:-- desc:会员头像
  807. * @return name:content type:string default:-- desc:内容
  808. */
  809. public function secondCommend()
  810. {
  811. $comment = ArticleComment::where('id',input('post.id'))->find()->toArray();
  812. $content = input('post.content');
  813. $user_info = $this->userInfo('name');
  814. if($comment['user_id'] != $this->user_id)UserMessage:: sendUserMessage($comment['user_id'],'article',3,0,$this->user_id,$comment['id'],$content,$comment['item_id'],$comment['article_id']);
  815. $send_user = ArticleItem::where('id',$comment['item_id'])->value('user_id');
  816. $comment_switch = ArticleItem::where('id',$comment['item_id'])->value('comment_switch');
  817. if(!$comment_switch) $this->error('评论功能已关闭');
  818. //if($send_user != $this->user_id) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$comment['item_id'],$content,$comment['item_id'],$comment['article_id']);
  819. $to_user = $comment['user_id'];
  820. unset($comment['id']);
  821. unset($comment['create_at']);
  822. unset($comment['to_deleted']);
  823. unset($comment['is_top']);
  824. unset($comment['is_deleted']);
  825. $comment['pid'] = input('post.id');
  826. $comment['user_id'] = $this->user_id;
  827. $comment['content'] = $content;
  828. $comment['lev']++;
  829. $comment['is_read']= $this->user_id == $to_user ? 1 :0 ;
  830. $comment['source_read'] = $this->user_id == $send_user ? 1 :0 ;
  831. if(!$comment['source_id']) $comment['source_id'] = input('post.id');
  832. $res = ArticleComment::create($comment);
  833. $detail = ArticleComment::where('c.id',$res->id)
  834. ->alias('c')
  835. ->field('c.id,c.content,c.create_at,u.name,u.headimg')
  836. ->leftJoin('store_member u','u.id = c.user_id')
  837. ->find()->toArray();
  838. $this->success('评论成功',['detail'=>$detail]);
  839. }
  840. /**
  841. * @title 评论点赞||取消点赞
  842. * @desc 评论
  843. * @author qc
  844. * @method POST
  845. * @url /api/Article/commentTags
  846. * @header name:Authorization require:1 desc:Token
  847. * @param name:comment_id type:int default:1 desc:评论记录id
  848. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  849. */
  850. public function commentTags()
  851. {
  852. $comment_id = input('post.comment_id');
  853. $ret_val = 0;
  854. $check_tags = ArticleCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$comment_id])->value('id');
  855. if($check_tags) {
  856. ArticleCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$comment_id])->delete();
  857. // ArticleItem::where('id',$comment_id)->setDec('like_times');
  858. }else{
  859. $p_user_id = ArticleComment::where('id',$comment_id)->value('user_id');
  860. $is_read = $p_user_id == $this->user_id ? 1 : 0;
  861. Data::save('ArticleCommentLike',
  862. ['user_id'=>$this->user_id,'like_id'=>$comment_id,'is_read'=>$is_read],'user_id',
  863. ['user_id'=>$this->user_id,'like_id'=>$comment_id]);
  864. $ret_val = 1;
  865. // ArticleItem::where('id',$comment_id)->setInc('like_times');
  866. }
  867. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  868. }
  869. /**
  870. * @title 图文收藏||取消收藏
  871. * @desc 用户收藏
  872. * @author qc
  873. * @method POST
  874. * @url /api/Article/articleCollect
  875. * @header name:Authorization require:1 desc:Token
  876. * @param name:article_id type:int require:1 default:-- desc:系列id
  877. * @param name:item_id type:int default:1 desc:item_id【详情的id】
  878. */
  879. public function articleCollect()
  880. {
  881. $coll_type = input('post.coll_type',3);
  882. $coll_id = input('post.article_id',0);
  883. $item_id = input('post.item_id',0);
  884. $collect_check = UserCollect::checkCollectByType($this->user_id,$coll_type,$coll_id,$item_id);
  885. if($collect_check) {
  886. UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$coll_id,'children_id'=>$item_id])->delete();
  887. $this->success('取消收藏成功',['status'=>0]);
  888. }else{
  889. Data::save('UserCollect', [
  890. 'user_id'=>$this->user_id,
  891. 'coll_type'=>$coll_type,
  892. 'coll_id'=>$coll_id,
  893. 'children_id'=>$item_id,
  894. 'create_int'=>time()],'user_id',['user_id'=>$this->user_id,'coll_type'=>$coll_type, 'coll_id'=>$coll_id,'children_id'=>$item_id]);
  895. $this->success('收藏成功',['status'=>1]);
  896. }
  897. }
  898. /**
  899. * @title 用户提交或修改图文【个人】
  900. * @desc 用户提交或修改图文【个人】
  901. * @author qc
  902. * @method POST
  903. * @url /api/Article/userReferArticle
  904. * @header name:Authorization require:1 desc:Token
  905. * @param name:id type:int default:-- desc:id(修改时必传)
  906. * @param name:title type:string default:-- desc:标题
  907. * @param name:images type:string default:-- desc:图片(多张用|隔开)
  908. * @param name:desc type:string default:-- desc:简介
  909. * @param name:label type:string default:-- desc:图文标签(多个用逗号隔开)
  910. * @param name:document type:string default:-- desc:文件路径【单文件】
  911. */
  912. public function userReferArticle()
  913. {
  914. $id = input('post.id',0);
  915. $title = input('post.title');
  916. $desc = input('post.desc');
  917. $images = input('post.images');
  918. $label = input('post.label');
  919. $document = input('post.document');
  920. //if(!$images) $this->error('请上传图文');
  921. if($id){
  922. $check_status = UserArticle::where('id',$id)->value('status');
  923. if($check_status == 1) $this->error('已审核通过,不允许修改');
  924. }
  925. $data = [
  926. 'title' => $title,
  927. 'user_id' => $this->user_id,
  928. 'desc' => $desc,
  929. 'images' => $images,
  930. 'label' => $label,
  931. 'document' => $document,
  932. 'cover' => $images ? explode('|',$images)[0] : '',
  933. 'status' => 0,
  934. 'remark' => '',
  935. ];
  936. if($id) $data['id'] = $id;
  937. if($id){
  938. UserArticle::where('id',$id)->update($data);
  939. }else{
  940. $res= UserArticle::create($data) ;
  941. }
  942. // UserMessage::sendUserMessage($this->user_id,'article',1,0,0,$id ? $id:$res->id);
  943. $this->success('提交成功,请等待审核',['id'=> $id ? :$res->id]);
  944. }
  945. /**
  946. * @title 我的发布--个人发布的
  947. * @desc 获取我的图文列表【个人】
  948. * @author qc
  949. * @method GET
  950. * @url /api/Article/getMyArticleList
  951. * @header name:Authorization require:1 desc:Token
  952. * @param name:title type:string default:-- desc:标题
  953. * @param name:page type:int default:0 desc:页数
  954. * @param name:page_num type:int default:20 desc:每页数
  955. * @return name:title type:string default:-- desc:标题
  956. * @return name:desc type:string default:-- desc:简介
  957. * @return name:images type:string default:-- desc:图片【多张|隔开】
  958. * @return name:images_arr type:array default:-- desc:图片数组
  959. * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
  960. * @return name:remark type:string default:-- desc:审核备注
  961. * @return name:create_at type:string default:-- desc:时间
  962. * @return name:label_name type:array default:-- desc:标签
  963. * @return name:cover type:string default:-- desc:封面
  964. */
  965. public function getMyArticleList()
  966. {
  967. $sel_where = [];
  968. $sel_where[] = ['is_deleted','=',0];
  969. $sel_where[] = ['user_id','=',$this->user_id];
  970. $title = input('get.title');
  971. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  972. $list = UserArticle::where($sel_where)
  973. ->field('id,title,desc,images,status,remark,create_at,label')
  974. ->order('id desc')
  975. ->limit($this->off_set,$this->page_num)
  976. ->select()->toArray();
  977. array_map(function (&$v){
  978. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')) :null;
  979. $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
  980. },$list);
  981. $total_num = UserArticle::where($sel_where)->count();
  982. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  983. }
  984. /**
  985. * @title 获取我的图文详情【个人】
  986. * @desc 获取我的图文列表【个人】
  987. * @author qc
  988. * @method GET
  989. * @url /api/Article/getUserArticleDetail
  990. * @header name:Authorization require:1 desc:Token
  991. * @param name:id type:string default:-- desc:记录id
  992. * @return name:title type:string default:-- desc:标题
  993. * @return name:desc type:string default:-- desc:简介
  994. * @return name:images type:string default:-- desc:图文[多张|隔开]
  995. * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
  996. * @return name:remark type:string default:-- desc:审核备注
  997. * @return name:label type:string default:-- desc:标签
  998. * @return name:document type:string default:-- desc:文件路径
  999. */
  1000. public function getUserArticleDetail()
  1001. {
  1002. $detail =UserArticle::where('id',input('get.id'))->field('id,title,desc,images,status,remark,label,document')->find();
  1003. if($this->user_id){
  1004. $General = new General();
  1005. $General->label($detail['label']);
  1006. }
  1007. if(!$detail) $this->error('图文有误');
  1008. $this->success('ok',['detail'=>$detail->toArray()]);
  1009. }
  1010. /**
  1011. * @title 用户删除图文记录【个人】
  1012. * @desc 用户删除图文记录【个人】
  1013. * @author qc
  1014. * @method POST
  1015. * @url /api/Article/delUserArticle
  1016. * @header name:Authorization require:1 desc:Token
  1017. * @param name:id type:int default:-- desc:id
  1018. */
  1019. public function delUserArticle()
  1020. {
  1021. UserArticle::where(['user_id'=>$this->user_id,'id'=>input('post.id')])->delete();
  1022. $this->success('删除成功');
  1023. }
  1024. /**
  1025. * @title 以下接口学习服务模块的
  1026. * @desc
  1027. * @author qc
  1028. * @method
  1029. * @url /api/Article/learn()
  1030. */
  1031. public function learn(){}
  1032. /**
  1033. * @title 图文学习历史
  1034. * @desc 图文学习历史
  1035. * @author qc
  1036. * @method GET
  1037. * @url /api/Article/getLearnHistory
  1038. * @header name:Authorization require:1 desc:Token
  1039. * @param name:title type:string default:-- desc:标题
  1040. * @param name:page type:int default:0 desc:页数
  1041. * @param name:page_num type:int default:20 desc:每页数
  1042. * @return name:title type:string default:-- desc:标题
  1043. * @return name:series_title type:string default:-- desc:系列标题
  1044. * @return name:article_id type:string default:-- desc:文章id
  1045. * @return name:item_id type:string default:-- desc:item_id
  1046. * @return name:cover type:string default:-- desc:封面
  1047. * @return name:time type:string default:-- desc:时间
  1048. * @return name:read_num type:int default:-- desc:阅读量
  1049. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1050. * @return name:app_name type:string default:-- desc:发布者
  1051. * @return name:app_logo type:string default:-- desc:发布者头像
  1052. */
  1053. public function getLearnHistory()
  1054. {
  1055. $sel_where = [];
  1056. $sel_where[] = ['t.user_id','=',$this->user_id];
  1057. $sel_where[] = ['t.type','=',3];
  1058. $title = input('get.title');
  1059. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1060. $list = UserTrack::where($sel_where)
  1061. ->alias('t')
  1062. ->field('t.id,t.update_int,t.first_id article_id,t.second_id item_id,i.title,i.cover,i.read_num,i.user_id,x.title series_title,x.is_vip')
  1063. ->leftJoin('ArticleItem i','t.second_id = i.id')
  1064. ->leftJoin('ArticleIntro x','t.first_id = x.id')
  1065. ->order('update_int desc')
  1066. ->limit($this->off_set,$this->page_num)
  1067. ->select()->toArray();
  1068. foreach ($list as &$v) {
  1069. $v['read_num'] = numTransform($v['read_num']);
  1070. $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
  1071. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1072. $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
  1073. $v['app_name'] = $article_auth['app_name'];
  1074. $v['app_logo'] = $article_auth['app_logo'];
  1075. }
  1076. $total_num = UserTrack::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.second_id = i.id')->count();
  1077. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1078. }
  1079. /**
  1080. * @title 我的收藏--图文
  1081. * @desc 图文收藏记录
  1082. * @author qc
  1083. * @method GET
  1084. * @url /api/Article/getArticleCollect
  1085. * @header name:Authorization require:1 desc:Token
  1086. * @param name:title type:string default:-- desc:标题
  1087. * @param name:page type:int default:0 desc:页数
  1088. * @param name:page_num type:int default:20 desc:每页数
  1089. * @return name:title type:string default:-- desc:标题
  1090. * @return name:series_title type:string default:-- desc:系列标题
  1091. * @return name:read_num type:int default:-- desc:阅读量
  1092. * @return name:article_id type:string default:-- desc:文章id
  1093. * @return name:item_id type:string default:-- desc:item_id
  1094. * @return name:cover type:string default:-- desc:封面
  1095. * @return name:create_at type:string default:-- desc:时间
  1096. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1097. * @return name:desc type:string default:-- desc:简介
  1098. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  1099. * @return name:transmit_num type:int default:-- desc:转发量
  1100. * @return name:comment_num type:int default:-- desc:评论量
  1101. * @return name:is_collect type:int default:-- desc:是否收藏
  1102. * @return name:collect_num type:int default:-- desc:收藏量
  1103. * @return name:like_num type:string default:-- desc:点赞量
  1104. * @return name:is_like type:string default:-- desc:是否点赞[0否1是]
  1105. */
  1106. public function getArticleCollect()
  1107. {
  1108. $sel_where = [];
  1109. $title = input('get.title');
  1110. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1111. $sel_where[] = ['t.user_id','=',$this->user_id];
  1112. $sel_where[] = ['t.coll_type','=',3];
  1113. $list = UserCollect::where($sel_where)
  1114. ->alias('t')
  1115. ->field('t.id,t.create_at,t.coll_id article_id,t.children_id item_id,i.title,i.cover,i.read_num,i.transmit_num,i.desc,x.title series_title,i.user_id')
  1116. ->leftJoin('ArticleItem i','t.children_id = i.id')
  1117. ->leftJoin('ArticleIntro x','t.coll_id = x.id')
  1118. ->order('id desc')
  1119. ->limit($this->off_set,$this->page_num)
  1120. ->select()->toArray();
  1121. array_walk($list,function (&$v){
  1122. $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['item_id'],8);
  1123. $v['read_num'] = numTransform($v['read_num']);
  1124. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1125. $v['transmit_num'] = numTransform($v['transmit_num']);
  1126. $v['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$v['article_id'],'children_id'=>$v['item_id']])->count();
  1127. $v['collect_num'] = numTransform($v['collect_num']);
  1128. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$v['article_id'],$v['item_id']);
  1129. $v['like_num'] = ArticleLike::where(['article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
  1130. $v['like_num'] = numTransform($v['like_num']);
  1131. $v['comment_num'] = ArticleComment::getArticleCommentNum($v['item_id']);
  1132. $v['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
  1133. $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
  1134. $v['app_name'] = $article_auth['app_name'];
  1135. $v['app_logo'] = $article_auth['app_logo'];
  1136. });
  1137. $total_num = UserCollect::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.children_id = i.id')->count();
  1138. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1139. }
  1140. /**
  1141. * @title 我的评论【学习服务--我评论过的图文】
  1142. * @desc 我的评论
  1143. * @author qc
  1144. * @method GET
  1145. * @url /api/Article/getCommentArticle
  1146. * @header name:Authorization require:1 desc:Token
  1147. * @param name:title type:string default:-- desc:标题
  1148. * @param name:page type:int default:0 desc:页数
  1149. * @param name:page_num type:int default:20 desc:每页数
  1150. * @return name:title type:string default:-- desc:标题
  1151. * @return name:series_title type:string default:-- desc:系列标题
  1152. * @return name:article_id type:string default:-- desc:文章id
  1153. * @return name:item_id type:string default:-- desc:item_id
  1154. * @return name:cover type:string default:-- desc:封面
  1155. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1156. * @return name:create_at type:string default:-- desc:时间
  1157. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  1158. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  1159. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1160. * @return name:app_name type:string default:-- desc:发布者
  1161. * @return name:app_logo type:string default:-- desc:发布者头像
  1162. */
  1163. public function getCommentArticle()
  1164. {
  1165. $user_info = $this->userInfo();
  1166. $sel_where = [];
  1167. $title = input('get.title');
  1168. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1169. $sel_where[] = ['t.user_id','=',$this->user_id];
  1170. $sel_where[] = ['t.is_deleted','=',0];
  1171. $sel_where[] = ['t.lev','=',1];
  1172. $sel_where[] = ['t.pid','=',0];
  1173. $list = ArticleComment::where($sel_where)
  1174. ->alias('t')
  1175. ->field('t.id,t.create_at,t.article_id,t.item_id,t.is_top,t.lev,t.content,i.title,i.cover,x.title series_title,i.user_id,i.read_num')
  1176. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1177. ->leftJoin('ArticleIntro x','t.article_id = x.id')
  1178. ->order('t.is_top desc,id desc')
  1179. ->limit($this->off_set,$this->page_num)
  1180. ->select()->toArray();
  1181. foreach ($list as &$v)
  1182. {
  1183. $v['read_num'] = numTransform($v['read_num']);
  1184. $v['user_name'] = $user_info['name'];
  1185. $v['headimg'] = $user_info['headimg'];
  1186. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1187. $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
  1188. $v['app_name'] = $article_auth['app_name'];
  1189. $v['app_logo'] = $article_auth['app_logo'];
  1190. }
  1191. $total_num = ArticleComment::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
  1192. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1193. }
  1194. /**
  1195. * @title 评论我的【学习服务--评论我的】
  1196. * @desc 评论我的
  1197. * @author qc
  1198. * @method GET
  1199. * @url /api/Article/commentMyArticle
  1200. * @header name:Authorization require:1 desc:Token
  1201. * @param name:title type:string default:-- desc:标题
  1202. * @param name:page type:int default:0 desc:页数
  1203. * @param name:page_num type:int default:20 desc:每页数
  1204. * @return name:title type:string default:-- desc:标题
  1205. * @return name:series_title type:string default:-- desc:系列标题
  1206. * @return name:article_id type:string default:-- desc:文章id
  1207. * @return name:item_id type:string default:-- desc:item_id
  1208. * @return name:cover type:string default:-- desc:封面
  1209. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  1210. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1211. * @return name:create_at type:string default:-- desc:时间
  1212. * @return name:user_name type:string default:-- desc:用户名
  1213. * @return name:headimg type:string default:-- desc:用户头像
  1214. * @return name:read_num type:int default:-- desc:阅读量
  1215. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1216. * @return name:app_name type:string default:-- desc:发布者
  1217. * @return name:app_logo type:string default:-- desc:发布者头像
  1218. */
  1219. public function commentMyArticle()
  1220. {
  1221. $sel_where = [];
  1222. $title = input('get.title');
  1223. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1224. $sel_where[] = ['t.is_deleted','=',0];
  1225. $sel_where[] = ['i.user_id','=',$this->user_id];
  1226. $sel_where[] = ['t.user_id','<>',$this->user_id];
  1227. $sel_where[] = ['t.source_deleted','=',0];
  1228. $sel_where[] = ['t.pid','=',0];
  1229. $list = ArticleComment::where($sel_where)
  1230. ->alias('t')
  1231. ->field('t.id,t.is_read,t.is_top,t.create_at,i.read_num,t.article_id,t.item_id,t.lev,t.content,i.title,i.label,i.cover,u.name user_name,u.headimg,x.title series_title')
  1232. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1233. ->leftJoin('ArticleIntro x','t.article_id = x.id')
  1234. ->leftJoin('store_member u','t.user_id = u.id')
  1235. ->order('t.id desc')
  1236. ->limit($this->off_set,$this->page_num)
  1237. ->select()->toArray();
  1238. $user_info = $this->userInfo('name,headimg');
  1239. array_walk($list,function (&$v)use ($user_info){
  1240. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1241. $v['read_num'] = numTransform($v['read_num']);
  1242. $v['app_name'] = $user_info['name'];
  1243. $v['app_logo'] = $user_info['headimg'];
  1244. });
  1245. $total_num= ArticleComment::where($sel_where)->alias('t')->leftJoin('ArticleItem i','t.item_id = i.id')
  1246. ->leftJoin('store_member u','t.user_id = u.id')->count();
  1247. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1248. }
  1249. /**
  1250. * @title 我的已购--已购列表
  1251. * @desc 我的已购--已购列表
  1252. * @author qc
  1253. * @method GET
  1254. * @url /api/Article/getPurchaseArticle
  1255. * @header name:Authorization require:1 desc:Token
  1256. * @param name:title type:string default:-- desc:标题
  1257. * @param name:page type:int default:0 desc:页数
  1258. * @param name:page_num type:int default:20 desc:每页数
  1259. * @return name:title type:string default:-- desc:标题
  1260. * @return name:article_id type:string default:-- desc:文章id
  1261. * @return name:item_id type:string default:-- desc:item_id
  1262. * @return name:cover type:string default:-- desc:封面
  1263. * @return name:create_at type:string default:-- desc:时间
  1264. * @return name:total_sequel type:int default:-- desc:期数
  1265. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1266. * @return name:is_recently type:int default:-- desc:是否最近观看【0否1是】
  1267. * @return name:recently_title type:string default:-- desc:上次观看标题
  1268. */
  1269. public function getPurchaseArticle()
  1270. {
  1271. $sel_where = [];
  1272. $title = input('get.title');
  1273. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1274. $sel_where[] = ['t.user_id','=',$this->user_id];
  1275. $sel_where[] = ['t.type','=',3];
  1276. $sel_where[] = ['t.end_int','>',time()];
  1277. $sel_where[] = ['t.is_deleted','=',0];
  1278. $sel_where[] = ['a.is_deleted','=',0];
  1279. $list = UserLearn::where($sel_where)
  1280. ->alias('t')
  1281. ->field('t.id,t.create_at,t.first_id article_id,t.second_id item_id,a.title,a.cover,a.total_sequel')
  1282. ->leftJoin('ArticleIntro a','t.first_id = a.id')
  1283. ->leftJoin('ArticleItem i','t.second_id = i.id')
  1284. ->order('id desc')
  1285. ->limit($this->off_set,$this->page_num)
  1286. ->select()->toArray();
  1287. array_walk($list,function (&$v){
  1288. $v['is_normal'] = 1;//CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1289. $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$v['article_id']);
  1290. $v['is_recently'] = $recently_id ? 1 : 0;
  1291. $v['recently_title'] = ArticleItem::where('id',$recently_id)->value('title');
  1292. });
  1293. $total_num = UserLearn::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.second_id = i.id')
  1294. ->leftJoin('ArticleIntro a','t.first_id = a.id')->count();
  1295. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1296. }
  1297. /**
  1298. * @title 我的回复【我的回复--我回复过的评论】
  1299. * @desc 我的回复
  1300. * @author qc
  1301. * @method GET
  1302. * @url /api/Article/getReplyArticle
  1303. * @header name:Authorization require:1 desc:Token
  1304. * @param name:title type:string default:-- desc:标题
  1305. * @param name:page type:int default:0 desc:页数
  1306. * @param name:page_num type:int default:20 desc:每页数
  1307. * @return name:title type:string default:-- desc:标题
  1308. * @return name:article_id type:string default:-- desc:文章id
  1309. * @return name:item_id type:string default:-- desc:item_id
  1310. * @return name:cover type:string default:-- desc:封面
  1311. * @return name:create_at type:string default:-- desc:时间
  1312. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1313. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  1314. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  1315. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1316. * @return name:parent_comment type:array default:-- desc:上级评论内容【你评论的那个评论】
  1317. * @return name:parent_comment.content type:string default:-- desc:内容
  1318. * @return name:parent_comment.name type:string default:-- desc:会员名称
  1319. * @return name:parent_comment.title type:string default:-- desc:图文标题
  1320. * @return name:parent_comment.series_title type:string default:-- desc:系列标题
  1321. * @return name:parent_comment.article_id type:string default:-- desc:文章id
  1322. * @return name:parent_comment.item_id type:string default:-- desc:item_id
  1323. * @return name:parent_comment.app_name type:string default:-- desc:发布方名称
  1324. * @return name:parent_comment.app_logo type:string default:-- desc:发布方头像
  1325. */
  1326. public function getReplyArticle()
  1327. {
  1328. $user_info = $this->userInfo();
  1329. $sel_where = [];
  1330. $title = input('get.title');
  1331. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1332. $sel_where[] = ['t.user_id','=',$this->user_id];
  1333. $sel_where[] = ['t.is_deleted','=',0];
  1334. $sel_where[] = ['t.lev','>=',2];
  1335. $list = ArticleComment::where($sel_where)
  1336. ->alias('t')
  1337. ->field('t.id,t.article_id,t.is_top,t.item_id,t.create_at,t.lev,t.content,i.title,t.pid,i.read_num')
  1338. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1339. ->order('t.is_top desc,t.id desc')
  1340. ->limit($this->off_set,$this->page_num)
  1341. ->select()->toArray();
  1342. foreach ($list as &$v) {
  1343. $v['user_name'] = $user_info['name'];
  1344. $v['headimg'] = $user_info['headimg'];
  1345. $v['read_num'] = numTransform($v['read_num']);
  1346. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1347. $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]])
  1348. ->field('t.id,t.article_id,t.is_top,t.item_id,t.content,i.title,i.user_id,i.cover,t.pid,u.name,x.title series_title')
  1349. ->alias('t')
  1350. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1351. ->leftJoin('ArticleIntro x','t.article_id = x.id')
  1352. ->leftJoin('store_member u','t.user_id = u.id')
  1353. ->find()->toArray();
  1354. $article_auth = ArticleItem::getArticleAuth($parent_comment['user_id'],APPNAME,APPLOGO);
  1355. $parent_comment['app_name'] = $article_auth['app_name'];
  1356. $parent_comment['app_logo'] = $article_auth['app_logo'];
  1357. $parent_comment['read_num'] = numTransform($v['read_num']);
  1358. $v['parent_comment'] = $parent_comment;
  1359. }
  1360. $total_num = ArticleComment::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
  1361. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1362. }
  1363. /**
  1364. * @title 回复我的【回复我的--回复过我的评论】
  1365. * @desc 回复我的
  1366. * @author qc
  1367. * @method GET
  1368. * @url /api/Article/getReplyComment
  1369. * @header name:Authorization require:1 desc:Token
  1370. * @param name:title type:string default:-- desc:标题
  1371. * @param name:page type:int default:0 desc:页数
  1372. * @param name:page_num type:int default:20 desc:每页数
  1373. * @return name:title type:string default:-- desc:标题
  1374. * @return name:article_id type:string default:-- desc:文章id
  1375. * @return name:item_id type:string default:-- desc:item_id
  1376. * @return name:cover type:string default:-- desc:封面
  1377. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  1378. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1379. * @return name:create_at type:string default:-- desc:时间
  1380. * @return name:is_deleted type:int default:-- desc:0未删除
  1381. * @return name:user_name type:string default:-- desc:用户名【其他会员】
  1382. * @return name:headimg type:string default:-- desc:用户头【其他会员】
  1383. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1384. * @return name:parent_comment type:array default:-- desc:你的评论内容【别人回复的那个评论】
  1385. * @return name:parent_comment.content type:string default:-- desc:内容
  1386. * @return name:parent_comment.name type:string default:-- desc:会员名称
  1387. * @return name:parent_comment.title type:string default:-- desc:图文标题
  1388. * @return name:parent_comment.series_title type:string default:-- desc:图文标题
  1389. * @return name:parent_comment.read_num type:string default:-- desc:阅读量
  1390. * @return name:parent_comment.article_id type:string default:-- desc:文章id
  1391. * @return name:parent_comment.item_id type:string default:-- desc:item_id
  1392. * @return name:parent_comment.is_deleted type:int default:-- desc:0未删除
  1393. * @return name:parent_comment.app_name type:string default:-- desc:发布方名称
  1394. * @return name:parent_comment.app_logo type:string default:-- desc:发布方头像
  1395. */
  1396. public function getReplyComment()
  1397. {
  1398. $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1399. if(empty($all_comment)) $this->success('ok',['list'=>[]]);
  1400. $sel_where = [];
  1401. $title = input('get.title');
  1402. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1403. $sel_where[] = ['t.is_deleted','=',0];
  1404. $sel_where[] = ['t.lev','>=',2];
  1405. $sel_where[] = ['t.user_id','<>',$this->user_id];
  1406. $sel_where[] = ['t.to_deleted','=',0];
  1407. $sel_where[] = ['t.pid','in',implode(',',$all_comment)];
  1408. $list = ArticleComment::where($sel_where)
  1409. ->alias('t')
  1410. ->field('t.id,t.is_read,t.article_id,t.is_top,t.is_deleted,t.item_id,t.create_at,t.lev,t.content,t.pid,u.name user_name,u.headimg,i.user_id')
  1411. ->leftJoin('store_member u','t.user_id = u.id')
  1412. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1413. ->order('t.is_top desc,t.id desc')
  1414. ->limit($this->off_set,$this->page_num)
  1415. ->select()->toArray();
  1416. foreach ($list as &$v) {
  1417. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1418. $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]])
  1419. ->field('t.id,t.article_id,t.is_top,t.item_id,t.content,i.title,i.cover,t.pid,u.name,t.is_deleted,i.user_id,i.read_num,x.title series_title')
  1420. ->alias('t')
  1421. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1422. ->leftJoin('ArticleIntro x','t.article_id = x.id')
  1423. ->leftJoin('store_member u','t.user_id = u.id')
  1424. ->find()->toArray();
  1425. $article_auth = ArticleItem::getArticleAuth($parent_comment['user_id'],APPNAME,APPLOGO);
  1426. $parent_comment['read_num'] = numTransform($parent_comment['read_num']);
  1427. $parent_comment['app_name'] = $article_auth['app_name'];
  1428. $parent_comment['app_logo'] = $article_auth['app_logo'];
  1429. $v['parent_comment'] = $parent_comment;
  1430. }
  1431. $total_num = ArticleComment::where($sel_where)->alias('t') ->leftJoin('store_member u','t.user_id = u.id')
  1432. ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
  1433. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1434. }
  1435. /**
  1436. * @title 图文点赞列表【我的点赞】
  1437. * @desc 图文点赞列表
  1438. * @author qc
  1439. * @method GET
  1440. * @url /api/Article/getTagsArticle
  1441. * @header name:Authorization require:1 desc:Token
  1442. * @param name:title type:string default:-- desc:标题
  1443. * @param name:page type:int default:0 desc:页数
  1444. * @param name:page_num type:int default:20 desc:每页数
  1445. * @return name:title type:string default:-- desc:标题
  1446. * @return name:series_title type:string default:-- desc:系列标题
  1447. * @return name:article_id type:string default:-- desc:文章id
  1448. * @return name:item_id type:string default:-- desc:item_id
  1449. * @return name:like_num type:string default:-- desc:点赞量
  1450. * @return name:is_like type:string default:-- desc:是否点赞[0否1是]
  1451. * @return name:cover type:string default:-- desc:封面
  1452. * @return name:is_vip type:int default:-- desc:是否vip[0否1是]
  1453. * @return name:create_at type:string default:-- desc:时间
  1454. * @return name:read_num type:int default:-- desc:阅读量
  1455. * @return name:images_arr type:array default:-- desc:图片
  1456. * @return name:app_name type:string default:-- desc:发布方名称
  1457. * @return name:app_logo type:string default:-- desc:发布方头像
  1458. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1459. * @return name:desc type:string default:-- desc:简介
  1460. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  1461. * @return name:transmit_num type:int default:-- desc:转发量
  1462. * @return name:comment_num type:int default:-- desc:评论量
  1463. * @return name:is_collect type:int default:-- desc:是否收藏
  1464. * @return name:collect_num type:int default:-- desc:收藏量
  1465. */
  1466. public function getTagsArticle()
  1467. {
  1468. $sel_where = [];
  1469. $title = input('get.title');
  1470. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1471. $sel_where[] = ['t.user_id','=',$this->user_id];
  1472. $list = ArticleLike::where($sel_where)
  1473. ->alias('t')
  1474. ->field('t.id,t.create_at,t.article_id,t.item_id,i.title,i.cover,i.is_vip,i.images,i.read_num,i.user_id,i.transmit_num,i.desc,x.title series_title')
  1475. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1476. ->leftJoin('ArticleIntro x','t.article_id = x.id')
  1477. ->order('id desc')
  1478. ->limit($this->off_set,$this->page_num)
  1479. ->select()->toArray();
  1480. foreach ($list as &$v) {
  1481. $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['item_id'],8);
  1482. $v['like_num'] = ArticleLike::where(['article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
  1483. $v['like_num'] = numTransform($v['like_num']);
  1484. $v['read_num'] = numTransform($v['read_num']);
  1485. $v['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
  1486. $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
  1487. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1488. $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
  1489. $v['app_name'] = $article_auth['app_name'];
  1490. $v['app_logo'] = $article_auth['app_logo'];
  1491. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$v['article_id'],$v['item_id']);
  1492. $v['collect_num'] = UserCollect::getCollectNum(3,$v['article_id'],$v['item_id']);
  1493. $v['comment_num'] = ArticleComment::getArticleCommentNum($v['item_id']);
  1494. }
  1495. $total_num = ArticleLike::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
  1496. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1497. }
  1498. /**
  1499. * @title 以下接口为二期需求
  1500. * @desc 以下接口为二期需求
  1501. * @author qc
  1502. * @url /api/Article/secondPhase
  1503. * @method
  1504. * @return name:1 type:string default:-- desc:以下接口为二期需求
  1505. */
  1506. public function secondPhase(){}
  1507. /**
  1508. * @title 我的发布[审核成功]--后台图文绑定该会员
  1509. * @desc 后台图文绑定该会员
  1510. * @author qc
  1511. * @method GET
  1512. * @url /api/Article/getBoundList
  1513. * @header name:Authorization require:1 desc:Token
  1514. * @param name:title type:string default:-- desc:标题
  1515. * @param name:page type:int default:0 desc:页数
  1516. * @param name:page_num type:int default:20 desc:每页数
  1517. * @return name:id type:string default:-- desc:记录id【item_id】
  1518. * @return name:title type:string default:-- desc:标题
  1519. * @return name:series_title type:string default:-- desc:系列标题
  1520. * @return name:article_id type:string default:-- desc:图文id
  1521. * @return name:cover type:string default:-- desc:封面
  1522. * @return name:create_at type:string default:-- desc:时间
  1523. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1524. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1525. */
  1526. public function getBoundList()
  1527. {
  1528. $sel_where = [];
  1529. $title = input('get.title');
  1530. $sel_where[] = ['t.user_id','=',$this->user_id];
  1531. $sel_where[] = ['t.is_deleted','=',0];
  1532. if($title) $sel_where[] = ['t.title|t.label','like','%'.$title.'%'];
  1533. $list = ArticleItem::where($sel_where)
  1534. ->alias('t')
  1535. ->field('t.id,t.title,t.cover,t.read_num,t.label,t.is_vip,t.article_id,t.create_at,x.title series_title')
  1536. ->leftJoin('ArticleIntro x','t.article_id = x.id')
  1537. ->order('id desc')
  1538. ->limit($this->off_set,$this->page_num)
  1539. ->select()->toArray();
  1540. foreach ($list as &$v) {
  1541. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['id'],$this->request->controller());;
  1542. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')) :null;
  1543. }
  1544. $total_num = ArticleItem::where($sel_where)->alias('t')->count();
  1545. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1546. }
  1547. /**
  1548. * @title 我的订阅列表--图文
  1549. * @desc 我的订阅列表
  1550. * @author qc
  1551. * @method GET
  1552. * @url /api/Article/getFollowUpList
  1553. * @header name:Authorization require:1 desc:Token
  1554. * @param name:title type:string default:-- desc:标题
  1555. * @param name:page type:int default:0 desc:页数
  1556. * @param name:page_num type:int default:20 desc:每页数
  1557. * @return name:create_at type:string default:-- desc:追更设置时间
  1558. * @return name:article_id type:int default:-- desc:图文id
  1559. * @return name:total_sequel type:int default:-- desc:期数
  1560. * @return name:title type:string default:-- desc:标题
  1561. * @return name:is_recently type:int default:-- desc:是否最近观看【0否1是】
  1562. * @return name:recently_title type:string default:-- desc:上次观看标题
  1563. * @return name:recently_id type:int default:-- desc:上次观看记录id
  1564. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1565. */
  1566. public function getFollowUpList()
  1567. {
  1568. $sel_where = [];
  1569. $sel_where[] = ['p.user_id','=',$this->user_id];
  1570. $sel_where[] = ['p.type','=',3];
  1571. $sel_where[] = ['p.switch_value','=',1];
  1572. $title = input('title');
  1573. if($title) $sel_where[] = ['a.title','like','%'.$title.'%'];
  1574. $field = 'p.id,p.switch_id as article_id,p.create_at,a.title,a.total_sequel,a.cover,a.status ,a.is_deleted';
  1575. $list = PlatformSwitch::field($field)
  1576. ->alias('p')
  1577. ->leftJoin('ArticleIntro a','p.switch_id = a.id')
  1578. ->where($sel_where)
  1579. ->limit($this->off_set,$this->page_num)
  1580. ->order('p.id desc')
  1581. ->select()->toArray();
  1582. array_walk($list,function (&$v){
  1583. $v['is_normal'] = $v['status'] == 1 && $v['is_deleted'] == 0 ? 1 : 0;
  1584. $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$v['article_id']);
  1585. $v['is_recently'] = $recently_id ? 1 : 0;
  1586. $v['recently_id'] = $recently_id ? $recently_id : 0;
  1587. $v['recently_title'] = ArticleItem::where('id',$recently_id)->value('title');
  1588. });
  1589. $total_num= PlatformSwitch::field($field)->alias('p') ->leftJoin('ArticleIntro a','p.switch_id = a.id')->where($sel_where)->count();
  1590. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1591. }
  1592. /**
  1593. * @title 我的订阅---消息
  1594. * @desc 订阅消息
  1595. * @author qc
  1596. * @method GET
  1597. * @url /api/Article/getFollowUpMessage
  1598. * @header name:Authorization require:1 desc:Token
  1599. * @param name:title type:int default:-- desc:搜索内容
  1600. * @param name:page type:int default:-- desc:页数
  1601. * @param name:page_num type:int default:-- desc:每页数
  1602. *
  1603. * @return name:id type:int default:-- desc:记录id
  1604. * @return name:title type:string default:-- desc:标题
  1605. * @return name:content type:string default:-- desc:内容
  1606. * @return name:create_at type:string default:-- desc:时间
  1607. * @return name:is_read type:int default:-- desc:是否已读【0否1是】
  1608. * @return name:article_title type:string default:-- desc:系列标题
  1609. * @return name:series_title type:string default:-- desc:系列标题
  1610. * @return name:article_id type:int default:-- desc:系列id
  1611. * @return name:children_id type:int default:-- desc:详情id
  1612. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1613. */
  1614. public function getFollowUpMessage()
  1615. {
  1616. $title = input('title');
  1617. $list = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'article','m.type_id'=>5])
  1618. ->alias('m')
  1619. ->when($title,function ($query)use ($title){
  1620. if($title) $query->where('m.content','like','%'.$title.'%');})
  1621. ->field('m.id,v.create_at,m.is_read,m.content,m.relation_id article_id,m.module,v.title article_title,m.children_id')
  1622. ->leftJoin('ArticleIntro v','v.id= m.relation_id')
  1623. ->limit($this->off_set,$this->page_num)
  1624. ->order(['m.id'=>'desc'])
  1625. ->select()->toArray();
  1626. foreach ($list as &$v) {
  1627. $v['series_title'] =$v['article_title'];
  1628. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['children_id'],$this->request->controller());
  1629. }
  1630. $total_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'article','m.type_id'=>5])
  1631. ->alias('m')->leftJoin('ArticleIntro v','v.id= m.relation_id')->count();
  1632. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1633. }
  1634. /**
  1635. * @title 评论点赞列表--我的点赞
  1636. * @desc 评论点赞列表
  1637. * @author qc
  1638. * @method GET
  1639. * @url /api/Article/getTagsComment
  1640. * @header name:Authorization require:1 desc:Token
  1641. * @param name:title type:string default:-- desc:标题
  1642. * @param name:page type:int default:0 desc:页数
  1643. * @param name:page_num type:int default:20 desc:每页数
  1644. * @return name:create_at type:string default:-- desc:时间
  1645. * @return name:user_name type:string default:-- desc:会员名称
  1646. * @return name:headimg type:string default:-- desc:会员头像
  1647. * @return name:content type:string default:-- desc:评论内容
  1648. * @return name:cover type:string default:-- desc:封面
  1649. * @return name:title type:string default:-- desc:标题
  1650. * @return name:series_title type:string default:-- desc:系列标题
  1651. * @return name:read_num type:string default:-- desc:阅读量
  1652. * @return name:app_name type:string default:-- desc:发布者
  1653. * @return name:app_logo type:string default:-- desc:发布者头像
  1654. */
  1655. public function getTagsComment()
  1656. {
  1657. $list = ArticleCommentLike::field('l.*,i.read_num,c.content,i.read_num,i.title,i.cover,u.name user_name,u.headimg,i.user_id buid,i.id item_id,i.article_id,x.title series_title')
  1658. ->alias('l')
  1659. ->where(['l.user_id'=>$this->user_id,'l.type'=>1])
  1660. ->leftJoin('ArticleComment c','l.like_id = c.id')
  1661. ->leftJoin('ArticleItem i','i.id = c.item_id')
  1662. ->leftJoin('ArticleIntro x','x.id = i.article_id')
  1663. ->leftJoin('store_member u','u.id = c.user_id')
  1664. ->order('l.id desc')
  1665. ->limit($this->off_set,$this->page_num)
  1666. ->select()->toArray();
  1667. array_walk($list,function (&$v){
  1668. $article_auth = ArticleItem::getArticleAuth($v['buid'],APPNAME,APPLOGO);
  1669. $v['app_name'] = $article_auth['app_name'];
  1670. $v['app_logo'] = $article_auth['app_logo'];
  1671. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1672. });
  1673. $total_num =ArticleCommentLike::where(['l.user_id'=>$this->user_id,'l.type'=>1])
  1674. ->alias('l')
  1675. ->leftJoin('ArticleComment c','l.like_id = c.id')
  1676. ->leftJoin('ArticleItem i','i.id = c.item_id')
  1677. ->leftJoin('store_member u','u.id = c.user_id')
  1678. ->count();
  1679. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1680. }
  1681. /**
  1682. * @title 获取角标数量
  1683. * @desc 获取角标数量
  1684. * @author qc
  1685. * @method GET
  1686. * @url /api/Article/getMarkNum
  1687. * @header name:Authorization require:1 desc:Token
  1688. * @return name:reply_num type:int default:-- desc:未读量--回复我的
  1689. * @return name:comment_num type:int default:-- desc:未读量--评论我的
  1690. * @return name:praise_num type:int default:-- desc:点赞我的【包含视频点赞和评论点赞】
  1691. * @return name:article_praise_num type:int default:-- desc:-图文点赞
  1692. * @return name:comment_praise_num type:int default:-- desc:评论点赞
  1693. * @return name:follow_num type:int default:-- desc:订阅
  1694. */
  1695. public function getMarkNum()
  1696. {
  1697. // 评论我的
  1698. $comment_num = ArticleComment::where([['t.is_deleted','=',0],['i.user_id','=',$this->user_id],['t.user_id','<>',$this->user_id],['is_read','=',0],['t.pid','=',0]])
  1699. ->leftJoin('ArticleItem i','t.item_id = i.id')
  1700. ->alias('t')->count();
  1701. // 回复我的
  1702. $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1703. $reply_num = $all_comment ? ArticleComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count() : 0;
  1704. // 点赞我的
  1705. $all_article = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1706. $article_praise_num = ArticleLike ::where([['is_read','=',0],['item_id','in',$all_article],['user_id','<>',$this->user_id]])->count();
  1707. $comment_praise_num = ArticleCommentLike::where([['is_read','=',0],['like_id','in',$all_comment],['user_id','<>',$this->user_id]])->count();
  1708. $praise_num = $article_praise_num + $comment_praise_num;
  1709. $follow_num = UserMessage::getUnreadNum($this->user_id,'article',5);
  1710. $this->success('ok',compact(['reply_num','comment_num','praise_num','article_praise_num','comment_praise_num','follow_num']));
  1711. }
  1712. /**
  1713. * @title 消息已读&&未读变更
  1714. * @desc 消息已读
  1715. * @author qc
  1716. * @method POST
  1717. * @url /api/Article/unreadChange
  1718. * @header name:Authorization require:1 desc:Token
  1719. * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部)
  1720. * @param name:type type:string default:1 desc:消息类型【1评论我的,2回复我的,3订阅消息,4点赞我的--图文,5点赞我的--评论】
  1721. * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
  1722. *
  1723. */
  1724. public function unreadChange()
  1725. {
  1726. $type = input('post.type',1);
  1727. $id = input('post.id');
  1728. $where = [];
  1729. switch ($type) {
  1730. case 1:
  1731. ArticleComment::where([['i.user_id','=',$this->user_id],['t.pid','=',0]])
  1732. ->when($id ,function ($query)use ($id){
  1733. if($id) return $query->where('t.id','in',$id);
  1734. })->leftJoin('ArticleItem i','t.item_id = i.id')
  1735. ->alias('t')->update(['source_read'=>input('post.is_read'),'is_read'=>input('post.is_read')]);
  1736. break;
  1737. case 2:
  1738. $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1739. ArticleComment::where([['t.pid','in',implode(',',$all_comment)]])
  1740. ->when($id ,function ($query)use ($id){
  1741. if($id) return $query->where('t.id','in',$id);
  1742. })->alias('t')->update(['is_read'=>input('post.is_read')]);
  1743. break;
  1744. case 3:
  1745. $where[] = ['user_id','=',$this->user_id];
  1746. if($id) $where[] = ['id','in',$id];
  1747. UserMessage::where($where)->update(['is_read'=>input('post.is_read')]);
  1748. break;
  1749. case 4:
  1750. $all_article = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1751. ArticleLike::where([['is_read','=',0],['item_id','in',$all_article]])->update(['is_read'=>1]);
  1752. break;
  1753. case 5:
  1754. $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1755. ArticleCommentLike ::where([['is_read','=',0],['like_id','in',$all_comment]])->update(['is_read'=>1]);
  1756. break;
  1757. }
  1758. $this->success('消息变更成功');
  1759. }
  1760. /**
  1761. * @title 批量删除||批量取消
  1762. * @desc 删除||取消
  1763. * @author qc
  1764. * @method POST
  1765. * @url /api/Article/batchesDel
  1766. * @header name:Authorization require:1 desc:Token
  1767. * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
  1768. * @param name:type type:string default:1 desc:消息类型【1我的评论,2评论我的,3我的回复,4我的已购,5用户图文删除,6订阅记录,7订阅消息,8我的点赞-图文,9我的点赞-评论,10回复我的,11点赞我的--图文,12点赞我的--评论,13我的收藏】
  1769. */
  1770. public function batchesDel(){
  1771. $type = input('post.type',1);
  1772. $del_where = [];
  1773. $del_where[] = ['id','in',input('post.id')];
  1774. if(in_array($type,[1,3,4,5,6,7,8,9])) $del_where[] = ['user_id','=',$this->user_id];
  1775. if(in_array($type,[1,3])) ArticleComment::where($del_where)->update(['is_deleted'=>1]);
  1776. if(in_array($type,[2])) ArticleComment::where($del_where)->update(['source_deleted'=>1,'source_read'=>1,'is_read'=>1]);
  1777. if(in_array($type,[10])) ArticleComment::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  1778. if(in_array($type,[4])) UserLearn::where($del_where)->update(['is_deleted'=>1]);
  1779. if(in_array($type,[5])) UserArticle::where($del_where)->update(['is_deleted'=>1]);
  1780. if(in_array($type,[6])) PlatformSwitch::where($del_where)->delete();
  1781. if(in_array($type,[7])) UserMessage::where($del_where)->update(['is_deleted'=>1]);
  1782. if(in_array($type,[8])) ArticleLike::where($del_where)->delete();
  1783. if(in_array($type,[11])) ArticleLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  1784. if(in_array($type,[9])) ArticleCommentLike::where($del_where)->delete();
  1785. if(in_array($type,[12])) ArticleCommentLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  1786. if(in_array($type,[13])) UserCollect::where($del_where)->delete();
  1787. $this->success('操作成功');
  1788. }
  1789. /**
  1790. * @title 点赞我的--图文
  1791. * @desc 点赞我的--图文
  1792. * @author qc
  1793. * @method GET
  1794. * @url /api/Article/praiseMyArticleList
  1795. * @header name:Authorization require:1 desc:Token
  1796. * @param name:page type:int default:-- desc:页数
  1797. * @param name:page_num type:int default:-- desc:每页数
  1798. *
  1799. * @return name:id type:int default:-- desc:记录id
  1800. * @return name:title type:string default:-- desc:标题
  1801. * @return name:series_title type:string default:-- desc:系列标题
  1802. * @return name:create_at type:string default:-- desc:时间
  1803. * @return name:read_num type:int default:-- desc:阅读量
  1804. * @return name:user_name type:string default:-- desc:会员名称
  1805. * @return name:headimg type:string default:-- desc:会员头像
  1806. * @return name:cover type:string default:-- desc:封面
  1807. */
  1808. public function praiseMyArticleList()
  1809. {
  1810. $all_list = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1811. $user_info = $this->userInfo('name,headimg');
  1812. $list = ArticleLike::where([['l.item_id','in',$all_list],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1813. ->alias('l')
  1814. ->field('l.id,l.user_id,m.name user_name,m.headimg,l.create_at,v.cover,v.title,v.read_num,x.title series_title,v.article_id,l.item_id')
  1815. ->leftJoin('StoreMember m','m.id = l.user_id')
  1816. ->leftJoin('ArticleItem v','v.id = l.item_id')
  1817. ->leftJoin('ArticleIntro x','x.id = v.article_id')
  1818. ->limit($this->off_set,$this->page_num)
  1819. ->select()->toArray();
  1820. array_walk($list,function (&$v,$k)use ($user_info){
  1821. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1822. $v['app_name'] = $user_info['name'] ;
  1823. $v['app_logo'] = $user_info['headimg'];
  1824. $v['read_num'] = numTransform($v['read_num']);
  1825. });
  1826. $total_num = ArticleLike::where([['item_id','in',$all_list],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1827. ->alias('l')
  1828. ->leftJoin('StoreMember m','m.id = l.user_id')
  1829. ->leftJoin('ArticleItem v','v.id = l.item_id')
  1830. ->count();
  1831. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1832. }
  1833. /**
  1834. * @title 点赞我的--评论
  1835. * @desc 点赞我的--评论
  1836. * @author qc
  1837. * @method GET
  1838. * @url /api/Article/praiseMyComment
  1839. * @header name:Authorization require:1 desc:Token
  1840. * @param name:page type:int default:-- desc:页数
  1841. * @param name:page_num type:int default:-- desc:每页数
  1842. * @return name:id type:int default:-- desc:记录id
  1843. * @return name:title type:string default:-- desc:标题
  1844. * @return name:series_title type:string default:-- desc:系列标题
  1845. * @return name:create_at type:string default:-- desc:时间
  1846. * @return name:read_num type:int default:-- desc:播放量
  1847. * @return name:self_name type:string default:-- desc:会员名称[自己的]
  1848. * @return name:user_name type:string default:-- desc:会员名称【别人的】
  1849. * @return name:headimg type:string default:-- desc:会员头像
  1850. * @return name:cover type:string default:-- desc:封面
  1851. * @return name:like_id type:int default:-- desc:评论id
  1852. */
  1853. public function praiseMyComment()
  1854. {
  1855. $user_info = $this->userInfo('name,headimg');
  1856. $list = ArticleCommentLike::where([['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1857. ->alias('l')
  1858. ->field('l.id,l.user_id,l.like_id,m.name user_name,m.headimg,l.create_at,v.cover,c.content,v.title,v.read_num,x.title series_title,v.article_id,c.item_id,v.user_id buid')
  1859. ->leftJoin('StoreMember m','m.id = l.user_id')
  1860. ->leftJoin('ArticleComment c','c.id = l.like_id')
  1861. ->leftJoin('ArticleItem v','v.id = c.item_id')
  1862. ->leftJoin('ArticleIntro x','x.id = v.article_id')
  1863. ->order('l.id desc')
  1864. ->limit($this->off_set,$this->page_num)
  1865. ->select()->toArray();
  1866. array_walk($list,function (&$v,$k)use ($user_info){
  1867. $v['self_name'] = $user_info['name'] ;
  1868. $article_auth = ArticleItem::getArticleAuth($v['buid'],APPNAME,APPLOGO);
  1869. $v['app_name'] = $article_auth['app_name'];
  1870. $v['app_logo'] = $article_auth['app_logo'];
  1871. $v['read_num'] = numTransform($v['read_num']);
  1872. $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
  1873. });
  1874. $total_num = ArticleCommentLike::where([['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1875. ->alias('l')->leftJoin('StoreMember m','m.id = l.user_id')
  1876. ->leftJoin('ArticleComment c','c.id = l.like_id')
  1877. ->leftJoin('ArticleItem v','v.id = c.item_id')->count();
  1878. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1879. }
  1880. }