BookController.php 32 KB

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