fly 4 anni fa
parent
commit
6c367f613a
1 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 8 6
      app/Modules/Book/Services/BookConfigService.php

+ 8 - 6
app/Modules/Book/Services/BookConfigService.php

@@ -521,14 +521,16 @@ class BookConfigService
      */
      */
     public static function judgeBookIsFree(int $bid)
     public static function judgeBookIsFree(int $bid)
     {
     {
-        $free_book = FreeBook::where('bid', $bid)
-            ->where('is_enabled', 1)->first();
-        if ($free_book) {
-            $config = self::findFreeBookConfig($free_book->sex);
+        $config = self::findFreeBookConfig(1);
+        $ids = [];
+        foreach ([1, 2] as $sex) {
+            $config = self::findFreeBookConfig($sex);
             if ($config) {
             if ($config) {
-                return $free_book->config_id == $config->id;
+                $ids[] = $config->id;
             }
             }
         }
         }
-        return false;
+        return FreeBook::where('bid', $bid)
+            ->where('config_id', $ids)
+            ->where('is_enabled', 1)->exists();
     }
     }
 }
 }