Browse Source

qapp chapter order remind

zz 3 years ago
parent
commit
c69708c26d

+ 30 - 3
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -131,6 +131,8 @@ class ChapterController extends BaseController
         if (empty($book_info))
             return response()->error('QAPP_SYS_ERROR');
 
+        $this->book_info = $book_info;
+
         //yuyuedu、xinghe  快应用这两个cp的书屏蔽下
         if(in_array($book_info->cp_source,['yuyuedu','xinghe','dingtian','dingtian3'])){
             return response()->error('QAPP_SYS_ERROR');
@@ -279,9 +281,9 @@ class ChapterController extends BaseController
         if(!$this->send_order_id){
             if($book_info->charge_type == 'BOOK'){
                 return response()->error('QAPP_BOOK_BUY', $data);
-            }else{
+            }/*else{
                 return response()->error('QAPP_CHAPTER_BUY', $data);
-            }
+            }*/
         }
 
         //付费 不提醒
@@ -331,7 +333,7 @@ class ChapterController extends BaseController
         $bid       = BookService::decodeBidStatic($bid);
         $book_info = BookConfigService::getBookById($bid);;
         if (empty($book_info)) response()->error('QAPP_SYS_ERROR');
-
+        $this->book_info = $book_info;
         if($this->distribution_channel_id == 7477 && $bid == 13765){
             $book_info->is_on_shelf = 2;
         }
@@ -473,9 +475,34 @@ class ChapterController extends BaseController
         $chapter->force_add_desk_type = $force_add_desk_type;
         //统计
         $this->stats();
+        $next_chapter_order_status = $this->nextChapterOrderStatus($bid,$chapter->next_cid);
+        $chapter->next_is_paid = $next_chapter_order_status['next_is_paid'];
+        $chapter->next_price = $next_chapter_order_status['next_price'];
+        $chapter->charge_type = $this->book_info->charge_type;
         $this->userBookCombination($chapter);
         return $chapter;
     }
+
+
+    private function nextChapterOrderStatus($bid,$cid){
+        $is_paid = $this->getOrderRecord($bid,$cid);
+        $result = ['next_is_paid'=>0,'next_price'=>0];
+        if(!$is_paid){
+            $chapter = ChapterService::getChapterNameById($cid, $bid);
+            if($chapter->is_vip == 0){
+                $result['next_is_paid'] = 1;
+                return $result;
+            }
+            if($chapter){
+                $fee  = $this->getPrice($this->book_info, $chapter->size);
+                $result['next_price'] = $fee;
+            }
+        }else{
+            $result['next_is_paid'] = 1;
+        }
+        return $result;
+    }
+
     //短续长
     private function userBookCombination($chapter){
         if($chapter->prev_cid && $chapter->next_cid){

+ 4 - 1
app/Http/Controllers/QuickApp/Book/Transformers/ChapterTransformer.php

@@ -18,7 +18,10 @@ class ChapterTransformer
             'recent_update_at'   =>  $chapter->recent_update_at,
             'chapter_content'   =>  $chapter->content,
             'sign_status'   =>  $chapter->sign_status,
-            'force_add_desk_type'   =>  $chapter->force_add_desk_type
+            'force_add_desk_type'   =>  $chapter->force_add_desk_type,
+            'next_is_paid'   =>  $chapter->next_is_paid,
+            'next_price'   =>  $chapter->next_price,
+            'charge_type'   =>  $chapter->charge_type
         ];
     }
 }