Browse Source

Merge branch 'stabble'

zz 6 years ago
parent
commit
3c282b21bd

+ 6 - 9
app/Console/Commands/YqBook.php

@@ -5,6 +5,7 @@ namespace App\Console\Commands;
 use App\Modules\Book\Models\Chapter;
 use App\Modules\Book\Models\Book;
 use App\Modules\Book\Models\BookConfig;
+use App\Modules\YunQi\Services\BookYunqiService;
 use Illuminate\Console\Command;
 use GuzzleHttp\Client;
 use GuzzleHttp\Psr7\Request;
@@ -96,26 +97,22 @@ class YqBook extends Command
             'cover'=>$book_info['cover'],
             'keyword'=>$book_info['keyword'],
             'chapter_count'=>$book_info['chapter_count'],
+            'category_name'=>$book_info['category_name'],
+            'status'=>$book_info['status'],
             'size'=>$book_info['size']
         ]);
         BookConfig::create([
             'bid'=>$book->id,
             'force_subscribe_chapter_seq'=>10,
             'price'=>8.99,
-            'cover'=>$book_info['book_name'],
+            'book_name'=>$book_info['book_name'],
+            'cover'=>$book_info['cover'],
             'promotion_domain'=>'iycdm.com',
             'charge_type'=>isset($book_info['charge_type'])?$book_info['charge_type']:'CHAPTER',
             'is_on_shelf'=>10,
             'cp_source'=>'yunqi',
         ]);
-
-        DB::table('book_yunqi')->insert([
-            'bid'=>$book->id,
-            'yq_bid'=>$bid,
-            'type'=>'DEFAULT',
-            'created_at'=>date('Y-m-d H:i:s'),
-            'updated_at'=>date('Y-m-d H:i:s')
-        ]);
+        BookYunqiService::create($book->id,$bid);
         return $book;
     }
 

+ 16 - 3
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Wap\Book;
 
+use App\Console\Commands\YqBook;
 use App\Modules\Book\Models\DataAnalysisBookConfig;
 use App\Modules\Book\Services\BookService;
 use App\Modules\Book\Services\ChapterCommentsService;
@@ -12,6 +13,7 @@ use App\Modules\Statistic\Services\DataAnalysisChapterService;
 use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
 use App\Modules\Statistic\Services\WapVisitStatService;
 use App\Modules\Subscribe\Services\OrderService;
+use App\Modules\YunQi\Services\BookUserService;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Wap\BaseController;
 use Cookie;
@@ -345,6 +347,10 @@ class ChapterController extends BaseController
         //用户是否强关
         $this->is_had_subscribe = $is_had_subscribe = $inter_not_need_sub ? true : $this->getSubscribe();
 
+        //阅读记录
+        ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
+            'cid' => $cid, 'chapter_name' => $chapter->name]);
+
         //判断当前是否有强制显示服务号信息的cookie、已经关注 跳转到服务号信息引导页
         if(Cookie::get('force_show_qrcode') && $is_had_subscribe)
         {
@@ -364,9 +370,6 @@ class ChapterController extends BaseController
             //vip前一张和枪管前一张的访问统计
             $this->beforeForceSubAndBeforeVipUvAndPv($book_info, $subscribe_seq, $chapter);
         }
-        //阅读记录
-        ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
-            'cid' => $cid, 'chapter_name' => $chapter->name]);
 
         //不用关注且不是vip章节
         if ($force_subscribe && $chapter->is_vip == 0) {
@@ -1231,6 +1234,16 @@ class ChapterController extends BaseController
             $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $book_info->bid);
             if (!$chapter_order) return true;
         }
+
+        if($book_info->is_on_shelf == 10){
+            //Log::info('ddddddddddddddddddddddddddd');
+            $yq_book_user = BookUserService::selectUser($this->uid);
+            //Log::info($yq_book_user);
+            if($yq_book_user && $yq_book_user->type == 'ENABLE'){
+                return false;
+            }
+            return true;
+        }
         return false;
     }
 

+ 7 - 6
app/Http/Controllers/Wap/Web/RedirectController.php

@@ -47,7 +47,13 @@ class RedirectController extends Controller
         $link = SendOrderService::getRedirectUrlById($param);
         $query_param = $request->except('_url');
         $query_param['soid'] = $param;
-        $query_param['source'] = 'wechatmsg';
+        //判断是否强制到服务号阅读
+        if($link->force_show_qrcode)
+        {
+            Cookie::queue('force_show_qrcode', 1, 1);
+        }else{
+            $query_param['source'] = 'wechatmsg';
+        }
         $query_param['stats'] = 3;
         $query = '';
         if ($query_param) {
@@ -110,11 +116,6 @@ class RedirectController extends Controller
                 $this->updateSendOrderTime($param, $uv);
             }
 
-            //判断是否强制到服务号阅读
-            if($link->force_show_qrcode)
-            {
-                Cookie::queue('force_show_qrcode', 1, 1);
-            }
             //
             $redirect_path = $request->get('redirect_path');
            if($redirect_path){

File diff suppressed because it is too large
+ 509 - 248
app/Http/Middleware/ReadOauth.php


+ 9 - 1
app/Libs/Helpers.php

@@ -457,6 +457,14 @@ function specialChannelAuthInfoV2(){
         '4568'=>'wx4cfa12302780e654',
         '4569'=>'wxa25b19c509ba7db5',
         '4578'=>'wx3beda81dba0b450b',
-        '4580'=>'wxb4bb620409a96ed7'
+        '4580'=>'wxb4bb620409a96ed7',
+        '4603'=>'wxf9df2ce5ea94fa4e',
+        '4604'=>'wxb479d38891b14286',
+        '4605'=>'wx72569a8f18599cdb',
+        '4606'=>'wxb17c22779a821271',
+        '4607'=>'wx2bc3eaf8840f81a8',
+        '4608'=>'wx3723054b39225b9d',
+        '4609'=>'wx504c20ebf5cfcd60',
+        '4617'=>'wxf45639677a2bb97c'
     ];
 }

+ 3 - 3
app/Modules/User/Services/ReadRecordService.php

@@ -123,7 +123,7 @@ class ReadRecordService
         //Redis::hset('book_read:'.$uid, $bid, $cid."_".time());
         Redis::hset('book_read:' . $uid, $bid, "{$cid}_" . time());
     }
-
+    
     /**
      * 删除
      * @param $uid
@@ -330,8 +330,8 @@ class ReadRecordService
             return $res;
         }
         foreach ($read_bids as $key => $v) {
-            if(in_array($key,self::$not_uid_key)){
-            	continue;
+            if(in_array($key,self::$not_uid_key)){
+            	continue;
             }
             array_push($res,$key);
         }

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

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

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

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Modules\YunQi\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class BookYunqi extends Model
+{
+    protected $table = 'book_yunqi';
+    protected $fillable = ['bid','yq_bid','type'];
+}

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

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Modules\YunQi\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class YqZsyTest extends Model
+{
+    protected $table = 'yq_zsy_test';
+    protected $fillable = ['bid','type','limit_area'];
+}

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

@@ -0,0 +1,47 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: z-yang
+ * Date: 2019/1/10
+ * Time: 11:30
+ */
+
+namespace App\Modules\YunQi\Services;
+
+use App\Modules\YunQi\Models\BookUser;
+use Redis;
+
+class BookUserService
+{
+    public static function getByUid($uid){
+        return BookUser::where('uid',$uid)->select('id','uid','area','type','bid','flag')->first();
+    }
+
+    public static function updateUser($uid,$data){
+        return BookUser::where('uid',$uid)->update($data);
+    }
+
+
+    public static function popUser($uid){
+        try{
+            Redis::srem('YQ_USER_TEST_BOOK:USER',$uid);
+        }catch (\Exception $e){}
+    }
+
+    public static function isUserInRedis($uid){
+        return Redis::SISMEMBER('YQ_USER_TEST_BOOK:USER',$uid);
+    }
+
+    /**
+     * 判断用户是否存在
+     * @param $uid
+     * @return bool
+     */
+    public static function selectUser($uid){
+        if(!self::isUserInRedis($uid)){
+            return null;
+        }
+        $user = self::getByUid($uid);
+        return $user;
+    }
+}

+ 39 - 0
app/Modules/YunQi/Services/BookYunqiService.php

@@ -0,0 +1,39 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: z-yang
+ * Date: 2019/1/10
+ * Time: 11:31
+ */
+
+namespace App\Modules\YunQi\Services;
+
+
+use App\Modules\YunQi\Models\BookYunqi;
+use Redis;
+
+class BookYunqiService
+{
+    public static function create($bid,$yq_bid){
+       $type = 'DEFAULT';
+        if(self::getByBid($bid)){
+            return false;
+        }
+       return BookYunqi::create(compact('bid','yq_bid','type'));
+    }
+
+    public static function getByBid($bid){
+        if(empty($bid))return false;
+        return BookYunqi::where('bid',$bid)->select('bid','type','id')->first();
+    }
+
+    public static function getRandomBooks($num=1):array{
+        $books = BookYunqi::select('bid')->get();
+        if($books->count()<=0){
+            return [];
+        }
+        $num = $books->count()>$num ?$num:$books->count();
+        return $books->random($num)->pluck('bid')->all();
+    }
+
+}

+ 37 - 0
app/Modules/YunQi/Services/YqZsyTestService.php

@@ -0,0 +1,37 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: z-yang
+ * Date: 2019/1/11
+ * Time: 9:50
+ */
+
+namespace App\Modules\YunQi\Services;
+
+use App\Modules\OfficialAccount\Services\ForceSubscribeService;
+use App\Modules\YunQi\Models\YqZsyTest;
+
+class YqZsyTestService
+{
+    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 [];
+        }
+        $num = $books->count()>$num ?$num:$books->count();
+        return $books->random($num)->pluck('bid')->all();
+    }
+
+    public static function getByBid($bid){
+        return YqZsyTest::where('bid',$bid)->select('id','bid','type')->first();
+    }
+}