浏览代码

调整显示的书单列表

lh 3 天之前
父节点
当前提交
d5dfbcc325
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7 5
      app/Services/Book/BookService.php

+ 7 - 5
app/Services/Book/BookService.php

@@ -29,7 +29,7 @@ class BookService
 
         $query = DB::table('books as b')->leftJoin('book_configs as bc', 'b.id', '=', 'bc.bid')
         ->where('b.size', '<', 30000)->where('b.status', 1)
-        ->whereIn('bc.cp_source', ['ycsd', 'yqsd'])->whereIn('bc.is_on_shelf', [1,2])->select('b.status', 'bc.*', 
+        ->whereIn('bc.cp_source', ['ycsd', 'yqsd'])->select('b.status', 'bc.*', 
         DB::raw('(select count(id) from mp_book_version where bid = b.id) as version_count'));
 
         if ($bid) {
@@ -53,16 +53,18 @@ class BookService
         $bid = getProp($data, 'bid');
         $book_name = getProp($data, 'book_name');
 
-        $query = DB::table('book_configs')->whereIn('is_on_shelf', [1,2])->select('bid', 'book_name');
+        $query = DB::table('books as b')->leftJoin('book_configs as bc', 'b.id', '=', 'bc.bid')
+        ->where('b.size', '<', 30000)->where('b.status', 1)
+        ->whereIn('bc.cp_source', ['ycsd', 'yqsd'])->select('bid', 'book_name');
         if ($bid) {
-            $query->where('bid', $bid);
+            $query->where('bc.bid', $bid);
         }
 
         if ($book_name) {
-            $query->where('book_name', 'like', "%{$book_name}%");
+            $query->where('bc.book_name', 'like', "%{$book_name}%");
         }
 
-        return $query->orderBy('bid', 'desc')->get()->map(function($value) {
+        return $query->orderBy('bc.bid', 'desc')->get()->map(function($value) {
             return (array)$value;
         })->toArray();
     }