BookController.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <?php
  2. namespace App\Http\Controllers\QuickApp\Book;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\QuickApp\BaseController;
  5. use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
  6. use App\Modules\Book\Services\BookConfigService;
  7. use App\Modules\Book\Services\UserShelfBooksService;
  8. use App\Modules\Book\Services\ChapterService;
  9. use Hashids;
  10. use App\Modules\Subscribe\Services\YearOrderService;
  11. use Log;
  12. class BookController extends BaseController
  13. {
  14. /**
  15. * @apiDefine Book 图书
  16. */
  17. /**
  18. * @apiVersion 1.0.0
  19. * @apiDescription 获取图书详情
  20. * @api {get} book/{bid} 获取图书详情
  21. * @apiGroup Book
  22. * @apiName index
  23. * @apiParam {String} [token] token
  24. * @apiHeader {String} [Authorization] token 两个token任选其一
  25. * @apiSuccess {int} code 状态码
  26. * @apiSuccess {String} msg 信息
  27. * @apiSuccess {object} data 结果集
  28. * @apiSuccess {Int} data.book_id bid
  29. * @apiSuccess {String} data.book_name 书名
  30. * @apiSuccess {String} data.book_summary 简介
  31. * @apiSuccess {String} data.book_author 作者
  32. * @apiSuccess {String} data.cover_url 封面
  33. * @apiSuccess {Int} data.book_word_count 字数
  34. * @apiSuccess {Int} data.book_chapter_total 章节数
  35. * @apiSuccess {Int} data.book_category_id 分类
  36. * @apiSuccess {String} data.book_category 分类名
  37. * @apiSuccess {Int} data.book_end_status 是否完结
  38. * @apiSuccess {String} data.book_published_time 发布时间
  39. * @apiSuccess {String} data.copyright 版权信息
  40. * @apiSuccess {Int} data.force_subscribe_chapter_id 强制关注的章节数
  41. * @apiSuccess {String} data.update_time 更新时间
  42. * @apiSuccess {Int} data.is_on_user_shelf 是否加入架
  43. * @apiSuccess {Int} data.book_price 是否上架
  44. * @apiSuccess {String} data.charge_type 收费类型
  45. * @apiSuccess {String} data.keyword 关键词
  46. * @apiSuccess {String} data.recommend_index 推荐指数
  47. * @apiSuccess {String} data.is_show_index_content 是否显示推荐指数文本
  48. * @apiSuccess {Int} data.click_count 点击数
  49. * @apiSuccess {Int} data.product_id product_id
  50. * @apiSuccess {Int} data.last_cid 最后一张cid
  51. * @apiSuccess {Int} data.last_chapter 第254章 婚礼(大结局)
  52. * @apiSuccess {Int} data.last_chapter_is_vip 第254章 婚礼(大结局)
  53. * @apiSuccess {Int} data.first_cid 第一章cid
  54. * @apiSuccessExample {json} Success-Response:
  55. * HTTP/1.1 200 OK
  56. * {
  57. * code: 0,
  58. * msg: "",
  59. * data: {
  60. * book_id: 5,
  61. * book_name: "肌缘巧合",
  62. * book_summary: "&nbsp;&nbsp;&nbsp;&nbsp;他是权势倾天,纵横商界的王者,却偏偏钟情于她,一宠成瘾。“女人,我要你......只要你能满足我,别墅、游轮、支票,你随便挑。”她羞涩的半低着头:“我只想要你。”他挑眉,“你野心不小啊!”她妩媚一笑,解开他的领带,“难道你不愿意!”他宠她爱她,给她所有想要的。只是有一天她终于忍不住暴走,“靠,你有没有节制呀?我要离婚。”",
  63. * book_author: "妖火",
  64. * cover_url: "http://www.leyuee.com/cover/0/8.jpg",
  65. * book_word_count: 0,
  66. * book_chapter_total: 0,
  67. * book_category_id: null,
  68. * book_category: "爆笑,宠文,潜规则",
  69. * book_end_status: 8,
  70. * book_published_time: null,
  71. * copyright: null,
  72. * charge_type: null,
  73. * force_subscribe_chapter_id: 0,
  74. * update_time: null,
  75. * is_on_user_shelf: 0,
  76. * book_price: null,
  77. * keyword: 关键词,
  78. * recommend_index:2,
  79. * is_show_index_content:0,
  80. * click_count:0,
  81. * product_id:0,
  82. * last_cid:0,
  83. * last_chapter:0,
  84. * last_chapter_is_vip:0,
  85. * }
  86. * }
  87. */
  88. public function index(Request $request,$bid){
  89. $bid = Hashids::decode($bid)[0];
  90. $book_info = BookConfigService::getBookById($bid);
  91. if(!$book_info){
  92. return response()->error('QAPP_SYS_ERROR');
  93. }
  94. if(!in_array($book_info->is_on_shelf,[1,2])){
  95. return response()->error('QAPP_OFF_SHELF');
  96. }
  97. $is_on_shelf = UserShelfBooksService::getUserShelfBooksListByUidAndBid($this->uid,$bid);
  98. $book_info['is_on_user_shelf'] = 0;
  99. if($is_on_shelf){
  100. $book_info['is_on_user_shelf'] = 1;
  101. }
  102. $last_chapter = ChapterService::getChapterNameById($book_info['last_cid'],$bid);//chapter_is_vip
  103. $book_info['last_chapter_is_vip'] = $last_chapter['is_vip'];
  104. return response()->item(new BookTransformer(), $book_info);
  105. }
  106. /**
  107. * @apiVersion 1.0.0
  108. * @apiDescription 首页(male|female)
  109. * @api {get} books/{sex}/index 首页(male|female)
  110. * @apiGroup Book
  111. * @apiParam {String} [token] token
  112. * @apiHeader {String} [Authorization] token 两个token任选其一
  113. * @apiName getBookLists
  114. * @apiSuccess {int} code 状态码
  115. * @apiSuccess {String} msg 信息
  116. * @apiSuccess {object} data 结果集
  117. * @apiSuccessExample {json} Success-Response:
  118. * HTTP/1.1 200 OK
  119. * {
  120. * code: 0,
  121. * msg: "",
  122. * data: [
  123. * {
  124. * type: "lunbo",
  125. * lable: "男频",
  126. * books: [
  127. * {},{}
  128. * ]
  129. * },
  130. * {
  131. * type: "hot",
  132. * lable: "热门推荐",
  133. * books: [
  134. * {},{}
  135. * ]
  136. * }
  137. * ]
  138. * }
  139. */
  140. public function getBookLists(Request $request,$sex){
  141. if($sex == 'male'){
  142. $type = [
  143. 'BOOK_MALE_LOOP',
  144. 'BOOK_MALE_HOT',
  145. 'BOOK_MALE_ZHIBO',
  146. 'BOOK_MALE_RECOM',
  147. 'BOOK_MALE_NEW_RECOM'
  148. ];
  149. }else{
  150. $type = [
  151. 'BOOK_FEMALE_LOOP',
  152. 'BOOK_FEMALE_HOT',
  153. 'BOOK_FEMALE_ZHIBO',
  154. 'BOOK_FEMALE_RECOM',
  155. 'BOOK_FEMALE_NEW_RECOM'
  156. ];
  157. }
  158. $book = [
  159. ['type'=>'lunbo','lable'=>'','books'=>''],
  160. ['type'=>'hot','lable'=>'热门推荐','books'=>''],
  161. ['type'=>'zhibo','lable'=>'神书直播','books'=>''],
  162. ['type'=>'recom','lable'=>'编辑推荐','books'=>''],
  163. ['type'=>'new_recom','lable'=>'新书推荐','books'=>''],
  164. ];
  165. foreach ($type as $key=>$v){
  166. $book[$key]['books'] = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',env($v))));
  167. }
  168. return response()->success($book);
  169. }
  170. /**
  171. * @apiVersion 1.0.0
  172. * @apiDescription 书库
  173. * @api {get} books/library 书库
  174. * @apiParam {String} key
  175. * @apiParam {Int} category_id 分类id
  176. * @apiParam {String} order_field 排序字段(推荐指数:recommend_index|点击数:click_count|字数:size|update:时间)
  177. * @apiParam {String} order_seq 排序顺序(顺序:asc|逆序:desc)
  178. * @apiParam {String} [page_size] 分页大小
  179. * @apiParam {String} [page] 页码
  180. * @apiParam {String} [status] 完结与否(0|1)完结1 连载0
  181. * @apiParam {String} [token] token
  182. * @apiHeader {String} [Authorization] token 两个token任选其一
  183. * @apiGroup Book
  184. * @apiName library
  185. * @apiSuccess {int} code 状态码
  186. * @apiSuccess {String} msg 信息
  187. * @apiSuccess {object} data 结果集
  188. * @apiSuccess {Array} data.list 结果数据集
  189. * @apiSuccess {Int} data.list.book_id bid
  190. * @apiSuccess {String} data.list.book_name 书名
  191. * @apiSuccess {String} data.list.book_summary 简介
  192. * @apiSuccess {String} data.list.book_author 作者
  193. * @apiSuccess {String} data.list.cover_url 封面
  194. * @apiSuccess {Int} data.list.book_word_count 字数
  195. * @apiSuccess {Int} data.list.book_chapter_total 章节数
  196. * @apiSuccess {Int} data.list.book_category_id 分类
  197. * @apiSuccess {String} data.list.book_category 分类名
  198. * @apiSuccess {String} data.list.book_end_status 是否完结
  199. * @apiSuccess {String} data.list.book_published_time 发布时间
  200. * @apiSuccess {String} data.list.copyright 版权信息
  201. * @apiSuccess {Int} data.list.force_subscribe_chapter_id 强制关注的章节数
  202. * @apiSuccess {String} data.list.update_time 更新时间
  203. * @apiSuccess {Int} data.list.is_on_shelf 是否上架
  204. * @apiSuccess {String} data.list.book_price 是否上架
  205. * @apiSuccess {String} data.list.recommend_index 推荐指数
  206. * @apiSuccess {Int} data.list.charge_type 收费类型
  207. * @apiSuccess {Int} data.list.keyword 关键词
  208. * @apiSuccess {Int} data.list.is_show_index_content 是否显示推荐指数文本
  209. * @apiSuccess {Int} data.list.click_count 点击数
  210. * @apiSuccess {Int} data.list.product_id product_id
  211. * @apiSuccess {Int} data.list.last_cid 1224
  212. * @apiSuccess {Int} data.list.last_chapter 第254章 婚礼(大结局)
  213. * @apiSuccess {object} data.meta 分页信息
  214. * @apiSuccess {Int} data.meta.total 总条数
  215. * @apiSuccess {Int} data.meta.per_page 每页条数
  216. * @apiSuccess {Int} data.meta.current_page 当前页
  217. * @apiSuccess {Int} data.meta.last_page 最后页
  218. * @apiSuccess {String} data.meta.next_page_url 下一页
  219. * @apiSuccess {String} data.meta.prev_page_url 上一页
  220. * @apiSuccessExample {json} Success-Response:
  221. * HTTP/1.1 200 OK
  222. * {
  223. * code: 0,
  224. * msg: "",
  225. * data: {
  226. * list: [
  227. * {
  228. * book_id: 5,
  229. * book_name: "肌缘巧合",
  230. * book_summary: "&nbsp;&nbsp;&nbsp;&nbsp;他是权势倾天,纵横商界的王者,却偏偏钟情于她,一宠成瘾。“女人,我要你......只要你能满足我,别墅、游轮、支票,你随便挑。”她羞涩的半低着头:“我只想要你。”他挑眉,“你野心不小啊!”她妩媚一笑,解开他的领带,“难道你不愿意!”他宠她爱她,给她所有想要的。只是有一天她终于忍不住暴走,“靠,你有没有节制呀?我要离婚。”",
  231. * book_author: "妖火",
  232. * cover_url: "http://www.leyuee.com/cover/0/8.jpg",
  233. * book_word_count: 0,
  234. * book_chapter_total: 0,
  235. * book_category_id: null,
  236. * book_category: "爆笑,宠文,潜规则",
  237. * book_end_status: 8,
  238. * book_published_time: null,
  239. * copyright: null,
  240. * charge_type: null,
  241. * force_subscribe_chapter_id: 0,
  242. * update_time: null,
  243. * is_on_shelf: 1,
  244. * book_price: null,
  245. * keyword: "温馨,虐心,清水",
  246. * recommend_index:2,
  247. * is_show_index_content:0,
  248. * click_count:0,
  249. * product_id:0,
  250. * last_cid:0,
  251. * last_chapter:第254章 婚礼(大结局),
  252. * },
  253. * ],
  254. * meta: {
  255. * total: 18,
  256. * per_page: 15,
  257. * current_page: 1,
  258. * last_page: 2,
  259. * next_page_url: "http://myapi.cn/api/hotrank/books?page=2",
  260. * prev_page_url: ""
  261. * }
  262. * }
  263. * }
  264. */
  265. public function library(Request $request){
  266. $where = [];
  267. //$order = ['book_configs.id','asc'];
  268. $order = [];
  269. $where['is_on_shelf'] = [1,2];
  270. $category_id = $request->input('category_id');
  271. if($category_id){
  272. if($category_id == 1){
  273. $where['channel_name'] = '男频';
  274. }elseif($category_id == 2){
  275. $where['channel_name'] = '女频';
  276. }else{
  277. $where['category_id'] = $category_id;
  278. }
  279. }
  280. $key = $request->input('key');
  281. $where['key'] = $key;
  282. $order_field = $request->input('order_field');
  283. $order_seq = $request->input('order_seq');
  284. if($order_field != '' && in_array($order_field,['recommend_index','click_count','update','size','create'])){
  285. if($order_field == 'update'){
  286. $order = ['book_configs.updated_at','desc'];
  287. }elseif ($order_field == 'create') {
  288. $order = ['book_configs.created_at','desc'];
  289. }
  290. else{
  291. $order = [$order_field,'desc'];
  292. }
  293. if($order_seq == 'asc'){
  294. $order = [$order_field,'asc'];
  295. }
  296. if($order_seq == 'desc'){
  297. $order = [$order_field,'desc'];
  298. }
  299. }
  300. $status = $request->input('status');
  301. if($status != ''){
  302. $where['status'] = $status;
  303. }
  304. $page_size = $request->input('page_size',15);
  305. $books = BookConfigService::getBooks($where,$order,$page_size);
  306. return response()->pagination(new BookTransformer,$books);
  307. }
  308. /**
  309. * @apiVersion 1.0.0
  310. * @apiDescription 相似推荐
  311. * @api {get} books/similar 相似推荐
  312. * @apiParam {Int} category_id
  313. * @apiParam {Int} bid
  314. * @apiGroup Book
  315. * @apiName similarRecom
  316. * @apiParam {String} [token] token
  317. * @apiHeader {String} [Authorization] token 两个token任选其一
  318. * @apiSuccess {int} code 状态码
  319. * @apiSuccess {String} msg 信息
  320. * @apiSuccess {object} data 结果集
  321. * @apiSuccess {Array} data 结果数据集
  322. * @apiSuccess {Int} data.book_id bid
  323. * @apiSuccess {String} data.book_name 书名
  324. * @apiSuccess {String} data.book_summary 简介
  325. * @apiSuccess {String} data.book_author 作者
  326. * @apiSuccess {String} data.cover_url 封面
  327. * @apiSuccess {Int} data.book_word_count 字数
  328. * @apiSuccess {Int} data.book_chapter_total 章节数
  329. * @apiSuccess {Int} data.book_category_id 分类
  330. * @apiSuccess {String} data.book_category 分类名
  331. * @apiSuccess {String} data.book_end_status 是否完结
  332. * @apiSuccess {String} data.book_published_time 发布时间
  333. * @apiSuccess {String} data.copyright 版权信息
  334. * @apiSuccess {Int} data.force_subscribe_chapter_id 强制关注的章节数
  335. * @apiSuccess {String} data.update_time 更新时间
  336. * @apiSuccess {Int} data.is_on_shelf 是否上架
  337. * @apiSuccess {String} data.book_price 是否上架
  338. * @apiSuccess {String} data.recommend_index 推荐指数
  339. * @apiSuccess {Int} data.charge_type 收费类型
  340. * @apiSuccess {Int} data.keyword 关键词
  341. * @apiSuccess {Int} data.is_show_index_content 是否显示推荐指数文本
  342. * @apiSuccess {Int} data.click_count 点击数
  343. * @apiSuccess {Int} data.product_id product_id
  344. * @apiSuccess {Int} data.last_cid 123
  345. * @apiSuccess {Int} data.last_chapter 第254章 婚礼(大结局)
  346. * @apiSuccessExample {json} Success-Response:
  347. * HTTP/1.1 200 OK
  348. * {
  349. * code: 0,
  350. * msg: "",
  351. * data: {
  352. * [
  353. * {
  354. * book_id: 5,
  355. * book_name: "肌缘巧合",
  356. * book_summary: "&nbsp;&nbsp;&nbsp;&nbsp;他是权势倾天,纵横商界的王者,却偏偏钟情于她,一宠成瘾。“女人,我要你......只要你能满足我,别墅、游轮、支票,你随便挑。”她羞涩的半低着头:“我只想要你。”他挑眉,“你野心不小啊!”她妩媚一笑,解开他的领带,“难道你不愿意!”他宠她爱她,给她所有想要的。只是有一天她终于忍不住暴走,“靠,你有没有节制呀?我要离婚。”",
  357. * book_author: "妖火",
  358. * cover_url: "http://www.leyuee.com/cover/0/8.jpg",
  359. * book_word_count: 0,
  360. * book_chapter_total: 0,
  361. * book_category_id: null,
  362. * book_category: "爆笑,宠文,潜规则",
  363. * book_end_status: 8,
  364. * book_published_time: null,
  365. * copyright: null,
  366. * charge_type: null,
  367. * force_subscribe_chapter_id: 0,
  368. * update_time: null,
  369. * is_on_shelf: 1,
  370. * book_price: null,
  371. * keyword: "温馨,虐心,清水",
  372. * recommend_index:2,
  373. * is_show_index_content:0,
  374. * click_count:0,
  375. * product_id:0,
  376. * last_cid:0,
  377. * last_chapter:第254章 婚礼(大结局),
  378. * },
  379. * ],
  380. * }
  381. * }
  382. */
  383. public function similarRecom (Request $request){
  384. $category_id = $request->input('category_id');
  385. $bid = $request->input('bid');
  386. if(empty($bid) || empty($category_id)){
  387. return response()->error('PARAM_ERROR');
  388. }
  389. $bid = Hashids::decode($bid)[0];
  390. $where = ['category_id'=>$category_id,'is_on_shelf'=>[1,2]];
  391. $books = BookConfigService::getBooks($where,[],4);
  392. $data = [];
  393. foreach ($books as $v){
  394. if($v->bid != $bid && count($data) <3){
  395. $data[] = $v;
  396. }
  397. }
  398. return response()->collection(new BookTransformer(),$data);
  399. }
  400. /**
  401. * @apiVersion 1.0.0
  402. * @apiDescription 尾页推荐
  403. * @api {get} books/readOverRecommend 尾页推荐
  404. * @apiParam {Int} bid
  405. * @apiGroup Book
  406. * @apiParam {String} [token] token
  407. * @apiHeader {String} [Authorization] token 两个token任选其一
  408. * @apiName readOverRecommend
  409. * @apiSuccess {int} code 状态码
  410. * @apiSuccess {String} msg 信息
  411. * @apiSuccess {object} data 结果集
  412. * @apiSuccess {Array} data 结果数据集
  413. * @apiSuccess {Int} data.book_id bid
  414. * @apiSuccess {String} data.book_name 书名
  415. * @apiSuccess {String} data.book_summary 简介
  416. * @apiSuccess {String} data.book_author 作者
  417. * @apiSuccess {String} data.cover_url 封面
  418. * @apiSuccess {Int} data.book_word_count 字数
  419. * @apiSuccess {Int} data.book_chapter_total 章节数
  420. * @apiSuccess {Int} data.book_category_id 分类
  421. * @apiSuccess {String} data.book_category 分类名
  422. * @apiSuccess {String} data.book_end_status 是否完结
  423. * @apiSuccess {String} data.book_published_time 发布时间
  424. * @apiSuccess {String} data.copyright 版权信息
  425. * @apiSuccess {Int} data.force_subscribe_chapter_id 强制关注的章节数
  426. * @apiSuccess {String} data.update_time 更新时间
  427. * @apiSuccess {Int} data.is_on_shelf 是否上架
  428. * @apiSuccess {String} data.book_price 是否上架
  429. * @apiSuccess {String} data.recommend_index 推荐指数
  430. * @apiSuccess {Int} data.charge_type 收费类型
  431. * @apiSuccess {Int} data.keyword 关键词
  432. * @apiSuccess {Int} data.is_show_index_content 是否显示推荐指数文本
  433. * @apiSuccess {Int} data.click_count 点击数
  434. * @apiSuccess {Int} data.product_id product_id
  435. * @apiSuccess {Int} data.last_cid 123
  436. * @apiSuccess {Int} data.last_chapter 第254章 婚礼(大结局)
  437. * @apiSuccessExample {json} Success-Response:
  438. * HTTP/1.1 200 OK
  439. * {
  440. * code: 0,
  441. * msg: "",
  442. * data: {
  443. * [
  444. * {
  445. * book_id: 5,
  446. * book_name: "肌缘巧合",
  447. * book_summary: "&nbsp;&nbsp;&nbsp;&nbsp;他是权势倾天,纵横商界的王者,却偏偏钟情于她,一宠成瘾。“女人,我要你......只要你能满足我,别墅、游轮、支票,你随便挑。”她羞涩的半低着头:“我只想要你。”他挑眉,“你野心不小啊!”她妩媚一笑,解开他的领带,“难道你不愿意!”他宠她爱她,给她所有想要的。只是有一天她终于忍不住暴走,“靠,你有没有节制呀?我要离婚。”",
  448. * book_author: "妖火",
  449. * cover_url: "http://www.leyuee.com/cover/0/8.jpg",
  450. * book_word_count: 0,
  451. * book_chapter_total: 0,
  452. * book_category_id: null,
  453. * book_category: "爆笑,宠文,潜规则",
  454. * book_end_status: 8,
  455. * book_published_time: null,
  456. * copyright: null,
  457. * charge_type: null,
  458. * force_subscribe_chapter_id: 0,
  459. * update_time: null,
  460. * is_on_shelf: 1,
  461. * book_price: null,
  462. * keyword: "温馨,虐心,清水",
  463. * recommend_index:2,
  464. * is_show_index_content:0,
  465. * click_count:0,
  466. * product_id:0,
  467. * last_cid:0,
  468. * last_chapter:第254章 婚礼(大结局),
  469. * },
  470. * ],
  471. * }
  472. * }
  473. */
  474. public function readOverRecommend(Request $request){
  475. $bid = $request->input('bid');
  476. if(empty($bid)){
  477. return response()->error('PARAM_ERROR');
  478. }
  479. $bid = Hashids::decode($bid)[0];
  480. $book_info = BookConfigService::getBookById($bid);
  481. $res = BookConfigService::getRecommendBooks($bid,$book_info->category_id);
  482. return response()->collection(new BookTransformer(),$res);
  483. }
  484. /**
  485. * @apiVersion 1.0.0
  486. * @apiDescription 排行帮
  487. * @api {get} books/rank 排行帮
  488. * @apiParam {Int} type (点击帮:1|字数帮:2|新书榜|3)
  489. * @apiParam {Int} time (周:1|月:2|总|3)
  490. * @apiParam {String} [token] token
  491. * @apiHeader {String} [Authorization] token 两个token任选其一
  492. * @apiGroup Book
  493. * @apiName rank
  494. * @apiSuccess {int} code 状态码
  495. * @apiSuccess {String} msg 信息
  496. * @apiSuccess {object} data 结果集
  497. * @apiSuccess {Array} data 结果数据集
  498. * @apiSuccess {Int} data.book_id bid
  499. * @apiSuccess {String} data.book_name 书名
  500. * @apiSuccess {String} data.book_summary 简介
  501. * @apiSuccess {String} data.book_author 作者
  502. * @apiSuccess {String} data.cover_url 封面
  503. * @apiSuccess {Int} data.book_word_count 字数
  504. * @apiSuccess {Int} data.book_chapter_total 章节数
  505. * @apiSuccess {Int} data.book_category_id 分类
  506. * @apiSuccess {String} data.book_category 分类名
  507. * @apiSuccess {String} data.book_end_status 是否完结
  508. * @apiSuccess {String} data.book_published_time 发布时间
  509. * @apiSuccess {String} data.copyright 版权信息
  510. * @apiSuccess {Int} data.force_subscribe_chapter_id 强制关注的章节数
  511. * @apiSuccess {String} data.update_time 更新时间
  512. * @apiSuccess {Int} data.is_on_shelf 是否上架
  513. * @apiSuccess {String} data.book_price 是否上架
  514. * @apiSuccess {String} data.recommend_index 推荐指数
  515. * @apiSuccess {Int} data.charge_type 收费类型
  516. * @apiSuccess {Int} data.keyword 关键词
  517. * @apiSuccess {Int} data.is_show_index_content 是否显示推荐指数文本
  518. * @apiSuccess {Int} data.click_count 点击数
  519. * @apiSuccess {Int} data.product_id product_id
  520. * @apiSuccess {Int} data.last_cid 123
  521. * @apiSuccess {Int} data.last_chapter 第254章 婚礼(大结局)
  522. * @apiSuccessExample {json} Success-Response:
  523. * HTTP/1.1 200 OK
  524. * {
  525. * code: 0,
  526. * msg: "",
  527. * data: {
  528. * male:[
  529. * {
  530. * book_id: 5,
  531. * book_name: "肌缘巧合",
  532. * book_summary: "&nbsp;&nbsp;&nbsp;&nbsp;他是权势倾天,纵横商界的王者,却偏偏钟情于她,一宠成瘾。“女人,我要你......只要你能满足我,别墅、游轮、支票,你随便挑。”她羞涩的半低着头:“我只想要你。”他挑眉,“你野心不小啊!”她妩媚一笑,解开他的领带,“难道你不愿意!”他宠她爱她,给她所有想要的。只是有一天她终于忍不住暴走,“靠,你有没有节制呀?我要离婚。”",
  533. * book_author: "妖火",
  534. * cover_url: "http://www.leyuee.com/cover/0/8.jpg",
  535. * book_word_count: 0,
  536. * book_chapter_total: 0,
  537. * book_category_id: null,
  538. * book_category: "爆笑,宠文,潜规则",
  539. * book_end_status: 8,
  540. * book_published_time: null,
  541. * copyright: null,
  542. * charge_type: null,
  543. * force_subscribe_chapter_id: 0,
  544. * update_time: null,
  545. * is_on_shelf: 1,
  546. * book_price: null,
  547. * keyword: "温馨,虐心,清水",
  548. * recommend_index:2,
  549. * is_show_index_content:0,
  550. * click_count:0,
  551. * product_id:0,
  552. * last_cid:0,
  553. * last_chapter:第254章 婚礼(大结局),
  554. * },
  555. * ],
  556. * female:[{},{}]
  557. * }
  558. * }
  559. */
  560. public function rank(Request $request){
  561. $type = $request->input('type');
  562. $time = $request->input('time');
  563. if($type == 1){
  564. //点击帮
  565. if($time == 1){
  566. //周
  567. $midstr = env('CLICK_RANK_MALE_WEEK','677,694,638,642,641,673,635,639,637,4');
  568. $fidstr = env('CLICK_RANK_FEMALE_WEEK','614,636,587,48,1,6,354,99,159,355');
  569. }elseif($time == 2){
  570. //月
  571. $midstr = env('CLICK_RANK_MALE_MONTH','757,775,780,612,638,635,694,639,642,693');
  572. $fidstr = env('CLICK_RANK_FEMALE_MONTH','324,614,6,1,5,10,48,57,41,58');
  573. }else{
  574. $midstr = env('CLICK_RANK_MALE_TOTAL','757,775,780,612,634,677,694,638,642,635');
  575. $fidstr = env('CLICK_RANK_FEMALE_TOTAL','324,614,636,1,5,6,521,10,41,48');
  576. }
  577. $female = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$fidstr)));
  578. $male = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$midstr)));
  579. }elseif($type == 2){
  580. //字数帮
  581. if($time == 1){
  582. //周
  583. $midstr = env('WORD_RANK_MALE_WEEK','638,673,635,637,680,642,86,774,764,736');
  584. $fidstr = env('WORD_RANK_FEMALE_WEEK','48,58,324,354,159,262,7,9,11,525');
  585. }elseif($time == 2){
  586. //月
  587. $midstr = env('WORD_RANK_MALE_MONTH','2,638,642,635,639,4,743,680,736,73');
  588. $fidstr = env('WORD_RANK_FEMALE_MONTH','1,10,48,58,324,354,159,442,355,464');
  589. }else{
  590. $midstr = env('WORD_RANK_MALE_TOTAL','638,677,694,635,612,693,634,642,775,780');
  591. $fidstr = env('WORD_RANK_FEMALE_TOTAL','57,636,614,1,10,48,58,324,354,99');
  592. }
  593. $female = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$fidstr)));
  594. $male = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$midstr)));
  595. }
  596. elseif ($type == 3) {
  597. //新书榜
  598. if($time == 1){
  599. //周
  600. $midstr = env('NEW_RANK_MALE_WEEK','635,639,4,642,629,446,741,737,731,86');
  601. $fidstr = env('NEW_RANK_FEMALE_WEEK','135,587,617,625,627,467,213,233,529,357');
  602. }elseif($time == 2){
  603. //月
  604. $midstr = env('NEW_RANK_MALE_MONTH','757,775,780,612,634,677,694,638,642,635');
  605. $fidstr = env('NEW_RANK_FEMALE_MONTH','33,39,40,51,587,617,625,627,50,60');
  606. }else{
  607. $midstr = env('NEW_RANK_MALE_TOTAL','693,641,673,637,4,3,612,634,677,694');
  608. $fidstr = env('NEW_RANK_FEMALE_TOTAL','284,30,33,39,40,51,587,50,60,357');
  609. }
  610. $female = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$fidstr)));
  611. $male = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$midstr)));
  612. }else{
  613. return response()->error('PARAM_ERROR');
  614. }
  615. $data = ['male'=>$male,'female'=>$female];
  616. return response()->success($data);
  617. }
  618. }