|  | @@ -78,32 +78,32 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //fromtype
 | 
	
		
			
				|  |  |          $from = $request->get('fromtype');
 | 
	
		
			
				|  |  | -        if(!$from){
 | 
	
		
			
				|  |  | -            $from =Cookie::get('from') ? Cookie::get('from') :'main';
 | 
	
		
			
				|  |  | +        if (!$from) {
 | 
	
		
			
				|  |  | +            $from = Cookie::get('from') ? Cookie::get('from') : 'main';
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          $channel_activities_flag = $this->judgeChannelActivity($user);
 | 
	
		
			
				|  |  |          //最近阅读页面 推荐
 | 
	
		
			
				|  |  | -        $latest_read_rec_books = $this->latest_read_rec_books($channel,$user->sex);
 | 
	
		
			
				|  |  | +        $latest_read_rec_books = $this->latest_read_rec_books($channel, $user->sex);
 | 
	
		
			
				|  |  |          //广告样本
 | 
	
		
			
				|  |  | -        $ad_status = env('AD_STATUS',1);
 | 
	
		
			
				|  |  | +        $ad_status = env('AD_STATUS', 1);
 | 
	
		
			
				|  |  |          $adTargetId = false;
 | 
	
		
			
				|  |  | -        if($ad_status){
 | 
	
		
			
				|  |  | +        if ($ad_status) {
 | 
	
		
			
				|  |  |              $adTargetId = $this->isUserInAdSample();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //广告frame
 | 
	
		
			
				|  |  | -        $is_show_ad_frame_setting = env('IS_SHOW_AD_FRAME_SETTING','123');
 | 
	
		
			
				|  |  | +        $is_show_ad_frame_setting = env('IS_SHOW_AD_FRAME_SETTING', '123');
 | 
	
		
			
				|  |  |          $is_show_ad_frame = false;
 | 
	
		
			
				|  |  | -        if($is_show_ad_frame_setting && in_array($this->distribution_channel_id,explode(',',$is_show_ad_frame_setting))){
 | 
	
		
			
				|  |  | +        if ($is_show_ad_frame_setting && in_array($this->distribution_channel_id, explode(',', $is_show_ad_frame_setting))) {
 | 
	
		
			
				|  |  |              $is_show_ad_frame = true;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //标题不显示书名
 | 
	
		
			
				|  |  |          $show_title_in_reader = false;
 | 
	
		
			
				|  |  |          $show_title_in_reader_setting = env('SHOW_TITLE_IN_READER_SETTING');
 | 
	
		
			
				|  |  | -        if($show_title_in_reader_setting && in_array($this->distribution_channel_id,explode(',',$show_title_in_reader_setting))){
 | 
	
		
			
				|  |  | +        if ($show_title_in_reader_setting && in_array($this->distribution_channel_id, explode(',', $show_title_in_reader_setting))) {
 | 
	
		
			
				|  |  |              $show_title_in_reader = true;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        $hide_chapter_channels = explode(',',env('HIDE_CHAPTER_CONSUME_CHANNEL'));
 | 
	
		
			
				|  |  | -        $is_hide_chapter_consume = in_array($this->distribution_channel_id,$hide_chapter_channels) ? 1 : 0;
 | 
	
		
			
				|  |  | +        $hide_chapter_channels = explode(',', env('HIDE_CHAPTER_CONSUME_CHANNEL'));
 | 
	
		
			
				|  |  | +        $is_hide_chapter_consume = in_array($this->distribution_channel_id, $hide_chapter_channels) ? 1 : 0;
 | 
	
		
			
				|  |  |          //广告
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          $options = json_encode([
 | 
	
	
		
			
				|  | @@ -129,41 +129,42 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |              'isOld' => $isOld,
 | 
	
		
			
				|  |  |              'sex' => $user ? $user->sex : 0,
 | 
	
		
			
				|  |  |              'latest_read_rec_books' => $latest_read_rec_books,
 | 
	
		
			
				|  |  | -            'fission'=>$this->fission(),//裂变
 | 
	
		
			
				|  |  | -            'channel_activities'=>$channel_activities_flag,
 | 
	
		
			
				|  |  | -            'adTargetId'=>$adTargetId,
 | 
	
		
			
				|  |  | -            'ad_type'=>'1',
 | 
	
		
			
				|  |  | -            'is_show_ad_frame'=>$is_show_ad_frame,
 | 
	
		
			
				|  |  | -            'show_title_in_reader'=>$show_title_in_reader,
 | 
	
		
			
				|  |  | -            'is_hide_chapter_consume'=>$is_hide_chapter_consume
 | 
	
		
			
				|  |  | +            'fission' => $this->fission(),//裂变
 | 
	
		
			
				|  |  | +            'channel_activities' => $channel_activities_flag,
 | 
	
		
			
				|  |  | +            'adTargetId' => $adTargetId,
 | 
	
		
			
				|  |  | +            'ad_type' => '1',
 | 
	
		
			
				|  |  | +            'is_show_ad_frame' => $is_show_ad_frame,
 | 
	
		
			
				|  |  | +            'show_title_in_reader' => $show_title_in_reader,
 | 
	
		
			
				|  |  | +            'is_hide_chapter_consume' => $is_hide_chapter_consume
 | 
	
		
			
				|  |  |          ]);
 | 
	
		
			
				|  |  | -        if($this->uid == env('SPECIAL_USER_LOG',2)){
 | 
	
		
			
				|  |  | +        if ($this->uid == env('SPECIAL_USER_LOG', 2)) {
 | 
	
		
			
				|  |  |              myLog('special')->info('welcome --------------------------');
 | 
	
		
			
				|  |  | -            myLog('special')->info(json_decode($options,1));
 | 
	
		
			
				|  |  | +            myLog('special')->info(json_decode($options, 1));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return view('wap.index', compact('options', 'title'));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private function judgeChannelActivity($user_info) {
 | 
	
		
			
				|  |  | +    private function judgeChannelActivity($user_info)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  |          //新渠道送书币活动
 | 
	
		
			
				|  |  |          $channel_activities_hash = [
 | 
	
		
			
				|  |  |              500 => 'https://cdn-novel.iycdm.com/h5/five_hundred_coin.png',
 | 
	
		
			
				|  |  |              1000 => 'https://cdn-novel.iycdm.com/h5/thoudends_coin.png'
 | 
	
		
			
				|  |  |          ];
 | 
	
		
			
				|  |  |          $channel_activities_flag = [
 | 
	
		
			
				|  |  | -            'shall_reward'=>0,
 | 
	
		
			
				|  |  | -            'amount'=>'',
 | 
	
		
			
				|  |  | -            'image'=>''
 | 
	
		
			
				|  |  | +            'shall_reward' => 0,
 | 
	
		
			
				|  |  | +            'amount' => '',
 | 
	
		
			
				|  |  | +            'image' => ''
 | 
	
		
			
				|  |  |          ];
 | 
	
		
			
				|  |  | -        try{
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  |              $channel_activities = ChannelActivitiesService::getValidActivity((int)$this->distribution_channel_id);
 | 
	
		
			
				|  |  | -            if($channel_activities) {
 | 
	
		
			
				|  |  | -                if(time() - strtotime($user_info->created_at->format('Y-m-d H:i:s')) <= 5*60) { //对在5分钟之内新注册的用户进行打赏
 | 
	
		
			
				|  |  | +            if ($channel_activities) {
 | 
	
		
			
				|  |  | +                if (time() - strtotime($user_info->created_at->format('Y-m-d H:i:s')) <= 5 * 60) { //对在5分钟之内新注册的用户进行打赏
 | 
	
		
			
				|  |  |                      $reward_info = DB::table('fission')->where([
 | 
	
		
			
				|  |  | -                        ['type','=',2],['uid','=',$this->uid]
 | 
	
		
			
				|  |  | +                        ['type', '=', 2], ['uid', '=', $this->uid]
 | 
	
		
			
				|  |  |                      ])->first();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    if(!$reward_info) { //未被打赏的新用户
 | 
	
		
			
				|  |  | +                    if (!$reward_info) { //未被打赏的新用户
 | 
	
		
			
				|  |  |                          //$user_info = UserService::getById($this->uid);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          DB::beginTransaction();
 | 
	
	
		
			
				|  | @@ -184,7 +185,7 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |                              $channel_activities_flag['amount'] = $channel_activities->amount;
 | 
	
		
			
				|  |  |                              $channel_activities_flag['image'] = $channel_activities_hash[$channel_activities->amount];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                            $force_sub_info = DB::table('force_subscribe_users')->where([['uid','=', $this->uid],['is_subscribed','=',1]])->first();
 | 
	
		
			
				|  |  | +                            $force_sub_info = DB::table('force_subscribe_users')->where([['uid', '=', $this->uid], ['is_subscribed', '=', 1]])->first();
 | 
	
		
			
				|  |  |                              if ($force_sub_info) {
 | 
	
		
			
				|  |  |                                  $bookUrl = env('PROTOCOL') . '://site' . encodeDistributionChannelId($this->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/';
 | 
	
		
			
				|  |  |                                  $res['openid'] = $force_sub_info->openid;
 | 
	
	
		
			
				|  | @@ -206,24 +207,27 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        }catch (\Exception $e) {
 | 
	
		
			
				|  |  | -            \Log::error('channel activities error:channel_id:'.($this->distribution_channel_id).'uid:'.($this->uid).':'.($e->getMessage()));
 | 
	
		
			
				|  |  | +        } catch (\Exception $e) {
 | 
	
		
			
				|  |  | +            \Log::error('channel activities error:channel_id:' . ($this->distribution_channel_id) . 'uid:' . ($this->uid) . ':' . ($e->getMessage()));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return $channel_activities_flag;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private function luckyUserForeverFree(){
 | 
	
		
			
				|  |  | +    private function luckyUserForeverFree()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  |          $lucky_user = 0;
 | 
	
		
			
				|  |  |          $lucky_user_img = '';
 | 
	
		
			
				|  |  | -        if(!in_array($this->distribution_channel_id,[2,14,211])) return compact('lucky_user','lucky_user_img');
 | 
	
		
			
				|  |  | -        try{
 | 
	
		
			
				|  |  | -            $lucky_user = Redis::SISMEMBER('luckyYearOrderUser',$this->uid);
 | 
	
		
			
				|  |  | -        }catch (\Exception $e){}
 | 
	
		
			
				|  |  | +        if (!in_array($this->distribution_channel_id, [2, 14, 211])) return compact('lucky_user', 'lucky_user_img');
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            $lucky_user = Redis::SISMEMBER('luckyYearOrderUser', $this->uid);
 | 
	
		
			
				|  |  | +        } catch (\Exception $e) {
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          $lucky_user && $luckuser_img = 'https://cdn-novel.iycdm.com//h5/lucky.jpg';
 | 
	
		
			
				|  |  | -        return compact('lucky_user','lucky_user_img');
 | 
	
		
			
				|  |  | +        return compact('lucky_user', 'lucky_user_img');
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private function latest_read_rec_books($channel,$sex){
 | 
	
		
			
				|  |  | +    private function latest_read_rec_books($channel, $sex)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  |          $latest_read_rec_books = [];
 | 
	
		
			
				|  |  |          if ($channel->is_yq_move)//云栖迁移过来的站点
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -241,6 +245,7 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return $latest_read_rec_books;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 获取123底部强管banner
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -254,23 +259,25 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |       * 裂变
 | 
	
		
			
				|  |  |       * @return int
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    private function fission(){
 | 
	
		
			
				|  |  | +    private function fission()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  |          $fission_send_order_id = env('FISSION_SEND_ORDER_ID');
 | 
	
		
			
				|  |  | -        if($fission_send_order_id && $this->send_order_id && in_array($this->send_order_id,explode(',',$fission_send_order_id))){
 | 
	
		
			
				|  |  | -            $is_exist = DB::table('fission')->where('uid',$this->uid)->select('uid')->first();
 | 
	
		
			
				|  |  | -            if(!$is_exist){
 | 
	
		
			
				|  |  | +        if ($fission_send_order_id && $this->send_order_id && in_array($this->send_order_id, explode(',', $fission_send_order_id))) {
 | 
	
		
			
				|  |  | +            $is_exist = DB::table('fission')->where('uid', $this->uid)->select('uid')->first();
 | 
	
		
			
				|  |  | +            if (!$is_exist) {
 | 
	
		
			
				|  |  |                  DB::table('fission')->insert([
 | 
	
		
			
				|  |  | -                    'uid'=>$this->uid,
 | 
	
		
			
				|  |  | -                    'prize'=>200,
 | 
	
		
			
				|  |  | -                    'created_at'=>date('Y-m-d H:i:s'),
 | 
	
		
			
				|  |  | -                    'updated_at'=>date('Y-m-d H:i:s')
 | 
	
		
			
				|  |  | +                    'uid' => $this->uid,
 | 
	
		
			
				|  |  | +                    'prize' => 200,
 | 
	
		
			
				|  |  | +                    'created_at' => date('Y-m-d H:i:s'),
 | 
	
		
			
				|  |  | +                    'updated_at' => date('Y-m-d H:i:s')
 | 
	
		
			
				|  |  |                  ]);
 | 
	
		
			
				|  |  | -                UserService::addBalance($this->uid,200,0,200);
 | 
	
		
			
				|  |  | +                UserService::addBalance($this->uid, 200, 0, 200);
 | 
	
		
			
				|  |  |                  return 1;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return 0;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 获取活动配置信息
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -443,11 +450,12 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //用户是否在广告样本中
 | 
	
		
			
				|  |  | -    private function isUserInAdSample(){
 | 
	
		
			
				|  |  | -        $res = DataAnalysisSelectUserService::getByUidAndType($this->uid,'AD');
 | 
	
		
			
				|  |  | -        if($res){
 | 
	
		
			
				|  |  | +    private function isUserInAdSample()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        $res = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'AD');
 | 
	
		
			
				|  |  | +        if ($res) {
 | 
	
		
			
				|  |  |              return true;
 | 
	
		
			
				|  |  | -        }else{
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  |              return false;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -678,7 +686,7 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |              Redis::hincrby($pv_key, date('Y-m-d'), 1);
 | 
	
		
			
				|  |  |              //渠道不符合
 | 
	
		
			
				|  |  |              if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
 | 
	
		
			
				|  |  | -                return view('pay.order.longactivitynine', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d',time()-86400*2), 'end_time' => date('Y-m-d',time()-86400)]);
 | 
	
		
			
				|  |  | +                return view('pay.order.longactivitynine', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //活动未开始
 | 
	
	
		
			
				|  | @@ -688,12 +696,12 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //活动结束
 | 
	
		
			
				|  |  |              if (time() > strtotime($activity_info->end_time)) {
 | 
	
		
			
				|  |  | -                return view('pay.order.longactivitynine', ['url' => '###', '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.longactivitynine', ['url' => '###', '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)]);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_info->id)->count();
 | 
	
		
			
				|  |  |              //参加过了
 | 
	
		
			
				|  |  |              if ($order) {
 | 
	
		
			
				|  |  | -                return view('pay.order.longactivitynine', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d',time()-86400*2), 'end_time' => date('Y-m-d',time()-86400)]);
 | 
	
		
			
				|  |  | +                return view('pay.order.longactivitynine', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time) && empty($order)) {
 | 
	
	
		
			
				|  | @@ -703,7 +711,7 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |                      in_array($this->distribution_channel_id, explode(',', $not_allow_paid_user_channel_id)) &&
 | 
	
		
			
				|  |  |                      Order::where('uid', $this->uid)->where('status', 'PAID')->first()
 | 
	
		
			
				|  |  |                  ) {
 | 
	
		
			
				|  |  | -                    return view('pay.order.longactivitynine', ['url' => '', 'code' => -4,'start_time'=>'', 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
 | 
	
		
			
				|  |  | +                    return view('pay.order.longactivitynine', ['url' => '', 'code' => -4, 'start_time' => '', 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  $param = [
 | 
	
		
			
				|  |  |                      'uid' => $this->uid,
 | 
	
	
		
			
				|  | @@ -715,10 +723,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.longactivitynine', ['url' => $url, '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.longactivitynine', ['url' => $url, '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.longactivitynine', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d',time()-86400*2), 'end_time' => date('Y-m-d',time()-86400)]);
 | 
	
		
			
				|  |  | +        return view('pay.order.longactivitynine', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public function channelActivitySixtyEight(Request $request)
 | 
	
	
		
			
				|  | @@ -737,15 +745,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' => '###', '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' => '###', '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' => '###', 'code' => -3, 'start_time' => date('Y-m-d',time()-86400*2), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
 | 
	
		
			
				|  |  | +                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', time() - 86400 * 2), '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' => '###', 'code' => -1, 'start_time' => date('Y-m-d',time()-86400*2), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
 | 
	
		
			
				|  |  | +                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), '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)) {
 | 
	
	
		
			
				|  | @@ -759,10 +767,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, '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, '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' => '###', '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' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -931,7 +939,7 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |          $is_get = 0;
 | 
	
		
			
				|  |  |          $discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->where('activity_id', $activity_id)->count();
 | 
	
		
			
				|  |  |          //$old_discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->where('activity_id', $old_year_activity_id)->count();
 | 
	
		
			
				|  |  | -        $old_discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->whereIn('activity_id', [643, 827,1104,1294])->count();
 | 
	
		
			
				|  |  | +        $old_discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->whereIn('activity_id', [643, 827, 1104, 1294])->count();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if ($discount_coupon) {
 | 
	
		
			
				|  |  |              $is_get = 1;
 | 
	
	
		
			
				|  | @@ -1431,8 +1439,11 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          $url_array = [];
 | 
	
		
			
				|  |  |          $time_diff = strtotime($activity_info->end_time) - time();
 | 
	
		
			
				|  |  | -        $day = 0;$hour = 0;$minute = 0;$second = 0;
 | 
	
		
			
				|  |  | -        if($time_diff>0){
 | 
	
		
			
				|  |  | +        $day = 0;
 | 
	
		
			
				|  |  | +        $hour = 0;
 | 
	
		
			
				|  |  | +        $minute = 0;
 | 
	
		
			
				|  |  | +        $second = 0;
 | 
	
		
			
				|  |  | +        if ($time_diff > 0) {
 | 
	
		
			
				|  |  |              $day = floor($time_diff / 86400);
 | 
	
		
			
				|  |  |              $hour = floor(($time_diff - $day * 86400) / 3600);
 | 
	
		
			
				|  |  |              $minute = floor(($time_diff - $day * 86400 - $hour * 3600) / 60);
 | 
	
	
		
			
				|  | @@ -1441,7 +1452,7 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          $product_id_array = explode(',', $activty_ids);
 | 
	
		
			
				|  |  | -        $product_infos = DB::table('products')->whereIn('id',$product_id_array)->select('id','price','given')->get();
 | 
	
		
			
				|  |  | +        $product_infos = DB::table('products')->whereIn('id', $product_id_array)->select('id', 'price', 'given')->get();
 | 
	
		
			
				|  |  |          foreach ($product_infos as $key => $v) {
 | 
	
		
			
				|  |  |              if ($user_charge_count >= 1 && $key == 0) {
 | 
	
		
			
				|  |  |                  continue;
 | 
	
	
		
			
				|  | @@ -1462,7 +1473,7 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            $url_array[] = ['url'=>$url,'price'=>(int)$v->price,'given'=>$v->given/100,'get'=>$v->price*100+$v->given];
 | 
	
		
			
				|  |  | +            $url_array[] = ['url' => $url, 'price' => (int)$v->price, 'given' => $v->given / 100, 'get' => $v->price * 100 + $v->given];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return view('pay.order.shoppingDayActivity', [
 | 
	
		
			
				|  |  |                  'url' => $url_array,
 | 
	
	
		
			
				|  | @@ -1470,12 +1481,13 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |                  'code' => $activity_status,
 | 
	
		
			
				|  |  |                  'time' => compact('day', 'hour', 'minute', 'second'),
 | 
	
		
			
				|  |  |                  'user_charge_count' => $user_charge_count,
 | 
	
		
			
				|  |  | -                'time_diff'=>$time_diff
 | 
	
		
			
				|  |  | +                'time_diff' => $time_diff
 | 
	
		
			
				|  |  |              ]
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public function thanksGivingDayActivity(Request $request){
 | 
	
		
			
				|  |  | +    public function thanksGivingDayActivity(Request $request)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  |          $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
 | 
	
		
			
				|  |  |          $from = $request->input('fromtype', 'main');
 | 
	
		
			
				|  |  |          $sites = env('YEAR_ACTIVITY_CHANNEL', '');
 | 
	
	
		
			
				|  | @@ -1508,20 +1520,20 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |          if (empty($start) || empty($end)) {
 | 
	
		
			
				|  |  |              return redirect()->to($not_access_url);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        $url = ['slow'=>'javascript:void(0)','height'=>'javascript:void(0)'];
 | 
	
		
			
				|  |  | +        $url = ['slow' => 'javascript:void(0)', 'height' => 'javascript:void(0)'];
 | 
	
		
			
				|  |  |          $order = Order::where('uid', $this->uid)->where('status', 'PAID')->select('id')->first();
 | 
	
		
			
				|  |  |          $charge_count = 0;
 | 
	
		
			
				|  |  | -        if($order){
 | 
	
		
			
				|  |  | +        if ($order) {
 | 
	
		
			
				|  |  |              $charge_count = 1;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (time() < strtotime($start)) {
 | 
	
		
			
				|  |  |              //未开始
 | 
	
		
			
				|  |  | -            return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 1,'charge_count'=>$charge_count]);
 | 
	
		
			
				|  |  | +            return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 1, 'charge_count' => $charge_count]);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (time() > strtotime($end)) {
 | 
	
		
			
				|  |  |              //结束
 | 
	
		
			
				|  |  | -            return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 2,'charge_count'=>$charge_count]);
 | 
	
		
			
				|  |  | +            return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 2, 'charge_count' => $charge_count]);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //3483  3484
 | 
	
	
		
			
				|  | @@ -1540,6 +1552,80 @@ class WelcomeController extends BaseController
 | 
	
		
			
				|  |  |          $param['product_id'] = 3484;
 | 
	
		
			
				|  |  |          $param['limit'] = 100;
 | 
	
		
			
				|  |  |          $url['height'] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
 | 
	
		
			
				|  |  | -        return view('pay.order.thanksGivingDayActivity',['url'=>$url,'code'=>0,'charge_count'=>$charge_count]);
 | 
	
		
			
				|  |  | +        return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 0, 'charge_count' => $charge_count]);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function greatColdActivity(Request $request)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
 | 
	
		
			
				|  |  | +        $token = $request->input('token');
 | 
	
		
			
				|  |  | +        $activity_info = ActivityService::getByToken($token);
 | 
	
		
			
				|  |  | +        if (!$activity_info) {
 | 
	
		
			
				|  |  | +            $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
 | 
	
		
			
				|  |  | +            return redirect()->to($default_url);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $from = $request->input('fromtype', 'main');
 | 
	
		
			
				|  |  | +        $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
 | 
	
		
			
				|  |  | +        $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
 | 
	
		
			
				|  |  | +        $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
 | 
	
		
			
				|  |  | +        $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
 | 
	
		
			
				|  |  | +        Redis::sadd($uv_key, $this->uid);
 | 
	
		
			
				|  |  | +        Redis::hincrby($pv_key, date('Y-m-d'), 1);
 | 
	
		
			
				|  |  | +        $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
 | 
	
		
			
				|  |  | +        if ($request->input('redirect_url')) {
 | 
	
		
			
				|  |  | +            $redirect_url = $request->input('redirect_url');
 | 
	
		
			
				|  |  | +            $redirect_url = urldecode($redirect_url);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $least_charge_amount = Order::select('id','price')
 | 
	
		
			
				|  |  | +            ->where('uid',$this->uid)
 | 
	
		
			
				|  |  | +            ->where('status','PAID')
 | 
	
		
			
				|  |  | +            ->where('created_at','>=',strtotime($activity_info->start_time)-60*86400)
 | 
	
		
			
				|  |  | +            ->max('price');
 | 
	
		
			
				|  |  | +        $type = 'litter';
 | 
	
		
			
				|  |  | +        $product_ids = [3962,3963];
 | 
	
		
			
				|  |  | +        $img = [
 | 
	
		
			
				|  |  | +            'litter'=>[
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/8-active.png',
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/8.png',
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23-active.png',
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23.png',
 | 
	
		
			
				|  |  | +            ],
 | 
	
		
			
				|  |  | +            'big'=>[
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23-active.png',
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23.png',
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/58-active.png',
 | 
	
		
			
				|  |  | +                'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/58.png',
 | 
	
		
			
				|  |  | +            ],
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        ];
 | 
	
		
			
				|  |  | +        if($least_charge_amount && $least_charge_amount>=30){
 | 
	
		
			
				|  |  | +            $type = 'big';
 | 
	
		
			
				|  |  | +            $product_ids = [3960,3961];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //未开始
 | 
	
		
			
				|  |  | +        if(time() < strtotime($activity_info->start_time)){
 | 
	
		
			
				|  |  | +             return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)','javascript:void(0)'], 'code' => -1, 'type' => $type,'img'=>$img]);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //结束
 | 
	
		
			
				|  |  | +        if(time() > strtotime($activity_info->end_time)){
 | 
	
		
			
				|  |  | +            return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)','javascript:void(0)'], 'code' => -2, 'type' => $type,'img'=>$img]);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $url = [];
 | 
	
		
			
				|  |  | +        foreach ($product_ids as $product_id){
 | 
	
		
			
				|  |  | +            $param = [
 | 
	
		
			
				|  |  | +                'uid' => $this->uid,
 | 
	
		
			
				|  |  | +                'distribution_channel_id' => $this->distribution_channel_id,
 | 
	
		
			
				|  |  | +                'product_id' => $product_id,
 | 
	
		
			
				|  |  | +                '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.greatColdActivity', ['url' => $url, 'code' => 0, 'type' => $type,'img'=>$img]);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |