|
@@ -24,6 +24,7 @@ class BookService
|
|
$status = getProp($data, 'status');
|
|
$status = getProp($data, 'status');
|
|
|
|
|
|
$query = DB::table('books as b')->leftJoin('book_configs as bc', 'b.id', '=', 'bc.bid')
|
|
$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'])->whereIn('bc.is_on_shelf', [1,2])->select('b.status', 'bc.*',
|
|
DB::raw('(select count(id) from mp_book_version where bid = b.id) as version_count'));
|
|
DB::raw('(select count(id) from mp_book_version where bid = b.id) as version_count'));
|
|
|
|
|
|
@@ -66,9 +67,11 @@ class BookService
|
|
$bid = getProp($data, 'bid');
|
|
$bid = getProp($data, 'bid');
|
|
if (!$bid) Utils::throwError('20003:请选择书籍');
|
|
if (!$bid) Utils::throwError('20003:请选择书籍');
|
|
|
|
|
|
- return DB::table('mp_book_version')->where('bid', $bid)->orderBy('id', 'desc')->select('bid', 'id as version_id', 'version_name')
|
|
|
|
|
|
+ return DB::table('mp_book_version')->where('bid', $bid)->orderBy('id', 'desc')->select('bid', 'book_name', 'id as version_id', 'version_name')
|
|
->get()->map(function($value) {
|
|
->get()->map(function($value) {
|
|
- return (array)$value;
|
|
|
|
|
|
+ $value = (array)$value;
|
|
|
|
+ $value['version_name'] = $value['book_name']."【{$value['version_name']}】";
|
|
|
|
+ return $value;
|
|
})->toArray();
|
|
})->toArray();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -79,7 +82,6 @@ class BookService
|
|
$version_name = trim(getProp($data, 'version_name'));
|
|
$version_name = trim(getProp($data, 'version_name'));
|
|
if (!$version_name) Utils::throwError('20003:请填写版本名');
|
|
if (!$version_name) Utils::throwError('20003:请填写版本名');
|
|
$book_name = DB::table('book_configs')->where('bid', $bid)->value('book_name');
|
|
$book_name = DB::table('book_configs')->where('bid', $bid)->value('book_name');
|
|
- $version_name = $book_name."【{$version_name}】";
|
|
|
|
if (DB::table('mp_book_version')->where('bid', $bid)->where('version_name', $version_name)->exists()) Utils::throwError('20003:版本名已存在');
|
|
if (DB::table('mp_book_version')->where('bid', $bid)->where('version_name', $version_name)->exists()) Utils::throwError('20003:版本名已存在');
|
|
|
|
|
|
$all_chapters = DB::table('chapters')->where('bid', $bid)->where('is_check', 1)->where('is_deleted', 0)->select('id', 'name', 'sequence', 'size', 'chapter_content_id')->get();
|
|
$all_chapters = DB::table('chapters')->where('bid', $bid)->where('is_check', 1)->where('is_deleted', 0)->select('id', 'name', 'sequence', 'size', 'chapter_content_id')->get();
|
|
@@ -88,6 +90,7 @@ class BookService
|
|
|
|
|
|
$version_id = DB::table('mp_book_version')->insertGetId([
|
|
$version_id = DB::table('mp_book_version')->insertGetId([
|
|
'bid' => $bid,
|
|
'bid' => $bid,
|
|
|
|
+ 'book_name' => $book_name,
|
|
'version_name' => $version_name,
|
|
'version_name' => $version_name,
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
@@ -103,6 +106,7 @@ class BookService
|
|
'bid' => $bid,
|
|
'bid' => $bid,
|
|
'book_name' => $book_name,
|
|
'book_name' => $book_name,
|
|
'version_id' => $version_id,
|
|
'version_id' => $version_id,
|
|
|
|
+ 'version_name' => $version_name,
|
|
'cid' => getProp($chapter, 'id'),
|
|
'cid' => getProp($chapter, 'id'),
|
|
'chapter_name' => getProp($chapter, 'name'),
|
|
'chapter_name' => getProp($chapter, 'name'),
|
|
'sequence' => getProp($chapter, 'sequence'),
|
|
'sequence' => getProp($chapter, 'sequence'),
|
|
@@ -129,7 +133,7 @@ class BookService
|
|
return [
|
|
return [
|
|
'bid' => $bid,
|
|
'bid' => $bid,
|
|
'version_id' => $version_id,
|
|
'version_id' => $version_id,
|
|
- 'version_name' => $version_name,
|
|
|
|
|
|
+ 'version_name' => $book_name."【{$version_name}】",
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|