wangzq 2 lat temu
rodzic
commit
e7d1f37e33

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

@@ -294,7 +294,7 @@ class BookController extends BaseController
     private function getCheckBooks($bid_list,$channel,$package,$is_author)
     {
         $hidden_cp = getHiddenCp();
-        if($package !== 'com.beidao.kuaiying.zsy'){
+        if(!is_public_package($package)){
             $hidden_cp = array_merge($hidden_cp,['lianshang']);
         }
         //获取书本数量
@@ -442,7 +442,7 @@ class BookController extends BaseController
         }
 
         $page_size = $request->input('page_size', 15);
-        $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+        $where['channel_id'] = $request->input('distribution_channel_id',0);
         $books     = BookConfigService::getBooks($where, $order, $page_size);
         return response()->pagination(new BookTransformer, $books);
     }
@@ -470,7 +470,7 @@ class BookController extends BaseController
             $where['cp_source'] = "ycsd";
         }
 
-        $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+        $where['channel_id'] = $request->input('distribution_channel_id',0);
 
         $books = BookConfigService::getBooks($where, [], 4);
         $data  = [];
@@ -562,7 +562,7 @@ class BookController extends BaseController
             }
         }
 
-        $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+        $channel_id = $request->input('distribution_channel_id',0);
         $books = collectionTransform(new BookTransformer, BookConfigService::getBookLists(compact('bids','channel_id')));
 
         return response()->success($books);
@@ -797,7 +797,7 @@ class BookController extends BaseController
         }
         return response()->success([]);
         $where = ['is_on_shelf' => [2]];
-        $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+        $where['channel_id'] = $request->input('distribution_channel_id',0);
 
         $books = BookConfigService::getBooks($where, [], 4);
         return response()->collection(new BookTransformer(), $books);
@@ -829,7 +829,7 @@ class BookController extends BaseController
         }
         return response()->success([]);
         $where = ['is_on_shelf' => [2]];
-        $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+        $where['channel_id'] = $request->input('distribution_channel_id',0);;
         $books = BookConfigService::getBooks($where, [], 4);
         return response()->collection(new BookTransformer(), $books);
     }

+ 2 - 2
app/Http/Controllers/QuickApp/Oauth/UsersController.php

@@ -68,8 +68,8 @@ class UsersController extends Controller
 //            $package = 'com.beidao.kuaiying.haohan';
 //        }
 
-        $package = get_real_package($package);
-        
+        // $package = get_real_package($package);
+
         //获取渠道id
         $channel_id = QappPackageService::getChannelId($package);
         if ($device_no && $channel_id > 0) {

+ 4 - 4
app/Http/Controllers/QuickApp/User/ReadRecordController.php

@@ -74,7 +74,7 @@ class ReadRecordController extends BaseController
 
         if ($res) {
             $bids = array_column($res,'bid');
-            $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+            $channel_id = $request->input('distribution_channel_id',0);
             $book = BookConfigService::getBooksByIds($bids, [], false);//下架图书最近阅读可看到
             foreach ($res as $key => &$value) {
                 $value['cover']        = '';
@@ -92,7 +92,7 @@ class ReadRecordController extends BaseController
                         $value['status'] = $val->status;
                         $value['size'] = $val->size;
                         $value['author'] = $val->author;
-                        if($channel_id === 7477){
+                        if(is_public_package_channel_id($channel_id)){
                             $hidden = getHiddenCp();
                         }else{
                             $hidden = array_merge(getHiddenCp(),['lianshang']);
@@ -143,7 +143,7 @@ class ReadRecordController extends BaseController
 
         if ($res) {
             $bids = array_column($res,'bid');
-            $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+            $channel_id = $request->input('distribution_channel_id',0);
             $book = BookConfigService::getBooksByIds($bids, [], false);//下架图书最近阅读可看到
             $book = array_column(($book->toArray()),null,'bid');
             foreach ($res as  &$value) {
@@ -162,7 +162,7 @@ class ReadRecordController extends BaseController
                     $value['status'] =  $info['status'];
                     $value['size'] =  $info['size'];
                     $value['author'] =  $info['author'];
-                    if($channel_id === 7477){
+                    if(is_public_package_channel_id($channel_id)){
                         $hidden = getHiddenCp();
                     }else{
                         $hidden = array_merge(getHiddenCp(),['lianshang']);

+ 2 - 1
app/Http/Middleware/QuickAppGetPackage.php

@@ -41,7 +41,8 @@ class QuickAppGetPackage extends BaseMiddleware
         }
         $sendOrderId = check_qapp_send_order_id($channel_id,$sendOrderId) ? $sendOrderId : 0;
         $request->headers->set('send-order-id',$sendOrderId);
-        $request->merge(['send_order_id' => $sendOrderId,'distribution_channel_id' => $channel_id]);
+        $request->headers->set('x-package',$package);
+        $request->merge(['send_order_id' => $sendOrderId,'distribution_channel_id' => $channel_id,'package' => $package]);
         if($channel_id > 0){
             return $next($request);
         }else{

+ 98 - 1
app/Libs/Helpers.php

@@ -872,6 +872,7 @@ if (!function_exists("check_qapp_send_order_id)")){
 
 
 
+
 if(!function_exists("str_decode")){
     /**
      * 字符解密
@@ -911,4 +912,100 @@ if(!function_exists('get_special_bid')){
         return [];
         // return [7742,7743,7748,8721,8749,64870,64871,64872,64873,64874,64875,64876,64877,64878,64879,64880,64881,64882,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64894,64895,64896,64897,64900,64899,64898];
     }
-}
+}
+
+/**
+ *  判断包是否是公共包
+ * name: is_public_package
+ * @param string $packageName
+ * @return bool
+ * date 2022/09/22 16:53
+ */
+if(!function_exists("is_public_package")){
+    function is_public_package($packageName = "")
+    {
+        if (empty($packageName)){
+            return false;
+        }
+        $publicPackageName = get_public_packages();
+        if (in_array($packageName,$publicPackageName)){
+            return  true;
+        }
+
+        return  false;
+    }
+}
+
+/**
+ *  判断包是否是公共包站点id
+ * name: is_public_package
+ * @param string $packageName
+ * @return bool
+ * date 2022/09/22 16:53
+ */
+if(!function_exists("is_public_package_channel_id")){
+    function is_public_package_channel_id($channelId = 0)
+    {
+        if (empty($$channelId)){
+            return false;
+        }
+        $publicPackageName = get_public_package_channel_ids();
+        if (in_array($channelId,$publicPackageName)){
+            return  true;
+        }
+
+        return  false;
+    }
+}
+
+/**
+ *  所有获取公共包
+ * name: get_public_packages
+ * @return \Illuminate\Config\Repository|\Illuminate\Foundation\Application|mixed
+ * date 2022/09/22 17:24
+ */
+if(!function_exists('get_public_packages')){
+    function  get_public_packages(){
+        return config("package.package_name");
+    }
+}
+
+/**
+ *  所有获取公共包站点id
+ * name: get_public_packages
+ * @return \Illuminate\Config\Repository|\Illuminate\Foundation\Application|mixed
+ * date 2022/09/22 17:24
+ */
+if(!function_exists('get_public_package_channel_ids')){
+    function  get_public_package_channel_ids(){
+        return config("package.channel_id");
+    }
+}
+
+/***
+ *  获取默认公共包站点id
+ * name: get_default_public_channel_id
+ * @return int|mixed
+ * date 2022/09/23 14:51
+ */
+if (!function_exists("get_default_public_channel_id")){
+
+    function get_default_public_channel_id()
+    {
+       $package = get_default_public_package_info();
+       return $package['channel_id'] ?? 0;
+    }
+}
+
+/***
+ * 获取默认公共包站点id和包名
+ * name: get_default_public_package_info
+ * @return \Illuminate\Config\Repository|\Illuminate\Foundation\Application|mixed
+ * date 2022/09/23 14:51
+ */
+if (!function_exists("get_default_public_channel_id")){
+    function get_default_public_package_info()
+    {
+        return config("package.default");
+    }
+}

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

@@ -165,7 +165,7 @@ class BookConfig extends Model
                 }
             }
         }
-        if(isset($where['channel_id']) && $where['channel_id'] == 7477){
+        if(isset($where['channel_id']) &&  is_public_package_channel_id($where['channel_id'])){
             $res->whereNotIn('book_configs.cp_source',getHiddenCp());
         }else{
             $res->whereNotIn('book_configs.cp_source',array_merge(getHiddenCp(),['lianshang']));
@@ -294,7 +294,7 @@ class BookConfig extends Model
             $field = 'bid,' . $str;
             $res->orderBy(DB::raw('field(' . $field . ')'));
         }
-        if(isset($where['channel_id']) && $where['channel_id'] == 7477){
+        if(isset($where['channel_id']) && is_public_package_channel_id($where['channel_id'])){
             $res->whereNotIn('book_configs.cp_source',getHiddenCp());
         }else{
             $res->whereNotIn('book_configs.cp_source',array_merge(getHiddenCp(),['lianshang']));

+ 2 - 2
app/Modules/Book/Services/BookAuditService.php

@@ -37,7 +37,7 @@ class BookAuditService
 
         // 一次性获取书籍列表
         $bids  = array_merge($hotBids, $liveBids, $recomBids, $newBids);
-        $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+        $channel_id = is_public_package($package) ? get_default_public_channel_id() : 0;
         $books = BookConfigService::getBookLists(compact('bids','channel_id'));
 
         return [
@@ -117,7 +117,7 @@ class BookAuditService
     private static function getCheckBooks($bid_list,$channel,$package,$is_author)
     {
         $hidden_cp = getHiddenCp();
-        if($package !== 'com.beidao.kuaiying.zsy'){
+        if(!is_public_package($package)){
             $hidden_cp = array_merge($hidden_cp,['lianshang']);
         }
         //获取书本数量

+ 26 - 0
config/package.php

@@ -0,0 +1,26 @@
+<?php
+/**
+ *  公共包配置
+ * @file:package.php
+ * @Created by gnitif
+ * @Date: 2022/9/22
+ * @Time: 16:36
+ */
+
+return [
+    // 包名
+    "package_name" =>  [
+        "com.beidao.kuaiying.zsy",
+        "com.beidao.kuaiying.qingmang",
+    ],
+    // 站点id
+    'channel_id' =>  [
+        7477,
+        13131,
+    ],
+    // 最新默认
+    'default' => [
+        'package_name' =>  "com.beidao.kuaiying.qingmang",
+        'channel_id' => 13131,
+    ],
+];