zz %!s(int64=5) %!d(string=hai) anos
pai
achega
73f170ca6f

+ 24 - 5
app/Http/Controllers/Wap/Order/OrdersController.php

@@ -266,8 +266,8 @@ class OrdersController extends BaseController
 
         $property = UserDivisionCpcPropertyService::getUserPropertyV2($this->uid);
         $user_info = $this->_user_info;
-        $this->monthPayExposureRecord($property,$user_info->openid);
-        $this->monthAbTest($property,$user_info->openid);
+        $result = $this->monthAbTest($property,$user_info->openid);
+        if($result == 0)$this->monthPayExposureRecord($property,$user_info->openid);
         foreach ($res as $v) {
             if ($template_id == 7 && $book_config && $book_config->charge_type == 'BOOK' && $v->price == 2) {
                 continue;
@@ -945,16 +945,35 @@ class OrdersController extends BaseController
             && in_array($property, ['none','low', 'medium'])
         ) {
             $exist = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'MONTH_V2');
-            if ($exist) return true;
+            if ($exist) {
+                $attach = $exist->attach;
+                if($attach == 'week-show' || $attach == 'show'){
+                    $ret = 0;
+                }else{
+                    $ret = -1;
+                }
+                return $ret;
+            }
             if(!UserMonthService::isSignMonth($openid)){
-                $attach = $this->uid %2 == 0 ? 'show':'hide';
+                if($property == 'low'){
+                    $attach = $this->uid %2 == 0 ? 'week-show':'week-hide';
+                }else{
+                    $attach = $this->uid %2 == 0 ? 'show':'hide';
+                }
+                if($attach == 'week-show' || $attach == 'show'){
+                    $ret = 0;
+                }else{
+                    $ret = -1;
+                }
+
                 DataAnalysisSelectUserService::create(
                     $this->uid,
                     $this->distribution_channel_id,
                     'MONTH_V2',
                     -1, $attach);
+                return $ret;
             }
         }
-        return '';
+        return -1;
     }
 }

+ 54 - 79
app/Http/Controllers/Wap/Pay/MonthOrderController.php

@@ -74,6 +74,15 @@ class MonthOrderController extends Controller
         $key = env('MONTH_ORDER_KEY');
         $app_id = $request->post('app_id');
         $plan_id = $request->post('plan_id');
+        $type = 'MONTH';
+        if($plan_id == env('MONTH_ORDER_PLAN_ID')){
+            $type = 'MONTH';
+        }
+
+        if($plan_id == env('MONTH_WEEK_ORDER_PLAN_ID')){
+            $type = 'WEEK';
+        }
+
         $user_id = $request->post('user_id');
         $change_type = $request->post('change_type');
         if ($check = checkParam($request->except('_url'), ['app_id', 'plan_id', 'user_id', 'change_type'])) {
@@ -88,56 +97,13 @@ class MonthOrderController extends Controller
             return response('fail');
         }
         if ($sign == $request->post('sign')) {
-            UserMonthService::createSign($user_id, $plan_id, $change_type, $user_info->openid);
+            UserMonthService::createSign($user_id, $plan_id, $change_type, $user_info->openid,$type);
         }
         Log::info('signCallBack-------------------end-----------------------signCallBack');
         return response('success');
     }
 
 
-    public function orderCallBackV2(Request $request)
-    {
-        Log::info('orderCallBack------------------------------------------orderCallBack');
-        Log::info($request->all());
-        Log::info($request->getMethod());
-
-        $key = env('MONTH_ORDER_KEY');//'sn7wluq5716brp8fzm';
-        $app_id = $request->post('app_id');
-        $plan_id = $request->post('plan_id', 0);
-        $user_id = $request->post('user_id');
-        $total_fee = $request->post('total_fee');
-        $trade_no = $request->post('trade_no');
-        $out_trade_no = $request->post('out_trade_no');
-        if ($check = checkParam($request->except('_url'), ['app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'])) {
-            return response()->error('PARAM_EMPTY', ['msg' => $check]);
-        }
-        $sign = _sign(compact('app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'), $key . $key);
-        $sign = strtoupper($sign);
-        Log::info('self sign is: ' . $sign);
-        $order_info = Order::find($user_id);
-        if (!$order_info) {
-            Log::error('month order not exist !!!order is :' . $trade_no);
-            return response('fail');
-        }
-        if ($order_info->status == 'PAID') {
-            Log::error('month order had deal !!!, order is :' . $trade_no);
-            return response('fail');
-        }
-        //if($sign == $request->post('sign')){
-        if (!UserMonthService::getOrderByOrder($trade_no, $out_trade_no)) {
-            UserMonthService::createLOrder($order_info->uid, $plan_id, $total_fee, $trade_no, $out_trade_no);
-            $order_info->transaction_id = $trade_no;
-            $order_info->status = 'PAID';
-            $order_info->pay_end_at = date('Y-m-d H:i:s');
-            $order_info->save();
-            self::addOrderAndVipV2($order_info->uid, $total_fee);
-        }
-        //}
-
-        Log::info('orderCallBack--------------------endend----------------------orderCallBack');
-        return response('success');
-    }
-
     public function orderCallBack(Request $request)
     {
         Log::info('orderCallBack------------------------------------------orderCallBack');
@@ -152,8 +118,16 @@ class MonthOrderController extends Controller
         $trade_no = $request->post('trade_no');
         $out_trade_no = $request->post('out_trade_no');
         $result_code = $request->post('result_code',0);
-        $this->recordOrderCallBack($request);
+        $this->recordOrderCallBack($request,'MONTH');
         if(!$result_code) return response('success');
+        $type = 'MONTH';
+        if($plan_id == env('MONTH_ORDER_PLAN_ID')){
+            $type = 'MONTH';
+        }
+
+        if($plan_id == env('MONTH_WEEK_ORDER_PLAN_ID')){
+            $type = 'WEEK';
+        }
         if ($check = checkParam($request->except('_url'), ['app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'])) {
             return response()->error('PARAM_EMPTY', ['msg' => $check]);
         }
@@ -161,9 +135,9 @@ class MonthOrderController extends Controller
         $sign = strtoupper($sign);
         //if($sign == $request->post('sign')){
         if (!UserMonthService::getOrderByOrder($trade_no, $out_trade_no)) {
-            UserMonthService::createLOrder($user_id, $plan_id, $total_fee, $trade_no, $out_trade_no);
-            $this->addOrderAndVip($user_id, $out_trade_no, $trade_no, $total_fee);
-            $this->successPayPushMsg($user_id);
+            UserMonthService::createLOrder($user_id, $plan_id, $total_fee, $trade_no, $out_trade_no,$type);
+            $this->addOrderAndVip($user_id, $out_trade_no, $trade_no, $total_fee,6826,$type);
+            $this->successPayPushMsg($user_id,$type);
             $this->userProperty($user_id);
         }
         //}
@@ -173,9 +147,8 @@ class MonthOrderController extends Controller
     }
 
 
-    private function addOrderAndVip($uid, $out_trade_no, $trade_no, $price)
+    private function addOrderAndVip($uid, $out_trade_no, $trade_no, $price,$product_id,$type)
     {
-
         $order_info = OrderService::getByTradeNo($out_trade_no);
         //订单已经存在
         if ($order_info) {
@@ -183,31 +156,28 @@ class MonthOrderController extends Controller
         }
         $user_info = UserService::getById($uid);
         if (!$user_info) return;
-        $this->createOrder($uid, $user_info->distribution_channel_id, 0, $price, $out_trade_no, $trade_no);
-        YearOrderService::save_month_order([
-            'uid' => $uid,
-            'distribution_channel_id' => $user_info->distribution_channel_id,
-            'fee' => $price / 100,
-            'send_order_id' => 0
-        ]);
+        $this->createOrder($uid, $user_info->distribution_channel_id, $product_id, $price, $out_trade_no, $trade_no,$type);
+        if($type == 'MONTH'){
+            YearOrderService::save_month_order([
+                'uid' => $uid,
+                'distribution_channel_id' => $user_info->distribution_channel_id,
+                'fee' => $price / 100,
+                'send_order_id' => 0
+            ]);
+        }
+        if($type == 'WEEK'){
+            YearOrderService::save_vip_order_daynum([
+                'uid' => $uid,
+                'distribution_channel_id' => $user_info->distribution_channel_id,
+                'fee' => $price / 100,
+                'send_order_id' => 0,
+                'day_num'=>7
+            ]);
+        }
     }
 
-    private function addOrderAndVipV2($uid, $price)
-    {
-
-
-        $user_info = UserService::getById($uid);
-        if (!$user_info) return;
 
-        YearOrderService::save_month_order([
-            'uid' => $uid,
-            'distribution_channel_id' => $user_info->distribution_channel_id,
-            'fee' => $price / 100,
-            'send_order_id' => 0
-        ]);
-    }
-
-    private function createOrder($uid, $distribution_channel_id, $product_id, $price, $trade_no, $transaction_id)
+    private function createOrder($uid, $distribution_channel_id, $product_id, $price, $trade_no, $transaction_id,$type)
     {
         $count = OrderService::getUserChargeTimes($uid);
         $count = $count + 1;
@@ -227,11 +197,11 @@ class MonthOrderController extends Controller
         $init_order = [
             'distribution_channel_id' => $distribution_channel_id,
             'uid' => $uid,
-            'product_id' => 6826,
+            'product_id' => $product_id,
             'price' => $price / 100,
             'pay_type' => $count,
             'trade_no' => $trade_no,
-            'pay_merchant_source' => 'MONTH',
+            'pay_merchant_source' => $type,
             'pay_merchant_id' => 99,
             'create_ip' => '',
             'send_order_id' => $send_order_id,
@@ -274,7 +244,7 @@ class MonthOrderController extends Controller
         return response()->error('WAP_SYS_ERROR');
     }
 
-    private function recordOrderCallBack(Request $request){
+    private function recordOrderCallBack(Request $request,$type){
         $app_id = $request->post('app_id','');
         $plan_id = $request->post('plan_id',0);
         $uid = $request->post('user_id','');
@@ -289,7 +259,7 @@ class MonthOrderController extends Controller
         try{
             DB::table('user_month_order_callback')->insert([
                 compact('uid','app_id','plan_id','total_fee','out_trade_no','origin_data',
-                    'trade_no','result_code','sign','created_at','updated_at'
+                    'trade_no','result_code','sign','created_at','updated_at','type'
                 )
             ]);
         }catch (\Exception $e){
@@ -299,7 +269,7 @@ class MonthOrderController extends Controller
 
     }
 
-    protected function successPayPushMsg($uid)
+    protected function successPayPushMsg($uid,$type)
     {
         try {
             $force_sub_info = DB::table('force_subscribe_users')->where('uid', $uid)->where('is_subscribed', 1)->first();
@@ -307,8 +277,13 @@ class MonthOrderController extends Controller
             if (!$force_sub_info) {
                 return;
             }
-
-            $content_format = "包月购买成功通知:\r\n购买类型: 30元包月\r\n><a href='%s'>点击继续上次阅读</a>\r\n包月特权:\r\n 💝 全站所有作品免费阅读\r\n 💝 全站无广告\r\n 💝 阅读管家1对1服务\r\n为保障包月权益,请<a href='%s'>置顶公众号</a> ";
+            $content_format = '';
+            if($type == 'MONTH'){
+                $content_format = "包月购买成功通知:\r\n购买类型: 30元包月\r\n><a href='%s'>点击继续上次阅读</a>\r\n包月特权:\r\n 💝 全站所有作品免费阅读\r\n 💝 全站无广告\r\n 💝 阅读管家1对1服务\r\n为保障包月权益,请<a href='%s'>置顶公众号</a> ";
+            }
+            if($type == 'WEEK'){
+                $content_format = "包周购买成功通知:\r\n购买类型: 30元包月\r\n><a href='%s'>点击继续上次阅读</a>\r\n包月特权:\r\n 💝 全站所有作品免费阅读\r\n 💝 全站无广告\r\n 💝 阅读管家1对1服务\r\n为保障包周权益,请<a href='%s'>置顶公众号</a> ";
+            }
 
             $delay = 0;
             $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($data->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/continue';;

+ 231 - 214
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -44,6 +44,7 @@ class WelcomeController extends BaseController
     private $property = '';
 
     private $user = null;
+
     /**
      * 首页
      */
@@ -109,9 +110,9 @@ class WelcomeController extends BaseController
         $this->setProperty($user->openid);
         $channel_activities_flag = $this->judgeChannelActivity($user);
         //最近阅读页面 推荐
-        if(isset($user->sex)){
+        if (isset($user->sex)) {
             $latest_read_rec_books = $this->latest_read_rec_books($channel, $user->sex);
-        }else{
+        } else {
             $latest_read_rec_books = [];
         }
         //广告样本
@@ -121,18 +122,18 @@ class WelcomeController extends BaseController
             $adTargetId = $this->cpcAd($user->openid);
         }
         $cpc_channel = '';
-        if($adTargetId){
-            $cpc_channel = Redis::hget('channel:setting:'.$this->distribution_channel_id,'cpc_channel');
-            if(!$cpc_channel) $cpc_channel = 'zw005';
-            $disable_channel = redisEnv('CPC_DISABLED_CHANNEL','');
-            if($disable_channel && in_array($cpc_channel,explode(',',$disable_channel))){
+        if ($adTargetId) {
+            $cpc_channel = Redis::hget('channel:setting:' . $this->distribution_channel_id, 'cpc_channel');
+            if (!$cpc_channel) $cpc_channel = 'zw005';
+            $disable_channel = redisEnv('CPC_DISABLED_CHANNEL', '');
+            if ($disable_channel && in_array($cpc_channel, explode(',', $disable_channel))) {
                 $adTargetId = false;
                 $cpc_channel = '';
             }
         }
         //目前推喜阅 自有广告曝光中低净值
         $self_pa_ad_switch = 0;
-        if(in_array($this->property,['none','low', 'medium']) && $this->isPddAdSites()) $self_pa_ad_switch = 1;
+        if (in_array($this->property, ['none', 'low', 'medium']) && $this->isPddAdSites()) $self_pa_ad_switch = 1;
 
 
         //广告frame
@@ -150,25 +151,25 @@ class WelcomeController extends BaseController
         $hide_chapter_channels = explode(',', env('HIDE_CHAPTER_CONSUME_CHANNEL'));
         $is_hide_chapter_consume = in_array($this->distribution_channel_id, $hide_chapter_channels) ? 1 : 0;
         //广告
-        
+
         // 屏蔽书名
-        $self_config = ChannelService::check_channel_account_priv($this->distribution_channel_id,'hide_book_name');
+        $self_config = ChannelService::check_channel_account_priv($this->distribution_channel_id, 'hide_book_name');
         $hide_book_name = 0;
-        if(!empty($self_config)){
-        	$hide_book_name = 1;
+        if (!empty($self_config)) {
+            $hide_book_name = 1;
         }
         //原创pv uv
         $yctj = false;
         $yctj_url = '';
-        if(in_array($this->distribution_channel_id,[2,146,155,255,691,722,4053,4174,4364,4426])){
+        if (in_array($this->distribution_channel_id, [2, 146, 155, 255, 691, 722, 4053, 4174, 4364, 4426])) {
             $yctj = true;
             $yctj_url = 'https://m.ycsd.cn/continueRead';
         }
         //app广告
-        $add_ad_status=[
-            'appad'=>false,
-            'appad_banner'=>'',
-            'appad_url'=>''
+        $add_ad_status = [
+            'appad' => false,
+            'appad_banner' => '',
+            'appad_url' => ''
         ];
 
         //突出包年的充值页面
@@ -176,24 +177,20 @@ class WelcomeController extends BaseController
         $pdd_ad = $this->pddAd();
 
         //banner 合并
-        if($is_show_activity)
-        {
+        if ($is_show_activity) {
             $banners[] = [
-                'img'=>$activity_img,
-                'jump_url'=>$url
+                'img' => $activity_img,
+                'jump_url' => $url
             ];
         }
         //pdd 广告用户--增加banner
-        if($pdd_ad)
-        {
+        if ($pdd_ad) {
             $pdd_ads = Redis::get('pdd_ads');//pdd广告
-            if($pdd_ads)
-            {
-                foreach (json_decode($pdd_ads,true) as $_ad)
-                {
+            if ($pdd_ads) {
+                foreach (json_decode($pdd_ads, true) as $_ad) {
                     $banners[] = [
-                        'img'=>$_ad['img'],
-                        'jump_url'=>$_ad['jump_url']
+                        'img' => $_ad['img'],
+                        'jump_url' => $_ad['jump_url']
                     ];
                 }
             }
@@ -233,24 +230,24 @@ class WelcomeController extends BaseController
             'is_show_ad_frame' => $is_show_ad_frame,
             'show_title_in_reader' => $show_title_in_reader,
             'is_hide_chapter_consume' => $is_hide_chapter_consume,
-        	'hide_book_name' => $hide_book_name,
-            'yctj'=>$yctj,
-            'yctj_url'=>$yctj_url,
-            'appad'=>$add_ad_status['appad'],
-            'appad_banner'=>$add_ad_status['appad_banner'],
-            'appad_url'=>$add_ad_status['appad_url'],
-            'outstanding_year_order'=>$outstanding_year_order,
-            'share_domain'=>env('share_domain_url'),
-            'share_switch'=>0,//无充值用户分享关闭
-            'pdd_ad'=>$pdd_ad,
-            'special_pay_template'=>$this->isMiWan(),  //米玩站点特殊充值页面
-            'crm'=>$crm,
-            'self_pa_ad_switch'=>$self_pa_ad_switch,//自有平台广告开关
-            'banners'=>$banners,
-            'guidepersonalaccount'=>$this->guidePersonalAccount($user->openid),
-            'cpc_channel'=>$cpc_channel,
-            'month_order_info'=>$month_order_info,
-            'xiyue_info'=>$xiyue_info
+            'hide_book_name' => $hide_book_name,
+            'yctj' => $yctj,
+            'yctj_url' => $yctj_url,
+            'appad' => $add_ad_status['appad'],
+            'appad_banner' => $add_ad_status['appad_banner'],
+            'appad_url' => $add_ad_status['appad_url'],
+            'outstanding_year_order' => $outstanding_year_order,
+            'share_domain' => env('share_domain_url'),
+            'share_switch' => 0,//无充值用户分享关闭
+            'pdd_ad' => $pdd_ad,
+            'special_pay_template' => $this->isMiWan(),  //米玩站点特殊充值页面
+            'crm' => $crm,
+            'self_pa_ad_switch' => $self_pa_ad_switch,//自有平台广告开关
+            'banners' => $banners,
+            'guidepersonalaccount' => $this->guidePersonalAccount($user->openid),
+            'cpc_channel' => $cpc_channel,
+            'month_order_info' => $month_order_info,
+            'xiyue_info' => $xiyue_info
         ]);
         if ($this->uid == env('SPECIAL_USER_LOG', 2)) {
             myLog('special')->info('welcome --------------------------');
@@ -333,21 +330,23 @@ class WelcomeController extends BaseController
         return $channel_activities_flag;
     }
 
-    private function outstandingYearOrder(){
+    private function outstandingYearOrder()
+    {
         $outstanding_year_order = false;
-        if(in_array($this->distribution_channel_id,explode(',',env('CAN_NOT_OUTSTANDING_YEAR_ORDER_SITE')))){
+        if (in_array($this->distribution_channel_id, explode(',', env('CAN_NOT_OUTSTANDING_YEAR_ORDER_SITE')))) {
             return $outstanding_year_order;
         }
         //if( in_array($this->distribution_channel_id,explode(',',env('OUTSTANDING_YEAR_ORDER_SITE'))) ){
-            //if($this->uid%2 == 0){
-                //$userDivisionProperty = UserDivisionPropertyService::getUserProperty($this->uid);
-                //$userDivisionProperty = UserDivisionCpcPropertyService::getUserProperty($this->uid);
+        //if($this->uid%2 == 0){
+        //$userDivisionProperty = UserDivisionPropertyService::getUserProperty($this->uid);
+        //$userDivisionProperty = UserDivisionCpcPropertyService::getUserProperty($this->uid);
 
-                $this->property == 'high' && $outstanding_year_order = true;
-            //}
+        $this->property == 'high' && $outstanding_year_order = true;
+        //}
         //}
         return $outstanding_year_order;
     }
+
     private function luckyUserForeverFree()
     {
         $lucky_user = 0;
@@ -449,11 +448,11 @@ class WelcomeController extends BaseController
 
         //自定义新用户活动
         $show_custom_new_user_activity_channel = env('SHOW_CUSTOM_NEW_USER_ACTIVITY_CHANNEL', '');
-        if($show_custom_new_user_activity_channel && in_array($this->distribution_channel_id, explode(',', $show_custom_new_user_activity_channel ))){
-            $custom_activity_page = ActivityService::getActiveCustomActivityByType($this->distribution_channel_id,'CUSTOM_NEW_USER');
-            if($custom_activity_page){
-                $charge_count = Order::where('uid',$this->uid)->where('status','PAID')->count();
-                if($charge_count ==0 ){
+        if ($show_custom_new_user_activity_channel && in_array($this->distribution_channel_id, explode(',', $show_custom_new_user_activity_channel))) {
+            $custom_activity_page = ActivityService::getActiveCustomActivityByType($this->distribution_channel_id, 'CUSTOM_NEW_USER');
+            if ($custom_activity_page) {
+                $charge_count = Order::where('uid', $this->uid)->where('status', 'PAID')->count();
+                if ($charge_count == 0) {
                     $url = $h5_scheme . '://' . _domain() . $custom_activity_page->activity_page;
                     $is_show_activity = 1;
                     $activity_title = '优惠活动';
@@ -490,8 +489,8 @@ class WelcomeController extends BaseController
                 if ($status) {
                     $is_show_activity = 1;
                     $bottom_show_type = 2;
-                    if($activity_setting['activity_id'] == env('OTHER_ACTIVITY_ID',0)){
-                        if(!in_array($this->distribution_channel_id, explode(',', env('OTHER_ACTIVITY_CHANNEL', '1')))){
+                    if ($activity_setting['activity_id'] == env('OTHER_ACTIVITY_ID', 0)) {
+                        if (!in_array($this->distribution_channel_id, explode(',', env('OTHER_ACTIVITY_CHANNEL', '1')))) {
                             $is_show_activity = 0;
                         }
                     }
@@ -534,19 +533,19 @@ class WelcomeController extends BaseController
      */
     private function getSiteTitle(Request $request)
     {
-        if($this->distribution_channel_id == 6398) return '花溪亭苑';
-        if($this->distribution_channel_id == 5216) return '花开文阁';
-        if($this->distribution_channel_id == 6985) return '喜阅微书店';
+        if ($this->distribution_channel_id == 6398) return '花溪亭苑';
+        if ($this->distribution_channel_id == 5216) return '花开文阁';
+        if ($this->distribution_channel_id == 6985) return '喜阅微书店';
         $title = "追书云";
         $get_force_subscribe_name = false;
         $subscribe = $request->cookie('force_subscribe_name');
         $appid = $request->get('appid');
         //用户进来携带的公众号信息
-        if($appid){
-            $force_subscribe_official = DB::table('official_accounts')->where('appid',$appid)->select('nickname')->first();
+        if ($appid) {
+            $force_subscribe_official = DB::table('official_accounts')->where('appid', $appid)->select('nickname')->first();
             if ($force_subscribe_official) {
                 $title = $force_subscribe_official->nickname;
-                if($title) return $title;
+                if ($title) return $title;
             }
         }
         if ($subscribe) return $subscribe;
@@ -554,7 +553,7 @@ class WelcomeController extends BaseController
         $force_subscribe = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
         $this->force_subscribe_info = $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) {
                 $title = $force_subscribe_official->nickname;
                 $get_force_subscribe_name = true;
@@ -573,51 +572,53 @@ class WelcomeController extends BaseController
     }
 
 
-    private function appad(){
-        if($this->force_subscribe_info){
+    private function appad()
+    {
+        if ($this->force_subscribe_info) {
             $force_subscribe_info = $this->force_subscribe_info;
-        }else{
+        } else {
             $force_subscribe_info = $this->force_subscribe_info = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
             //\Log::info(':'.($this->uid).'force_subs1:'.json_encode($force_subscribe_info));
         }
-        if(!$force_subscribe_info){
+        if (!$force_subscribe_info) {
             return false;
         }
         $force_sub_user_by_openid = ForceSubscribeUserIService::getForceSubscribeByUidOpenid($this->uid);
-        if($force_sub_user_by_openid){
+        if ($force_sub_user_by_openid) {
             $force_subscribe_info = $force_sub_user_by_openid;
             //\Log::info('force_subs:'.json_encode($force_subscribe_info));
         }
         //\Log::info('force_subscribe_:'.json_encode($force_subscribe_info));
         //\Log::info('distribution_channel_id:'.$this->distribution_channel_id);
-        if($force_subscribe_info->subscribe_time &&
-            (time()-strtotime($force_subscribe_info->subscribe_time) >=3*86400)
+        if ($force_subscribe_info->subscribe_time &&
+            (time() - strtotime($force_subscribe_info->subscribe_time) >= 3 * 86400)
             && !OrderService::isPaidUserByOpenid($force_subscribe_info->openid) &&
             //!AdvertiseUserQueueService::getUserAdvertise($this->uid) &&
-            in_array($this->distribution_channel_id,explode(',',env('SHARE_OPEN_SITE')))
-        ){
+            in_array($this->distribution_channel_id, explode(',', env('SHARE_OPEN_SITE')))
+        ) {
             return true;
         }
         return false;
     }
 
     //CPC广告的优化逻辑
-    private function cpcAd($openid){
+    private function cpcAd($openid)
+    {
 
         if (in_array($this->uid, explode(',', env('TEST_CPC_UID')))) {
             return true;
         }
         //if(in_array($this->distribution_channel_id,[2,5,8,14,123,146,148,155,160,196,202,211,255,256,266,271,273,318,691,695,722,4025,4053,4174,4236,4237,4241,4334,4364,4426,4427,4487,4488,4593,4742,4889,4891,5204])){
-        $cpc_status = Redis::hget('channel:setting:'.$this->distribution_channel_id,'cpc_status');
-        if(is_null($cpc_status) || $cpc_status == 1){
+        $cpc_status = Redis::hget('channel:setting:' . $this->distribution_channel_id, 'cpc_status');
+        if (is_null($cpc_status) || $cpc_status == 1) {
             $cookie_ad_status = Cookie::get('cpc_ad_status');
-            if($cookie_ad_status) return $cookie_ad_status == 'show';
+            if ($cookie_ad_status) return $cookie_ad_status == 'show';
             //$property = UserDivisionCpcPropertyService::userLevel($openid);
             /*if(UserService::isCpcUser($this->uid)){
                 Cookie::queue('cpc_ad_status', 'show');
                 return true;
             }*/
-            if($this->property == 'none'){
+            if ($this->property == 'none') {
                 Cookie::queue('cpc_ad_status', 'show');
                 return true;
             }
@@ -626,11 +627,12 @@ class WelcomeController extends BaseController
         return false;
     }
 
-    private function pddAd(){
-        if($this->isPddAdSites()){
+    private function pddAd()
+    {
+        if ($this->isPddAdSites()) {
             return [
-                'banner'=>'https://cdn-novel.iycdm.com/h5/20190531/banner.jpg',
-                'url'=>'https://m.ycsd.cn/reader/9F69C5F384552E71/663249E009CA5AC0?u=13002705&isLogin=1'
+                'banner' => 'https://cdn-novel.iycdm.com/h5/20190531/banner.jpg',
+                'url' => 'https://m.ycsd.cn/reader/9F69C5F384552E71/663249E009CA5AC0?u=13002705&isLogin=1'
             ];
         }
         return '';
@@ -638,14 +640,15 @@ class WelcomeController extends BaseController
 
     private function isPddAdSites()
     {
-        return in_array($this->distribution_channel_id,[2,123,146,155,211,256,691,695,722,4025,4053,4174,4237,4241,4334,4364,4426,4427,4487,4593,4889,4891,5611]);
+        return in_array($this->distribution_channel_id, [2, 123, 146, 155, 211, 256, 691, 695, 722, 4025, 4053, 4174, 4237, 4241, 4334, 4364, 4426, 4427, 4487, 4593, 4889, 4891, 5611]);
     }
 
 
-    private function isMiWan(){
+    private function isMiWan()
+    {
         $miwan_channel_ids = redisEnv('MIWAN_CHANNEL_ID');
-        if(!$miwan_channel_ids) return false;
-        return in_array($this->distribution_channel_id,explode(',',$miwan_channel_ids));
+        if (!$miwan_channel_ids) return false;
+        return in_array($this->distribution_channel_id, explode(',', $miwan_channel_ids));
     }
 
     /**
@@ -657,7 +660,7 @@ class WelcomeController extends BaseController
         if ($setting && $setting->customer_img_url) {
             $customer_service = $setting->customer_img_url;
         } else {
-            $customer_service = env('KE_FU_QRCODE','https://cdn-novel.iycdm.com/static/img/kefu20190319.jpg');
+            $customer_service = env('KE_FU_QRCODE', 'https://cdn-novel.iycdm.com/static/img/kefu20190319.jpg');
             //$customer_service = 'https://cdn-novel.iycdm.com/static/img/kefu20190330.jpg';
         }
         return $customer_service;
@@ -1058,15 +1061,15 @@ class WelcomeController extends BaseController
             //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
             //渠道不符合
             if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img,'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
             }
             //活动未开始
             if (time() < strtotime($activity_info->start_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
             //活动结束
             if (time() > strtotime($activity_info->end_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
 
             if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
@@ -1080,10 +1083,10 @@ class WelcomeController extends BaseController
                     'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
                 ];
                 $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
-                return view('pay.order.longactivitysixtyeight', ['url' => $url, 'img'=>$img, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => $url, 'img' => $img, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
         }
-        return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+        return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
     }
 
     public function channelActivityFortyEight(Request $request)
@@ -1103,15 +1106,15 @@ class WelcomeController extends BaseController
             //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
             //渠道不符合
             if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img,'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
             }
             //活动未开始
             if (time() < strtotime($activity_info->start_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
             //活动结束
             if (time() > strtotime($activity_info->end_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
 
             if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
@@ -1125,10 +1128,10 @@ class WelcomeController extends BaseController
                     'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
                 ];
                 $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
-                return view('pay.order.longactivitysixtyeight', ['url' => $url, 'img'=>$img, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => $url, 'img' => $img, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
         }
-        return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
+        return view('pay.order.longactivitysixtyeight', ['url' => '###', 'img' => $img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
     }
 
     public function channelNewUserActivity(Request $request)
@@ -1141,7 +1144,7 @@ class WelcomeController extends BaseController
         $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
         $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
 
-        if ($activity_info && $activity_info->product_id){
+        if ($activity_info && $activity_info->product_id) {
             $activity_id = $activity_info->id;
             $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
             $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
@@ -1149,18 +1152,18 @@ class WelcomeController extends BaseController
             Redis::hincrby($pv_key, date('Y-m-d'), 1);
             //活动未开始
             if (time() < strtotime($activity_info->start_time)) {
-                return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => substr($activity_info->start_time,0,10), 'end_time' => substr($activity_info->end_time,0,10)]);
+                return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => substr($activity_info->start_time, 0, 10), 'end_time' => substr($activity_info->end_time, 0, 10)]);
             }
 
             //活动结束
             if (time() > strtotime($activity_info->end_time)) {
-                return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => substr($activity_info->start_time,0,10), 'end_time' => substr($activity_info->end_time,0,10)]);
+                return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => substr($activity_info->start_time, 0, 10), 'end_time' => substr($activity_info->end_time, 0, 10)]);
             }
 
-            $charge_count = Order::where('uid',$this->uid)->where('status','PAID')->count();
-            if($charge_count >0){
+            $charge_count = Order::where('uid', $this->uid)->where('status', 'PAID')->count();
+            if ($charge_count > 0) {
                 //不是新用户
-                return view('pay.order.newUserActivity', ['url' => '###', 'code' => -1, 'start_time' => substr($activity_info->start_time,0,10), 'end_time' => substr($activity_info->end_time,0,10)]);
+                return view('pay.order.newUserActivity', ['url' => '###', 'code' => -1, 'start_time' => substr($activity_info->start_time, 0, 10), 'end_time' => substr($activity_info->end_time, 0, 10)]);
             }
 
             $param = [
@@ -1172,9 +1175,9 @@ class WelcomeController extends BaseController
                 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
             ];
             $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
-            return view('pay.order.newUserActivity', ['url' => $url, 'code' => 0, 'start_time' => substr($activity_info->start_time,0,10), 'end_time' => substr($activity_info->end_time,0,10)]);
+            return view('pay.order.newUserActivity', ['url' => $url, 'code' => 0, 'start_time' => substr($activity_info->start_time, 0, 10), 'end_time' => substr($activity_info->end_time, 0, 10)]);
         }
-        return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d',time()-86400*2), 'end_time' => date('Y-m-d',time()-86400)]);
+        return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
     }
 
     /**
@@ -1520,7 +1523,7 @@ class WelcomeController extends BaseController
             return $url_info;
         }
         foreach ($product as $v) {
-            if(in_array($this->distribution_channel_id,[6917,6918,6939]) && $v->type == 'YEAR_ORDER'){
+            if (in_array($this->distribution_channel_id, [6917, 6918, 6939]) && $v->type == 'YEAR_ORDER') {
                 continue;
             }
             if ($is_access) {
@@ -2098,7 +2101,7 @@ class WelcomeController extends BaseController
         if ($least_charge_amount && $least_charge_amount >= 30) {
             $img = 'https://cdn-novel.iycdm.com/h5/activity-2019-03-20/bg50.jpg';
             $product_ids = 4806;
-        }else{
+        } else {
             $img = 'https://cdn-novel.iycdm.com/h5/activity-2019-03-20/bg23.jpg';
             $product_ids = 4805;
         }
@@ -2112,26 +2115,27 @@ class WelcomeController extends BaseController
             return view('pay.order.vernalEquinoxActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2, 'type' => $type, 'img' => $img]);
         }
 
-            $param = [
-                'uid' => $this->uid,
-                'distribution_channel_id' => $this->distribution_channel_id,
-                'product_id' => $product_ids,
-                'activity_id' => $activity_info->id,
-                'fromtype' => $from,
-                'pay_redirect_url' => $redirect_url,
-                'limit' => 100,
-            ];
-            $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
+        $param = [
+            'uid' => $this->uid,
+            'distribution_channel_id' => $this->distribution_channel_id,
+            'product_id' => $product_ids,
+            'activity_id' => $activity_info->id,
+            'fromtype' => $from,
+            'pay_redirect_url' => $redirect_url,
+            'limit' => 100,
+        ];
+        $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
         return view('pay.order.vernalEquinoxActivity', ['url' => $url, 'code' => 0, 'type' => $type, 'img' => $img]);
     }
 
 
-    private function userPproperty(){
-        if($this->property == 'undefined'){
-            if($this->user && time()-strtotime($this->user->created_at) >= 3*66400){
+    private function userPproperty()
+    {
+        if ($this->property == 'undefined') {
+            if ($this->user && time() - strtotime($this->user->created_at) >= 3 * 66400) {
                 $info = UserDivisionCpcPropertyService::calculateUserPropertyV2($this->uid);
-                if($info && $info['property'] != 'undefined'){
-                    UserDivisionCpcPropertyService::updateV2($info['openid'],$info['property']);
+                if ($info && $info['property'] != 'undefined') {
+                    UserDivisionCpcPropertyService::updateV2($info['openid'], $info['property']);
                 }
             }
         }
@@ -2153,48 +2157,49 @@ class WelcomeController extends BaseController
         }*/
     }
 
-    private function guidePersonalAccount($openid){
+    private function guidePersonalAccount($openid)
+    {
         //weidian
-        $other_crm_config = Redis::hmget('channel:setting:'.$this->distribution_channel_id,['crm_status','crm_link']);
-        $crm_config = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
+        $other_crm_config = Redis::hmget('channel:setting:' . $this->distribution_channel_id, ['crm_status', 'crm_link']);
+        $crm_config = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES', 'ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE', 'OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
 
-        $out_status = Redis::SISMEMBER('crm:out_channel_sites',$this->distribution_channel_id);
+        $out_status = Redis::SISMEMBER('crm:out_channel_sites', $this->distribution_channel_id);
 
-        if(empty($other_crm_config[0]) && empty($other_crm_config[1]) && empty($crm_config[0]) && empty($crm_config[1]) && empty($out_status)){
+        if (empty($other_crm_config[0]) && empty($other_crm_config[1]) && empty($crm_config[0]) && empty($crm_config[1]) && empty($out_status)) {
             return '';
         }
 
         //Log::info('guidePersonalAccount1111111111111111111111');
         $get_info = UserBindHkWelfareService::isHasGet($this->uid);
-        if($get_info)   return '';
+        if ($get_info) return '';
         //Log::info('guidePersonalAccount2222222222222222222222');
         $charge = false;
-        if(in_array($this->property, ['medium','high'])){
+        if (in_array($this->property, ['medium', 'high'])) {
             $charge = true;
-        }else{
-           if($this->property == 'undefined' && OrderService::getChargeNum($this->uid) >=10){
-               $charge = true;
-           }
+        } else {
+            if ($this->property == 'undefined' && OrderService::getChargeNum($this->uid) >= 10) {
+                $charge = true;
+            }
         }
 
-        if($this->distribution_channel_id == 6687){
+        if ($this->distribution_channel_id == 6687) {
             $charge = true;
         }
 
-        if(!$charge) return '';
+        if (!$charge) return '';
         //其他渠道自己导粉
-        if($other_crm_config[0] && $other_crm_config[1]){
-            if($charge)
-                return ['title'=>'点击领取200书币>>','link'=>$other_crm_config[1]];
+        if ($other_crm_config[0] && $other_crm_config[1]) {
+            if ($charge)
+                return ['title' => '点击领取200书币>>', 'link' => $other_crm_config[1]];
             return '';
         }
         //站外导粉
-        if($out_status){
-            if(!$charge) return '';
-            if(empty($crm_config[2])){
+        if ($out_status) {
+            if (!$charge) return '';
+            if (empty($crm_config[2])) {
                 return '';
             }
-            $filter_city = ['长沙','深圳','杭州'];
+            $filter_city = ['长沙', '深圳', '杭州'];
             $ip2region = new Ip2Region();
             if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
                 $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
@@ -2202,53 +2207,56 @@ class WelcomeController extends BaseController
                 $ip = get_client_ip();
             }
             $info = [];
-            try{
+            try {
                 $info = $ip2region->btreeSearch($ip);
-            }catch (\Exception $e){}
+            } catch (\Exception $e) {
+            }
 
-            if(!$info || !isset($info['region'])) return '';
-            $region = explode('|',$info['region']);
-            $city = isset($region[3])? $region[3]:'';
-            if(in_array($city,$filter_city)){
+            if (!$info || !isset($info['region'])) return '';
+            $region = explode('|', $info['region']);
+            $city = isset($region[3]) ? $region[3] : '';
+            if (in_array($city, $filter_city)) {
                 return '';
             }
             $count = ChapterOrderService::getRecentChapterOrderCount($this->uid);
-            if ($count<50) {
+            if ($count < 50) {
                 return '';
             }
             Cookie::queue('is_force_out_guide', 1);
             //Redis::hset('crm:out_guide_exposure_user',$openid,$this->uid);
-            return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid.'&fee=500'];
+            return ['title' => '您有500书币待领取>>', 'link' => '/guidestrem?uid=' . $this->uid . '&fee=500'];
 
         }
         //Log::info('guidePersonalAccount33333333333333333');
-        if(empty($crm_config[0]) || empty($crm_config[1])) return '';
+        if (empty($crm_config[0]) || empty($crm_config[1])) return '';
         //Log::info('guidePersonalAccount4444444444444444');
-        if(!in_array($this->distribution_channel_id,explode(',',$crm_config[0]))){
+        if (!in_array($this->distribution_channel_id, explode(',', $crm_config[0]))) {
             return '';
         }
         //Log::info('guidePersonalAccount555555555555555');
-        if($charge){
-            return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid.'&fee=500'];
+        if ($charge) {
+            return ['title' => '您有500书币待领取>>', 'link' => '/guidestrem?uid=' . $this->uid . '&fee=500'];
         }
         return '';
     }
 
-    private function setIsPaid(){
-        $charge = Order::where('uid',$this->uid)
-            ->where('status','PAID')
+    private function setIsPaid()
+    {
+        $charge = Order::where('uid', $this->uid)
+            ->where('status', 'PAID')
             ->select('id')
             ->first();
-        if($charge){
+        if ($charge) {
             Cookie::queue('is_paid', 1);
             $this->is_paid = true;
-        }else{
+        } else {
             Cookie::queue('is_paid', 0);
             $this->is_paid = false;
         }
     }
 
-    private function setProperty($openid){
+    private function setProperty($openid)
+    {
         $property = UserDivisionCpcPropertyService::userLevelV2($openid);
         $this->property = $property;
     }
@@ -2257,70 +2265,78 @@ class WelcomeController extends BaseController
     private function recordUA($ua)
     {
         $is_ua_open = RedisEnv('ua_open');
-        if($is_ua_open && $ua)//开启
+        if ($is_ua_open && $ua)//开启
         {
             //判断是否已经统计
-            $has_got = Redis::hget('book_read:'.$this->uid,'ua');
-            if(!$has_got)
-            {
-                try{
-                    Redis::hset('book_read:'.$this->uid,'ua',1);
-                    UserService::recordUA($ua,$this->uid);
-                }catch (\Exception $e) {
+            $has_got = Redis::hget('book_read:' . $this->uid, 'ua');
+            if (!$has_got) {
+                try {
+                    Redis::hset('book_read:' . $this->uid, 'ua', 1);
+                    UserService::recordUA($ua, $this->uid);
+                } catch (\Exception $e) {
 
                 }
             }
         }
     }
-    private function monthOrderInfo($openid){
+
+    private function monthOrderInfo($openid)
+    {
         $property = $this->property;
         if (!$property) return '';
-        if(in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))){
-            $info = DataAnalysisSelectUserService::getByUidAndType($this->uid,'MONTH_V2');
-            if($info){
-                if($info->attach == 'show'){
+        if (in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))) {
+            $info = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'MONTH_V2');
+            if ($info) {
+                if ($info->attach == 'show') {
                     return [
-                        'price'=>'30元',
+                        'price' => '30元',
                         'text' => '30元包月 全站万本精彩小说免费看',
-                        'link'=> generateMonthOrderUrl($this->uid)
-                        //'link'=> '/rmonthpay'
+                        'link' => generateMonthOrderUrl($this->uid)
+                    ];
+                }
+                if ($info->attach == 'week-show') {
+                    return [
+                        'price' => '7元',
+                        'text' => '7元包周 全站万本精彩小说免费看',
+                        'link' => generateMonthOrderUrlV2($this->uid, env('MONTH_WEEK_ORDER_PLAN_ID'), _getIp())
                     ];
                 }
                 return '';
             }
         }
         if (in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))
-            && in_array($property, ['none','low', 'medium'])
+            && in_array($property, ['none', 'low', 'medium'])
         ) {
-            if(!UserMonthService::isSignMonth($openid)){
+            if (!UserMonthService::isSignMonth($openid)) {
                 $start_time = redisEnv('MONTH_TEMPLATE_COMPARE_START_TIME', 0);
-                if($start_time){
-                    if (strtotime($this->user->created_at) < $start_time) {
-                         return [
-                            'price'=>'30元',
+                if (!$start_time || (strtotime($this->user->created_at) < $start_time)) {
+                    if ($property == 'low') {
+                        return [
+                            'price' => '7元',
+                            'text' => '7元包周 全站万本精彩小说免费看',
+                            'link' => generateMonthOrderUrlV2($this->uid, env('MONTH_WEEK_ORDER_PLAN_ID'), _getIp())
+                        ];
+                    } else {
+                        return [
+                            'price' => '30元',
                             'text' => '30元包月 全站万本精彩小说免费看',
-                            'link'=> generateMonthOrderUrl($this->uid)
-                            //'link'=> '/rmonthpay'
+                            'link' => generateMonthOrderUrl($this->uid)
                         ];
-                    }else{
-                        $attach = $this->uid %2 == 0 ? 'show':'hide';
-                        if($attach == 'show'){
-                            return [
-                                'price'=>'30元',
-                                'text' => '30元包月 全站万本精彩小说免费看',
-                                'link'=> generateMonthOrderUrl($this->uid)
-                                //'link'=> '/rmonthpay'
-                            ];
-                        }else{
-                            return '';
-                        }
                     }
-                }else{
+                }
+                $attach = $this->uid % 2 == 0 ? 'show' : 'hide';
+                if ($attach == 'hide') return '';
+                if ($property == 'low') {
                     return [
-                        'price'=>'30元',
+                        'price' => '7元',
+                        'text' => '7元包周 全站万本精彩小说免费看',
+                        'link' => generateMonthOrderUrlV2($this->uid, env('MONTH_WEEK_ORDER_PLAN_ID'), _getIp())
+                    ];
+                } else {
+                    return [
+                        'price' => '30元',
                         'text' => '30元包月 全站万本精彩小说免费看',
-                        'link'=> generateMonthOrderUrl($this->uid)
-                        //'link'=> '/rmonthpay'
+                        'link' => generateMonthOrderUrl($this->uid)
                     ];
                 }
 
@@ -2329,18 +2345,19 @@ class WelcomeController extends BaseController
         return '';
     }
 
-    private function isXiyueUser(){
+    private function isXiyueUser()
+    {
         //$result = DB::table('xiyue_zsy_users')->where('uid',$this->uid)->select('id')->first();
-        if($this->distribution_channel_id == 6985){
+        if ($this->distribution_channel_id == 6985) {
             return [
-                'is_xiyue_user'=>1,
-                'debug'=>(int)env('XI_YUE_SHARE_DEBUG',0),
-                'xiyue_index_page'=>env('XIYUE_HOST').'/',
-                'xiyue_pay_page'=>env('XIYUE_HOST').'/',
-                'xiyue_pay_unfocus_img'=>'https://cdn-novel.iycdm.com/h5/xiyue/xiyue_pay_unfocus_img.png',
-                'xiyue_pay_focus_img'=>'https://cdn-novel.iycdm.com/h5/xiyue/xiyue_pay_focus_img.png',
-                'openid'=>$this->user->openid,
-                'register_url'=>'https://sitel12x4nj487yevw0m.leyuee.com/xiyue/sharelink'
+                'is_xiyue_user' => 1,
+                'debug' => (int)env('XI_YUE_SHARE_DEBUG', 0),
+                'xiyue_index_page' => env('XIYUE_HOST') . '/',
+                'xiyue_pay_page' => env('XIYUE_HOST') . '/',
+                'xiyue_pay_unfocus_img' => 'https://cdn-novel.iycdm.com/h5/xiyue/xiyue_pay_unfocus_img.png',
+                'xiyue_pay_focus_img' => 'https://cdn-novel.iycdm.com/h5/xiyue/xiyue_pay_focus_img.png',
+                'openid' => $this->user->openid,
+                'register_url' => 'https://sitel12x4nj487yevw0m.leyuee.com/xiyue/sharelink'
             ];
         }
         return "";

+ 12 - 0
app/Libs/Helpers.php

@@ -630,3 +630,15 @@ function generateMonthOrderUrl($user_id){
     $url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign','return_web'));
     return $url;
 }
+
+function generateMonthOrderUrlV2($user_id,$plan_id,$ip){
+    $app_id = env('MONTH_ORDER_APPID');
+    $app_secret = env('MONTH_ORDER_APP_SECRET');
+    $key = env('MONTH_ORDER_KEY');
+    $sign = _sign(compact('app_id','app_secret','plan_id','user_id','ip'),$key.$key);
+    $sign = strtoupper($sign);
+    $return_web = 1;
+    $url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign','return_web'));
+    return $url;
+}
+

+ 29 - 0
app/Modules/Subscribe/Services/YearOrderService.php

@@ -82,6 +82,35 @@ class YearOrderService
         }
     }
 
+    static function save_vip_order_daynum($data)
+    {
+        $insert_data = array();
+        $insert_data['uid'] = $data['uid'];
+        $insert_data['begin_time'] = date('Y-m-d H:i:s');
+        $insert_data['end_time'] = date('Y-m-d H:i:s', time()+$data['day_num']*86400);
+        $insert_data['distribution_channel_id'] = $data['distribution_channel_id'];
+        $insert_data['fee'] = $data['fee'];
+        $insert_data['send_order_id'] = $data['send_order_id'];
+        $old = YearOrder::where('uid', $data['uid'])->select('id', 'uid', 'u', 'begin_time', 'end_time', 'fee')->first();
+        if ($old) {
+            //如果包过年
+            if (strtotime($old->end_time) > time()) {
+                //旧的包年没过期
+                $old->end_time = date('Y-m-d H:i:s', strtotime($old->end_time) + 86400 * $data['day_num']);
+                $old->fee = $old->fee + $data['fee'];
+                $old->save();
+            } else {
+                //旧的包年过期了
+                $old->end_time = date('Y-m-d H:i:s', $insert_data['end_time']);
+                $old->fee = $old->fee + $data['fee'];
+                $old->save();
+            }
+            return $old;
+        } else {
+            return YearOrder::create($insert_data);
+        }
+    }
+
     static function foreverFree($data)
     {
         $insert_data = array();

+ 1 - 1
app/Modules/User/Models/UserMonthOrder.php

@@ -8,5 +8,5 @@ class UserMonthOrder extends Model
 {
     protected $table = 'user_month_order';
 
-    protected $fillable = ['uid','plan_id','total_fee','trade_no','out_trade_no'];
+    protected $fillable = ['uid','plan_id','total_fee','trade_no','out_trade_no','type'];
 }

+ 1 - 1
app/Modules/User/Models/UserMonthSign.php

@@ -7,5 +7,5 @@ use Illuminate\Database\Eloquent\Model;
 class UserMonthSign extends Model
 {
     protected $table = 'user_month_sign';
-    protected $fillable = ['uid','plan_id','change_type','openid'];
+    protected $fillable = ['uid','plan_id','change_type','openid','type'];
 }

+ 4 - 2
app/Modules/User/Services/UserMonthService.php

@@ -14,7 +14,7 @@ use GuzzleHttp\Client;
 
 class UserMonthService
 {
-    public static function createSign(int $uid, int $plan_id, string $change_type,string $openid)
+    public static function createSign(int $uid, int $plan_id, string $change_type,string $openid,string $type)
     {
         $model = new UserMonthSign();
         $info = $model->where('uid', $uid)->where('plan_id', $plan_id)->first();
@@ -26,6 +26,7 @@ class UserMonthService
             $model->plan_id = $plan_id;
             $model->change_type = $change_type;
             $model->openid = $openid;
+            $model->type = $type;
             $model->save();
         }
         return;
@@ -41,7 +42,7 @@ class UserMonthService
         return $model->where('uid',$uid)->orderBy('id','desc')->first();
     }
 
-    public static function createLOrder(int $uid, int $plan_id, int $total_fee, string $trade_no,string $out_trade_no)
+    public static function createLOrder(int $uid, int $plan_id, int $total_fee, string $trade_no,string $out_trade_no,string $type)
     {
         $model = new UserMonthOrder();
         $model->uid = $uid;
@@ -49,6 +50,7 @@ class UserMonthService
         $model->total_fee = $total_fee;
         $model->trade_no = $trade_no;
         $model->out_trade_no = $out_trade_no;
+        $model->type = $type;
         $model->save();
         return;
     }