Bläddra i källkod

Merge branch 'kuaiyingyong' into quickapp_fly

fly 4 år sedan
förälder
incheckning
24da6162f8

+ 1 - 1
app/Exceptions/Handler.php

@@ -36,7 +36,7 @@ class Handler extends ExceptionHandler
     public function report(Exception $e)
     {
         $appEnv = env('APP_ENV', 'production');
-        if ($this->shouldReport($e) && env('APP_ENV') !== 'local') {
+        if ($this->shouldReport($e) && env('APP_ENV') == 'production') {
             $date        = date('Y-m-d H:i:s');
             $file        = $e->getFile();
             $line        = $e->getLine();

+ 27 - 2
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -127,8 +127,33 @@ class ChapterController extends BaseController
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
 
-        //已经付费 或者 书籍是否限免
-        if ($this->getOrderRecord($bid, $cid) || BookConfigService::judgeBookIsFree($bid)) {
+        // 书籍是否限免
+        $free = BookConfigService::judgeBookIsFree($bid);
+        if ($free) {
+            ReadRecordService::addReadLog($this->uid, [
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'bid' => $bid,
+                'cid' => $chapter->id,
+                'uid' => $this->uid,
+                'send_order_id' => $this->send_order_id,
+                'sequence' => $chapter->sequence,
+            ]);
+            ReadRecordService::addReadRecord([
+                'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
+                'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
+            ]);
+            if ($chapter->is_vip == 1) {
+                $fee  = $this->getPrice($book_info, $chapter->size);
+                $now = date('Y-m-d');
+                Redis::hincrby('qapp:book:free:virtual:' . $free->id, $now, $fee);
+                Redis::sadd('qapp:free:virtual' . $now, $free->id);
+            }
+            return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
+        }
+
+
+        //已经付费
+        if ($this->getOrderRecord($bid, $cid)) {
             ReadRecordService::addReadLog($this->uid, [
                 'distribution_channel_id' => $this->distribution_channel_id,
                 'bid' => $bid,

+ 6 - 0
app/Http/Controllers/QuickApp/User/UserShelfBooksController.php

@@ -37,6 +37,12 @@ class UserShelfBooksController extends BaseController
                     break;
                 }
             }
+
+            //补充逻辑 书架有、阅读记录没有场景
+            if(!isset($v['recent_cid']))
+            {
+                $v['recent_cid']             = $v['first_cid'];
+            }
         }
         return response()->collection(new UserShelfBooksTransformer(), $res);
     }

+ 1 - 1
app/Http/Controllers/QuickApp/WelcomeController.php

@@ -35,7 +35,7 @@ class WelcomeController extends BaseController
             }
             if ($send_order && $qappPackage) {
                 $this->sendOrderStatistic($send_order);//统计
-                return view('qapp.welcome')->with([
+                return view('qapp.start')->with([
                     'package'       => $qappPackage->package,
                     'hash_bid'      => Hashids::encode($send_order->book_id),
                     'cid'           => $send_order->chapter_id,

+ 18 - 1
app/Modules/Book/Services/BookConfigService.php

@@ -530,6 +530,23 @@ class BookConfigService
         }
         return FreeBook::where('bid', $bid)
             ->whereIn('config_id', $ids)
-            ->where('is_enabled', 1)->exists();
+            ->where('is_enabled', 1)->select('id')->first();
+    }
+
+
+    public static function getByBidNoFilter($bid){
+        return   FreeBook::join('free_book_config','free_book_config.id','=','free_books.config_id')
+            ->where('bid',$bid)
+            ->select('free_books.id','end_time')
+            ->where('end_time','<',date('Y-m-d H:i:s'))
+            ->orderBy('free_book_config.end_time','desc')
+            ->first();
+    }
+
+    public static function chargeStats($id,$amount){
+        $now = date('Y-m-d');
+        $amount = $amount*100;
+        Redis::hincrby('qapp:book:free:charge:'.$id,$now,$amount);
+        Redis::sadd('qapp:free:charge'.$now,$id);
     }
 }

+ 10 - 0
app/Modules/Trade/Pay/OrderPaySuccess.php

@@ -2,6 +2,7 @@
 
 namespace App\Modules\Trade\Pay;
 
+use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Subscribe\Models\Order;
 use DB;
 
@@ -44,6 +45,7 @@ class OrderPaySuccess
                     'created_at' => date('Y-m-d H:i:s')
                 ]);
             }
+            self::freeBookStats($order->from_bid,$order->price);
             return $status;
         } else {
             return false;
@@ -51,6 +53,14 @@ class OrderPaySuccess
     }
 
 
+    private static function freeBookStats($bid,$price){
+        if(!$bid) return ;
+        $free_book = BookConfigService::getByBidNoFilter($bid);
+        if(!$free_book) return ;
+        if(strtotime($free_book->end_time)+14*86400 < time())   return ;
+        BookConfigService::chargeStats($free_book->id,$price);
+    }
+
     private static function orderAcrossDay($order_info)
     {
         if (date('Y-m-d', strtotime($order_info->created_at)) == date('Y-m-d')) return false;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 403 - 0
resources/views/qapp/start.blade.php