|
@@ -3,6 +3,8 @@
|
|
|
namespace App\Console\Commands\Temp;
|
|
|
|
|
|
use App\Modules\Book\Models\BookConfig;
|
|
|
+use App\Modules\Book\Models\Chapter;
|
|
|
+use App\Modules\Message\MessageNotify;
|
|
|
use Illuminate\Console\Command;
|
|
|
use Hashids;
|
|
|
use Matrix\Exception;
|
|
@@ -102,6 +104,7 @@ XML;
|
|
|
//在管理后台设置为新书的书籍标记成新书
|
|
|
$is_new_book = in_array($book->bid, $gdt_new_bids) ? '是' : '否';
|
|
|
$bid = Hashids::encode($book->bid);
|
|
|
+ $chapters = Chapter::where('bid',$book->bid)->select('name','content','id')->orderBy('sequence')->limit(4)->get();
|
|
|
$data =
|
|
|
array(
|
|
|
'product_id' => $bid,
|
|
@@ -124,6 +127,19 @@ XML;
|
|
|
'if_new_book' => $is_new_book,
|
|
|
'pay_status' => '付费',
|
|
|
);
|
|
|
+
|
|
|
+ $front_chapters_data = [];
|
|
|
+ foreach ($chapters as $chapter_item){
|
|
|
+ $content = preg_replace("/[\n|\r\n]+/","\n",$chapter_item->content);
|
|
|
+
|
|
|
+ $front_chapters_data['chapters'][] = [
|
|
|
+ 'subtitle'=>htmlspecialchars($chapter_item->name),
|
|
|
+ 'chapterid'=>$chapter_item->id,
|
|
|
+ 'text'=>explode("\n",htmlspecialchars($content))
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $data['book_json'] = json_encode($front_chapters_data,JSON_UNESCAPED_UNICODE);
|
|
|
+
|
|
|
$item = $xml->addChild('product');
|
|
|
if (is_array($data)) {
|
|
|
foreach ($data as $key => $row) {
|