ソースを参照

Merge branch 'auth' of iqiyoo:zhuishuyun_wap into stabble

zz 6 年 前
コミット
06ffcfeb7c

+ 142 - 8
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -298,6 +298,7 @@ class ChapterController extends BaseController
      */
     public function index(Request $request, $t, $domain, $bid, $cid)
     {
+        $special_user_log = env('SPECIAL_USER_LOG');
         //注意:内部约定用  有此参数不需要强关
         $inter_not_need_sub = $request->has('inter_not_need_sub') ? true : false;
 
@@ -309,13 +310,32 @@ class ChapterController extends BaseController
         if (!$this->checkUid()) {
             return response()->error('WAP_NOT_LOGIN');
         }
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('in chapters--------------------------');
+            $my_log->info('param is');
+            $my_log->info($request->all());
+            $my_log->info('$t is: '.$t);
+            $my_log->info('$domain is: '.$domain);
+            $my_log->info('$bid is: '.$bid);
+            $my_log->info('$cid is: '.$cid);
+            $my_log->info('$uri is: '. $request->path());
+        }
+
         $this->en_bid = $bid;
 
         $bid = explode(',',$bid)[0];
         $bid = Hashids::decode($bid)[0];
+        if($special_user_log && $special_user_log == $this->uid){
+            myLog('special')->info('decode bid  is: '.$bid);
+        }
         //获取图书信息
         $book_info = BookConfigService::getBookById($bid);
-
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('book_info is ');
+            $my_log->info($book_info);
+        }
         //是否开启全站按章模式
         $global_charge_by_chapter_channels = explode(',',env('GLOBAL_CHARGE_BY_CHAPTER_CHANNEL'));
         if(in_array($this->distribution_channel_id,$global_charge_by_chapter_channels))
@@ -324,6 +344,10 @@ class ChapterController extends BaseController
         }
 
         if (empty($book_info)) return response()->error('WAP_SYS_ERROR');
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('book info ok--------------------------');
+        }
         $this->book_info = $book_info;
         $this->cid = $cid;
 
@@ -331,17 +355,32 @@ class ChapterController extends BaseController
         if ($this->isOffShelf()) {
             return response()->error('WAP_OFF_SHELF');
         }
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('on shelf ok--------------------------');
+        }
         //获取章节信息
         $chapter = ChapterService::getChapterNameById($cid, $bid);
         $this->chapter = $chapter;
-
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('chapters-info--is-----------------------');
+            $my_log->info($chapter);
+        }
         //章节被删除
         if (($is_delete = $this->chapterNotExists())) {
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('chapters-----delete---------------------');
+            }
             return response()->error('WAP_DOMAIN_NOT_MATCH', [
                 'url' => $is_delete
             ]);
         }
-
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('chapters-----ok---------------------');
+        }
         //获取强关章节数
         $subscribe_seq = $this->getSubscribeChapterNum($book_info);
         //章节是否需要强关 TRUE:不需要,false:需要
@@ -351,11 +390,18 @@ class ChapterController extends BaseController
 
         //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配 在强关章节后
         if ($this->is_need_subscribe && $this->isVisitDomainEqualBookDomain($domain)) {
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('book domain not match------------------------');
+            }
             return response()->error('WAP_DOMAIN_NOT_MATCH', [
                 'url' => $this->getCorrespondBookUrl()
             ]);
         }
-
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('book domain jump--------------------------');
+        }
         $user_info = $this->_user_info;
         $this->user = $user_info;
         //用户是否强关
@@ -368,11 +414,18 @@ class ChapterController extends BaseController
         //判断当前是否有强制显示服务号信息的cookie、已经关注 跳转到服务号信息引导页
         if($has_force_show_qrcode_cookie && $is_had_subscribe)
         {
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('do not have force show qrcode cookie-------------------------');
+            }
             $force_read_url = '/subscribe/getFromUser';//服务号信息引导页
             $force_read_data = ['src' => $force_read_url];
             return response()->error('WAP_NOT_SUBSCRIBE', $force_read_data);
         }
-
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('has force show qrcode cookie-ok-------------------------');
+        }
 
         if ($force_subscribe || $chapter->is_vip == 0) {
             //vip前一张和枪管前一张的访问统计
@@ -391,40 +444,75 @@ class ChapterController extends BaseController
                     $this->chapter->is_show_subscribe_link = 1;
                 }
             }
-
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('do not force subscribe-and is not vip-------------------------');
+            }
             $this->getChapter();
             return response()->item(new ChapterTransformer, $this->chapter);
         }
-
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('11111111111111111111111111111111111111111');
+        }
         //需要强制关注 不是vip章节 已经关注了
         if (!$force_subscribe && $chapter->is_vip == 0 && $is_had_subscribe) {
             $this->getChapter();
             return response()->item(new ChapterTransformer, $this->chapter);
         }
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('222222222222222222222222222222222222222');
+        }
         //需要强制关注 没关注
         if ((!$force_subscribe) && !$is_had_subscribe) {
             $force_data = $this->forceSubscribe();
             if ($force_data) {
                 $this->subscribeStats();
+                if($special_user_log && $special_user_log == $this->uid){
+                    $my_log = myLog('special');
+                    $my_log->info('need subscribe-------------------------');
+                }
                 return response()->error($force_data['error_type'], $force_data['data']);
             }
 
             //取不到公众号则不用强关
             if ($chapter->is_vip == 0) {
                 $this->getChapter();
+                if($special_user_log && $special_user_log == $this->uid){
+                    $my_log = myLog('special');
+                    $my_log->info('official fail--------------------------');
+                }
                 return response()->item(new ChapterTransformer, $this->chapter);
             }
         }
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('33333333333333333333333333333333333333333');
+        }
         //已经付费
         if ($this->getOrderRecord($bid, $cid)) {
             $this->getChapter();
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('had order order record--------------------------');
+            }
             return response()->item(new ChapterTransformer, $this->chapter);
         }
+
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('4444444444444444444444444444444444444444444');
+        }
         //获取价格
         $fee = $this->getPrice($book_info, $chapter);
         //广告
         if($this->isUserInAdSample() && $ad_status && $ad_status == 1 && $user_info->balance < $fee){
             $this->getChapter();
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('ad-----in--------------------');
+            }
             //广告解锁2张
             if($this->chapter->next_cid){
                 $next_chapter  = ChapterService::getChapterNameById($this->chapter->next_cid, $bid);
@@ -438,6 +526,10 @@ class ChapterController extends BaseController
             $this->bookOrderOrChapterOrder($book_info, $cid, 0, $chapter->name, 1);
             return response()->item(new ChapterTransformer, $this->chapter);
         }
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('5555555555555555555555555555555555');
+        }
         //以上都是不用付费的情况******************************************************
         //未付费
 
@@ -457,32 +549,74 @@ class ChapterController extends BaseController
             'discount_fee' => '',
             'discount' => ''
         ];
-
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('data is:');
+            $my_log->info($data);
+        }
         //余额不足 弹窗提醒
         if ($user_info['balance'] < $fee) {
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('balance is lack');
+                $my_log->info('user balance is: '.$user_info['balance']);
+                $my_log->info('fee is: '.$fee);
+            }
             $this->smartPushTestBookPayPageUv($bid);
             //$this->sendOrderPayPageUv($bid);
             //除了单本订购 其他的都不提醒,直接跳转到充值页面
             if ($book_info->charge_type == 'CHAPTER') {
+                if($special_user_log && $special_user_log == $this->uid){
+                    $my_log = myLog('special');
+                    $my_log->info('chapter order balance lack');
+                }
                 return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
             }
             //需要提箱
             if ($this->isOrderRemind($bid)) {
+                if($special_user_log && $special_user_log == $this->uid){
+                    $my_log = myLog('special');
+                    $my_log->info('balance lack remind');
+                }
                 return response()->error('WAP_BOOK_BALANCE_PAY', $data);
             } else {
+                if($special_user_log && $special_user_log == $this->uid){
+                    $my_log = myLog('special');
+                    $my_log->info('balance lack not remind');
+                }
                 return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
             }
 
         }
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('6666666666666666666666666666666666666');
+        }
         //余额充足 单本弹窗提醒,章节直接扣费
         if ($this->isOrderRemind($bid) && $book_info->charge_type == 'BOOK') {
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('balance enough remind');
+            }
             return response()->error('WAP_BOOK_BUY', $data);
         }
+        if($special_user_log && $special_user_log == $this->uid){
+            $my_log = myLog('special');
+            $my_log->info('77777777777777777777777777777');
+        }
         //付费 不提醒
         if ($this->balancePay($book_info, $chapter, 0)) {
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('balance pay ok-----');
+            }
             $this->getChapter();
             return response()->item(new ChapterTransformer, $this->chapter);
         } else {
+            if($special_user_log && $special_user_log == $this->uid){
+                $my_log = myLog('special');
+                $my_log->info('balance pay fails!!!!!!!!!!!!!!!!');
+            }
             //付费 异常
             return response()->error('WAP_SYS_ERROR');
         }

+ 17 - 11
app/Http/Controllers/Wap/Order/OrdersController.php

@@ -633,23 +633,29 @@ class OrdersController extends BaseController
 
     private function templateCompare(){
         //if(!in_array($this->distribution_channel_id,[2,14,211,155,4427,4488,256,691,146,255,722,4364,5,202,318,4237,266,196,273,4236,148,8,4241,160,271,4053,123,4334,4487,4593,695,4025,4426,4174])){
-        if(!in_array($this->distribution_channel_id,[2,14,123,211,5,8,160,4236,4237,4241])){
+        $start_time = env('TEMPLATE_COMPARE_START_TIME_3',0);
+        if(!$start_time){
             return 0;
         }
-
-        $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPARE');
-        if(!$user){
+        if(!in_array($this->distribution_channel_id,[14,123,211,5,8,160,4236,4237,4241])){
             return 0;
         }
 
-        $template_id = $user->attach;
-
-        if($template_id && $template_id == 3 && !OrderService::isPaidUser($this->uid)){
-            $template_id = 2;
+        $user = $this->_user_info;
+        if(strtotime($user->created_at) < $start_time){
+            return 0;
         }
 
-        if($template_id == 3){
-            $template_id = 5;
+        $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPARE_V3');
+        if($user){
+            $template_id = $user->attach;
+        }else{
+            $template_id = $this->uid % 2 == 0? 2:4;
+            DataAnalysisSelectUserService::create(
+                $this->uid,
+                $this->distribution_channel_id,
+                'TEMPLATE_COMPARE_V3',
+                -1, $template_id);
         }
 
         return $template_id;
@@ -662,7 +668,7 @@ class OrdersController extends BaseController
             return 0;
         }
 
-        if(!in_array($this->distribution_channel_id,[2,14,146 ,155 ,255 ,256 ,691 ,722 ,4364 ,695 ,4174 ,4025 ,4593 ,4426 ,4742 ,4053 ,4334 ,4487])){
+        if(!in_array($this->distribution_channel_id,[2,146 ,155 ,255 ,256 ,691 ,722 ,4364 ,695 ,4174 ,4025 ,4593 ,4426 ,4742 ,4053 ,4334 ,4487])){
             return 0;
         }
         $user = $this->_user_info;

+ 17 - 5
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -7,6 +7,7 @@ use App\Jobs\SendTexts;
 use App\Modules\Activity\Services\ActivitySwitchService;
 use App\Modules\Channel\Services\ChannelActivitiesService;
 use App\Modules\Channel\Services\ChannelService;
+use App\Modules\OfficialAccount\Services\ForceSubscribeService;
 use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
 use App\Modules\Subscribe\Services\OrderService;
 use App\Modules\User\Services\UserService;
@@ -373,14 +374,25 @@ class WelcomeController extends BaseController
     private function getSiteTitle(Request $request)
     {
         $title = "追书云";
+        $get_force_subscribe_name = false;
         $subscribe = $request->cookie('force_subscribe_name');
-        if ($subscribe) {
-            $title = $subscribe;
-        } else {
+        if ($subscribe) return $subscribe;
+        //强关公众号名称
+        $force_subscribe = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
+        if ($force_subscribe) {
+            $force_subscribe_official = DB::table('official_accounts')->where('appid',$force_subscribe->appid)->select('nickname')->first();
+            if ($force_subscribe_official) {
+                $title = $force_subscribe_official->nickname;
+                $get_force_subscribe_name = true;
+                Cookie::queue('force_subscribe_name', $title, 12 * 3600);
+            }
+        }
+        //可用公众号名称
+        if (!$get_force_subscribe_name) {
             $res = OfficialAccountService::canUseOfficialAccountByChannelId(['distribution_channel_id' => $this->distribution_channel_id]);
             if ($res && isset($res->nickname) && !empty($res->nickname)) {
-                Cookie::queue('force_subscribe_name', $res->nickname, 12 * 3600);
                 $title = $res->nickname;
+                Cookie::queue('force_subscribe_name', $title, 12 * 3600);
             }
         }
         return $title;
@@ -613,7 +625,7 @@ class WelcomeController extends BaseController
         }
         //结束
         if (time() > strtotime($activity_info->end_time)) {
-            return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2 ]);
+            return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2]);
         }
         $product_ids = [4063, 4064];
         $url = [];

+ 10 - 2
app/Libs/Helpers.php

@@ -449,7 +449,7 @@ function specialChannelAuthInfo(){
         '157'=>'wx5ebe6187c0fb0bd5',
         '4175'=>'wx64cf3051ceb145ae',
         '4217'=>'wxdb15f8db194bf6f4',
-        '4604'=>'wxc177995c55b5e75e'
+        //'4604'=>'wxc177995c55b5e75e'
     ];
 }
 
@@ -481,6 +481,14 @@ function specialChannelAuthInfoV2(){
         '4434'=>'wx7ea67b55ac102fd3',
         '4440'=>'wxddd622a5c195a3a9',
         '4438'=>'wx007ef65244b47f7c',
-        '4815'=>'wx33f6cc190b194b3e'
+        '4815'=>'wx33f6cc190b194b3e',
+        '4839'=>'wx27b946dad6c3aa91',
+        '4905'=>'wxe1a06f73c723c2a6',
+        '4906'=>'wxf03275b6863c2806',
+        '4907'=>'wxadc68453a4500191',
+        '4908'=>'wx8d46d69ab9d76c55',
+        '4909'=>'wx2c62f7f4a02176d7',
+        '4910'=>'wx7ee2ad6685e3d5b3',
+        '4820'=>'wx30ecb35d13959f8d'
     ];
 }