|
@@ -177,20 +177,35 @@ class BookController extends BaseController
|
|
$reco_banner_type = ['FEMALE', 'PUBLIC'];
|
|
$reco_banner_type = ['FEMALE', 'PUBLIC'];
|
|
$channel = 2;
|
|
$channel = 2;
|
|
}
|
|
}
|
|
-
|
|
|
|
- $book = [
|
|
|
|
- ['type' => 'reco_banner', 'lable' => '首页banner', 'books' => RecoBannerService::getByTypeStatic($reco_banner_type)],
|
|
|
|
|
|
+ $books = RecoBannerService::getByTypeStatic($reco_banner_type);
|
|
|
|
+ $books->transform(function ($item) {
|
|
|
|
+ $result = $this->getBidCidFromUrl($item->redirect_url);
|
|
|
|
+ $item->bid = $result['bid'];
|
|
|
|
+ $item->cid = $result['cid'];
|
|
|
|
+ return $item;
|
|
|
|
+ });
|
|
|
|
+ $result = [
|
|
|
|
+ ['type' => 'reco_banner', 'lable' => '首页banner', 'books' => $books],
|
|
['type' => 'hot', 'lable' => '热门推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'hot')))],
|
|
['type' => 'hot', 'lable' => '热门推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'hot')))],
|
|
['type' => 'zhibo', 'lable' => '神书直播', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'live')))],
|
|
['type' => 'zhibo', 'lable' => '神书直播', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'live')))],
|
|
['type' => 'recom', 'lable' => '编辑推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'recom')))],
|
|
['type' => 'recom', 'lable' => '编辑推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'recom')))],
|
|
['type' => 'new_recom', 'lable' => '新书推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'new_recom')))],
|
|
['type' => 'new_recom', 'lable' => '新书推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'new_recom')))],
|
|
|
|
|
|
];
|
|
];
|
|
- return response()->success($book);
|
|
|
|
|
|
+ return response()->success($result);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+ private function getBidCidFromUrl(string $url)
|
|
|
|
+ {
|
|
|
|
+ if (preg_match('/bid=(\w+)\S+cid=(\w+)/', $url, $matches)) {
|
|
|
|
+ return [
|
|
|
|
+ 'bid' => $matches[1],
|
|
|
|
+ 'cid' => $matches[2],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -510,19 +525,19 @@ class BookController extends BaseController
|
|
}
|
|
}
|
|
$bid = BookService::decodeBidStatic($bid);
|
|
$bid = BookService::decodeBidStatic($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
- $res = BookConfigService::getRecommendBooks($bid,$book_info->channel_name);
|
|
|
|
|
|
+ $res = BookConfigService::getRecommendBooks($bid, $book_info->channel_name);
|
|
$urge_status = 0;
|
|
$urge_status = 0;
|
|
- if($book_info->status == 0 && !BookUrgeUpdateService::isHadUrged($this->uid,$bid)){
|
|
|
|
|
|
+ if ($book_info->status == 0 && !BookUrgeUpdateService::isHadUrged($this->uid, $bid)) {
|
|
$urge_status = 1;
|
|
$urge_status = 1;
|
|
}
|
|
}
|
|
- $recommend_result = collectionTransform(new BookTransformer(),$res);
|
|
|
|
|
|
+ $recommend_result = collectionTransform(new BookTransformer(), $res);
|
|
$book_status = [
|
|
$book_status = [
|
|
- 'status'=>$book_info->status,
|
|
|
|
- 'urge_status'=>$urge_status
|
|
|
|
|
|
+ 'status' => $book_info->status,
|
|
|
|
+ 'urge_status' => $urge_status
|
|
];
|
|
];
|
|
$data = [
|
|
$data = [
|
|
- 'recommend_result'=>$recommend_result,
|
|
|
|
- 'book_status'=>$book_status
|
|
|
|
|
|
+ 'recommend_result' => $recommend_result,
|
|
|
|
+ 'book_status' => $book_status
|
|
];
|
|
];
|
|
return response()->success($data);
|
|
return response()->success($data);
|
|
}
|
|
}
|