BookController.php 31 KB

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