wangzq 2 vuotta sitten
vanhempi
commit
44a6edc7ba
1 muutettua tiedostoa jossa 79 lisäystä ja 0 poistoa
  1. 79 0
      app/Http/Controllers/QuickApp/Book/ChapterController.php

+ 79 - 0
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -56,6 +56,7 @@ class ChapterController extends BaseController
         if ($page_size >= 100) $page_size = 100;
         $page_size  = 15;
         $res   = ChapterService::getChapterListsPage($bid, $page_size);
+
         $lists = $this->getChapterCatalog($bid, $res, $book_info);
 
         return response()->pagination(new ChapterListTransformer, $lists);
@@ -140,6 +141,84 @@ class ChapterController extends BaseController
         return $chapters;
     }
 
+    private function getChapterCatalogOld(int $bid, $chapters, $book_info)
+    {
+        // 查询书籍是否限免
+        $isFree = BookConfigService::judgeBookIsFree($bid);
+
+        //渠道自定义vip章节
+        //$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
+        $vip_sequence = BookService::getVipSequence($bid,$this->distribution_channel_id,$this->send_order_id);
+        list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
+        $change_chapter_name = 0;
+        if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
+            $change_chapter_name = 1;
+        }
+        switch ($book_info->charge_type) {
+            case 'BOOK':
+                $price          = $this->getPrice($book_info);
+                $is_need_charge = $this->isBookNeedCharge($bid, $price);
+                foreach ($chapters as $v) {
+                    $v->next_chapter_status = 0;
+                    $v->next_price = 0;
+                    $v->is_need_charge = $v->is_vip ? $is_need_charge : false;
+                    $v->price          = $price;
+
+                    // 限免判断
+                    if ($isFree) {
+                        $v->is_need_charge = false;
+                        $v->price          = 0;
+                    }
+                    if($vip_sequence){
+                        if($v->sequence >= $vip_sequence){
+                            $v->is_vip = 1;
+                        }else{
+                            $v->is_vip = 0;
+                        }
+                    }
+                    //拆章
+                    if($change_chapter_name){
+                        $v->name = '第'.$v->sequence.'章';
+                    }
+                }
+                break;
+            default:
+                foreach ($chapters as $v) {
+                    if($vip_sequence){
+                        if($v->sequence >= $vip_sequence){
+                            $v->is_vip = 1;
+                        }else{
+                            $v->is_vip = 0;
+                        }
+                    }
+
+                    // 限免判断
+                    if ($isFree) {
+                        $v->is_need_charge = false;
+                        $v->price          = 0;
+                    } else {
+                        $v->price          = $v->is_vip ? $this->getPrice($book_info, $v->size) : 0;
+                        $v->is_need_charge = $v->is_vip ? $this->isChapterNeedCharge($bid, $v->id, $v->price) : false;
+                    }
+                    //下一章付费信息
+                    $v->next_chapter_status = 0;
+                    $v->next_price = 0;
+                    if($v->is_vip){
+                        $next_chapter_order_status = $this->nextChapterOrderStatus($bid,$v->next_cid);
+                        $v->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
+                        $v->next_price = $next_chapter_order_status['next_price'];
+                    }
+
+                    //拆章
+                    if($change_chapter_name){
+                        $v->name = '第'.$v->sequence.'章';
+                    }
+                }
+                break;
+        }
+        return $chapters;
+    }
+
     public function index(Request $request, $bid, $cid)
     {
         $send_order_id   = $request->header('send_order_id', '');