BookController.php 32 KB

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