zz 6 éve
szülő
commit
4455449c31

+ 12 - 5
app/Http/Middleware/ReadOauth.php

@@ -10,6 +10,7 @@ use App\Modules\User\Models\YqMove;
 use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\UserService;
 use App\Modules\YunQi\Services\BookUserService;
+use App\Modules\YunQi\Services\YqUserBidRelationService;
 use App\Modules\YunQi\Services\YqZsyTestService;
 use Closure;
 use Cookie;
@@ -142,8 +143,8 @@ class ReadOauth
         //云栖测试
         $qy_test_url = $this->yqTest($request,$uid_cookie,$distribution_channel_id);
         if($qy_test_url){
-            //Log::info('url is: '.$qy_test_url);
-            return redirect()->to($qy_test_url);
+            Log::info('url is: '.$qy_test_url);
+            //return redirect()->to($qy_test_url);
         }
 
         //只能推送的统计
@@ -800,6 +801,7 @@ class ReadOauth
         //Log::info('44444444444444444444444444444');
         //如果是group_1 不错操作
         if($flag == 'group_1'){
+            YqUserBidRelationService::create($uid,$bid,'GROUP_1',0);
             if ($yq_book_user->type == 'INIT'){
                 BookUserService::updateUser($uid, ['type'=>'GROUP_1']);
             }
@@ -824,6 +826,7 @@ class ReadOauth
             if ('ENABLE' == $type) {
                 $yq_zsy_test = YqZsyTestService::getByBid($bid);
                 if ($yq_zsy_test) {
+                    YqUserBidRelationService::create($uid,$bid,'GROUP_2',$bid);
                     //书在测试列表中
                     $data['bid'] = $bid;
                     BookUserService::updateUser($uid, $data);
@@ -849,6 +852,7 @@ class ReadOauth
                     if($redirect){
                         $data['bid'] = $redirect_bid;
                     }
+                    YqUserBidRelationService::create($uid,$bid,'GROUP_2',$redirect_bid);
                     BookUserService::updateUser($uid, $data);
                     return $redirect.'&'.$other_str;
                 }
@@ -871,17 +875,19 @@ class ReadOauth
         $yq_zsy_test = YqZsyTestService::getByBid($bid);
         //如果书在测试样本中 不跳转
         if ($yq_zsy_test) {
+            YqUserBidRelationService::create($uid,$bid,'GROUP_2',0);
             return '';
         }
         //Log::info('ccccccccccccccccccccccccccccc');
         // 用户符合条件 且看的书不样本中
-        if($yq_book_user->bid){
+        $relate_info = YqUserBidRelationService::getByUidAndBid($uid,$bid);
+        if($relate_info && $relate_info->to_bid){
             //已经有对应关系
             //如果有阅读记录
-            $record_url = $this->readerRecpord($uid,$yq_book_user->bid,$channel_id);
+            $record_url = $this->readerRecpord($uid,$relate_info->to_bid,$channel_id);
             if($record_url) return $record_url.'&'.$other_str;
             //没有阅读记录
-            $book_url = $this->getBookReaderUrl($yq_book_user->bid,$channel_id);
+            $book_url = $this->getBookReaderUrl($relate_info->to_bid,$channel_id);
             //Log::info('dddddddddddddddddddddddddd');
             //Log::info($book_url.'&'.$other_str);
             return $book_url.'&'.$other_str;
@@ -903,6 +909,7 @@ class ReadOauth
                 //更新对应关系
                 BookUserService::updateUser($uid, $data);
                 //Log::info('ffffffffffffffffffffffff');
+                YqUserBidRelationService::create($uid,$bid,'GROUP_2',$redirect_bid);
                 return $redirect.'&'.$other_str;
             }
             //Log::info('gggggggggggggggggggggggggggggggg');

+ 11 - 0
app/Modules/YunQi/Models/YqUserBidRelation.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Modules\YunQi\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class YqUserBidRelation extends Model
+{
+    protected $table = 'yq_user_bid_relation';
+    protected $fillable = ['uid','type','from_bid','to_bid'];
+}

+ 47 - 0
app/Modules/YunQi/Services/YqUserBidRelationService.php

@@ -0,0 +1,47 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: z-yang
+ * Date: 2019/1/19
+ * Time: 10:08
+ */
+
+namespace App\Modules\YunQi\Services;
+
+
+use App\Modules\YunQi\Models\YqUserBidRelation;
+
+class YqUserBidRelationService
+{
+    public static function getByUidAndBid($uid,$bid){
+        if(empty($uid) || empty($bid)){
+            return false;
+        }
+        try{
+            return YqUserBidRelation::where('uid',$uid)->where('from_bid',$bid)->select('id','to_bid')->first();
+        }catch (\Exception $e){
+
+        }
+       return false;
+    }
+
+    public static function create($uid,$from_bid,$type,$to_bid){
+        if(empty($uid) || empty($bid) || empty($type)){
+            return false;
+        }
+        if(!self::getByUidAndBid($uid,$from_bid)){
+            try{
+                YqUserBidRelation::create([
+                    'uid'=>$uid,
+                    'from_bid'=>$from_bid,
+                    'type'=>$type,
+                    'to_bid'=>$to_bid
+                ]);
+            }catch (\Exception $e){
+
+            }
+
+        }
+        return true;
+    }
+}