BookController.php 33 KB

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