Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

zhoulj 6 tahun lalu
induk
melakukan
03c486381e

+ 96 - 1
app/Console/Commands/BookTest.php

@@ -3,6 +3,8 @@
 namespace App\Console\Commands;
 namespace App\Console\Commands;
 
 
 use App\Modules\Book\Services\BookSubscribleChapterService;
 use App\Modules\Book\Services\BookSubscribleChapterService;
+use App\Modules\Subscribe\Services\ChapterOrderService;
+use App\Modules\YunQi\Models\BookUser;
 use GuzzleHttp\Client;
 use GuzzleHttp\Client;
 use Illuminate\Console\Command;
 use Illuminate\Console\Command;
 
 
@@ -18,6 +20,7 @@ use App\Jobs\SendStatisticsList;
 use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
 use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
 use App\Modules\User\Services\UserSignService;
 use App\Modules\User\Services\UserSignService;
 use App\Modules\Book\Models\BookUvStat;
 use App\Modules\Book\Models\BookUvStat;
+use App\Modules\Subscribe\Models\ChapterOrder;
 
 
 class BookTest extends Command
 class BookTest extends Command
 {
 {
@@ -59,7 +62,8 @@ class BookTest extends Command
         //$this->testTest();
         //$this->testTest();
         //$this->activity();
         //$this->activity();
         //$this->testBookSmartPushStats();
         //$this->testBookSmartPushStats();
-        $this->sendOrderStats105();
+        //$this->sendOrderStats105();
+        $this->you2();
     }
     }
 
 
 
 
@@ -311,4 +315,95 @@ class BookTest extends Command
             }
             }
         }
         }
     }
     }
+
+    private function you2(){
+        $result = [];
+        $info = BookUser::where('bid','>',0)->select('bid','uid','type','updated_at')->get();
+        $info2 = BookUser::where('type','GROUP_1')->select('bid','uid','type','updated_at')->get();
+        foreach ($info as $item){
+            $bid_price = Order::where('uid',$item->uid)
+                ->where('status','PAID')
+                ->where('created_at','>=',$item->updated_at)
+                ->where('from_bid',$item->bid)
+                ->sum('price');
+            $all_price = Order::where('uid',$item->uid)
+                ->where('status','PAID')
+                ->where('created_at','>=',$item->updated_at)
+                ->sum('price');
+            $chapter_model = new ChapterOrder();
+            $chapter_model->setCurrentTable($item->uid);
+            $chapter_fee = $chapter_model->where('uid', $item->uid)
+                ->where('bid', $item->bid)
+                ->where('created_at','>=',$item->updated_at)
+                ->sum('fee');
+            $all_fee = $chapter_model->where('uid', $item->uid)
+                ->where('created_at','>=',$item->updated_at)
+                ->sum('fee');
+            $result[] = [
+                'uid'=>$item->uid,
+                'type'=>$item->type,
+                'amount'=>$bid_price?$bid_price:0,
+                'fee'=>$chapter_fee?$chapter_fee:0,
+                'bid'=>$item->bid,
+                'all_price'=>$all_price?$all_price:0,
+                'all_fee'=>$all_fee?$all_fee:0
+            ];
+        }
+        $item = null;
+        foreach ($info2 as $item){
+            $all_price = Order::where('uid',$item->uid)
+                ->where('status','PAID')
+                ->where('created_at','>=',$item->updated_at)
+                ->sum('price');
+            $chapter_model = new ChapterOrder();
+            $chapter_model->setCurrentTable($item->uid);
+            $all = $chapter_model->where('uid', $item->uid)
+                ->where('created_at','>=',$item->updated_at)
+                ->groupBy('bid')
+                ->select(DB::raw('sum(fee) as fee'),'bid','book_name')
+                ->orderBy('fee','desc')
+                ->first();
+            $all_fee = 0;
+            $bid = 0;
+            $book_name = '';
+            if($all){
+                $all_fee = $all->fee;
+                $bid = $all->bid;
+                $book_name = $all->book_name;
+            }
+            $result[] = [
+                'uid'=>$item->uid,
+                'type'=>$item->type,
+                'amount'=>0,
+                'fee'=>0,
+                'bid'=>$bid,
+                'all_price'=>$all_price?$all_price:0,
+                'all_fee'=>$all_fee?$all_fee:0,
+                'book_name'=>$book_name
+            ];
+        }
+
+        $str = "图书id,书名,用户类型,用户id,本书订阅书币,本书充值,总充值,总订阅\r\n";
+        $str = mb_convert_encoding($str, 'gbk');
+        $file_name = date('Y-m-d') . '-you2.csv';
+        file_put_contents($file_name, $str);
+        $temp = '';
+        foreach ($result as $val) {
+            $books = DB::table('book_configs')->where('bid',$val['bid'])->select('book_name')->first();
+            if($books){
+                $book_name = $books->book_name;
+            }else{
+                $book_name = 'un';
+            }
+            if($val['type'] == 'GROUP_1'){
+                $type = 'GROUP_1';
+            }else{
+                $type = 'GROUP_2';
+            }
+            $t = "{$val['bid']},{$book_name},{$type},{$val['uid']},{$val['fee']},{$val['amount']},{$val['all_price']},{$val['all_fee']}\r\n";
+            $temp .=  mb_convert_encoding($t, 'gbk');
+        }
+        file_put_contents($file_name, $temp, FILE_APPEND);
+    }
+
 }
 }

+ 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\Chapter;
 use App\Modules\Book\Models\Book;
 use App\Modules\Book\Models\Book;
 use App\Modules\Book\Models\BookConfig;
 use App\Modules\Book\Models\BookConfig;
+use App\Modules\YunQi\Services\BookYunqiService;
 use Illuminate\Console\Command;
 use Illuminate\Console\Command;
 use GuzzleHttp\Client;
 use GuzzleHttp\Client;
 use GuzzleHttp\Psr7\Request;
 use GuzzleHttp\Psr7\Request;
@@ -96,26 +97,22 @@ class YqBook extends Command
             'cover'=>$book_info['cover'],
             'cover'=>$book_info['cover'],
             'keyword'=>$book_info['keyword'],
             'keyword'=>$book_info['keyword'],
             'chapter_count'=>$book_info['chapter_count'],
             'chapter_count'=>$book_info['chapter_count'],
+            'category_name'=>$book_info['category_name'],
+            'status'=>$book_info['status'],
             'size'=>$book_info['size']
             'size'=>$book_info['size']
         ]);
         ]);
         BookConfig::create([
         BookConfig::create([
             'bid'=>$book->id,
             'bid'=>$book->id,
             'force_subscribe_chapter_seq'=>10,
             'force_subscribe_chapter_seq'=>10,
             'price'=>8.99,
             'price'=>8.99,
-            'cover'=>$book_info['book_name'],
+            'book_name'=>$book_info['book_name'],
+            'cover'=>$book_info['cover'],
             'promotion_domain'=>'iycdm.com',
             'promotion_domain'=>'iycdm.com',
             'charge_type'=>isset($book_info['charge_type'])?$book_info['charge_type']:'CHAPTER',
             'charge_type'=>isset($book_info['charge_type'])?$book_info['charge_type']:'CHAPTER',
             'is_on_shelf'=>10,
             'is_on_shelf'=>10,
             'cp_source'=>'yunqi',
             '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;
         return $book;
     }
     }
 
 

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

@@ -2,6 +2,7 @@
 
 
 namespace App\Http\Controllers\Wap\Book;
 namespace App\Http\Controllers\Wap\Book;
 
 
+use App\Console\Commands\YqBook;
 use App\Modules\Book\Models\DataAnalysisBookConfig;
 use App\Modules\Book\Models\DataAnalysisBookConfig;
 use App\Modules\Book\Services\BookService;
 use App\Modules\Book\Services\BookService;
 use App\Modules\Book\Services\ChapterCommentsService;
 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\DataAnalysisSelectUserService;
 use App\Modules\Statistic\Services\WapVisitStatService;
 use App\Modules\Statistic\Services\WapVisitStatService;
 use App\Modules\Subscribe\Services\OrderService;
 use App\Modules\Subscribe\Services\OrderService;
+use App\Modules\YunQi\Services\BookUserService;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Wap\BaseController;
 use App\Http\Controllers\Wap\BaseController;
 use Cookie;
 use Cookie;
@@ -345,6 +347,10 @@ class ChapterController extends BaseController
         //用户是否强关
         //用户是否强关
         $this->is_had_subscribe = $is_had_subscribe = $inter_not_need_sub ? true : $this->getSubscribe();
         $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、已经关注 跳转到服务号信息引导页
         //判断当前是否有强制显示服务号信息的cookie、已经关注 跳转到服务号信息引导页
         if(Cookie::get('force_show_qrcode') && $is_had_subscribe)
         if(Cookie::get('force_show_qrcode') && $is_had_subscribe)
         {
         {
@@ -364,9 +370,6 @@ class ChapterController extends BaseController
             //vip前一张和枪管前一张的访问统计
             //vip前一张和枪管前一张的访问统计
             $this->beforeForceSubAndBeforeVipUvAndPv($book_info, $subscribe_seq, $chapter);
             $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章节
         //不用关注且不是vip章节
         if ($force_subscribe && $chapter->is_vip == 0) {
         if ($force_subscribe && $chapter->is_vip == 0) {
@@ -1231,6 +1234,16 @@ class ChapterController extends BaseController
             $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $book_info->bid);
             $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $book_info->bid);
             if (!$chapter_order) return true;
             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;
         return false;
     }
     }
 
 
@@ -1527,6 +1540,10 @@ class ChapterController extends BaseController
     }
     }
     //阅读页面底部是否显示广告
     //阅读页面底部是否显示广告
     private function isShowAd(){
     private function isShowAd(){
+        $ad_status = env('AD_STATUS',1);
+        if(!$ad_status){
+            return ;
+        }
         if(!in_array($this->distribution_channel_id,[2,14,123,211])){
         if(!in_array($this->distribution_channel_id,[2,14,123,211])){
             return ;
             return ;
         }
         }

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

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

+ 6 - 1
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -85,7 +85,11 @@ class WelcomeController extends BaseController
         //最近阅读页面 推荐
         //最近阅读页面 推荐
         $latest_read_rec_books = $this->latest_read_rec_books($channel,$user->sex);
         $latest_read_rec_books = $this->latest_read_rec_books($channel,$user->sex);
         //广告样本
         //广告样本
-        $adTargetId = $this->isUserInAdSample();
+        $ad_status = env('AD_STATUS',1);
+        $adTargetId = false;
+        if($ad_status){
+            $adTargetId = $this->isUserInAdSample();
+        }
         //广告frame
         //广告frame
         $is_show_ad_frame_setting = env('IS_SHOW_AD_FRAME_SETTING','123');
         $is_show_ad_frame_setting = env('IS_SHOW_AD_FRAME_SETTING','123');
         $is_show_ad_frame = false;
         $is_show_ad_frame = false;
@@ -100,6 +104,7 @@ class WelcomeController extends BaseController
         }
         }
         $hide_chapter_channels = explode(',',env('HIDE_CHAPTER_CONSUME_CHANNEL'));
         $hide_chapter_channels = explode(',',env('HIDE_CHAPTER_CONSUME_CHANNEL'));
         $is_hide_chapter_consume = in_array($this->distribution_channel_id,$hide_chapter_channels) ? 1 : 0;
         $is_hide_chapter_consume = in_array($this->distribution_channel_id,$hide_chapter_channels) ? 1 : 0;
+        //广告
 
 
         $options = json_encode([
         $options = json_encode([
             'distribution_channel_id' => (int)$this->distribution_channel_id,
             'distribution_channel_id' => (int)$this->distribution_channel_id,

File diff ditekan karena terlalu besar
+ 515 - 248
app/Http/Middleware/ReadOauth.php


+ 9 - 1
app/Libs/Helpers.php

@@ -457,6 +457,14 @@ function specialChannelAuthInfoV2(){
         '4568'=>'wx4cfa12302780e654',
         '4568'=>'wx4cfa12302780e654',
         '4569'=>'wxa25b19c509ba7db5',
         '4569'=>'wxa25b19c509ba7db5',
         '4578'=>'wx3beda81dba0b450b',
         '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());
         Redis::hset('book_read:' . $uid, $bid, "{$cid}_" . time());
         Redis::hset('book_read:' . $uid, $bid, "{$cid}_" . time());
     }
     }
-
+    
     /**
     /**
      * 删除
      * 删除
      * @param $uid
      * @param $uid
@@ -330,8 +330,8 @@ class ReadRecordService
             return $res;
             return $res;
         }
         }
         foreach ($read_bids as $key => $v) {
         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);
             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();
+    }
+}

+ 5 - 5
resources/views/wap/index.blade.php

@@ -9,7 +9,7 @@
     <script src="https://cdn-novel.iycdm.com/static/vue-router.min.js"></script>
     <script src="https://cdn-novel.iycdm.com/static/vue-router.min.js"></script>
     <script src="https://cdn-novel.iycdm.com/static/vue-lazyload.js"></script>
     <script src="https://cdn-novel.iycdm.com/static/vue-lazyload.js"></script>
     <title>{{$title}}</title>
     <title>{{$title}}</title>
-    <link href=https://cdn-novel.iycdm.com/static2019-1-15/css/app.5dc8b154836ba1b208cc3f1235ab4202.css rel=stylesheet>
+    <link href=https://cdn-novel.iycdm.com/static2019-1-17/css/app.50f9955d9118487757d6342a5d9eca7d.css rel=stylesheet>
 </head>
 </head>
 <body>
 <body>
 <div id=app></div>
 <div id=app></div>
@@ -32,9 +32,9 @@
     })();</script>
     })();</script>
 <script>window.options = {!! $options!!};</script>
 <script>window.options = {!! $options!!};</script>
 <script type=text/javascript
 <script type=text/javascript
-        src=https://cdn-novel.iycdm.com/static2019-1-15/js/manifest.c84eae1a4e83da40997f.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-1-15/js/vendor.ef6f589527f41af98f5c.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-1-15/js/app.cecb5465118889c276e2.js></script>
+        src=https://cdn-novel.iycdm.com/static2019-1-17/js/manifest.73b31d9e526603714e07.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-1-17/js/vendor.ef6f589527f41af98f5c.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-1-17/js/app.bab37d2bd6fb05bf3a89.js></script>
 </body>
 </body>
-<script src=//cdn.ipadview.com/jssdk/combo.bundle.js></script>
+<script src=//cdn.ipadview.com/jssdk/combo.bundle.js?v=1.3></script>
 </html>
 </html>