|
@@ -521,14 +521,16 @@ class BookConfigService
|
|
|
*/
|
|
|
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) {
|
|
|
- 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();
|
|
|
}
|
|
|
}
|