BookController.php 31 KB

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