fly %!s(int64=4) %!d(string=hai) anos
pai
achega
f10e53eed4
Modificáronse 1 ficheiros con 7 adicións e 5 borrados
  1. 7 5
      app/Modules/Book/Services/BookConfigService.php

+ 7 - 5
app/Modules/Book/Services/BookConfigService.php

@@ -474,7 +474,7 @@ class BookConfigService
      */
     public static function findFreeBookConfig(int $sex)
     {
-        return FreeBookConfig::firstWhere(['sex' => $sex, 'is_enable' => 1])->orderBy('end_time');
+        return FreeBookConfig::where(['sex' => $sex, 'is_enable' => 1])->orderBy('end_time')->first();
     }
 
     /**
@@ -494,18 +494,20 @@ class BookConfigService
                 ->select('bid', 'book_name', 'cover')
                 ->get();
             $books = Book::whereIn('id', $bids)->select('id', 'intro')->get();
-            return $book_configs->transform(function ($item) use ($books, $free_books) {
-                $free_book = $free_books->where('bid', $item->bid)->first();
+            $book_list = $book_configs->transform(function ($item) use ($books) {
                 $book = $books->where('id', $item->bid)->first();
                 return [
                     'bid' => Hashids::encode($item->bid),
                     'cover' => $item->cover,
                     'book_name' => $item->book_name,
                     'intro' => $book->intro,
-                    'start_time' => $free_book->start_time,
-                    'end_time' => $free_book->end_time,
                 ];
             })->all();
+            return [
+                'title' => $config->name,
+                'end_time' => $config->end_time,
+                'list' => $book_list,
+            ];
         }
         return [];
     }