BookController.php 32 KB

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