BookController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <?php
  2. namespace App\Http\Controllers\QuickApp\Book;
  3. use App\Libs\Utils;
  4. use App\Modules\Book\Services\BookAuditService;
  5. use App\Modules\RecommendBook\Services\QappRecommendService;
  6. use App\Modules\RecommendBook\Services\RecommendService;
  7. use App\Modules\Book\Services\RecoBannerService;
  8. use App\Modules\User\Models\QappPackage;
  9. use App\Modules\User\Services\QappUserService;
  10. use Illuminate\Http\Request;
  11. use App\Http\Controllers\QuickApp\BaseController;
  12. use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
  13. use App\Http\Controllers\QuickApp\Book\Transformers\KeywordTransformer;
  14. use App\Modules\Book\Models\BookConfig;
  15. use App\Modules\Book\Services\BookConfigService;
  16. use App\Modules\Book\Services\BookService;
  17. use App\Modules\Book\Services\BookUrgeUpdateService;
  18. use App\Modules\Book\Services\UserShelfBooksService;
  19. use App\Modules\Book\Services\ChapterService;
  20. use App\Modules\Subscribe\Services\BookOrderService;
  21. use App\Modules\Subscribe\Services\ChapterOrderService;
  22. use App\Modules\Subscribe\Services\YearOrderService;
  23. use App\Modules\User\Services\ReadRecordService;
  24. use Hashids;
  25. class BookController extends BaseController
  26. {
  27. public function index(Request $request, $bid)
  28. {
  29. $bid = BookService::decodeBidStatic($bid);
  30. $book_info = BookConfigService::getBookById($bid);
  31. if (!$book_info) {
  32. return response()->error('QAPP_SYS_ERROR');
  33. }
  34. //yuyuedu、xinghe 快应用这两个cp的书屏蔽下
  35. if(in_array($book_info->cp_source,getHiddenCp())){
  36. return response()->error('QAPP_SYS_ERROR');
  37. }
  38. if($this->distribution_channel_id == 7477 && $bid == 13765){
  39. $book_info->is_on_shelf = 2;
  40. }
  41. if($bid == 58886){
  42. $book_info->is_on_shelf = 0;
  43. }
  44. if (!in_array($book_info->is_on_shelf, [1,2])) {
  45. return response()->error('QAPP_OFF_SHELF');
  46. }
  47. $is_on_shelf = UserShelfBooksService::getUserShelfBooksListByUidAndBid($this->uid, $bid);
  48. $book_info['is_on_user_shelf'] = 0;
  49. if ($is_on_shelf) {
  50. $book_info['is_on_user_shelf'] = 1;
  51. }
  52. $last_chapter = ChapterService::getChapterNameById($book_info['last_cid'], $bid);
  53. $book_info->last_chapter = $last_chapter['name'];
  54. list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
  55. if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
  56. $book_info->last_chapter = '第'.$book_info->chapter_count.'章';
  57. }
  58. $book_info['last_chapter_is_vip'] = $last_chapter['is_vip'];
  59. $book_info['is_need_charge'] = $this->isNeedCharge($bid, $last_chapter, $book_info);
  60. $record = ReadRecordService::getBookReadRecordStatic($this->uid, $bid);
  61. if ($record) {
  62. $book_info['record_chapter_id'] = $record['record_chapter_id'];
  63. $book_info['record_chapter_name'] = $record['record_chapter_name'];
  64. }
  65. return response()->item(new BookTransformer(), $book_info);
  66. }
  67. /**
  68. * 获取订购记录
  69. * @param $book_info
  70. * @param $chapter_id
  71. * @return bool
  72. */
  73. protected function getOrderRecord($bid, $chapter_id)
  74. {
  75. //包年记录
  76. $uid = $this->uid;
  77. $res = YearOrderService::getRecord($uid);
  78. if ($res) return true;
  79. $res = null;
  80. //单本订购记录
  81. $res = BookOrderService::getRecordByuidBid($uid, $bid);
  82. if ($res) return true;
  83. $res = null;
  84. //章节订购记录
  85. $chapterOrder = new ChapterOrderService();
  86. if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id)) return true;
  87. return false;
  88. }
  89. /**
  90. * 判断是否需要充值
  91. */
  92. private function isBookNeedCharge(int $bid, float $price)
  93. {
  94. $book_order = $this->getOrderRecord($bid, 0);
  95. if ($book_order) {
  96. return false;
  97. } else {
  98. $user_info = $this->user_info;
  99. return $user_info['balance'] < $price;
  100. }
  101. }
  102. /**
  103. * 判断章节是否需要充值
  104. */
  105. private function isChapterNeedCharge(int $bid, int $cid, float $price)
  106. {
  107. $book_order = $this->getOrderRecord($bid, $cid);
  108. if ($book_order) {
  109. return false;
  110. } else {
  111. $user_info = $this->user_info;
  112. return $user_info['balance'] < $price;
  113. }
  114. }
  115. /**
  116. * 判断是否需要充值
  117. */
  118. private function isNeedCharge(int $bid, $last_chapter, $book_info)
  119. {
  120. $is_free = BookConfigService::judgeBookIsFree($bid);
  121. if ($is_free) {
  122. return false;
  123. }
  124. switch ($book_info->charge_type) {
  125. case 'BOOK':
  126. $price = $this->getPrice($book_info);
  127. return $this->isBookNeedCharge($bid, $price);
  128. default:
  129. $price = isset($last_chapter->is_vip) ? $this->getPrice($book_info, $last_chapter->size) : 0;
  130. return isset($last_chapter->is_vip) ? $this->isChapterNeedCharge($bid, $last_chapter->id, $price) : false;
  131. }
  132. }
  133. /**
  134. * 计算价格
  135. * @param $book_info
  136. * @param $chapter_size
  137. * @return float
  138. */
  139. protected function getPrice($book_info, $chapter_size = 0)
  140. {
  141. if ($book_info->charge_type == 'BOOK')
  142. return $book_info->price * 100;
  143. return ceil($chapter_size / 100);
  144. }
  145. /**
  146. * 首页
  147. */
  148. public function getBookLists(Request $request, $sex)
  149. {
  150. // 获取基本数据
  151. $package = $request->header('x-package', '');
  152. $brand = $request->header('x-nbrand', '');
  153. $codeVersion = $request->header('x-codeversion', '');
  154. $isAuth = check_qapp_auth($package ,0);
  155. $send_order_id = $request->header('send-order-id', 0);
  156. // 根据包名、平台、版本号判断是否审核
  157. if (Utils::checkIsAudit($package, $brand, $codeVersion) || $isAuth == false) {
  158. $result = BookAuditService::getHomeBooksData($sex, $package,$isAuth);
  159. return response()->success($result);
  160. }
  161. if($send_order_id > 0 && $package == "com.beidao.kuaiying.yueai" && $sex == "male"){
  162. $result = BookAuditService::getYueaiHomeBooksData($sex, $package,$isAuth,$channel);
  163. return response()->success($result);
  164. }
  165. if ($sex == 'male') {
  166. $channel = 1;
  167. $reco_banner_type = ['MALE', 'PUBLIC'];
  168. } else {
  169. $reco_banner_type = ['FEMALE', 'PUBLIC'];
  170. $channel = 2;
  171. }
  172. if($isAuth){
  173. $books = (new RecoBannerService)->getByType($reco_banner_type, 2);
  174. $books->transform(function ($item) {
  175. $result = $this->getBidCidFromUrl($item->redirect_url);
  176. $item->bid = $result['bid'];
  177. $item->cid = $result['cid'];
  178. if ($result['cid']) {
  179. $item->redirect_url = "views/Reader";
  180. } else {
  181. $item->redirect_url = "views/Detail";
  182. }
  183. return $item;
  184. });
  185. }else{
  186. $home = config('home.ycsd');
  187. $banner = $home['reco_banner'];
  188. $books = $banner[$sex];
  189. }
  190. //新判断: 根据包名来获取对应所需的bid
  191. $qapp_package = QappPackage::getPackageByPackage($package);
  192. if($qapp_package){
  193. $package_id = $qapp_package->id;
  194. }else{
  195. $package_id = 0;
  196. }
  197. \Log::info('un_send_order_book:package_id1:'.$package_id.' $package:'.$package);
  198. $user = (new QappUserService)->getGolableUser();
  199. if(isset($user->uid) && !empty($user->uid)){
  200. if(!$this->send_order_id || $this->send_order_id == 0 ){
  201. \Log::info('un_send_order_book:uid:'.$this->uid.' $package:'.$package);
  202. $result = $this->getCheckBids($channel,$books,$package_id,$package);
  203. if(isset($result[1]['books']) && count((array)$result[1]['books']) > 1){
  204. return response()->success($result);
  205. }
  206. $result = $this->getCheckBids($channel,$books,0,$package);
  207. return response()->success($result);
  208. }else{
  209. $package_id = 0;
  210. }
  211. \Log::info('un_send_order_book:package_id2:'.$package_id.' $package:'.$package);
  212. }else{
  213. $package_id = 0;
  214. }
  215. \Log::info('un_send_order_book:package_id3:'.$package_id.' $package:'.$package);
  216. $result = $this->getCheckBids($channel,$books,$package_id,$package);
  217. return response()->success($result);
  218. }
  219. /**
  220. * 根据包名
  221. * @param $channel
  222. * @param $books
  223. * @param $package_id
  224. * @return array
  225. */
  226. private function getCheckBids($channel,$books,$package_id,$package)
  227. {
  228. $isAuthor = check_qapp_auth($package_id,1);
  229. $hotBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'hot',$package_id),$channel,$package,$isAuthor);
  230. $liveBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'live',$package_id),$channel,$package,$isAuthor);
  231. $recomBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'recom',$package_id),$channel,$package,$isAuthor);
  232. $newBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'new_recom',$package_id),$channel,$package,$isAuthor);
  233. return array_filter([
  234. ['type' => 'reco_banner', 'lable' => '首页banner', 'books' => $books],
  235. ['type' => 'hot', 'lable' => '热门书单', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($hotBids))],
  236. ['type' => 'zhibo', 'lable' => '神书直播', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($liveBids))],
  237. ['type' => 'recom', 'lable' => '小编精选', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($recomBids))],
  238. ['type' => 'new_recom', 'lable' => '人气新书', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($newBids))]
  239. ]);
  240. }
  241. /**
  242. * 检测并补充不满足条件的书籍id
  243. * @param $bid_list
  244. * @param $channel : 频道
  245. * @param $package : 频道
  246. * @return array
  247. */
  248. private function getCheckBooks($bid_list,$channel,$package,$is_author)
  249. {
  250. $hidden_cp = getHiddenCp();
  251. if($package !== 'com.beidao.kuaiying.zsy'){
  252. $hidden_cp = array_merge($hidden_cp,['lianshang']);
  253. }
  254. //获取书本数量
  255. $count = count($bid_list);
  256. if (!$is_author){
  257. $where = [
  258. ['book_configs.charge_type','!=','BOOK'],
  259. ['book_configs.cp_source','=','ycsd'],
  260. ];
  261. }else{
  262. $where = [
  263. ['book_configs.charge_type','!=','BOOK'],
  264. ];
  265. }
  266. //获取当前有效书本数量
  267. $book_count = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
  268. ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
  269. ->whereIn('book_configs.bid',$bid_list)
  270. ->where('book_configs.is_on_shelf',2)
  271. ->where('book_configs.charge_type','!=','BOOK')
  272. ->whereNotIn('book_configs.cp_source',$hidden_cp)
  273. ->where($where)
  274. ->where('book_categories.pid',$channel)
  275. ->count();
  276. if($count == $book_count){
  277. return $bid_list;
  278. }
  279. //获取需要补充的书籍数量
  280. $supplement_count = (($count - $book_count) > 0) ? $count - $book_count : 0;
  281. if($supplement_count <= 0){
  282. return $bid_list;
  283. }
  284. //获取书籍交集bid,过滤掉不符合要求的书
  285. $bids = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
  286. ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
  287. ->whereIn('book_configs.bid',$bid_list)
  288. ->where('book_configs.is_on_shelf',2)
  289. ->where($where)
  290. ->whereNotIn('book_configs.cp_source',$hidden_cp)
  291. ->where('book_categories.pid',$channel)
  292. ->pluck('book_configs.bid')->all();
  293. $bid_list = array_intersect($bid_list,$bids);
  294. //获取随机的有效的书籍bid
  295. $rand_bid = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
  296. ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
  297. ->where('book_configs.is_on_shelf',2)
  298. // ->where('book_configs.charge_type','!=','BOOK')
  299. ->where($where)
  300. ->whereNotIn('book_configs.cp_source',$hidden_cp)
  301. ->where('book_categories.pid',$channel)
  302. ->inRandomOrder()
  303. ->limit($supplement_count)
  304. ->get()->pluck('bid')->toArray();
  305. return array_filter(array_merge($bid_list,$rand_bid));
  306. }
  307. private function getBidCidFromUrl(string $url)
  308. {
  309. if (preg_match('/\?bid=(\w+)\S+cid=(\w+)/', $url, $matches) || preg_match('/\?id=(\w+)/', $url, $matches)) {
  310. return [
  311. 'bid' => $matches[1],
  312. 'cid' => isset($matches[2]) ? $matches[2] : 0,
  313. ];
  314. } else {
  315. return [
  316. 'bid' => '',
  317. 'cid' => 0,
  318. ];
  319. }
  320. }
  321. public function library(Request $request)
  322. {
  323. $where = [];
  324. $order = [];
  325. $where['is_on_shelf'] = [2];
  326. $category_id = $request->input('category_id');
  327. if ($category_id) {
  328. if ($category_id == 1) {
  329. $where['channel_name'] = '男频';
  330. } elseif ($category_id == 2) {
  331. $where['channel_name'] = '女频';
  332. } else {
  333. $where['category_id'] = $category_id;
  334. }
  335. }
  336. $key = $request->input('key');
  337. $uid = $request->input('uid', 0);
  338. if ($key && $uid && is_numeric($uid)) {
  339. BookConfigService::saveUserSearchLog($key, $uid);
  340. }
  341. $where['key'] = $key;
  342. $order_field = $request->input('order_field');
  343. $order_seq = $request->input('order_seq');
  344. if ($order_field != '' && in_array($order_field, ['recommend_index', 'click_count', 'update', 'size', 'create'])) {
  345. if ($order_field == 'update') {
  346. $order = ['book_configs.updated_at', 'desc'];
  347. } elseif ($order_field == 'create') {
  348. $order = ['book_configs.created_at', 'desc'];
  349. } else {
  350. $order = [$order_field, 'desc'];
  351. }
  352. if ($order_seq == 'asc') {
  353. $order = [$order_field, 'asc'];
  354. }
  355. if ($order_seq == 'desc') {
  356. $order = [$order_field, 'desc'];
  357. }
  358. }
  359. // 审核状态默认值
  360. $package = $request->header('x-package', '');
  361. $brand = $request->header('x-nbrand', '');
  362. $codeVersion = $request->header('x-codeversion', '');
  363. if ($order_field === 'recommend_index' && Utils::checkIsAudit($package, $brand, $codeVersion)) {
  364. $order = ['book_configs.bid', 'desc'];
  365. }
  366. // 是否只使用原创书殿的书
  367. $isAuth = check_qapp_auth($package ,0);
  368. if (!$isAuth){
  369. $where['cp_source'] = "ycsd";
  370. }
  371. $status = $request->input('status');
  372. if ($status != '') {
  373. $where['status'] = $status;
  374. }
  375. // 搜索关键词的情况下,屏蔽书籍完本状态
  376. if ($key && isset($where['status'])) {
  377. unset($where['status']);
  378. }
  379. $page_size = $request->input('page_size', 15);
  380. $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
  381. $books = BookConfigService::getBooks($where, $order, $page_size);
  382. return response()->pagination(new BookTransformer, $books);
  383. }
  384. public function hotWords(Request $request)
  385. {
  386. $result = BookConfigService::findBookKeywords();
  387. return response()->pagination(new KeywordTransformer, $result);
  388. }
  389. public function similarRecom(Request $request)
  390. {
  391. $package = $request->header('x-package', '');
  392. $category_id = $request->input('category_id');
  393. $bid = $request->input('bid');
  394. $package = $request->header('x-package', '');
  395. if (empty($bid) || (empty($category_id) && $category_id != 0)) {
  396. return response()->error('PARAM_ERROR');
  397. }
  398. $isAuth = check_qapp_auth($package ,0);
  399. $bid = BookService::decodeBidStatic($bid);
  400. $where = ['category_id' => $category_id, 'is_on_shelf' => [2]];
  401. if (!$isAuth){
  402. $where['cp_source'] = "ycsd";
  403. }
  404. $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
  405. $books = BookConfigService::getBooks($where, [], 4);
  406. $data = [];
  407. foreach ($books as $v) {
  408. if ($v->bid != $bid && count($data) < 3) {
  409. $data[] = $v;
  410. }
  411. }
  412. return response()->collection(new BookTransformer(), $data);
  413. }
  414. public function readOverRecommend(Request $request)
  415. {
  416. $bid = $request->input('bid');
  417. if (empty($bid)) {
  418. return response()->error('PARAM_ERROR');
  419. }
  420. $bid = BookService::decodeBidStatic($bid);
  421. $book_info = BookConfigService::getBookById($bid);
  422. $res = BookConfigService::getRecommendBooks($bid, $book_info->channel_name);
  423. $urge_status = 0;
  424. if ($book_info->status == 0 && !BookUrgeUpdateService::isHadUrged($this->uid, $bid)) {
  425. $urge_status = 1;
  426. }
  427. $recommend_result = collectionTransform(new BookTransformer(), $res);
  428. $book_status = [
  429. 'status' => $book_info->status,
  430. 'urge_status' => $urge_status
  431. ];
  432. $data = [
  433. 'recommend_result' => $recommend_result,
  434. 'book_status' => $book_status
  435. ];
  436. return response()->success($data);
  437. }
  438. public function rank(Request $request)
  439. {
  440. // 1:男频,2:女频
  441. $sex = (int)$request->input('sex');
  442. if (!in_array($sex, [1, 2], true)) {
  443. return response()->error('PARAM_ERROR');
  444. }
  445. // 默认
  446. $bids = [11529, 11941, 12720, 11990, 11988, 11976, 11977, 4183, 12717, 11833,
  447. 7287,14297,12716,14312,14000,13577,16712,13002,12717,15103,13928,14793,
  448. 12708,13286];
  449. if ($sex === 2) {
  450. $bids = [8469, 11660, 9117, 7891, 12281, 12470, 8167, 11661, 11670, 8476, 8557, 11662,
  451. 11680, 11926, 12462, 7836, 11681, 11664, 11928, 8631];
  452. }
  453. /**
  454. * pid:1为男频 2为女频
  455. SELECT
  456. CONCAT( books.id, ',' )
  457. FROM
  458. books
  459. LEFT JOIN book_configs ON books.id = book_configs.bid
  460. WHERE
  461. book_configs.is_on_shelf = 2
  462. AND books.category_id IN ( SELECT id FROM book_categories WHERE pid = 2 )
  463. ORDER BY
  464. book_configs.recommend_index DESC
  465. LIMIT 10;
  466. */
  467. // 根据包名、平台、版本号判断是否审核
  468. $package = $request->header('x-package', '');
  469. $brand = $request->header('x-nbrand', '');
  470. $codeVersion = $request->header('x-codeversion', '');
  471. if (Utils::checkIsAudit($package, $brand, $codeVersion)) {
  472. $bids = [2266, 3838, 9700, 10175, 10301, 3422, 1166, 4546, 9163, 2509,
  473. 7287,14297,12716,14312,14000,13577,16712,13002,12717,15103,13928,
  474. 14793,12708,13286,13336,13275,13073,15121,13929,12693,13254,3526,
  475. 10313,3483,13278,14004,4098,10378,14072,21376,21139,21757,19449];
  476. if ($sex === 2) {
  477. $bids = [159, 2439, 6276, 10074, 5409, 9379, 10323, 9078, 3603, 487];
  478. }
  479. }
  480. $isAuth = check_qapp_auth($package,0);
  481. if (!$isAuth){
  482. $rank = config('home.rank');
  483. $bids = $rank['male'];
  484. if ($sex === 2) {
  485. $bids = $rank['female'];;
  486. }
  487. }
  488. $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
  489. $books = collectionTransform(new BookTransformer, BookConfigService::getBookLists(compact('bids','channel_id')));
  490. return response()->success($books);
  491. }
  492. /**
  493. * 推荐书
  494. */
  495. public function recommen()
  496. {
  497. $reco_banner_type = ['FEMALE', 'PUBLIC'];
  498. $books = (new RecoBannerService)->getByType($reco_banner_type, 2);
  499. $books->transform(function ($item) {
  500. $result = $this->getBidCidFromUrl($item->redirect_url);
  501. $item->bid = $result['bid'];
  502. $item->cid = $result['cid'];
  503. if ($result['cid']) {
  504. $item->redirect_url = "views/Reader";
  505. } else {
  506. $item->redirect_url = "views/Detail";
  507. }
  508. return $item;
  509. });
  510. return response()->success($books);
  511. }
  512. /**
  513. * 阅爱小说任务轮播图
  514. */
  515. public function recommenYueAi()
  516. {
  517. $data = config('home.yueai');
  518. $books = $data['task_banner'];
  519. foreach ($books as &$value){
  520. $value['bid'] =Hashids::encode($value['bid']);
  521. $value['redirect_url '] = empty($value['cid']) ? "views/Detail" : "views/Reader";
  522. }
  523. unset($value);
  524. return response()->success($books);
  525. }
  526. /**
  527. * 限免
  528. */
  529. public function free(int $sex)
  530. {
  531. $result = BookConfigService::findFreeBooks($sex);
  532. return response()->success($result);
  533. }
  534. public function yueaiBackRecom(Request $request)
  535. {
  536. $category_id = $request->input('category_id');
  537. $bid = $request->input('bid');
  538. $package = $request->header('x-package', '');
  539. if (empty($package) || $package != 'com.beidao.kuaiying.yueai') {
  540. return response()->error('PARAM_ERROR');
  541. }
  542. $bid = [58238,60534,63220,12587,63221,60490,14022,4553,63179,61596,61701];
  543. $bid = array_random($bid,4);
  544. $books = BookConfigService::getBooksByIds($bid,[],false);
  545. return response()->collection(new BookTransformer(), $books);
  546. }
  547. public function shelfRecom(Request $request)
  548. {
  549. $category_id = $request->input('category_id');
  550. $bid = $request->input('bid');
  551. $package = $request->header('x-package', '');
  552. if (empty($package) || $package != 'com.beidao.kuaiying.yueai') {
  553. return response()->success([]);
  554. }
  555. $bid = [58238,60534,63220,12587,63221,60490,14022,4553,63179,61596,61701];
  556. $bid = array_random($bid,4);
  557. $books = BookConfigService::getBooksByIds($bid,[],false);
  558. return response()->collection(new BookTransformer(), $books);
  559. }
  560. }