zz пре 4 година
родитељ
комит
d2241380d4

+ 6 - 0
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -40,6 +40,12 @@ class BookController extends BaseController
             $book_info['is_on_user_shelf'] = 1;
             $book_info['is_on_user_shelf'] = 1;
         }
         }
         $last_chapter                     = ChapterService::getChapterNameById($book_info['last_cid'], $bid);
         $last_chapter                     = ChapterService::getChapterNameById($book_info['last_cid'], $bid);
+        $book_info->last_chapter = $last_chapter['name'];
+        list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
+        if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
+            $book_info->last_chapter = '第'.$book_info->chapter_count.'章';
+        }
+
         $book_info['last_chapter_is_vip'] = $last_chapter['is_vip'];
         $book_info['last_chapter_is_vip'] = $last_chapter['is_vip'];
         $book_info['is_need_charge']      = $this->isNeedCharge($bid, $last_chapter, $book_info);
         $book_info['is_need_charge']      = $this->isNeedCharge($bid, $last_chapter, $book_info);
         $record                           = ReadRecordService::getBookReadRecordStatic($this->uid, $bid);
         $record                           = ReadRecordService::getBookReadRecordStatic($this->uid, $bid);

+ 19 - 0
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -51,6 +51,7 @@ class ChapterController extends BaseController
         if ($page_size >= 100) $page_size = 100;
         if ($page_size >= 100) $page_size = 100;
         $res   = ChapterService::getChapterListsPage($bid, $page_size);
         $res   = ChapterService::getChapterListsPage($bid, $page_size);
         $lists = $this->getChapterCatalog($bid, $res, $book_info);
         $lists = $this->getChapterCatalog($bid, $res, $book_info);
+
         return response()->pagination(new ChapterListTransformer, $lists);
         return response()->pagination(new ChapterListTransformer, $lists);
     }
     }
 
 
@@ -60,6 +61,12 @@ class ChapterController extends BaseController
         $isFree = BookConfigService::judgeBookIsFree($bid);
         $isFree = BookConfigService::judgeBookIsFree($bid);
         //渠道自定义vip章节
         //渠道自定义vip章节
         $vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
         $vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
+        list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
+        $change_chapter_name = 0;
+        if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
+            $change_chapter_name = 1;
+        }
+
         switch ($book_info->charge_type) {
         switch ($book_info->charge_type) {
             case 'BOOK':
             case 'BOOK':
                 $price          = $this->getPrice($book_info);
                 $price          = $this->getPrice($book_info);
@@ -80,6 +87,10 @@ class ChapterController extends BaseController
                             $v->is_vip = 0;
                             $v->is_vip = 0;
                         }
                         }
                     }
                     }
+                    //拆章
+                    if($change_chapter_name){
+                        $v->name = '第'.$v->sequence.'章';
+                    }
                 }
                 }
                 break;
                 break;
             default:
             default:
@@ -99,6 +110,10 @@ class ChapterController extends BaseController
                             $v->is_vip = 0;
                             $v->is_vip = 0;
                         }
                         }
                     }
                     }
+                    //拆章
+                    if($change_chapter_name){
+                        $v->name = '第'.$v->sequence.'章';
+                    }
                 }
                 }
                 break;
                 break;
         }
         }
@@ -119,6 +134,10 @@ class ChapterController extends BaseController
         if (!$chapter) {
         if (!$chapter) {
             return response()->error('QAPP_SYS_ERROR');
             return response()->error('QAPP_SYS_ERROR');
         }
         }
+        list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
+        if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
+            $chapter->name = '第'.$chapter->sequence.'章';
+        }
 
 
         $is_next_day = date('Y-m-d', strtotime($this->user_info->created_at)) == date('Y-m-d', strtotime('-1 days'));
         $is_next_day = date('Y-m-d', strtotime($this->user_info->created_at)) == date('Y-m-d', strtotime('-1 days'));
         if ($is_next_day) {
         if ($is_next_day) {

+ 2 - 2
app/Modules/Book/Models/BookConfig.php

@@ -420,8 +420,8 @@ class BookConfig extends Model
                 'books.name as old_name',
                 'books.name as old_name',
                 'book_configs.recommend_cid',
                 'book_configs.recommend_cid',
                 'book_configs.is_high_quality',
                 'book_configs.is_high_quality',
-		'book_configs.unit_price',
-		'book_configs.calculate_price_type'
+		        'book_configs.unit_price',
+		        'book_configs.calculate_price_type'
             )->where('book_configs.bid', $bid)->first();
             )->where('book_configs.bid', $bid)->first();
     }
     }
 
 

+ 18 - 2
app/Modules/Book/Services/BookService.php

@@ -170,7 +170,7 @@ class BookService
         if($channel_calculate_price_type){
         if($channel_calculate_price_type){
             $calculate_price_type = $channel_calculate_price_type;
             $calculate_price_type = $channel_calculate_price_type;
         }
         }
-	 $distribution_channel_id_price = Redis::hget('channel:price:setting:'.$distribution_channel_id,$book_info->bid);
+	    $distribution_channel_id_price = Redis::hget('channel:price:setting:'.$distribution_channel_id,$book_info->bid);
         //固定价格
         //固定价格
         if(strtolower($calculate_price_type) == 'const'){
         if(strtolower($calculate_price_type) == 'const'){
             $price = (int)$book_info->unit_price;
             $price = (int)$book_info->unit_price;
@@ -191,7 +191,7 @@ class BookService
         if($book_info->unit_price){
         if($book_info->unit_price){
             $price_rate = $book_info->unit_price;
             $price_rate = $book_info->unit_price;
         }
         }
-	if($distribution_channel_id_price){
+	    if($distribution_channel_id_price){
             $price_rate = $distribution_channel_id_price;
             $price_rate = $distribution_channel_id_price;
         }
         }
 
 
@@ -200,4 +200,20 @@ class BookService
         if($fee <37) $fee = 37;
         if($fee <37) $fee = 37;
         return $fee;
         return $fee;
     }
     }
+
+    /**
+     * 切章后,[是否切章,是否改名]
+     * @param $bid
+     * @return array
+     */
+    public static function splitContent($bid){
+        $config = DB::table('book_split_operate_record')->where('bid',$bid)->select('chapter_name_type','is_process')->orderBy('id','desc')->first();
+        if(!$config) return [0,0];
+        if($config->is_process == 2){
+            return [1,$config->chapter_name_type];
+        }
+        return [0,0];
+    }
+
+
 }
 }

+ 24 - 6
app/Modules/User/Services/ReadRecordService.php

@@ -9,6 +9,7 @@
 
 
 namespace App\Modules\User\Services;
 namespace App\Modules\User\Services;
 
 
+use App\Modules\Book\Services\BookService;
 use App\Modules\User\Models\ReadRecordFromRedis;
 use App\Modules\User\Models\ReadRecordFromRedis;
 use Redis;
 use Redis;
 use Hashids;
 use Hashids;
@@ -24,7 +25,7 @@ class ReadRecordService
         $record = Redis::hGet('book_read:' . $uid, $bid);
         $record = Redis::hGet('book_read:' . $uid, $bid);
         if ($record) {
         if ($record) {
             $cid  = explode('_', $record)[0];
             $cid  = explode('_', $record)[0];
-            $name = self::cid2ChapterName($cid);
+            $name = self::cid2ChapterName($cid,0);
             return ['record_chapter_id' => $cid, 'record_chapter_name' => $name];
             return ['record_chapter_id' => $cid, 'record_chapter_name' => $name];
         }
         }
         return false;
         return false;
@@ -135,8 +136,18 @@ class ReadRecordService
             $record           = explode('_', $v);
             $record           = explode('_', $v);
             $latest_read_cid  = $record[0];
             $latest_read_cid  = $record[0];
             $latest_read_time = $record[count($record) - 1];
             $latest_read_time = $record[count($record) - 1];
-            $book_name        = self::bid2BookName($key);
-            $chapter_name     = self::cid2ChapterName($latest_read_cid);
+            $channel_name = '';
+            $book_name        = self::bid2BookName($key,$channel_name);
+
+            $change_chapter_name = 0;
+
+            list($is_split,$is_change_chapter_name) = BookService::splitContent($key);
+            if($is_split && ($channel_name == '男频' || $is_change_chapter_name) ){
+                $change_chapter_name = 1;
+            }
+
+
+            $chapter_name     = self::cid2ChapterName($latest_read_cid,$change_chapter_name);
             $res[$i]          = ['book_name' => $book_name, 'bid' => $key, 'cid' => (int)$latest_read_cid, 'time' => (int)$latest_read_time, 'chapter_name' => $chapter_name];
             $res[$i]          = ['book_name' => $book_name, 'bid' => $key, 'cid' => (int)$latest_read_cid, 'time' => (int)$latest_read_time, 'chapter_name' => $chapter_name];
             $i++;
             $i++;
         }
         }
@@ -306,7 +317,7 @@ class ReadRecordService
      * @param $bid
      * @param $bid
      * @return bool|null|string
      * @return bool|null|string
      */
      */
-    public static function bid2BookName($bid)
+    public static function bid2BookName($bid,&$channel_name)
     {
     {
         $book_key  = 'wap:string:book:' . $bid;
         $book_key  = 'wap:string:book:' . $bid;
         $book_name = Redis::get($book_key);
         $book_name = Redis::get($book_key);
@@ -316,8 +327,10 @@ class ReadRecordService
             $book_info = BookConfigService::getBookById($bid);
             $book_info = BookConfigService::getBookById($bid);
             if ($book_info && isset($book_info->book_name)) {
             if ($book_info && isset($book_info->book_name)) {
                 $book_name = $book_info->book_name;
                 $book_name = $book_info->book_name;
+                $channel_name = $book_info->channel_name;
             }
             }
         }
         }
+        return $book_name;
     }
     }
 
 
     /**
     /**
@@ -325,7 +338,7 @@ class ReadRecordService
      * @param $cid
      * @param $cid
      * @return bool|null|string
      * @return bool|null|string
      */
      */
-    public static function cid2ChapterName($cid)
+    public static function cid2ChapterName($cid,$change_chapter_name)
     {
     {
         $chapter_key  = 'wap:string:chapter:' . $cid;
         $chapter_key  = 'wap:string:chapter:' . $cid;
         $chapter_name = Redis::get($chapter_key);
         $chapter_name = Redis::get($chapter_key);
@@ -334,7 +347,12 @@ class ReadRecordService
             $chapter_name = '';
             $chapter_name = '';
             $chapter_info = Chapter::getChapterNameById($cid);
             $chapter_info = Chapter::getChapterNameById($cid);
             if ($chapter_info && isset($chapter_info->name)) {
             if ($chapter_info && isset($chapter_info->name)) {
-                $chapter_name = $chapter_info->name;
+                //$chapter_name = $chapter_info->name;
+                if($change_chapter_name){
+                    $chapter_name = '第'.$chapter_info->sequence.'章';
+                }else{
+                    $chapter_name = $chapter_info->name;
+                }
             }
             }
         }
         }
         return $chapter_name;
         return $chapter_name;