|
@@ -9,6 +9,7 @@ use App\Modules\RecommendBook\Services\RecommendService;
|
|
|
use App\Modules\Book\Services\RecoBannerService;
|
|
|
use App\Modules\User\Models\QappPackage;
|
|
|
use App\Modules\User\Services\QappUserService;
|
|
|
+use Hashids\Hashids;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Http\Controllers\QuickApp\BaseController;
|
|
|
use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
|
|
@@ -169,10 +170,10 @@ class BookController extends BaseController
|
|
|
$package = $request->header('x-package', '');
|
|
|
$brand = $request->header('x-nbrand', '');
|
|
|
$codeVersion = $request->header('x-codeversion', '');
|
|
|
-
|
|
|
+ $isAuth = check_qapp_auth($package ,0);
|
|
|
// 根据包名、平台、版本号判断是否审核
|
|
|
- if (Utils::checkIsAudit($package, $brand, $codeVersion)) {
|
|
|
- $result = BookAuditService::getHomeBooksData($sex, $package);
|
|
|
+ if (Utils::checkIsAudit($package, $brand, $codeVersion) && $isAuth === false) {
|
|
|
+ $result = BookAuditService::getHomeBooksData($sex, $package,$isAuth);
|
|
|
return response()->success($result);
|
|
|
}
|
|
|
|
|
@@ -183,7 +184,9 @@ class BookController extends BaseController
|
|
|
$reco_banner_type = ['FEMALE', 'PUBLIC'];
|
|
|
$channel = 2;
|
|
|
}
|
|
|
+
|
|
|
$books = (new RecoBannerService)->getByType($reco_banner_type, 2);
|
|
|
+
|
|
|
$books->transform(function ($item) {
|
|
|
$result = $this->getBidCidFromUrl($item->redirect_url);
|
|
|
$item->bid = $result['bid'];
|
|
@@ -196,6 +199,7 @@ class BookController extends BaseController
|
|
|
return $item;
|
|
|
});
|
|
|
|
|
|
+
|
|
|
//新判断: 根据包名来获取对应所需的bid
|
|
|
$qapp_package = QappPackage::getPackageByPackage($package);
|
|
|
if($qapp_package){
|
|
@@ -203,6 +207,20 @@ class BookController extends BaseController
|
|
|
}else{
|
|
|
$package_id = 0;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ if($isAuth == false && !$books->isEmpty()){
|
|
|
+ // 未授权快应
|
|
|
+ $bookIds = array_column($books->toArray(),'bid');
|
|
|
+ $bookIds = BookConfigService::checkBookId($bookIds);
|
|
|
+ foreach ($books as &$value){
|
|
|
+ if (!in_array($value->bid,$bookIds)){
|
|
|
+ $value->redirect_url = "#";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ unset($value);
|
|
|
+ }
|
|
|
+
|
|
|
\Log::info('un_send_order_book:package_id1:'.$package_id.' $package:'.$package);
|
|
|
$user = (new QappUserService)->getGolableUser();
|
|
|
if(isset($user->uid) && !empty($user->uid)){
|
|
@@ -236,10 +254,11 @@ class BookController extends BaseController
|
|
|
*/
|
|
|
private function getCheckBids($channel,$books,$package_id)
|
|
|
{
|
|
|
- $hotBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'hot',$package_id),$channel);
|
|
|
- $liveBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'live',$package_id),$channel);
|
|
|
- $recomBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'recom',$package_id),$channel);
|
|
|
- $newBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'new_recom',$package_id),$channel);
|
|
|
+ $isAuthor = check_qapp_auth($package_id,1);
|
|
|
+ $hotBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'hot',$package_id),$channel,$isAuthor);
|
|
|
+ $liveBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'live',$package_id),$channel,$isAuthor);
|
|
|
+ $recomBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'recom',$package_id),$channel,$isAuthor);
|
|
|
+ $newBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'new_recom',$package_id),$channel,$isAuthor);
|
|
|
|
|
|
return array_filter([
|
|
|
['type' => 'reco_banner', 'lable' => '首页banner', 'books' => $books],
|
|
@@ -257,10 +276,21 @@ class BookController extends BaseController
|
|
|
* @param $channel : 频道
|
|
|
* @return array
|
|
|
*/
|
|
|
- private function getCheckBooks($bid_list,$channel)
|
|
|
+ private function getCheckBooks($bid_list,$channel,$is_author)
|
|
|
{
|
|
|
+
|
|
|
//获取书本数量
|
|
|
$count = count($bid_list);
|
|
|
+ if (!$is_author){
|
|
|
+ $where = [
|
|
|
+ ['book_configs.charge_type','!=','BOOK'],
|
|
|
+ ['book_configs.cp_source','=','ycsd'],
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $where = [
|
|
|
+ ['book_configs.charge_type','!=','BOOK'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
//获取当前有效书本数量
|
|
|
$book_count = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
|
|
|
->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
|
|
@@ -268,8 +298,10 @@ class BookController extends BaseController
|
|
|
->where('book_configs.is_on_shelf',2)
|
|
|
->where('book_configs.charge_type','!=','BOOK')
|
|
|
->whereNotIn('book_configs.cp_source',getHiddenCp())
|
|
|
+ ->where($where)
|
|
|
->where('book_categories.pid',$channel)
|
|
|
->count();
|
|
|
+
|
|
|
if($count == $book_count){
|
|
|
return $bid_list;
|
|
|
}
|
|
@@ -283,7 +315,7 @@ class BookController extends BaseController
|
|
|
->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
|
|
|
->whereIn('book_configs.bid',$bid_list)
|
|
|
->where('book_configs.is_on_shelf',2)
|
|
|
- ->where('book_configs.charge_type','!=','BOOK')
|
|
|
+ ->where($where)
|
|
|
->whereNotIn('book_configs.cp_source',getHiddenCp())
|
|
|
->where('book_categories.pid',$channel)
|
|
|
->pluck('book_configs.bid')->all();
|
|
@@ -293,7 +325,8 @@ class BookController extends BaseController
|
|
|
$rand_bid = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
|
|
|
->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
|
|
|
->where('book_configs.is_on_shelf',2)
|
|
|
- ->where('book_configs.charge_type','!=','BOOK')
|
|
|
+ // ->where('book_configs.charge_type','!=','BOOK')
|
|
|
+ ->where($where)
|
|
|
->whereNotIn('book_configs.cp_source',getHiddenCp())
|
|
|
->where('book_categories.pid',$channel)
|
|
|
->inRandomOrder()
|
|
@@ -366,6 +399,12 @@ class BookController extends BaseController
|
|
|
$order = ['book_configs.bid', 'desc'];
|
|
|
}
|
|
|
|
|
|
+ // 是否只使用原创书殿的书
|
|
|
+ $isAuth = check_qapp_auth($package ,0);
|
|
|
+ if (!$isAuth){
|
|
|
+ $where['cp_source'] = "ycsd";
|
|
|
+ }
|
|
|
+
|
|
|
$status = $request->input('status');
|
|
|
if ($status != '') {
|
|
|
$where['status'] = $status;
|
|
@@ -389,13 +428,18 @@ class BookController extends BaseController
|
|
|
|
|
|
public function similarRecom(Request $request)
|
|
|
{
|
|
|
+ $package = $request->header('x-package', '');
|
|
|
$category_id = $request->input('category_id');
|
|
|
$bid = $request->input('bid');
|
|
|
if (empty($bid) || (empty($category_id) && $category_id != 0)) {
|
|
|
return response()->error('PARAM_ERROR');
|
|
|
}
|
|
|
+ $isAuth = check_qapp_auth($package ,0);
|
|
|
$bid = BookService::decodeBidStatic($bid);
|
|
|
$where = ['category_id' => $category_id, 'is_on_shelf' => [2]];
|
|
|
+ if (!$isAuth){
|
|
|
+ $where['cp_source'] = "ycsd";
|
|
|
+ }
|
|
|
$books = BookConfigService::getBooks($where, [], 4);
|
|
|
$data = [];
|
|
|
foreach ($books as $v) {
|
|
@@ -466,6 +510,7 @@ class BookController extends BaseController
|
|
|
$package = $request->header('x-package', '');
|
|
|
$brand = $request->header('x-nbrand', '');
|
|
|
$codeVersion = $request->header('x-codeversion', '');
|
|
|
+
|
|
|
if (Utils::checkIsAudit($package, $brand, $codeVersion)) {
|
|
|
$bids = [2266, 3838, 9700, 10175, 10301, 3422, 1166, 4546, 9163, 2509,
|
|
|
7287,14297,12716,14312,14000,13577,16712,13002,12717,15103,13928,
|
|
@@ -475,6 +520,14 @@ class BookController extends BaseController
|
|
|
$bids = [159, 2439, 6276, 10074, 5409, 9379, 10323, 9078, 3603, 487];
|
|
|
}
|
|
|
}
|
|
|
+ $isAuth = check_qapp_auth($package,0);
|
|
|
+ if (!$isAuth){
|
|
|
+ $rank = config('home.rank');
|
|
|
+ $bids = $rank['male'];
|
|
|
+ if ($sex === 2) {
|
|
|
+ $bids = $rank['female'];;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds($bids));
|
|
|
return response()->success($books);
|