BookAuditService.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Modules\Book\Services;
  3. use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
  4. class BookAuditService
  5. {
  6. /**
  7. * 审核数据
  8. * @param $sex
  9. * @param $package
  10. * @return array[]
  11. */
  12. public static function getHomeBooksData($sex, $package,$is_auth): array
  13. {
  14. // 基本配置数据
  15. $home = config('home.default');
  16. if ($package === 'com.app.kyy.jdqyy') {
  17. $home = config('home.new');
  18. }
  19. if (!$is_auth){
  20. $home = config('home.ycsd');
  21. }
  22. // banner
  23. $banner = $home['reco_banner'];
  24. $bannerBooks = $banner[$sex];
  25. // 模块
  26. [$hot, $live, $recom, $new] = [$home['hot'], $home['zhibo'], $home['recom'], $home['new_recom']];
  27. [$hotBids, $liveBids, $recomBids, $newBids] = [$hot[$sex], $live[$sex], $recom[$sex], $new[$sex]];
  28. // 一次性获取书籍列表
  29. $bids = array_merge($hotBids, $liveBids, $recomBids, $newBids);
  30. $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
  31. $books = BookConfigService::getBookLists(compact('bids','channel_id'));
  32. return [
  33. [
  34. 'type' => 'reco_banner',
  35. 'lable' => $banner['label'],
  36. 'books' => $bannerBooks
  37. ],
  38. [
  39. 'type' => 'hot',
  40. 'lable' => $hot['label'],
  41. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $hotBids)->all())
  42. ],
  43. [
  44. 'type' => 'zhibo',
  45. 'lable' => $live['label'],
  46. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $liveBids)->all())
  47. ],
  48. [
  49. 'type' => 'recom',
  50. 'lable' => $recom['label'],
  51. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $recomBids)->all())
  52. ],
  53. [
  54. 'type' => 'new_recom',
  55. 'lable' => $new['label'],
  56. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $newBids)->all())
  57. ],
  58. ];
  59. }
  60. }