zz 6 år sedan
förälder
incheckning
1c2aa4dddb
1 ändrade filer med 29 tillägg och 1 borttagningar
  1. 29 1
      app/Http/Controllers/Wap/Web/WelcomeController.php

+ 29 - 1
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -29,6 +29,7 @@ use App\Http\Controllers\Wap\Book\Transformers\BookTransformer;
 class WelcomeController extends BaseController
 class WelcomeController extends BaseController
 {
 {
 
 
+    private $force_subscribe_info = null;
     /**
     /**
      * 首页
      * 首页
      */
      */
@@ -120,6 +121,8 @@ class WelcomeController extends BaseController
             $yctj = true;
             $yctj = true;
             $yctj_url = 'https://m.ycsd.cn/continue';
             $yctj_url = 'https://m.ycsd.cn/continue';
         }
         }
+        //app广告
+        $add_ad_status = $this->appad();
         $options = json_encode([
         $options = json_encode([
             'distribution_channel_id' => (int)$this->distribution_channel_id,
             'distribution_channel_id' => (int)$this->distribution_channel_id,
             'send_order_id' => $send_order_id,
             'send_order_id' => $send_order_id,
@@ -152,7 +155,10 @@ class WelcomeController extends BaseController
             'is_hide_chapter_consume' => $is_hide_chapter_consume,
             'is_hide_chapter_consume' => $is_hide_chapter_consume,
         	'hide_book_name' => $hide_book_name,
         	'hide_book_name' => $hide_book_name,
             'yctj'=>$yctj,
             'yctj'=>$yctj,
-            'yctj_url'=>$yctj_url
+            'yctj_url'=>$yctj_url,
+            'appad'=>$add_ad_status['appad'],
+            'appad_banner'=>$add_ad_status['appad_banner'],
+            'appad_url'=>$add_ad_status['appad_url']
         ]);
         ]);
         if ($this->uid == env('SPECIAL_USER_LOG', 2)) {
         if ($this->uid == env('SPECIAL_USER_LOG', 2)) {
             myLog('special')->info('welcome --------------------------');
             myLog('special')->info('welcome --------------------------');
@@ -409,6 +415,7 @@ class WelcomeController extends BaseController
         if ($subscribe) return $subscribe;
         if ($subscribe) return $subscribe;
         //强关公众号名称
         //强关公众号名称
         $force_subscribe = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
         $force_subscribe = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
+        $this->force_subscribe_info = $force_subscribe;
         if ($force_subscribe) {
         if ($force_subscribe) {
             $force_subscribe_official = DB::table('official_accounts')->where('appid',$force_subscribe->appid)->select('nickname')->first();
             $force_subscribe_official = DB::table('official_accounts')->where('appid',$force_subscribe->appid)->select('nickname')->first();
             if ($force_subscribe_official) {
             if ($force_subscribe_official) {
@@ -428,6 +435,27 @@ class WelcomeController extends BaseController
         return $title;
         return $title;
     }
     }
 
 
+
+    private function appad(){
+        if(!$this->force_subscribe_info){
+            $this->force_subscribe_info = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
+        }
+        if(!$this->force_subscribe_info){
+            return ['appad'=>false,'appad_banner'=>'','appad_url'=>''];
+        }
+        if($this->force_subscribe_info->subscribe_time &&
+            (time()-strtotime($this->force_subscribe_info->subscribe_time) >=3*86400)
+            && !OrderService::isPaidUser($this->uid)
+        ){
+            return [
+                'appad'=>true,
+                'appad_banner'=>'https://cdn-novel.iycdm.com/h5/app-ad-banner.jpg',
+                'appad_url'=>'/advertise/show?uid='.Hashids::encode($this->uid)
+            ];
+        }
+        return ['appad'=>false,'appad_banner'=>'','appad_url'=>''];
+    }
+
     /**
     /**
      * 获取客服图片
      * 获取客服图片
      */
      */