Browse Source

加密机密使用统一方法,书籍屏蔽提示下架

wangzq 2 years ago
parent
commit
053e24e14a

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

@@ -759,6 +759,7 @@ class BookController extends BaseController
     public function yueaiBackRecom(Request $request)
     {
         $package     = $request->header('x-package', '');
+
         if (empty($package) || $package != 'com.beidao.kuaiying.yueai') {
             return response()->success([]);
         }
@@ -832,7 +833,7 @@ class BookController extends BaseController
 
         if(!empty($bid)){
             \Log::info('recommendBooks:2');
-            $bid = Hashids::decode($bid)[0];
+            $bid = str_decode($bid);
         }
 
         //判断包是否存在
@@ -887,7 +888,7 @@ class BookController extends BaseController
             return response()->success([]);
         }
         $date = date('Ymd');
-        $bid = Hashids::decode($bid)[0];
+        $bid = str_decode($bid);
 
         $cacheKey = 'recommend:click:'.$date.':'.$distribution_id.$bid;
         $this->incrRedisKey($cacheKey);
@@ -1016,7 +1017,7 @@ class BookController extends BaseController
             return response()->success();
         }
 
-        $id = Hashids::decode($id)[0];
+        $id = str_decode($id);
         if(!$id){
             return response()->success();
         }
@@ -1106,7 +1107,7 @@ class BookController extends BaseController
                         if(!isset($content[2])){
                             return response()->success();
                         }
-                        if($order->from_bid == 0 || $order->from_bid != Hashids::decode($content[2])[0]){
+                        if($order->from_bid == 0 || $order->from_bid != str_decode($content[2])){
                             return response()->success();
                         }
                     }
@@ -1121,11 +1122,11 @@ class BookController extends BaseController
                     $bid = $result['bid'];
                     $cid = $result['cid'];
                     if($cid){
-                        if($order->from_bid == 0 || $order->from_bid != Hashids::decode($bid)[0]){
+                        if($order->from_bid == 0 || $order->from_bid != str_decode($bid)){
                             return response()->success();
                         }
                     }else{
-                        if($order->activity_id == 0 || $order->from_bid != Hashids::decode($bid)[0]){
+                        if($order->activity_id == 0 || $order->from_bid != str_decode($bid)){
                             return response()->success();
                         }
                     }

+ 1 - 1
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -154,7 +154,7 @@ class ChapterController extends BaseController
 
         //yuyuedu、xinghe  快应用这两个cp的书屏蔽下 wutong,wutong2,wutong3下所有内容都不放快应用
         if(in_array($book_info->cp_source,getHiddenCp())){
-            return response()->error('QAPP_SYS_ERROR');
+            return response()->error('QAPP_OFF_SHELF');
         }
 
         if($this->distribution_channel_id == 7477 && $bid == 13765){

+ 36 - 0
app/Libs/Helpers.php

@@ -1,6 +1,8 @@
 <?php
 
 
+
+
 /**
  * 获取当前域名
  */
@@ -866,4 +868,38 @@ if (!function_exists("check_qapp_send_order_id)")){
 
         return true;
     }
+}
+
+
+if(!function_exists("str_decode")){
+    /**
+     * 字符解密
+     * name: str_decode
+     * @param $str
+     * @return int
+     * date 2022/09/27 11:38
+     */
+    function str_decode($str){
+
+        $decode = Hashids::decode($str);
+        $decode = is_array($decode) ? array_shift($decode) : $decode;
+        if(empty($decodeBid)){
+            myLog("StrDecodeError")->info("str : {$str}, decode : ".var_export($decode,true));
+        }
+        return intval($decode);
+    }
+}
+
+if (!function_exists('str_encode')){
+    /***
+     *  字符加密
+     * name: str_decode
+     * @param mixed $str
+     * @return mixed
+     * date 2022/09/27 11:38
+     */
+    function str_encode($str)
+    {
+        return  Hashids::encode($str);
+    }
 }