Browse Source

Merge branch 'stabble' of iqiyoo:zhuishuyun_wap into stabble

onlinetest 6 years ago
parent
commit
eadf8670ce

+ 35 - 1
app/Console/Commands/BookAfterSpider.php

@@ -30,6 +30,8 @@ class BookAfterSpider extends Command
      *
      * @return void
      */
+     private $update_info = [];
+
     public function __construct()
     {
         parent::__construct();
@@ -54,12 +56,13 @@ class BookAfterSpider extends Command
                 $this->starts($value);
             }
         }
+        $this->recordUpdateInfo();
     }
 
     private function starts($bid)
     {
-        $this->bookChapterInfo($bid);
         $this->addbookConfig($bid);
+        $this->bookChapterInfo($bid);
         $this->adjustSequentOne($bid);
     }
 
@@ -98,6 +101,11 @@ class BookAfterSpider extends Command
             if ($vip && isset($vip->sequence)) {
                 $vip_seq = $vip->sequence;
             }
+            $this->update_info[$bid] = [];
+            $this->update_info[$bid]['add'] = true;
+            $this->update_info[$bid]['channel_name'] = $book_info->category_id >=13 ? '女频':'男频';
+            $this->update_info[$bid]['update_type'] = 'add_book';
+            $this->update_info[$bid]['book_name'] = $book_info->name;
             DB::table('book_configs')->insert([
                 'bid' => $bid,
                 'force_subscribe_chapter_seq' => 10,
@@ -123,6 +131,10 @@ class BookAfterSpider extends Command
         $res3 = DB::table('chapters')->where('bid', $bid)->count();
 
         $res4 = DB::table('chapters')->where('bid', $bid)->sum('size');
+        if(isset($this->update_info[$bid])){
+            $this->update_info[$bid]['update_words'] = $res4;
+            $this->update_info[$bid]['update_chapter_count'] = $res3;
+        }
         DB::table('books')->where('id', $bid)->update(
             [
                 'chapter_count' => $res3,
@@ -161,4 +173,26 @@ class BookAfterSpider extends Command
             $prev = $chapter->id;
         }
     }
+
+    private function recordUpdateInfo()
+    {
+        if(!$this->update_info) {
+            return;
+        }
+        foreach ($this->update_info as $k=>$v){
+            if(!$v['add']) continue;
+            // 2 book_updates 的更新记录
+            DB::table('book_updates')->insert([
+                'bid' => $k,
+                'book_name' => $v['book_name'],
+                'channel_name' => $v['channel_name'],
+                'update_date' => date('Y-m-d'),
+                'update_chapter_count' => $v['update_chapter_count'],
+                'update_words' => $v['update_words'],
+                'update_type' => $v['update_type'],
+                'created_at' => date('Y-m-d H:i:s'),
+                'updated_at' => date('Y-m-d H:i:s')
+            ]);
+        }
+    }
 }

+ 28 - 0
app/Console/Commands/BookUpdateOne.php

@@ -8,6 +8,8 @@ use App\Modules\Book\Models\Book;
 use App\Modules\Book\Models\Chapter;
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\Book\Services\BookConfigService;
+use DB;
+
 class BookUpdateOne extends Command
 {
     /**
@@ -80,8 +82,10 @@ class BookUpdateOne extends Command
         $res = $this->client->get(sprintf($chapter_list_fromat,$book_info->ly_bid));
         $res = $res->getBody()->getContents();
         if(!$res) return '';
+        $book_config_info = DB::table('book_configs')->where('bid',$bid)->first();
         $res = json_decode($res,true);
         $j = 0;
+        $size = 0;
         $local_count = Chapter::where('bid',$bid)->count();
         $remote_count = 0;
 
@@ -119,6 +123,7 @@ class BookUpdateOne extends Command
                     $cahpter_content = json_decode($cahpter_content, true);
                     $temp['size'] = ceil(strlen($cahpter_content['data']['chapter_content']) / 3);
                     $temp['content'] = $cahpter_content['data']['chapter_content'];
+                    $size += $temp['size'];
                 }
                 $insert_res = Chapter::create($temp);
                 Chapter::where('id', $max_sequence_chapter_id)->update(['next_cid' => $insert_res->id]);
@@ -131,6 +136,13 @@ class BookUpdateOne extends Command
         $chapter_size = Chapter::where('bid',$bid)->sum('size');
         if($j>0){
             Book::where('id',$bid)->update(['chapter_count'=>$chapter_count,'last_cid'=>$max_sequence_chapter_id,'size'=>$chapter_size,'last_chapter'=>$v['chapter_name']]);
+            $this->recordUpdateInfo($bid,[
+                'book_name'=>$book_config_info->book_name,
+                'update_chapter_count'=>$j,
+                'update_words'=>$size,
+                'update_type'=>'add_chapter',
+                'channel_name'=>$book_info->category_id >=13 ? '女频':'男频'
+            ]);
         }
         return $j;
     }
@@ -195,4 +207,20 @@ class BookUpdateOne extends Command
             }
         }
     }
+
+    private function recordUpdateInfo($bid, $data)
+    {
+        // 2 book_updates 的更新记录
+        DB::table('book_updates')->insert([
+            'bid' => $bid,
+            'book_name' => $data['book_name'],
+            'channel_name' => $data['channel_name'],
+            'update_date' => date('Y-m-d'),
+            'update_chapter_count' => $data['update_chapter_count'],
+            'update_words' => $data['update_words'],
+            'update_type' => $data['update_type'],
+            'created_at' => date('Y-m-d H:i:s'),
+            'updated_at' => date('Y-m-d H:i:s')
+        ]);
+    }
 }

+ 7 - 1
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -135,6 +135,9 @@ class ChapterController extends BaseController
      */
     public function getCatalog(Request $request, $t, $domain, $bid)
     {
+        if (!$this->checkUid()) {
+            return response()->error('WAP_NOT_LOGIN');
+        }
         $this->en_bid = $bid;
         $bid = Hashids::decode($bid)[0];
         $lists = ChapterService::getChapterLists($bid);
@@ -229,6 +232,9 @@ class ChapterController extends BaseController
      */
     public function getCatalogPerPage(Request $request, $t, $domain, $bid)
     {
+        if (!$this->checkUid()) {
+            return response()->error('WAP_NOT_LOGIN');
+        }
         $this->en_bid = $bid;
 
         $bid_array = Hashids::decode($bid);
@@ -244,7 +250,7 @@ class ChapterController extends BaseController
         }
         $this->book_info = $book_info;
         $page_size = $request->input('page_size', 15);
-
+        if($page_size>=100) $page_size=100;
         $res = ChapterService::getChapterListsPage($bid, $page_size);
         $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
         foreach ($res as $v) {

+ 3 - 3
app/Http/Controllers/Wap/Pay/OrdersController.php

@@ -1462,9 +1462,9 @@ class OrdersController extends Controller
 
     private function payAlert($pay_merchant_id, $trade_no = '', $pay_info = '', $n = 0)
     {
-        $change_pay_id = 9;
-        if ($pay_merchant_id == 9) {
-            //$change_pay_id = 12;
+        $change_pay_id = 40;
+        if ($pay_merchant_id == 40) {
+            $change_pay_id = 9;
         }
         try {
             $time = (int)date('G');

+ 7 - 1
app/Http/Controllers/Wap/User/UserController.php

@@ -142,7 +142,13 @@ class UserController extends BaseController
      *   }
      */
     public function signRecord(Request $request){
-        return response()->pagination(new SignRecordTransformer(),UserSignService::getUserSignRecord($this->uid));
+        $sign_result = paginationTransform(new SignRecordTransformer(),UserSignService::getUserSignRecord($this->uid));
+        $sign_status = UserSignService::isSign($this->uid);
+        $result = [
+            'sign_status'=>$sign_status,
+            'sign_result'=>$sign_result
+        ];
+        return response()->success($result);
     }
 
     public function getCoupons(Request $request){

+ 65 - 0
app/Http/Middleware/ReadOauth.php

@@ -6,6 +6,8 @@ use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Channel\Models\YqMoveChannel;
 use App\Modules\Channel\Services\ChannelService;
 use App\Modules\OfficialAccount\Services\ForceSubscribeService;
+use App\Modules\SendOrder\Services\SendOrderService;
+use App\Modules\Statistic\Services\WapVisitStatService;
 use App\Modules\User\Models\YqMove;
 use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\UserService;
@@ -1018,4 +1020,67 @@ class ReadOauth
         }
         return $area;
     }
+
+    private function yun(Request $request,$uid,$distribution_channel_id){
+        $param = $request->get('yun');
+        if(!$param) return ;
+        $bid = $request->get('bid');
+        if($bid){
+            $bid_arr = Hashids::decode($bid);
+            isset($bid_arr[0]) && $bid = $bid_arr[0];
+            is_numeric($bid) && $this->specialChannelIdStats($param,$distribution_channel_id,$uid,$bid);
+        }
+        $key = date('Y-m-d');
+        Cookie::queue('send_order_id', $param, env('U_COOKIE_EXPIRE'), null, null, false, false);
+        $send_order_flag = Cookie::get('send_order_flag');
+        $send_orders = explode(',', $send_order_flag);
+        //uv
+        if (!Cookie::get('send_order_flag_' . $param) && !in_array($param, $send_orders)) {
+            Redis::hincrby('send_order_uv_' . $param, $key, 1);
+            Redis::hincrby('send_order_uv_' . $param, 'total', 1);
+            //Cookie::queue('send_order_flag_'.$param,$param, env('U_COOKIE_EXPIRE'), null, null, false, false);
+            array_push($send_orders, $param);
+            $str = implode(',', $send_orders);
+            Cookie::queue('send_order_flag', $str, env('U_COOKIE_EXPIRE'), null, null, false, false);
+        }
+
+        if (Cookie::get('send_order_flag_' . $param)) {
+            array_push($send_orders, $param);
+            $str = implode(',', $send_orders);
+            Cookie::queue('send_order_flag', $str, env('U_COOKIE_EXPIRE'), null, null, false, false);
+            Cookie::queue('send_order_flag_' . $param, null, -1);
+        }
+        //pv
+        Redis::hincrby('send_order_pv_' . $param, $key, 1);//每天
+        Redis::hincrby('send_order_pv_' . $param, 'total', 1);//汇总
+        Redis::sadd('send_order' . $key, $param);
+
+        $uv = Redis::hget('send_order_uv_' . $param, $key);
+
+        $uv && $uv>=20 && SendOrderService::updateSendOrderTime($param);
+    }
+
+    /**
+     * 用户从A连接推送的书,进入后,被标记bookid+派单id,之后所有的统计计算到该派单下
+     * @param int $send_order_id
+     * @param int $distribution_channel_id
+     * @param int $uid
+     * @param int $bid
+     */
+    private function specialChannelIdStats(
+        int $send_order_id,
+        int $distribution_channel_id,
+        int $uid,
+        int $bid
+    ):void{
+
+        if(!$bid || !$distribution_channel_id || !$uid || !$send_order_id)
+            return ;
+        $specialChannelIdStats = env('SPECIAL_CHANNEL_STATS',211);
+        if(!in_array($distribution_channel_id,explode(',',$specialChannelIdStats)) ){
+            return ;
+        }
+        WapVisitStatService::specialChannelIdStatsMarkUser($uid,$bid,$send_order_id);
+        return ;
+    }
 }

+ 24 - 3
app/Libs/Helpers.php

@@ -202,7 +202,27 @@ function collectionTransform($trans, $data){
     return $ret_data;
 }
 
+function paginationTransform ($trans, $paginator) {
+    $ret = [];
+    $ret['list'] = [];
+    if($paginator)
+    {
+        foreach ($paginator as $item)
+        {
+            $ret['list'][] = $trans->transform($item);
+        }
 
+        $ret['meta']= [
+            'total'=>(int)$paginator->total(),
+            'per_page'=>(int)$paginator->perPage(),
+            'current_page'=>(int)$paginator->currentPage(),
+            'last_page'=>(int)$paginator->lastPage(),
+            'next_page_url'=>(string)$paginator->nextPageUrl(),
+            'prev_page_url'=>(string)$paginator->previousPageUrl()
+        ];
+    }
+    return $ret;
+}
 function ImageNewsToArray($datas){
     if(empty($datas)) return null;
     if(!is_array($datas)){
@@ -223,7 +243,7 @@ function ImageNewsToArray($datas){
  * 加密site id
  */
 function encodeDistributionChannelId($id){
-    $encrypt_pool = ['14'=>'xyvz5MEXLL52Mzn4','13'=>'laosiji','4372'=>'qhyeyue','365'=>'vciam5tg71','384'=>'sdxisd'];
+    $encrypt_pool = ['14'=>'xyvz5mexll52mzn4','13'=>'laosiji','4372'=>'qhyeyue','365'=>'vciam5tg71','384'=>'sdxisd'];
     if(isset($encrypt_pool[$id])){
         return $encrypt_pool[$id];
     }
@@ -244,7 +264,7 @@ function encodeDistributionChannelId($id){
  * 解密密site id
  */
 function decodeDistributionChannelId($code){
-    $encrypt_pool = ['xyvz5MEXLL52Mzn4'=>'14','laosiji'=>'13','qhyeyue'=>'4372','vciam5tg71'=>'365'];
+    $encrypt_pool = ['xyvz5mexll52mzn4'=>'14','laosiji'=>'13','qhyeyue'=>'4372','vciam5tg71'=>'365','sdxisd'=>'384'];
     if(isset($encrypt_pool[$code])){
         return $encrypt_pool[$code];
     }
@@ -515,6 +535,7 @@ function specialChannelAuthInfoV2(){
         '4909'=>'wx2c62f7f4a02176d7',
         '4910'=>'wx7ee2ad6685e3d5b3',
         '4820'=>'wx30ecb35d13959f8d',
-        '4980'=>'wx002be80fb65d808e'
+        '4980'=>'wx002be80fb65d808e',
+        '5148'=>'wx8e9ff7a97fa67675'
     ];
 }

+ 19 - 8
app/Modules/Book/Models/BookConfig.php

@@ -670,17 +670,17 @@ class BookConfig extends Model
     	// 判断渠道男女频
     	$user = User::getById($uid);
     	$distribution_channel_id = isset($user->distribution_channel_id)?$user->distribution_channel_id:'';
-    	// 男频强制推广男频书
+    	// 男频强制推广男频书
     	$channel_sex = ChannelService::getChannelCompanySex($distribution_channel_id);
-    	$channel_name = '';
-    	if($channel_sex == 1){
-    		$channel_name = '男频';
-    	}else{
+    	$channel_name = '';
+    	if($channel_sex == 1){
+    		$channel_name = '男频';
+    	}else{
 	    	$sex = ForceSubscribeService::getSimpleSexByUid($uid);
-	    	$channel_name = $sex==1?'男频':'女频';
+	    	$channel_name = $sex==1?'男频':'女频';
     	}
-
-    	\Log::info('getH5RecommendBooks:pos:'.$pos.' uid:'.$uid.' num:'.$num.' channel_name:'.$channel_name.' channel_sex:'.$channel_sex.' distribution_channel_id:'.$distribution_channel_id);
+
+    	\Log::info('getH5RecommendBooks:pos:'.$pos.' uid:'.$uid.' num:'.$num.' channel_name:'.$channel_name.' channel_sex:'.$channel_sex.' distribution_channel_id:'.$distribution_channel_id);
     	
     	$bids = [];
     	$random_recommend = true;
@@ -713,6 +713,14 @@ class BookConfig extends Model
      * 获取随机的推荐书籍bid
      */
     public static function  getRandomRecommendBooks($channel_name, $num){
+        if($channel_name == '男频'){
+            $channel_name_replace = 'male';
+        }else{
+            $channel_name_replace = 'female';
+        }
+        $redis_key = sprintf('channel_name:%s:num:%s',$channel_name_replace,$num);
+        $cache = Redis::get($redis_key);
+        if($cache) return explode(',',$cache);
 	    $bids = self::join('books', 'book_configs.bid', '=', 'books.id')
 	    ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
 	    ->select('book_configs.bid')
@@ -723,6 +731,9 @@ class BookConfig extends Model
 	    ->inRandomOrder()
 	    ->limit($num)
 	    ->get()->pluck('bid')->all();
+        if($bids){
+            Redis::setex($redis_key,7200,implode(',',$bids));
+        }
 	    return $bids;
     }
 

+ 1 - 1
app/Modules/OfficialAccount/Models/ForceSubscribeUsers.php

@@ -45,7 +45,7 @@ class ForceSubscribeUsers extends Model
     static function forceSubscribeUsersByUid($uid)
     {
 
-        return self::where(['uid' => $uid, 'is_subscribed' => 1])->first();
+        return self::where(['uid' => $uid, 'is_subscribed' => 1])->orderBy('id','desc')->first();
 
     }
 

+ 1 - 1
app/Modules/User/Models/UserSign.php

@@ -34,6 +34,6 @@ class UserSign extends Model
      * 用户签到记录
      */
     public static function getUserSignRecord($uid){
-        return self::where('uid',$uid)->select('price','sign_time')->orderBy('sign_time','desc')->paginate();
+        return self::where('uid',$uid)->where('day','<',date('Y-m-d'))->select('price','sign_time')->orderBy('sign_time','desc')->paginate();
     }
 }

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

@@ -9,7 +9,7 @@
     <script>window.VueRouter || document.write('<script src="https://cdn-novel.iycdm.com/static/vue-router.min.js"><\/script>')</script>
     <script>(window.Vue && window.VueLazyload) || document.write('<script src="https://cdn-novel.iycdm.com/static/vue-lazyload.js"><\/script>')</script>
     <title>{{$title}}</title>
-    <link href=https://cdn-novel.iycdm.com/static2019-3-5/css/app.20d0e4ffe5003af6da68ba496073648b.css rel=stylesheet>
+    <link href=https://cdn-novel.iycdm.com/static2019-3-13/css/app.8265f802aa5560f22d807cbe63b3c559.css rel=stylesheet>
 </head>
 <body>
 <div id=app></div>
@@ -32,8 +32,8 @@
     })();</script>
 <script id=options>window.options = {!! $options!!};</script>
 <script type=text/javascript
-        src=https://cdn-novel.iycdm.com/static2019-3-5/js/manifest.a66f4944ad2ae01e4dcd.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-5/js/vendor.ffff3089fc2f18220e2f.js></script>
-<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-5/js/app.1c61a2726de943356a04.js></script>
+        src=https://cdn-novel.iycdm.com/static2019-3-13/js/manifest.2fdc8e991727729472cc.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-13/js/vendor.ffff3089fc2f18220e2f.js></script>
+<script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-3-13/js/app.0acccf6776c5cc9fd62a.js></script>
 </body>
 </html>