Преглед изворни кода

Merge branch 'stabble' of iqiyoo:zhuishuyun_wap

onlinetest пре 6 година
родитељ
комит
f184bbbfdb

+ 37 - 30
app/Console/Commands/BookTest.php

@@ -317,18 +317,24 @@ class BookTest extends Command
     }
 
     private function you2(){
+        $sql1 = 'TRUNCATE yq_stats';
+        DB::update($sql1);
         $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();
+        $info = BookUser::where('type','ENABLE')->select('bid','uid','type','updated_at')
+            ->orderBy('updated_at')->limit(1000)->get();
+        $info2 = BookUser::where('type','GROUP_1')
+            ->select('bid','uid','type','updated_at')->orderBy('updated_at')->limit(1000)->get();
         foreach ($info as $item){
             $bid_price = Order::where('uid',$item->uid)
                 ->where('status','PAID')
                 ->where('created_at','>=',$item->updated_at)
+                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
                 ->where('from_bid',$item->bid)
                 ->sum('price');
             $all_price = Order::where('uid',$item->uid)
                 ->where('status','PAID')
                 ->where('created_at','>=',$item->updated_at)
+                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
                 ->sum('price');
             $chapter_model = new ChapterOrder();
             $chapter_model->setCurrentTable($item->uid);
@@ -339,26 +345,37 @@ class BookTest extends Command
             $all_fee = $chapter_model->where('uid', $item->uid)
                 ->where('created_at','>=',$item->updated_at)
                 ->sum('fee');
+            $books = DB::table('book_configs')->where('bid',$item->bid)->select('book_name')->first();
+            if($books){
+                $book_name = $books->book_name;
+            }else{
+                $book_name = 'un';
+            }
             $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
+                'total_amount'=>$all_price?$all_price:0,
+                'total_fee'=>$all_fee?$all_fee:0,
+                'book_name'=>$book_name
             ];
         }
+        DB::table('yq_stats')->insert($result);
+        $result = [];
         $item = null;
         foreach ($info2 as $item){
             $all_price = Order::where('uid',$item->uid)
                 ->where('status','PAID')
                 ->where('created_at','>=',$item->updated_at)
+                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
                 ->sum('price');
             $chapter_model = new ChapterOrder();
             $chapter_model->setCurrentTable($item->uid);
             $all = $chapter_model->where('uid', $item->uid)
                 ->where('created_at','>=',$item->updated_at)
+                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
                 ->groupBy('bid')
                 ->select(DB::raw('sum(fee) as fee'),'bid','book_name')
                 ->orderBy('fee','desc')
@@ -371,39 +388,29 @@ class BookTest extends Command
                 $bid = $all->bid;
                 $book_name = $all->book_name;
             }
+            $bid_price = Order::where('uid',$item->uid)
+                ->where('status','PAID')
+                ->where('created_at','>=',$item->updated_at)
+                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
+                ->where('from_bid',$bid)
+                ->sum('price');
+            $chapter_fee = $chapter_model->where('uid', $item->uid)
+                ->where('bid', $bid)
+                ->where('created_at','>=',$item->updated_at)
+                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
+                ->sum('fee');
             $result[] = [
                 'uid'=>$item->uid,
                 'type'=>$item->type,
-                'amount'=>0,
-                'fee'=>0,
+                'amount'=>$bid_price?$bid_price:0,
+                'fee'=>$chapter_fee,
                 'bid'=>$bid,
-                'all_price'=>$all_price?$all_price:0,
-                'all_fee'=>$all_fee?$all_fee:0,
+                'total_amount'=>$all_price?$all_price:0,
+                'total_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);
+        DB::table('yq_stats')->insert($result);
     }
 
 }

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

@@ -301,6 +301,8 @@ class ChapterController extends BaseController
         $inter_not_need_sub = $request->has('inter_not_need_sub') ? true : false;
 
         $ad_status = $request->get('ad_status');
+        $has_force_show_qrcode_cookie = Cookie::get('force_show_qrcode');
+        Cookie::queue('force_show_qrcode', 1, -1);
 
         if (!$this->checkUid()) {
             return response()->error('WAP_NOT_LOGIN');
@@ -352,7 +354,7 @@ class ChapterController extends BaseController
             'cid' => $cid, 'chapter_name' => $chapter->name]);
 
         //判断当前是否有强制显示服务号信息的cookie、已经关注 跳转到服务号信息引导页
-        if(Cookie::get('force_show_qrcode') && $is_had_subscribe)
+        if($has_force_show_qrcode_cookie && $is_had_subscribe)
         {
             $force_read_url = '/subscribe/getFromUser';//服务号信息引导页
             $force_read_data = ['src' => $force_read_url];

+ 4 - 4
app/Modules/YunQi/Services/BookUserService.php

@@ -23,9 +23,9 @@ class BookUserService
 
 
     public static function popUser($uid){
-        try{
+        /*try{
             Redis::srem('YQ_USER_TEST_BOOK:USER',$uid);
-        }catch (\Exception $e){}
+        }catch (\Exception $e){}*/
     }
 
     public static function isUserInRedis($uid){
@@ -38,9 +38,9 @@ class BookUserService
      * @return bool
      */
     public static function selectUser($uid){
-        if(!self::isUserInRedis($uid)){
+        /*if(!self::isUserInRedis($uid)){
             return null;
-        }
+        }*/
         $user = self::getByUid($uid);
         return $user;
     }