|
@@ -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;
|