瀏覽代碼

you2 data and book domain

zz 6 年之前
父節點
當前提交
407c7f2333
共有 2 個文件被更改,包括 28 次插入21 次删除
  1. 13 9
      app/Console/Commands/BookTest.php
  2. 15 12
      app/Http/Controllers/Wap/Book/ChapterController.php

+ 13 - 9
app/Console/Commands/BookTest.php

@@ -334,11 +334,13 @@ class BookTest extends Command
         $result = [];
         $chapter_model = new ChapterOrder();
         foreach ($info as $item){
-            $to_bids = YqUserBidRelation::where('uid',$item->uid)->select('to_bid','created_at')->get()->pluck('created_at','to_bid')->all();
-            $from_bid = YqUserBidRelation::where('uid',$item->uid)->select('from_bid','created_at')->get()->pluck('created_at','from_bid')->all();
+            $to_bids = YqUserBidRelation::where('uid',$item->uid)->select('to_bid','created_at')->get();
+            $from_bids = YqUserBidRelation::where('uid',$item->uid)->where('from_bid','>',0)->select('from_bid','created_at')->get();
             $chapter_model->setCurrentTable($item->uid);
             if($to_bids){
-                foreach ($to_bids as $to_bid=>$time){
+                foreach ($to_bids as $v){
+                    $to_bid = $v->to_bid;
+                    $time = $to_bids->created_at->format('Y-m-d H:i:s');
                     if(!$to_bid) continue;
                     $fee = $chapter_model->where('uid',$item->uid)
                         ->where('bid',$to_bid)
@@ -366,21 +368,23 @@ class BookTest extends Command
                     $result = [];
                 }
             }
-
-            if($from_bid){
-                foreach ($from_bid as $to_bid=>$time){
+            $to_bid = null;
+            if($from_bids){
+                foreach ($from_bids as $from_bid){
+                    $bid = $from_bid->from_bid;
+                    $time = $from_bid->created_at->format('Y-m-d H:i:s');
                     if(!$to_bid) continue;
                     $fee = $chapter_model->where('uid',$item->uid)
-                        ->where('bid',$to_bid)
+                        ->where('bid',$bid)
                         ->where('created_at','>=',$time)
                         ->sum('fee');
                     $amount = Order::where('uid',$item->uid)
-                        ->where('from_bid',$to_bid)
+                        ->where('from_bid',$bid)
                         ->where('created_at','>=',$time)
                         ->where('status','PAID')
                         ->sum('price');
                     $result[] = [
-                        'bid'=>$to_bid,
+                        'bid'=>$bid,
                         'uid'=>$item->uid,
                         'fee'=>$fee,
                         'amount'=>$amount,

+ 15 - 12
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -323,12 +323,6 @@ class ChapterController extends BaseController
         if (empty($book_info)) return response()->error('WAP_SYS_ERROR');
         $this->book_info = $book_info;
         $this->cid = $cid;
-        //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配
-        if ($this->isVisitDomainEqualBookDomain($domain)) {
-            return response()->error('WAP_DOMAIN_NOT_MATCH', [
-                'url' => $this->getCorrespondBookUrl()
-            ]);
-        }
 
         //下架图书不能看
         if ($this->isOffShelf()) {
@@ -344,6 +338,21 @@ class ChapterController extends BaseController
                 'url' => $is_delete
             ]);
         }
+
+        //获取强关章节数
+        $subscribe_seq = $this->getSubscribeChapterNum($book_info);
+        //章节是否需要强关 TRUE:不需要,false:需要
+        $force_subscribe = $subscribe_seq > $chapter->sequence;
+
+        $this->is_need_subscribe = !$force_subscribe;
+
+        //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配 在强关章节后
+        if ($this->is_need_subscribe && $this->isVisitDomainEqualBookDomain($domain)) {
+            return response()->error('WAP_DOMAIN_NOT_MATCH', [
+                'url' => $this->getCorrespondBookUrl()
+            ]);
+        }
+
         $user_info = $this->_user_info;
         $this->user = $user_info;
         //用户是否强关
@@ -360,13 +369,7 @@ class ChapterController extends BaseController
             $force_read_data = ['src' => $force_read_url];
             return response()->error('WAP_NOT_SUBSCRIBE', $force_read_data);
         }
-        
-        //获取强关章节数
-        $subscribe_seq = $this->getSubscribeChapterNum($book_info);
-        //章节是否需要强关 TRUE:不需要,false:需要
-        $force_subscribe = $subscribe_seq > $chapter->sequence;
 
-        $this->is_need_subscribe = !$force_subscribe;
 
         if ($force_subscribe || $chapter->is_vip == 0) {
             //vip前一张和枪管前一张的访问统计