zz 6 سال پیش
والد
کامیت
37237dded2

+ 45 - 6
app/Http/Middleware/ReadOauth.php

@@ -751,7 +751,20 @@ class ReadOauth
     private function yqTest(Request $request, $uid,$channel_id)
     {
         if (!$request->has('param')) return '';
-        $uri = $request->input('_url');
+        $flag = $request->get('param');
+        if(empty($flag)){
+            return '';
+        }
+        Log::info('1111111111111111111111111111111');
+        $param = $request->except('_url');
+        if (isset($param['bid']))  unset($param['bid']);
+        if(isset($param['bid']))  unset($param['bid']);
+        unset($param['param']);
+        $other_str = 't=1';
+        if($param){
+            $other_str = http_build_query($param);
+        }
+        //$uri = $request->input('_url');
         $bid = $request->get('bid');
         if (!$bid) return '';
         try {
@@ -760,12 +773,27 @@ class ReadOauth
         } catch (\Exception $e) {
             return '';
         }
+        Log::info('222222222222222222222222222222');
         if (!$bid) return '';
+        Log::info('333333333333333333333333333333');
         //用户是否在样本中
         $yq_book_user = BookUserService::selectUser($uid);
         if (!$yq_book_user) {
             return '';
         }
+        Log::info('44444444444444444444444444444');
+        //如果是group_1 不错操作
+        if($flag == 'group_1'){
+            if ($yq_book_user->type == 'INIT'){
+                BookUserService::updateUser($uid, ['type'=>'GROUP_1']);
+            }
+            return '';
+        }
+        Log::info('5555555555555555555555555555');
+        if($flag != 'group_2'){
+            return '';
+        }
+        Log::info('66666666666666666666666666666');
         //用户的类型是初始类型  区域还没获取
         if ($yq_book_user->type == 'INIT') {
             $area = $this->getIpArea(get_client_ip());
@@ -776,12 +804,14 @@ class ReadOauth
                 $yq_zsy_test = YqZsyTestService::getByBid($bid);
                 if ($yq_zsy_test) {
                     //书在测试列表中
+                    $data['bid'] = $bid;
                     BookUserService::updateUser($uid, $data);
                     return '';
                 }
+                Log::info('7777777777777777777777777');
                 //书不在在测试列表中
                 //获取随机获取一本书,获取不到则返回
-                $redirect_bids = YqZsyTestService::getRandomBooks(1);
+                $redirect_bids = YqZsyTestService::getRandomBooks($uid,1);
                 $redirect_bid = 0;
                 if ($redirect_bids && isset($redirect_bids[0])) {
                     $redirect_bid = $redirect_bids[0];
@@ -790,6 +820,7 @@ class ReadOauth
                     BookUserService::updateUser($uid, $data);
                     return '';
                 };
+                Log::info('88888888888888888888888888');
                 $redirect_book_info = BookConfigService::getBookById($redirect_bid);
                 if ($redirect_book_info) {
                     $redirect = $this->getBookReaderUrl($redirect_bid,$channel_id);
@@ -797,8 +828,9 @@ class ReadOauth
                         $data['bid'] = $redirect_bid;
                     }
                     BookUserService::updateUser($uid, $data);
-                    return $redirect;
+                    return $redirect.'&'.$other_str;
                 }
+                Log::info('9999999999999999999999999');
                 return '';
 
             }
@@ -808,15 +840,18 @@ class ReadOauth
                 BookUserService::popUser($uid);
                 return '';
             }
+            Log::info('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
         }
         if($yq_book_user->type == 'DISABLED'){
             return '';
         }
+        Log::info('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
         $yq_zsy_test = YqZsyTestService::getByBid($bid);
         //如果书在测试样本中 不跳转
         if ($yq_zsy_test) {
             return '';
         }
+        Log::info('ccccccccccccccccccccccccccccc');
         // 用户符合条件 且看的书不样本中
         if($yq_book_user->bid){
             //已经有对应关系
@@ -825,11 +860,12 @@ class ReadOauth
             if($record_url) return $record_url;
             //没有阅读记录
             $book_url = $this->getBookReaderUrl($bid,$channel_id);
-            return $book_url;
+            Log::info('dddddddddddddddddddddddddd');
+            return $book_url.'&'.$other_str;
         }else{
             //没有对应关系
             //随机获取一本书
-            $redirect_bids = YqZsyTestService::getRandomBooks(1);
+            $redirect_bids = YqZsyTestService::getRandomBooks($uid,1);
             $redirect_bid = 0;
             if ($redirect_bids && isset($redirect_bids[0])) {
                 $redirect_bid = $redirect_bids[0];
@@ -837,13 +873,16 @@ class ReadOauth
             if (!$redirect_bid) {
                 return '';
             };
+            Log::info('eeeeeeeeeeeeeeeeeeeeeeeeeeeee');
             $redirect = $this->getBookReaderUrl($redirect_bid,$channel_id);
             if($redirect){
                 $data['bid'] = $redirect_bid;
                 //更新对应关系
                 BookUserService::updateUser($uid, $data);
-                return $redirect;
+                Log::info('ffffffffffffffffffffffff');
+                return $redirect.'&'.$other_str;
             }
+            Log::info('gggggggggggggggggggggggggggggggg');
             return '';
         }
     }

+ 2 - 2
app/Modules/YunQi/Services/BookUserService.php

@@ -24,12 +24,12 @@ class BookUserService
 
     public static function popUser($uid){
         try{
-            Redis::srem('xx',$uid);
+            Redis::srem('YQ_USER_TEST_BOOK:USER',$uid);
         }catch (\Exception $e){}
     }
 
     public static function isUserInRedis($uid){
-        return Redis::SISMEMBER('key',$uid);
+        return Redis::SISMEMBER('YQ_USER_TEST_BOOK:USER',$uid);
     }
 
     /**

+ 12 - 2
app/Modules/YunQi/Services/YqZsyTestService.php

@@ -8,12 +8,22 @@
 
 namespace App\Modules\YunQi\Services;
 
+use App\Modules\OfficialAccount\Services\ForceSubscribeService;
 use App\Modules\YunQi\Models\YqZsyTest;
 
 class YqZsyTestService
 {
-    public static function getRandomBooks($num=1):array{
-        $books = YqZsyTest::select('bid')->where('type','yunqi')->get();
+    public static function getRandomBooks($uid,$num=1):array{
+        $sex = ForceSubscribeService::getSimpleSexByUid($uid);
+        if($sex == 1){
+            $channel_name = '男频';
+        }else{
+            $channel_name = '女频';
+        }
+        $books = YqZsyTest::join('books','books.id','=','yq_zsy_test.bid')
+            ->join('book_categories','book_categories.id','=','books.category_id')
+            ->where('book_categories.channel_name',$channel_name)
+            ->select('yq_zsy_test.bid')->where('type','yunqi')->get();
         if($books->count()<=0){
             return [];
         }