BookAuditService.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. public static function getYueaiHomeBooksData($sex, $package,$is_auth): array
  61. {
  62. $home = config('home.yueai');
  63. if (!$is_auth){
  64. $home = config('home.ycsd');
  65. }
  66. $banner = $home['reco_banner'];
  67. $bannerBooks = $banner[$sex];
  68. // 模块
  69. [$hot, $live, $recom, $new] = [$home['hot'], $home['zhibo'], $home['recom'], $home['new_recom']];
  70. [$hotBids, $liveBids, $recomBids, $newBids] = [$hot[$sex], $live[$sex], $recom[$sex], $new[$sex]];
  71. // 一次性获取书籍列表
  72. $bids = array_merge($hotBids, $liveBids, $recomBids, $newBids);
  73. $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
  74. $books = BookConfigService::getBookLists(compact('bids','channel_id'),[],false);
  75. return [
  76. [
  77. 'type' => 'reco_banner',
  78. 'lable' => $banner['label'],
  79. 'books' => $bannerBooks
  80. ],
  81. [
  82. 'type' => 'hot',
  83. 'lable' => $hot['label'],
  84. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $hotBids)->all())
  85. ],
  86. [
  87. 'type' => 'zhibo',
  88. 'lable' => $live['label'],
  89. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $liveBids)->all())
  90. ],
  91. [
  92. 'type' => 'recom',
  93. 'lable' => $recom['label'],
  94. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $recomBids)->all())
  95. ],
  96. [
  97. 'type' => 'new_recom',
  98. 'lable' => $new['label'],
  99. 'books' => collectionTransform(new BookTransformer, collect($books)->whereIn('bid', $newBids)->all())
  100. ],
  101. ];
  102. }
  103. }