1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503 |
- <?php
- namespace App\Http\Controllers\Wap\Web;
- use App\Jobs\SendStatisticsList;
- use App\Jobs\SendTexts;
- use App\Libs\Ip2Region;
- use App\Modules\Activity\Services\ActivitySwitchService;
- use App\Modules\Channel\Services\ChannelActivitiesService;
- use App\Modules\Channel\Services\ChannelService;
- use App\Modules\Cpa\Services\AdvertiseUserQueueService;
- use App\Modules\Cpa\Services\AdvertiseUsersService;
- use App\Modules\OfficialAccount\Services\ForceSubscribeService;
- use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
- use App\Modules\Subscribe\Services\ChapterOrderService;
- use App\Modules\Subscribe\Services\OrderService;
- use App\Modules\User\Services\ForceSubscribeUserIService;
- use App\Modules\User\Services\UserBindHkWelfareService;
- use App\Modules\User\Services\UserDivisionCpcPropertyService;
- use App\Modules\User\Services\UserDivisionPropertyService;
- use App\Modules\User\Services\UserMonthService;
- use App\Modules\User\Services\UserService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Wap\BaseController;
- use Cookie;
- use App\Modules\OfficialAccount\Services\CustomMsgService;
- use App\Modules\Activity\Services\ActivityService;
- use Redis;
- use App\Modules\Subscribe\Models\Order;
- use App\Modules\Activity\Models\Activity;
- use App\Modules\OfficialAccount\Services\OfficialAccountService;
- use Hashids;
- use App\Modules\User\Services\ReadRecordService;
- use App\Modules\Book\Services\BookConfigService;
- use DB;
- use App\Http\Controllers\Wap\Book\Transformers\BookTransformer;
- use Log;
- class WelcomeController extends BaseController
- {
- private $force_subscribe_info = null;
- private $property = '';
- private $user = null;
- private $activity_status = 0;
- /**
- * 首页
- */
- public function index(Request $request)
- {
- $url = $this->formWechatMsgJump($request);
- if ($url) {
- return redirect()->to($url);
- }
- $banners = [];//合并banner
- //site标题
- $title = $this->getSiteTitle($request);
- //客服图片
- $customer_service = $this->getCustomerServiceImg();
- //活动配置
- $activity_options = $this->activityOptions();
- $url = $activity_options['url'];
- $is_show_activity = $activity_options['is_show_activity'];
- $this->activity_status = $is_show_activity;
- $activity_title = $activity_options['activity_title'];
- $bottom_show_type = $activity_options['bottom_show_type'];
- $activity_img = $activity_options['activity_img'];
- $user = $activity_options['user'];
- $this->user = $user;
- $hidden_reader_menus = false;
- $send_order_id = $this->send_order_id;
- //隐藏阅读页面菜单
- if ($send_order_id && in_array($send_order_id, explode(',', env('HIDDEN_READER_MENUS')))) {
- $hidden_reader_menus = true;
- }
- $hidden_reader_bootstrap = false;
- //隐藏阅读引导页
- if (env('HIDDEN_READ_BOOTSTRAP') &&
- in_array($this->distribution_channel_id, explode(',', env('HIDDEN_READ_BOOTSTRAP')))
- ) {
- $hidden_reader_bootstrap = true;
- }
- //隐藏活动底部banner
- if (env('HIDDEN_ACTIVITY_BANNER') &&
- in_array($this->distribution_channel_id, explode(',', env('HIDDEN_ACTIVITY_BANNER')))
- ) {
- $is_show_activity = 0;
- }
- //代付
- $showDaiChong = \App\Modules\OfficialAccount\Services\PaySubstituteSwitchService::getChannelSwitch($this->distribution_channel_id);
- //老年站点
- $isOld = 0;
- $channel = ChannelService::getDistributionChannel($this->distribution_channel_id);
- if ($channel) {
- $isOld = $channel->is_old_user_site;
- }
- //fromtype
- $from = $request->get('fromtype');
- if (!$from) {
- $from = Cookie::get('from') ? Cookie::get('from') : 'main';
- }
- //crm
- $crm = $request->get('crm');
- if (!$crm) {
- $crm = Cookie::get('crm') ? Cookie::get('crm') : '';
- }
- //设置用户是否充值
- $this->setIsPaid();
- $this->setProperty($user->openid);
- $channel_activities_flag = $this->judgeChannelActivity($user);
- //最近阅读页面 推荐
- if (isset($user->sex)) {
- $latest_read_rec_books = $this->latest_read_rec_books($channel, $user->sex);
- } else {
- $latest_read_rec_books = [];
- }
- //广告样本
- $ad_status = env('AD_STATUS', 1);
- $adTargetId = false;
- if ($ad_status) {
- $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))) {
- $adTargetId = false;
- $cpc_channel = '';
- }
- }
- //目前推喜阅 自有广告曝光中低净值
- $self_pa_ad_switch = 0;
- if (in_array($this->property, ['none', 'low', 'medium']) && $this->isPddAdSites()) $self_pa_ad_switch = 1;
- //广告frame
- $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))) {
- $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))) {
- $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;
- //广告
- // 屏蔽书名
- $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;
- }
- //原创pv uv
- $yctj = false;
- $yctj_url = '';
- 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' => ''
- ];
- //突出包年的充值页面
- $outstanding_year_order = $this->outstandingYearOrder();
- $pdd_ad = $this->pddAd();
- //banner 合并
- if ($is_show_activity) {
- $banners[] = [
- 'img' => $activity_img,
- 'jump_url' => $url
- ];
- }
- //pdd 广告用户--增加banner
- if ($pdd_ad) {
- $pdd_ads = Redis::get('pdd_ads');//pdd广告
- if ($pdd_ads) {
- foreach (json_decode($pdd_ads, true) as $_ad) {
- $banners[] = [
- 'img' => $_ad['img'],
- 'jump_url' => $_ad['jump_url']
- ];
- }
- }
- }
- $xiyue_info = $this->isXiyueUser();
- //用户分割
- $this->userPproperty();
- $month_order_info = $this->monthOrderInfo($user->openid);
- $options = json_encode([
- 'distribution_channel_id' => (int)$this->distribution_channel_id,
- 'send_order_id' => $send_order_id,
- 'uid' => $this->uid,
- 'pay_url' => env('CREATE_PAY_URL'),
- 'title' => $title,
- 'kefu' => $customer_service,
- 'background' => env('WEB_READER_BACKGROUND'),
- 'font_size' => env('WEB_READER_FONT_SIZE'),
- 'page_style' => env('WEB_READER_PAGE_STYLE'),
- 'from' => $from,
- 'is_show_activity' => $is_show_activity,
- 'activity_url' => $url,
- 'activity_title' => $activity_title,
- 'bottom_show_type' => $bottom_show_type,
- 'activity_img' => $activity_img,
- 'special_bottom_sub_banner' => $this->getSpecialBottomSubBanner(),
- 'hidden_reader_menus' => $hidden_reader_menus,
- 'hidden_reader_bootstrap' => $hidden_reader_bootstrap,
- 'showDaiChong' => (int)$showDaiChong,
- '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,
- '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->guidePersonalAccountV2(),
- '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 --------------------------');
- myLog('special')->info(json_decode($options, 1));
- }
- //统计用户ua
- $ua = $request->server('HTTP_USER_AGENT');
- $this->recordUA($ua);
- return view('wap.index', compact('options', 'title'));
- }
- 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' => ''
- ];
- 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分钟之内新注册的用户进行打赏
- $reward_info = DB::table('fission')->where([
- ['type', '=', 2], ['uid', '=', $this->uid]
- ])->first();
- if (!$reward_info) { //未被打赏的新用户
- //$user_info = UserService::getById($this->uid);
- DB::beginTransaction();
- $user_info->balance = $user_info->balance + $channel_activities->amount;
- $user_info->reward_balance = $user_info->reward_balance + $channel_activities->amount;
- if ($user_info->save()) {
- $fission_data = [
- 'uid' => $this->uid,
- 'prize' => $channel_activities->amount,
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s'),
- 'type' => 2
- ];
- DB::table('fission')->insert($fission_data);
- DB::commit();
- $channel_activities_flag['shall_reward'] = 1;
- $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();
- if ($force_sub_info) {
- $bookUrl = env('PROTOCOL') . '://site' . encodeDistributionChannelId($this->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/';
- $res['openid'] = $force_sub_info->openid;
- $res['appid'] = $force_sub_info->appid;
- $res['content'] = "亲爱的会员您好:\n恭喜您获得" . ($channel_activities->amount) . "书币奖励\n<a href='" . $bookUrl . "'>去书城看书</a>";
- $res['type'] = 'one_task';
- $res['send_time'] = date("Y-m-d H:i:s");
- $res['task_id'] = md5('channel_activity_push');
- $send_data = array(
- 'send_time' => date("Y-m-d H:i:s"),
- 'data' => $res
- );
- dispatch((new SendTexts($send_data))->onConnection('rabbitmq')->delay(0)->onQueue('send_texts_list'));
- }
- } else {
- DB::rollBack();
- }
- }
- }
- }
- } 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 outstandingYearOrder()
- {
- $outstanding_year_order = false;
- 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);
- $this->property == 'high' && $outstanding_year_order = true;
- //}
- //}
- return $outstanding_year_order;
- }
- 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) {
- }
- $lucky_user && $luckuser_img = 'https://cdn-novel.iycdm.com//h5/lucky.jpg';
- return compact('lucky_user', 'lucky_user_img');
- }
- private function latest_read_rec_books($channel, $sex)
- {
- $latest_read_rec_books = [];
- if ($channel->is_yq_move)//云栖迁移过来的站点
- {
- //用户性别
- if ($sex == 1)//男
- {
- $bids = [1896, 1969, 2115, 2526, 2610];
- } else {
- $bids = [1148, 1460, 1572, 1634, 2434, 2436];
- if (in_array($this->distribution_channel_id, [4042, 4043, 4044])) {
- $bids = [2323, 1347, 2168, 1550, 1295, 1574];
- }
- }
- $latest_read_rec_books = collectionTransform(new BookTransformer(), BookConfigService::getBooksByIds($bids));
- }
- return $latest_read_rec_books;
- }
- /**
- * 获取123底部强管banner
- */
- private function getSpecialBottomSubBanner()
- {
- $week = date('N');
- return 'https://cdn-novel.iycdm.com/h5/bottom_sub_banner/' . $week . '.jpg';
- }
- /**
- * 裂变
- * @return int
- */
- 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) {
- 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')
- ]);
- UserService::addBalance($this->uid, 200, 0, 200);
- return 1;
- }
- }
- return 0;
- }
- /**
- * 获取活动配置信息
- */
- private function activityOptions()
- {
- $h5_scheme = env('H5_SCHEME', 'https');
- $url = '';
- $is_show_activity = 0;
- $activity_title = '';
- $bottom_show_type = 1;
- $activity_img = '';
- $user = $this->userInfo($this->uid);
- /*$no_participate_activity = env('no_participate_activity', '');
- if ($no_participate_activity && in_array($this->distribution_channel_id, explode(',', $no_participate_activity))) {
- return compact('url', 'is_show_activity', 'activity_title', 'bottom_show_type', 'activity_img', 'user');
- }*/
- //自定义活动
- $show_custom_activity_channel = env('SHOW_CUSTOM_ACTIVITY_CHANNEL', '');
- if ($show_custom_activity_channel) {
- $custom_activity_page = ActivityService::getActiveCustomActivity($this->distribution_channel_id);
- if ($custom_activity_page) {
- if ($show_custom_activity_channel == 'all'
- || in_array($this->distribution_channel_id, explode(',', $show_custom_activity_channel))
- ) {
- $url = $h5_scheme . '://' . _domain() . $custom_activity_page->activity_page . '&fromtype=reader';;
- $is_show_activity = 1;
- $activity_title = '优惠活动';
- $bottom_show_type = 1;
- $activity_img = 'https://cdn-novel.iycdm.com/h5/2018-08-24-banner.png';
- }
- }
- }
- //自定义新用户活动
- $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) {
- $url = $h5_scheme . '://' . _domain() . $custom_activity_page->activity_page;
- $is_show_activity = 1;
- $activity_title = '优惠活动';
- $bottom_show_type = 1;
- $activity_img = 'https://cdn-novel.iycdm.com/h5/2019-04-04-banner.jpg';
- }
- }
- }
- $activity_setting = ActivityService::getActivitySetting();
- if ($activity_setting) {
- $activity_id = isset($activity_setting['activity_id']) ? $activity_setting['activity_id'] : 0;
- $activity_info = Activity::find($activity_id);
- if ($activity_info &&
- time() > strtotime($activity_info->start_time) &&
- time() < strtotime($activity_info->end_time) &&
- $user &&
- isset($user->created_at) &&
- (time() - strtotime($user->created_at)) >= 86400 * 2
- ) {
- $activity_img = isset($activity_setting['wap_bottom_img']) ? $activity_setting['wap_bottom_img'] : '';
- //if (in_array($this->distribution_channel_id, [123, 211, 146, 155, 255, 256, 691, 722, 4364, 4427, 695, 4174, 4025, 4593, 4426, 4889, 4891, 4742, 4053, 4334, 4487, 5611, 6122, 6123, 6124, 8, 5, 160, 4236, 4237, 4241, 273, 148, 266, 202, 271])){
- $activity_pool = [
- 'https://cdn-novel.iycdm.com/h5/activity-2019-09-25/reader-banner-1.jpg',
- 'https://cdn-novel.iycdm.com/h5/activity-2019-09-25/reader-banner-2.jpg',
- 'https://cdn-novel.iycdm.com/h5/activity-2019-09-25/reader-banner-3.jpg'
- ];
- $activity_img = collect($activity_pool)->random();
- //}
- $url = $h5_scheme . '://' . _domain() . $activity_info->activity_page . '&fromtype=reader';
- $activity_title = isset($activity_setting['activity_title']) ? $activity_setting['activity_title'] : '';
- $status = ActivitySwitchService::isShowInPage($activity_id, $this->distribution_channel_id);
- 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')))) {
- $is_show_activity = 0;
- }
- }
- }
- }
- }
- $year_activity_id = env('YEAR_ACTIVITY_ID');
- if ($year_activity_id) {
- $activity_info = Activity::find($year_activity_id);
- if ($activity_info &&
- time() > strtotime($activity_info->start_time) &&
- time() < strtotime($activity_info->end_time) &&
- $user &&
- isset($user->created_at) &&
- (time() - strtotime($user->created_at)) >= 86400 * 2
- ) {
- $sites = env('YEAR_ACTIVITY_CHANNEL', '');
- if ($sites && in_array($this->distribution_channel_id, explode(',', $sites))) {
- $is_show_activity = 1;
- $bottom_show_type = 2;
- /*$old_discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->whereIn('activity_id', [643, 827,1104])->count();
- if ($old_discount_coupon) {
- $activity_img = 'https://cdn-novel.iycdm.com/h5/activity-2019-05-10/reader-80.jpg';
- } else {
- $activity_img = 'https://cdn-novel.iycdm.com/h5/activity-2019-05-10/reader-50.jpg';
- }*/
- //$activity_img = sprintf('https://cdn-novel.iycdm.com/h5/activity-2019-07-10/reader-banner%s.jpg',random_int(1,3));
- $activity_img = 'https://cdn-novel.iycdm.com/h5/activity-2019-07-25/reader-banner.png';
- $url = $h5_scheme . '://' . _domain() . $activity_info->activity_page . '&fromtype=reader';
- }
- }
- }
- return compact('url', 'is_show_activity', 'activity_title', 'bottom_show_type', 'activity_img', 'user');
- }
- /**
- * 获取site标题
- */
- 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 == 6375) return '荷香淑苑';
- if ($this->distribution_channel_id == 5237) return '悦月文摘';
- if ($this->distribution_channel_id == 6130) return '微友书坊';
- if ($this->distribution_channel_id == 6667) return '青青书舍';
- if ($this->distribution_channel_id == 7264) return '悠悠书汇';
- if ($this->distribution_channel_id == 7070) 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 ($force_subscribe_official) {
- $title = $force_subscribe_official->nickname;
- if ($title) return $title;
- }
- }
- if ($subscribe) return $subscribe;
- //强关公众号名称
- $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();
- if ($force_subscribe_official) {
- $title = $force_subscribe_official->nickname;
- $get_force_subscribe_name = true;
- Cookie::queue('force_subscribe_name', $title, 12 * 3600);
- }
- }
- //可用公众号名称
- if (!$get_force_subscribe_name) {
- $res = OfficialAccountService::canUseOfficialAccountByChannelId(['distribution_channel_id' => $this->distribution_channel_id]);
- if ($res && isset($res->nickname) && !empty($res->nickname)) {
- $title = $res->nickname;
- Cookie::queue('force_subscribe_name', $title, 12 * 3600);
- }
- }
- return $title;
- }
- private function appad()
- {
- if ($this->force_subscribe_info) {
- $force_subscribe_info = $this->force_subscribe_info;
- } 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) {
- return false;
- }
- $force_sub_user_by_openid = ForceSubscribeUserIService::getForceSubscribeByUidOpenid($this->uid);
- 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)
- && !OrderService::isPaidUserByOpenid($force_subscribe_info->openid) &&
- //!AdvertiseUserQueueService::getUserAdvertise($this->uid) &&
- in_array($this->distribution_channel_id, explode(',', env('SHARE_OPEN_SITE')))
- ) {
- return true;
- }
- return false;
- }
- //CPC广告的优化逻辑
- 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) {
- $cookie_ad_status = Cookie::get('cpc_ad_status');
- 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') {
- Cookie::queue('cpc_ad_status', 'show');
- return true;
- }
- }
- Cookie::queue('cpc_ad_status', 'unshow');
- return false;
- }
- 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'
- ];
- }
- return '';
- }
- 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]);
- }
- 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));
- }
- /**
- * 获取客服图片
- */
- private function getCustomerServiceImg()
- {
- $setting = CustomMsgService::customerImgUrlByChannelId($this->distribution_channel_id);
- 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 = 'https://cdn-novel.iycdm.com/static/img/kefu20190330.jpg';
- }
- return $customer_service;
- }
- /**
- * 推广链接跳转到用户上一阅读的章节
- */
- private function formWechatMsgJump(Request $request)
- {
- $path = $request->path();
- if ($path != 'reader') {
- return null;
- }
- $source = $request->input('source');
- if (!$source || $source != 'wechatmsg') {
- return null;
- }
- $bid = 0;
- $bid_str = $request->input('bid');
- $cid = $request->input('cid');
- try {
- $bid_arr = Hashids::decode($bid_str);
- if (isset($bid_arr[0])) {
- $bid = $bid_arr[0];
- }
- } catch (\Exception $e) {
- }
- if (!$bid) return null;
- $record_info = '';
- try {
- $record_info = ReadRecordService::getRecordByUidBid($this->uid, $bid);
- } catch (\Exception $e) {
- }
- if (!$record_info) return null;
- $record_info_arr = explode('_', $record_info);
- $param = $request->except(['_url', 'source', 'cid']);
- $param['stats'] = 1;
- if (isset($record_info_arr[0])) {
- $param['cid'] = $record_info_arr[0];
- if ($cid && $cid != $record_info_arr[0]) {
- $h5_scheme = env('H5_SCHEME', 'https');
- $param_str = http_build_query($param);
- $url = $h5_scheme . '://' . _domain() . '/reader?' . $param_str;
- return $url;
- }
- }
- return null;
- }
- //用户是否在广告样本中
- private function isUserInAdSample()
- {
- $res = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'AD_V2');
- if ($res) {
- return true;
- } else {
- return false;
- }
- }
- /**
- * 三天回本活动
- * @param Request $request
- * @return
- */
- public function activity(Request $request)
- {
- $send_time = Redis::hget('add_news_recovery_push_activity' . $this->uid, 'time');
- $send_time = time() - 100;
- if ($send_time) {
- if (time() - $send_time < 86400) {
- $activity_id = 1;
- $activity_info = ActivityService::getById($activity_id);
- if ($activity_info && $activity_info->product_id) {
- $from = $request->input('fromtype', 'main');
- Redis::sadd('push:activity:distribution_channel_id:' . $this->distribution_channel_id . 'from:' . $from . ':date:' . date('Y-m-d'), $this->uid);
- Redis::hincrby('customer:push:click:activity:distribution_channel_id:' . $this->distribution_channel_id . 'from:' . $from, date('Y-m-d'), 1);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . encodeDistributionChannelId($this->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/person'
- ];
- Redis::hdel('add_news_recovery_push_activity' . $this->uid, 'time');
- $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- return view('pay.order.activity', ['url' => $url, 'code' => 0]);
- }
- }
- }
- return redirect('/continue');
- //return view('pay.order.activity', ['code' => 1, 'url' => '']);
- }
- /**
- * 商户活动
- * @param Request $request
- * @return view
- */
- public function channelActivity(Request $request)
- {
- $token = $request->input('token');
- //return view('pay.order.saleactivity', ['url' => $token, 'code' => 0]);
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info && $activity_info->product_id) {
- $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);
- $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_info->id)->count();
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time) && empty($order)) {
- // $from = $request->input('from', '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);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
- ];
- $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- return view('pay.order.saleactivity', ['url' => $url, 'code' => 0]);
- }
- }
- return view('pay.order.saleactivity', ['url' => '###', 'code' => 0]);
- }
- public function springActivityV1(Request $request)
- {
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info) {
- $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' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->input('redirect_url')) {
- $redirect_url = $request->input('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $param_fifty = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => env('SPRING_ACTIVITY_PRODUCT_FIFTY', 2),
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url
- ];
- $param_hundred = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => env('SPRING_ACTIVITY_PRODUCT_HUNDRED', 3),
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url
- ];
- $url_fifty = env('CREATE_PAY_URL') . '?' . http_build_query($param_fifty);
- $url_hundred = env('CREATE_PAY_URL') . '?' . http_build_query($param_hundred);
- return view('pay.order.springactivity', ['url' => ['fifty' => $url_fifty, 'hundred' => $url_hundred], 'code' => 0]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.springactivity', ['url' => [], 'code' => 1]);
- } else {
- return view('pay.order.springactivity', ['url' => [], 'code' => 2]);
- }
- }
- return view('pay.order.springactivity', ['url' => [], 'code' => 3]);
- }
- public function springActivity(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);
- }
- //未开始
- if (time() < strtotime($activity_info->start_time)) {
- return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -1]);
- }
- //结束
- if (time() > strtotime($activity_info->end_time)) {
- return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2]);
- }
- $product_ids = [4063, 4064];
- $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.springactivity2019', ['url' => $url, 'code' => 0]);
- }
- /**
- *
- */
- public function womenActivity(Request $request)
- {
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info) {
- $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' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->input('redirect_url')) {
- $redirect_url = $request->input('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url
- ];
- $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- return view('pay.order.womenactivity', ['url' => $url, 'code' => 0]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.womenactivity', ['url' => [], 'code' => 1]);
- } else {
- return view('pay.order.womenactivity', ['url' => [], 'code' => 2]);
- }
- }
- return view('pay.order.womenactivity', ['url' => [], 'code' => 3]);
- }
- public function newUserActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $from = $request->input('fromtype', 'main');
- $send_time = $request->input('send_time');
- $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
- $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
- $activity_id = env('NEW_USER_ACTIVITY_ID', 5);
- $activity_info = ActivityService::getById($activity_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);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- if (!$send_time) {
- 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)]);
- }
- $end_time_str = date('Y-m-d', $send_time + 86400);
- $end_time = strtotime(date('Y-m-d', $send_time + 86400) . ' 23:59:59');
- if ($send_time > $end_time) {
- return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- if (time() > $end_time) {
- return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
- if ($order) {
- return view('pay.order.newUserActivity', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
- //return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- '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' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- public function channelActivityNine(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info && $activity_info->product_id) {
- $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);
- //渠道不符合
- 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)]);
- }
- //活动未开始
- if (time() < strtotime($activity_info->start_time)) {
- return view('pay.order.longactivitynine', ['url' => '###', 'code' => -3, '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.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)]);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time) && empty($order)) {
- $not_allow_paid_user_channel_id = env('NOT_ALLOW_PAID_USER_CHANNEL_ID', 0);
- //不允许支付过的用户参见9.9的活动
- if ($not_allow_paid_user_channel_id &&
- 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)]);
- }
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'limit' => 1,
- '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' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
- }
- public function channelActivitySixtyEight(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $token = $request->input('token');
- $img = 'https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn68.jpg';
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info && $activity_info->product_id) {
- $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);
- //$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)]);
- }
- //活动未开始
- 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)]);
- }
- //活动结束
- 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)]);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'limit' => 100,
- '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' => '###', '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)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- $img = 'https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn48.jpg';
- if ($activity_info && $activity_info->product_id) {
- $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);
- //$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)]);
- }
- //活动未开始
- 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)]);
- }
- //活动结束
- 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)]);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'limit' => 100,
- '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' => '###', '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)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $token = $request->get('token');
- $activity_info = ActivityService::getByToken($token);
- $from = $request->get('fromtype', 'main');
- $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) {
- $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);
- Redis::sadd($uv_key, $this->uid);
- 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)]);
- }
- //活动结束
- 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)]);
- }
- $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)]);
- }
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- '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' => '###', 'code' => -2, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
- }
- /**
- * 清明活动
- */
- public function qingMingActivity(Request $request)
- {
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info) {
- $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' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->input('redirect_url')) {
- $redirect_url = $request->input('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url
- ];
- $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- return view('pay.order.qingmingactivity', ['url' => $url, 'code' => 0]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.qingmingactivity', ['url' => [], 'code' => 1]);
- } else {
- return view('pay.order.qingmingactivity', ['url' => [], 'code' => 2]);
- }
- }
- return view('pay.order.qingmingactivity', ['url' => [], 'code' => 3]);
- }
- public function readDayActivity(Request $request)
- {
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info) {
- $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' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->input('redirect_url')) {
- $redirect_url = $request->input('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->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.laborDay', ['url' => $url, 'code' => 0]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.laborDay', ['url' => [], 'code' => 1]);
- } else {
- return view('pay.order.laborDay', ['url' => [], 'code' => 2]);
- }
- }
- return view('pay.order.laborDay', ['url' => [], 'code' => 3]);
- }
- public function commonActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info && isset($activity_info->setting) && empty(!$activity_info->setting)) {
- $imgs = json_decode($activity_info->setting, 1);
- $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);
- $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);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->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.common', ['url' => $url, 'code' => 0, 'img' => $imgs]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.common', ['url' => [], 'code' => 1, 'img' => $imgs]);
- } else {
- return view('pay.order.common', ['url' => [], 'code' => 2, 'img' => $imgs]);
- }
- }
- $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- return redirect()->to($default_url);
- }
- public function yearActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $from = $request->input('fromtype', 'main');
- $sites = env('YEAR_ACTIVITY_CHANNEL', '');
- $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- if (empty($sites)) {
- return redirect()->to($not_access_url);
- }
- $site_arr = explode(',', $sites);
- if (!in_array($this->distribution_channel_id, $site_arr)) {
- return redirect()->to($not_access_url);
- }
- $year_activity_id = env('YEAR_ACTIVITY_ID');
- if (!$year_activity_id) {
- return redirect()->to($not_access_url);
- }
- $activity_info = Activity::find($year_activity_id);
- if (!$activity_info) {
- return redirect()->to($not_access_url);
- }
- $activity_id = $year_activity_id;
- $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_id, $this->distribution_channel_id, date('Y-m-d'));
- $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $start = $activity_info->start_time;
- $end = $activity_info->end_time;
- if (empty($start) || empty($end)) {
- return redirect()->to($not_access_url);
- }
- $male_site = env('YEAR_MALE_SITE');
- if ($male_site && in_array($this->distribution_channel_id, explode(',', $male_site))) {
- $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('YEAR_MALE_BID'))));
- } else {
- $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('YEAR_FEMALE_BID'))));
- }
- $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();
- if ($discount_coupon) {
- $is_get = 1;
- }
- if ($old_discount_coupon) {
- //51活动领取过 优惠80
- $discount = 80;
- $product_id = $activity_info->product_id;
- } else {
- //51活动领未取过 优惠50
- $discount = 50;
- $product_id = 1450;
- }
- if (time() < strtotime($start)) {
- //未开始
- return view('pay.order.yearactivityV3', ['url' => '', 'is_get' => 1, 'coupons_url' => '', 'code' => 1, 'books' => $books, 'activity_id' => $activity_id, 'discount' => $discount]);
- }
- if (time() > strtotime($end)) {
- //结束
- return view('pay.order.yearactivityV3', ['url' => '', 'is_get' => 1, 'coupons_url' => '', 'code' => 2, 'books' => $books, 'activity_id' => $activity_id, 'discount' => $discount]);
- }
- $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
- //参加过了
- if ($order) {
- //return view('pay.order.yearactivityV2', ['url' => '', 'is_get' => 1, 'coupons_url' => '', 'code' => 3, 'books' => $books, 'activity_id' => $activity_id, 'discount' => $discount]);
- }
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $product_id,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'limit' => 10,
- 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
- ];
- $this->getCoupons($activity_id);
- $coupons_url = $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- $param['product_id'] = 5;
- $primary_url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- return view('pay.order.yearactivityV3', ['url' => $primary_url, 'is_get' => $is_get, 'coupons_url' => $coupons_url, 'code' => 0, 'books' => $books, 'activity_id' => $activity_id, 'discount' => $discount]);
- }
- private function getCoupons($activity_id)
- {
- if (!DB::table('discount_coupons')->where('uid', $this->uid)->where('activity_id', $activity_id)->count()) {
- DB::table('discount_coupons')->insert([
- 'uid' => $this->uid,
- 'activity_id' => $activity_id,
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s')
- ]);
- }
- }
- public function summerActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $from = $request->input('fromtype', 'main');
- $sites = env('YEAR_ACTIVITY_CHANNEL', '');
- $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- if (empty($sites)) {
- return redirect()->to($not_access_url);
- }
- if ($sites != 'all') {
- $site_arr = explode(',', $sites);
- if (!in_array($this->distribution_channel_id, $site_arr)) {
- return redirect()->to($not_access_url);
- }
- }
- $activity_id = 350;
- $activity_info = Activity::find($activity_id);
- $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_id, $this->distribution_channel_id, date('Y-m-d'));
- $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
- $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);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $url_array = [];
- $product_id_array = [2158, 2159, 2160, 2161];
- foreach ($product_id_array as $v) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $v,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => 100,
- ];
- $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- $url_array[] = $url;
- }
- return view('pay.order.summerActivity', ['url' => '', 'code' => 0, 'url_array' => $url_array]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.summerActivity', ['url' => [], 'code' => 1]);
- } else {
- return view('pay.order.summerActivity', ['url' => [], 'code' => 2]);
- }
- }
- public function newUserSale(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $from = $request->input('fromtype', 'main');
- $send_time = $request->input('send_time');
- $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
- $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
- $activity_id = 402;
- $activity_info = ActivityService::getById($activity_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);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- // 2226,2227,2228,22229,2230
- if (!$send_time) {
- $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
- return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
- }
- $end_time_str = date('Y-m-d', $send_time + 3 * 86400);
- $end_time = strtotime(date('Y-m-d', $send_time + 3 * 86400) . ' 23:59:59');
- if ($send_time > $end_time) {
- $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
- return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => -1, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- if (time() > $end_time) {
- $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
- return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => -2, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
- if ($order) {
- $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
- return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id, true);
- return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => 0, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }
- private function getUrls($activity_info_setting, $from, $channel_id, $encode_channel_id, $activity_id, $is_access = false)
- {
- $product = DB::table('products')
- ->whereIn('id', explode(',', $activity_info_setting))
- ->select('id', 'price', 'type', 'given')
- ->get();
- $url_info = [];
- $url_info['year'] = ['url' => '###'];
- $url_info['charge'] = [];
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $channel_id,
- 'limit' => 1,
- 'fromtype' => $from,
- 'activity_id' => $activity_id,
- 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
- ];
- if (!$product) {
- return $url_info;
- }
- foreach ($product as $v) {
- if (in_array($this->distribution_channel_id, [6917, 6918, 6939]) && $v->type == 'YEAR_ORDER') {
- continue;
- }
- if ($is_access) {
- $param['product_id'] = $v->id;
- $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- } else {
- $url = '###';
- }
- if ($v->type == 'YEAR_ORDER') {
- $url_info['year']['url'] = $url;
- } else {
- $temp = [];
- $temp['url'] = $url;
- $temp['price'] = (int)$v->price;
- $temp['given'] = (int)($v->given / 100);
- $temp['total'] = $v->price * 100 + $v->given;
- if ($v->price == 30) {
- $temp['old_given'] = '无折扣';
- } elseif ($v->price == 50) {
- $temp['old_given'] = '送40元';
- } elseif ($v->price == 100) {
- $temp['old_given'] = '送100元';
- } elseif ($v->price == 200) {
- $temp['old_given'] = '送200元';
- } else {
- $temp['old_given'] = '';
- }
- $url_info['charge'][] = $temp;
- }
- }
- return $url_info;
- }
- public function nationalDayActivity(Request $request)
- {
- $token = $request->input('token', '');
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $activity_info = ActivityService::getByToken($token);
- if (!$activity_info) {
- $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- return redirect()->to($not_access_url);
- }
- $from = $request->input('fromtype', 'main');
- $activity_id = $activity_info->id;
- $activty_ids = env('NATIONAL_DAY_ACTIVITY_IDS', '1,2,3');
- $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_id, $this->distribution_channel_id, date('Y-m-d'));
- $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
- $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);
- }
- $activity_status = -1;
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $activity_status = 1;
- }
- if (time() < strtotime($activity_info->start_time)) {
- //未开始
- $activity_status = -1;
- }
- if (time() > strtotime($activity_info->end_time)) {
- //结束
- $activity_status = -2;
- }
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $user_charge_count = (int)(Order::where('uid', $this->uid)->where('status', 'PAID')->count());
- if ($user_charge_count == 0) {
- $is_first_charge = 1;
- } else {
- $is_first_charge = 0;
- }
- $url_array = [];
- $product_id_array = explode(',', $activty_ids);
- foreach ($product_id_array as $key => $v) {
- if ($user_charge_count >= 1 && $key == 0) {
- //continue;
- }
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $v,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => 100,
- ];
- $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- $url_array[] = $url;
- }
- return view('pay.order.nationalDayActivity', ['url' => $url_array, 'is_first_charge' => $is_first_charge, 'code' => $activity_status]);
- }
- public function cYactivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- $site_arr = explode(',', env('YEAR_ACTIVITY_CHANNEL', '2'));
- if (!in_array($this->distribution_channel_id, $site_arr)) {
- return redirect()->to($default_url);
- }
- $activity_info = ActivityService::getById(929);
- if ($activity_info) {
- $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);
- $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);
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->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.cyangActivity', ['url' => $url, 'code' => 0,]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.cyangActivity', ['url' => [], 'code' => 1,]);
- } else {
- return view('pay.order.cyangActivity', ['url' => [], 'code' => 2,]);
- }
- }
- return redirect()->to($default_url);
- return view('pay.order.cyangActivity', []);
- }
- public function newUserForeverActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $from = $request->input('fromtype', 'main');
- $send_time = $request->input('send_time');
- $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- if ($this->distribution_channel_id != 123) {
- return redirect()->to($default_url);
- }
- $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
- $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
- $activity_id = env('FOREVER_ACTIVITY_ID', 5);
- $activity_info = ActivityService::getById($activity_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);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
- if (!$send_time) {
- return view('pay.order.foreverActivity', ['url' => '###', 'code' => -3, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'books' => $books]);
- }
- $end_time = $send_time + 86400 * 3;
- $time_diff = $end_time - time();
- if ($time_diff <= 0) {
- return view('pay.order.foreverActivity', ['url' => '###', 'code' => -2, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'books' => $books]);
- }
- /*$order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
- if ($order) {
- return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }*/
- $books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
- $day = floor($time_diff / 86400);
- $hour = floor(($time_diff - $day * 86400) / 3600);
- $minute = floor(($time_diff - $day * 86400 - $hour * 3600) / 60);
- $second = $time_diff - $day * 86400 - $hour * 3600 - $minute * 60;
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- '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.foreverActivity', ['url' => $url, 'code' => 0, 'time' => compact('day', 'hour', 'minute', 'second'), 'books' => $books]);
- }
- public function tempC()
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => 1450,
- 'activity_id' => 0,
- 'fromtype' => 'tempC',
- 'limit' => 10,
- '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 redirect()->to($url);
- }
- /**
- * 68元包年活动
- * @param Request $request
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\Swoft\Http\Message\Server\Response
- */
- public function otherYearActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $from = $request->input('fromtype', 'main');
- $send_time = $request->input('send_time');
- $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- if ($this->distribution_channel_id != 123) {
- return redirect()->to($default_url);
- }
- $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
- $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
- $activity_id = env('68_YEAR_ACTIVITY_ID', 5);
- $activity_info = ActivityService::getById($activity_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);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- //$books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
- $books = '';
- $time_diff = 0;
- if (!$send_time) {
- return view('pay.order.otherYearActivity', ['url' => '###', 'code' => -3, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'time_diff' => $time_diff]);
- }
- $end_time = $send_time + 86400 * 3;
- $time_diff = $end_time - time();
- if ($time_diff <= 0) {
- return view('pay.order.otherYearActivity', ['url' => '###', 'code' => -2, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'time_diff' => $time_diff]);
- }
- /*$order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
- if ($order) {
- return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
- }*/
- //$books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
- $day = floor($time_diff / 86400);
- $hour = floor(($time_diff - $day * 86400) / 3600);
- $minute = floor(($time_diff - $day * 86400 - $hour * 3600) / 60);
- $second = $time_diff - $day * 86400 - $hour * 3600 - $minute * 60;
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- '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.otherYearActivity', ['url' => $url, 'code' => 0, 'time' => compact('day', 'hour', 'minute', 'second'), 'time_diff' => $time_diff]);
- }
- /**
- * 双十一购物节统计
- * @param Request $request
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\Swoft\Http\Message\Server\Response
- */
- public function shoppingDayActivity(Request $request)
- {
- $token = $request->input('token', '');
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $activity_info = ActivityService::getByToken($token);
- if (!$activity_info) {
- $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- return redirect()->to($not_access_url);
- }
- $from = $request->input('fromtype', 'main');
- $activity_id = $activity_info->id;
- $activty_ids = env('SHOPPING_DAY_ACTIVITY_IDS', '1,2,3');
- $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_id, $this->distribution_channel_id, date('Y-m-d'));
- $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
- $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);
- }
- $activity_status = -1;
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- $activity_status = 1;
- }
- if (time() < strtotime($activity_info->start_time)) {
- //未开始
- $activity_status = -1;
- }
- if (time() > strtotime($activity_info->end_time)) {
- //结束
- $activity_status = -2;
- }
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $user_charge_count = (int)(Order::where('uid', $this->uid)->where('status', 'PAID')->count());
- if ($user_charge_count == 0) {
- $is_first_charge = 1;
- } else {
- $is_first_charge = 0;
- }
- $url_array = [];
- $time_diff = strtotime($activity_info->end_time) - time();
- $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);
- $second = $time_diff - $day * 86400 - $hour * 3600 - $minute * 60;
- }
- $product_id_array = explode(',', $activty_ids);
- $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;
- }
- $limit = 100;
- if ($key == 0) {
- $limit = 1;
- }
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $v->id,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => $limit,
- ];
- $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];
- }
- return view('pay.order.shoppingDayActivity', [
- 'url' => $url_array,
- 'is_first_charge' => $is_first_charge,
- 'code' => $activity_status,
- 'time' => compact('day', 'hour', 'minute', 'second'),
- 'user_charge_count' => $user_charge_count,
- 'time_diff' => $time_diff
- ]
- );
- }
- public function thanksGivingDayActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $from = $request->input('fromtype', 'main');
- $sites = env('YEAR_ACTIVITY_CHANNEL', '');
- $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- if (empty($sites)) {
- return redirect()->to($not_access_url);
- }
- $site_arr = explode(',', $sites);
- if (!in_array($this->distribution_channel_id, $site_arr)) {
- return redirect()->to($not_access_url);
- }
- $year_activity_id = 1367;
- $activity_info = Activity::find($year_activity_id);
- if (!$activity_info) {
- return redirect()->to($not_access_url);
- }
- $activity_id = $year_activity_id;
- $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_id, $this->distribution_channel_id, date('Y-m-d'));
- $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $start = $activity_info->start_time;
- $end = $activity_info->end_time;
- if (empty($start) || empty($end)) {
- return redirect()->to($not_access_url);
- }
- $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) {
- $charge_count = 1;
- }
- if (time() < strtotime($start)) {
- //未开始
- 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]);
- }
- //3483 3484
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => 3483,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'limit' => 1,
- 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
- ];
- $this->getCoupons($activity_id);
- $url['slow'] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
- $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]);
- }
- 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]);
- }
- public function channelYearActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $id = 2628;
- $activity_info = ActivityService::getById($id);
- if ($activity_info && $activity_info->product_id) {
- $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);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'limit' => 30,
- '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.channelYearActivity', ['url' => $url]);
- }
- $url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- return redirect()->to($url);
- }
- //春分活动
- public function vernalEquinoxActivity(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';
- 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 {
- $img = 'https://cdn-novel.iycdm.com/h5/activity-2019-03-20/bg23.jpg';
- $product_ids = 4805;
- }
- //未开始
- if (time() < strtotime($activity_info->start_time)) {
- return view('pay.order.vernalEquinoxActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -1, 'type' => $type, 'img' => $img]);
- }
- //结束
- if (time() > strtotime($activity_info->end_time)) {
- 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);
- 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) {
- $info = UserDivisionCpcPropertyService::calculateUserPropertyV2($this->uid);
- if ($info && $info['property'] != 'undefined') {
- UserDivisionCpcPropertyService::updateV2($info['openid'], $info['property']);
- }
- }
- }
- /*$old = UserDivisionCpcPropertyService::userLevel($openid);
- if(!$old) return ;
- $this->property = $old->property;
- if($old->type != 'NEW') return ;
- $send_data = array(
- 'type' => 'visit',
- 'data' => ['openid'=>$openid,'uid'=>$this->uid]
- );
- try {
- $send = new SendStatisticsList($send_data);
- $job = ($send)->onConnection('rabbitmq')->delay(0)->onQueue('send_statistics_list');
- dispatch($job);
- } catch (\Exception $e) {
- \Log::info($e);
- }*/
- }
- private function guidePersonalAccountV2(){
- //内部站点导粉
- list($inner_sites,$year_qrcode,$month_qrcode,$out_qrcode,$active_qrcode) = redisEnvMulti(
- 'GUIDE_PERSONAL_ACCOUNT_SITES',
- 'ACTIVE_YEAR_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',
- 'ACTIVE_MONTH_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',
- 'OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE',
- 'ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE'
- );
- $banner = '';
- if(!$this->activity_status){
- $banner = 'https://cdn-novel.iycdm.com/crm/guide/reader-banner.jpg';
- }
- //if(in_array($thy))
- if ($inner_sites && in_array($this->distribution_channel_id, explode(',', $inner_sites))) {
- //1.包年包月用户
- $get_info = UserBindHkWelfareService::isHasGet($this->uid);
- if ($get_info) return '';
- $charge = false;
- if (in_array($this->property, ['medium', 'high'])) {
- $charge = true;
- } else {
- if ($this->property == 'undefined' && OrderService::getChargeNum($this->uid) >= 10) {
- $charge = true;
- }
- }
- if(!$charge) return '';
- if($year_qrcode && OrderService::isYearOrderUser($this->uid) ){
- //包年
- return ['title' => '包年VIP专属爆款小说书单>>', 'link' => '/guidestremv2?group=ACTIVE_YEAR&fee=500','banner'=>$banner];
- }
- if($month_qrcode && UserMonthService::isMonthOrderUser($this->uid) ){
- //包月
- return ['title' => '包月VIP专属爆款小说书单>>', 'link' => '/guidestremv2?group=ACTIVE_MONTH&fee=500','banner'=>$banner];
- }
- if($active_qrcode){
- return ['title' => '您有500书币待领取>>', 'link' => '/guidestrem?uid=' . $this->uid . '&fee=500','banner'=>$banner];
- }
- return '';
- }
- //外站导粉
- if($out_qrcode && Redis::SISMEMBER('crm:out_channel_sites', $this->distribution_channel_id)){
- $get_info = UserBindHkWelfareService::isHasGet($this->uid);
- if ($get_info) return '';
- $charge = false;
- if (in_array($this->property, ['medium', 'high'])) {
- $charge = true;
- } else {
- if ($this->property == 'undefined' && OrderService::getChargeNum($this->uid) >= 10) {
- $charge = true;
- }
- }
- if(!$charge) return '';
- $filter_city = ['长沙', '深圳', '杭州'];
- $ip2region = new Ip2Region();
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } else {
- $ip = get_client_ip();
- }
- $info = [];
- try {
- $info = $ip2region->btreeSearch($ip);
- } 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)) {
- return '';
- }
- $count = ChapterOrderService::getRecentChapterOrderCount($this->uid);
- if ($count < 50) {
- return '';
- }
- Cookie::queue('is_force_out_guide', 1);
- return ['title' => '您有500书币待领取>>', 'link' => '/guidestrem?uid=' . $this->uid . '&fee=500','banner'=>$banner];
- }
- //渠道自己导粉
- $other_crm_config = Redis::hmget('channel:setting:' . $this->distribution_channel_id, ['crm_status', 'crm_link']);
- if (empty($other_crm_config[0]) && empty($other_crm_config[1])) return '';
- $get_info = UserBindHkWelfareService::isHasGet($this->uid);
- if ($get_info) return '';
- if($this->is_paid || $this->distribution_channel_id == 6687)
- return ['title' => '点击领取200书币>>', 'link' => $other_crm_config[1],'banner'=>''];
- return '';
- }
- 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');
- $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)) {
- return '';
- }
- //Log::info('guidePersonalAccount1111111111111111111111');
- $get_info = UserBindHkWelfareService::isHasGet($this->uid);
- if ($get_info) return '';
- //Log::info('guidePersonalAccount2222222222222222222222');
- $charge = false;
- if (in_array($this->property, ['medium', 'high'])) {
- $charge = true;
- } else {
- if ($this->property == 'undefined' && OrderService::getChargeNum($this->uid) >= 10) {
- $charge = true;
- }
- }
- if ($this->distribution_channel_id == 6687) {
- $charge = true;
- }
- if (!$charge) return '';
- //其他渠道自己导粉
- 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])) {
- return '';
- }
- $filter_city = ['长沙', '深圳', '杭州'];
- $ip2region = new Ip2Region();
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } else {
- $ip = get_client_ip();
- }
- $info = [];
- try {
- $info = $ip2region->btreeSearch($ip);
- } 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)) {
- return '';
- }
- $count = ChapterOrderService::getRecentChapterOrderCount($this->uid);
- 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'];
- }
- //Log::info('guidePersonalAccount33333333333333333');
- if (empty($crm_config[0]) || empty($crm_config[1])) return '';
- //Log::info('guidePersonalAccount4444444444444444');
- 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'];
- //return ['title' => '您有500书币待领取>>', 'link' => '/guidestrem?uid=' . $this->uid . '&fee=500'];
- }
- return '';
- }
- private function setIsPaid()
- {
- $charge = Order::where('uid', $this->uid)
- ->where('status', 'PAID')
- ->select('id')
- ->first();
- if ($charge) {
- Cookie::queue('is_paid', 1);
- $this->is_paid = true;
- } else {
- Cookie::queue('is_paid', 0);
- $this->is_paid = false;
- }
- }
- private function setProperty($openid)
- {
- $property = UserDivisionCpcPropertyService::userLevelV2($openid);
- $this->property = $property;
- }
- //统计ua
- private function recordUA($ua)
- {
- $is_ua_open = RedisEnv('ua_open');
- 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) {
- }
- }
- }
- }
- private function monthOrderInfo($openid)
- {
- return '';
- $property = $this->property;
- if (!$property) return '';
- $month_info = UserMonthService::getOrderAndSignStatusByUid($this->uid);
- if($month_info){
- return [
- 'price' => '30元',
- 'text' => '30元包月 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrl($this->uid),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_check.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_1.png'
- ];
- /*if(in_array('MONTH',$month_info)){
- return [
- 'price' => '30元',
- 'text' => '30元包月 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrl($this->uid),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_check.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_1.png'
- ];
- }
- if(in_array('WEEK',$month_info)){
- return [
- 'price' => '7元',
- 'text' => '7元包周 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrlV2($this->uid, env('MONTH_WEEK_ORDER_PLAN_ID'), _getIp()),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-2.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-1.png'
- ];
- }*/
- }
- 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' || $info->attach == 'week-show') {
- return [
- 'price' => '30元',
- 'text' => '30元包月 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrl($this->uid),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_check.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_1.png'
- ];
- }
- /*if ($info->attach == 'week-show') {
- return [
- 'price' => '7元',
- 'text' => '7元包周 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrlV2($this->uid, env('MONTH_WEEK_ORDER_PLAN_ID'), _getIp()),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-2.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-1.png'
- ];
- }*/
- return '';
- }
- }
- if (in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))
- && in_array($property, ['none', 'low', 'medium'])
- ) {
- if (!UserMonthService::isSignMonth($openid)) {
- $start_time = redisEnv('MONTH_TEMPLATE_COMPARE_START_TIME', 0);
- if (!$start_time || (strtotime($this->user->created_at) < $start_time)) {
- if ($property == 'nonenone') {
- return [
- 'price' => '7元',
- 'text' => '7元包周 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrlV2($this->uid, env('MONTH_WEEK_ORDER_PLAN_ID'), _getIp()),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-2.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-1.png'
- ];
- } else {
- return [
- 'price' => '30元',
- 'text' => '30元包月 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrl($this->uid),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_check.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_1.png'
- ];
- }
- }
- $attach = $this->uid % 2 == 0 ? 'show' : 'hide';
- if ($attach == 'hide') return '';
- if ($property == 'nonenone') {
- return [
- 'price' => '7元',
- 'text' => '7元包周 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrlV2($this->uid, env('MONTH_WEEK_ORDER_PLAN_ID'), _getIp()),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-2.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/week-order-1.png'
- ];
- } else {
- return [
- 'price' => '30元',
- 'text' => '30元包月 全站万本精彩小说免费看',
- 'link' => generateMonthOrderUrl($this->uid),
- 'focus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_check.png',
- 'unfocus_img'=>'https://cdn-novel.iycdm.com/h5/monthpay/month_order_1.png'
- ];
- }
- }
- }
- return '';
- }
- private function isXiyueUser()
- {
- //$result = DB::table('xiyue_zsy_users')->where('uid',$this->uid)->select('id')->first();
- 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'
- ];
- }
- return "";
- }
- }
|