Explorar el Código

Merge branch 'master' of iqiyoo:zhuishuyun_wap into zhoulj

onlinetest hace 6 años
padre
commit
232c8b20fa

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

@@ -30,6 +30,8 @@ class BookAfterSpider extends Command
      *
      *
      * @return void
      * @return void
      */
      */
+     private $update_info = [];
+
     public function __construct()
     public function __construct()
     {
     {
         parent::__construct();
         parent::__construct();
@@ -54,12 +56,13 @@ class BookAfterSpider extends Command
                 $this->starts($value);
                 $this->starts($value);
             }
             }
         }
         }
+        $this->recordUpdateInfo();
     }
     }
 
 
     private function starts($bid)
     private function starts($bid)
     {
     {
-        $this->bookChapterInfo($bid);
         $this->addbookConfig($bid);
         $this->addbookConfig($bid);
+        $this->bookChapterInfo($bid);
         $this->adjustSequentOne($bid);
         $this->adjustSequentOne($bid);
     }
     }
 
 
@@ -98,6 +101,11 @@ class BookAfterSpider extends Command
             if ($vip && isset($vip->sequence)) {
             if ($vip && isset($vip->sequence)) {
                 $vip_seq = $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([
             DB::table('book_configs')->insert([
                 'bid' => $bid,
                 'bid' => $bid,
                 'force_subscribe_chapter_seq' => 10,
                 'force_subscribe_chapter_seq' => 10,
@@ -123,6 +131,10 @@ class BookAfterSpider extends Command
         $res3 = DB::table('chapters')->where('bid', $bid)->count();
         $res3 = DB::table('chapters')->where('bid', $bid)->count();
 
 
         $res4 = DB::table('chapters')->where('bid', $bid)->sum('size');
         $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(
         DB::table('books')->where('id', $bid)->update(
             [
             [
                 'chapter_count' => $res3,
                 'chapter_count' => $res3,
@@ -161,4 +173,26 @@ class BookAfterSpider extends Command
             $prev = $chapter->id;
             $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\Models\Chapter;
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Book\Services\BookConfigService;
+use DB;
+
 class BookUpdateOne extends Command
 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 = $this->client->get(sprintf($chapter_list_fromat,$book_info->ly_bid));
         $res = $res->getBody()->getContents();
         $res = $res->getBody()->getContents();
         if(!$res) return '';
         if(!$res) return '';
+        $book_config_info = DB::table('book_configs')->where('bid',$bid)->first();
         $res = json_decode($res,true);
         $res = json_decode($res,true);
         $j = 0;
         $j = 0;
+        $size = 0;
         $local_count = Chapter::where('bid',$bid)->count();
         $local_count = Chapter::where('bid',$bid)->count();
         $remote_count = 0;
         $remote_count = 0;
 
 
@@ -119,6 +123,7 @@ class BookUpdateOne extends Command
                     $cahpter_content = json_decode($cahpter_content, true);
                     $cahpter_content = json_decode($cahpter_content, true);
                     $temp['size'] = ceil(strlen($cahpter_content['data']['chapter_content']) / 3);
                     $temp['size'] = ceil(strlen($cahpter_content['data']['chapter_content']) / 3);
                     $temp['content'] = $cahpter_content['data']['chapter_content'];
                     $temp['content'] = $cahpter_content['data']['chapter_content'];
+                    $size += $temp['size'];
                 }
                 }
                 $insert_res = Chapter::create($temp);
                 $insert_res = Chapter::create($temp);
                 Chapter::where('id', $max_sequence_chapter_id)->update(['next_cid' => $insert_res->id]);
                 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');
         $chapter_size = Chapter::where('bid',$bid)->sum('size');
         if($j>0){
         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']]);
             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;
         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)
     public function getCatalog(Request $request, $t, $domain, $bid)
     {
     {
+        if (!$this->checkUid()) {
+            return response()->error('WAP_NOT_LOGIN');
+        }
         $this->en_bid = $bid;
         $this->en_bid = $bid;
         $bid = Hashids::decode($bid)[0];
         $bid = Hashids::decode($bid)[0];
         $lists = ChapterService::getChapterLists($bid);
         $lists = ChapterService::getChapterLists($bid);
@@ -229,6 +232,9 @@ class ChapterController extends BaseController
      */
      */
     public function getCatalogPerPage(Request $request, $t, $domain, $bid)
     public function getCatalogPerPage(Request $request, $t, $domain, $bid)
     {
     {
+        if (!$this->checkUid()) {
+            return response()->error('WAP_NOT_LOGIN');
+        }
         $this->en_bid = $bid;
         $this->en_bid = $bid;
 
 
         $bid_array = Hashids::decode($bid);
         $bid_array = Hashids::decode($bid);
@@ -244,7 +250,7 @@ class ChapterController extends BaseController
         }
         }
         $this->book_info = $book_info;
         $this->book_info = $book_info;
         $page_size = $request->input('page_size', 15);
         $page_size = $request->input('page_size', 15);
-
+        if($page_size>=100) $page_size=100;
         $res = ChapterService::getChapterListsPage($bid, $page_size);
         $res = ChapterService::getChapterListsPage($bid, $page_size);
         $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
         $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
         foreach ($res as $v) {
         foreach ($res as $v) {

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

@@ -1482,9 +1482,9 @@ class OrdersController extends Controller
 
 
     private function payAlert($pay_merchant_id, $trade_no = '', $pay_info = '', $n = 0)
     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 {
         try {
             $time = (int)date('G');
             $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){
     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){
     public function getCoupons(Request $request){

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

@@ -1018,4 +1018,8 @@ class ReadOauth
         }
         }
         return $area;
         return $area;
     }
     }
+
+    private function yun(Request $request,$uid){
+
+    }
 }
 }

+ 24 - 3
app/Libs/Helpers.php

@@ -202,7 +202,27 @@ function collectionTransform($trans, $data){
     return $ret_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){
 function ImageNewsToArray($datas){
     if(empty($datas)) return null;
     if(empty($datas)) return null;
     if(!is_array($datas)){
     if(!is_array($datas)){
@@ -223,7 +243,7 @@ function ImageNewsToArray($datas){
  * 加密site id
  * 加密site id
  */
  */
 function encodeDistributionChannelId($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])){
     if(isset($encrypt_pool[$id])){
         return $encrypt_pool[$id];
         return $encrypt_pool[$id];
     }
     }
@@ -244,7 +264,7 @@ function encodeDistributionChannelId($id){
  * 解密密site id
  * 解密密site id
  */
  */
 function decodeDistributionChannelId($code){
 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])){
     if(isset($encrypt_pool[$code])){
         return $encrypt_pool[$code];
         return $encrypt_pool[$code];
     }
     }
@@ -515,6 +535,7 @@ function specialChannelAuthInfoV2(){
         '4909'=>'wx2c62f7f4a02176d7',
         '4909'=>'wx2c62f7f4a02176d7',
         '4910'=>'wx7ee2ad6685e3d5b3',
         '4910'=>'wx7ee2ad6685e3d5b3',
         '4820'=>'wx30ecb35d13959f8d',
         '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);
     	$user = User::getById($uid);
     	$distribution_channel_id = isset($user->distribution_channel_id)?$user->distribution_channel_id:'';
     	$distribution_channel_id = isset($user->distribution_channel_id)?$user->distribution_channel_id:'';
-    	// 男频强制推广男频书
+    	// 男频强制推广男频书
     	$channel_sex = ChannelService::getChannelCompanySex($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);
 	    	$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 = [];
     	$bids = [];
     	$random_recommend = true;
     	$random_recommend = true;
@@ -713,6 +713,14 @@ class BookConfig extends Model
      * 获取随机的推荐书籍bid
      * 获取随机的推荐书籍bid
      */
      */
     public static function  getRandomRecommendBooks($channel_name, $num){
     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')
 	    $bids = self::join('books', 'book_configs.bid', '=', 'books.id')
 	    ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
 	    ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
 	    ->select('book_configs.bid')
 	    ->select('book_configs.bid')
@@ -723,6 +731,9 @@ class BookConfig extends Model
 	    ->inRandomOrder()
 	    ->inRandomOrder()
 	    ->limit($num)
 	    ->limit($num)
 	    ->get()->pluck('bid')->all();
 	    ->get()->pluck('bid')->all();
+        if($bids){
+            Redis::setex($redis_key,7200,implode(',',$bids));
+        }
 	    return $bids;
 	    return $bids;
     }
     }
 
 

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

@@ -45,7 +45,7 @@ class ForceSubscribeUsers extends Model
     static function forceSubscribeUsersByUid($uid)
     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){
     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();
     }
     }
 }
 }