WelcomeController.php 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225
  1. <?php
  2. namespace App\Http\Controllers\Wap\Web;
  3. use App\Jobs\SendStatisticsList;
  4. use App\Jobs\SendTexts;
  5. use App\Modules\Activity\Services\ActivitySwitchService;
  6. use App\Modules\Channel\Services\ChannelActivitiesService;
  7. use App\Modules\Channel\Services\ChannelService;
  8. use App\Modules\Cpa\Services\AdvertiseUserQueueService;
  9. use App\Modules\Cpa\Services\AdvertiseUsersService;
  10. use App\Modules\OfficialAccount\Services\ForceSubscribeService;
  11. use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
  12. use App\Modules\Subscribe\Services\OrderService;
  13. use App\Modules\User\Services\ForceSubscribeUserIService;
  14. use App\Modules\User\Services\UserBindHkWelfareService;
  15. use App\Modules\User\Services\UserDivisionCpcPropertyService;
  16. use App\Modules\User\Services\UserDivisionPropertyService;
  17. use App\Modules\User\Services\UserMonthService;
  18. use App\Modules\User\Services\UserService;
  19. use Illuminate\Http\Request;
  20. use App\Http\Controllers\Wap\BaseController;
  21. use Cookie;
  22. use App\Modules\OfficialAccount\Services\CustomMsgService;
  23. use App\Modules\Activity\Services\ActivityService;
  24. use Redis;
  25. use App\Modules\Subscribe\Models\Order;
  26. use App\Modules\Activity\Models\Activity;
  27. use App\Modules\OfficialAccount\Services\OfficialAccountService;
  28. use Hashids;
  29. use App\Modules\User\Services\ReadRecordService;
  30. use App\Modules\Book\Services\BookConfigService;
  31. use DB;
  32. use App\Http\Controllers\Wap\Book\Transformers\BookTransformer;
  33. use Log;
  34. class WelcomeController extends BaseController
  35. {
  36. private $force_subscribe_info = null;
  37. private $property = '';
  38. /**
  39. * 首页
  40. */
  41. public function index(Request $request)
  42. {
  43. $url = $this->formWechatMsgJump($request);
  44. if ($url) {
  45. return redirect()->to($url);
  46. }
  47. $banners = [];//合并banner
  48. //site标题
  49. $title = $this->getSiteTitle($request);
  50. //客服图片
  51. $customer_service = $this->getCustomerServiceImg();
  52. //活动配置
  53. $activity_options = $this->activityOptions();
  54. $url = $activity_options['url'];
  55. $is_show_activity = $activity_options['is_show_activity'];
  56. $activity_title = $activity_options['activity_title'];
  57. $bottom_show_type = $activity_options['bottom_show_type'];
  58. $activity_img = $activity_options['activity_img'];
  59. $user = $activity_options['user'];
  60. $hidden_reader_menus = false;
  61. $send_order_id = $this->send_order_id;
  62. //隐藏阅读页面菜单
  63. if ($send_order_id && in_array($send_order_id, explode(',', env('HIDDEN_READER_MENUS')))) {
  64. $hidden_reader_menus = true;
  65. }
  66. $hidden_reader_bootstrap = false;
  67. //隐藏阅读引导页
  68. if (env('HIDDEN_READ_BOOTSTRAP') &&
  69. in_array($this->distribution_channel_id, explode(',', env('HIDDEN_READ_BOOTSTRAP')))
  70. ) {
  71. $hidden_reader_bootstrap = true;
  72. }
  73. //隐藏活动底部banner
  74. if (env('HIDDEN_ACTIVITY_BANNER') &&
  75. in_array($this->distribution_channel_id, explode(',', env('HIDDEN_ACTIVITY_BANNER')))
  76. ) {
  77. $is_show_activity = 0;
  78. }
  79. //代付
  80. $showDaiChong = \App\Modules\OfficialAccount\Services\PaySubstituteSwitchService::getChannelSwitch($this->distribution_channel_id);
  81. //老年站点
  82. $isOld = 0;
  83. $channel = ChannelService::getDistributionChannel($this->distribution_channel_id);
  84. if ($channel) {
  85. $isOld = $channel->is_old_user_site;
  86. }
  87. //fromtype
  88. $from = $request->get('fromtype');
  89. if (!$from) {
  90. $from = Cookie::get('from') ? Cookie::get('from') : 'main';
  91. }
  92. //crm
  93. $crm = $request->get('crm');
  94. if (!$crm) {
  95. $crm = Cookie::get('crm') ? Cookie::get('crm') : '';
  96. }
  97. //设置用户是否充值
  98. $this->setIsPaid();
  99. $channel_activities_flag = $this->judgeChannelActivity($user);
  100. //最近阅读页面 推荐
  101. if(isset($user->sex)){
  102. $latest_read_rec_books = $this->latest_read_rec_books($channel, $user->sex);
  103. }else{
  104. $latest_read_rec_books = [];
  105. }
  106. //广告样本
  107. $ad_status = env('AD_STATUS', 1);
  108. $adTargetId = false;
  109. if ($ad_status) {
  110. $adTargetId = $this->cpcAd($user->openid);
  111. }
  112. $cpc_channel = '';
  113. if($adTargetId){
  114. $cpc_channel = Redis::hget('channel:setting:'.$this->distribution_channel_id,'cpc_channel');
  115. if(!$cpc_channel) $cpc_channel = 'zw005';
  116. $disable_channel = redisEnv('CPC_DISABLED_CHANNEL','');
  117. if($disable_channel && in_array($cpc_channel,explode(',',$disable_channel))){
  118. $adTargetId = false;
  119. $cpc_channel = '';
  120. }
  121. }
  122. //广告frame
  123. $is_show_ad_frame_setting = env('IS_SHOW_AD_FRAME_SETTING', '123');
  124. $is_show_ad_frame = false;
  125. if ($is_show_ad_frame_setting && in_array($this->distribution_channel_id, explode(',', $is_show_ad_frame_setting))) {
  126. $is_show_ad_frame = true;
  127. }
  128. //标题不显示书名
  129. $show_title_in_reader = false;
  130. $show_title_in_reader_setting = env('SHOW_TITLE_IN_READER_SETTING');
  131. if ($show_title_in_reader_setting && in_array($this->distribution_channel_id, explode(',', $show_title_in_reader_setting))) {
  132. $show_title_in_reader = true;
  133. }
  134. $hide_chapter_channels = explode(',', env('HIDE_CHAPTER_CONSUME_CHANNEL'));
  135. $is_hide_chapter_consume = in_array($this->distribution_channel_id, $hide_chapter_channels) ? 1 : 0;
  136. //广告
  137. // 屏蔽书名
  138. $self_config = ChannelService::check_channel_account_priv($this->distribution_channel_id,'hide_book_name');
  139. $hide_book_name = 0;
  140. if(!empty($self_config)){
  141. $hide_book_name = 1;
  142. }
  143. //原创pv uv
  144. $yctj = false;
  145. $yctj_url = '';
  146. if(in_array($this->distribution_channel_id,[2,146,155,255,691,722,4053,4174,4364,4426])){
  147. $yctj = true;
  148. $yctj_url = 'https://m.ycsd.cn/continueRead';
  149. }
  150. //app广告
  151. $add_ad_status=[
  152. 'appad'=>false,
  153. 'appad_banner'=>'',
  154. 'appad_url'=>''
  155. ];
  156. //突出包年的充值页面
  157. $outstanding_year_order = $this->outstandingYearOrder();
  158. $pdd_ad = $this->pddAd();
  159. //banner 合并
  160. if($is_show_activity)
  161. {
  162. $banners[] = [
  163. 'img'=>$activity_img,
  164. 'jump_url'=>$url
  165. ];
  166. }
  167. //pdd 广告用户--增加banner
  168. if($pdd_ad)
  169. {
  170. $pdd_ads = Redis::get('pdd_ads');//pdd广告
  171. if($pdd_ads)
  172. {
  173. foreach (json_decode($pdd_ads,true) as $_ad)
  174. {
  175. $banners[] = [
  176. 'img'=>$_ad['img'],
  177. 'jump_url'=>$_ad['jump_url']
  178. ];
  179. }
  180. }
  181. }
  182. //用户分割
  183. $this->userPproperty($user->openid);
  184. $month_order_info = $this->monthOrderInfo($user->openid);
  185. $options = json_encode([
  186. 'distribution_channel_id' => (int)$this->distribution_channel_id,
  187. 'send_order_id' => $send_order_id,
  188. 'uid' => $this->uid,
  189. 'pay_url' => env('CREATE_PAY_URL'),
  190. 'title' => $title,
  191. 'kefu' => $customer_service,
  192. 'background' => env('WEB_READER_BACKGROUND'),
  193. 'font_size' => env('WEB_READER_FONT_SIZE'),
  194. 'page_style' => env('WEB_READER_PAGE_STYLE'),
  195. 'from' => $from,
  196. 'is_show_activity' => $is_show_activity,
  197. 'activity_url' => $url,
  198. 'activity_title' => $activity_title,
  199. 'bottom_show_type' => $bottom_show_type,
  200. 'activity_img' => $activity_img,
  201. 'special_bottom_sub_banner' => $this->getSpecialBottomSubBanner(),
  202. 'hidden_reader_menus' => $hidden_reader_menus,
  203. 'hidden_reader_bootstrap' => $hidden_reader_bootstrap,
  204. 'showDaiChong' => (int)$showDaiChong,
  205. 'isOld' => $isOld,
  206. 'sex' => $user ? $user->sex : 0,
  207. 'latest_read_rec_books' => $latest_read_rec_books,
  208. 'fission' => $this->fission(),//裂变
  209. 'channel_activities' => $channel_activities_flag,
  210. 'adTargetId' => $adTargetId,
  211. 'ad_type' => '1',
  212. 'is_show_ad_frame' => $is_show_ad_frame,
  213. 'show_title_in_reader' => $show_title_in_reader,
  214. 'is_hide_chapter_consume' => $is_hide_chapter_consume,
  215. 'hide_book_name' => $hide_book_name,
  216. 'yctj'=>$yctj,
  217. 'yctj_url'=>$yctj_url,
  218. 'appad'=>$add_ad_status['appad'],
  219. 'appad_banner'=>$add_ad_status['appad_banner'],
  220. 'appad_url'=>$add_ad_status['appad_url'],
  221. 'outstanding_year_order'=>$outstanding_year_order,
  222. 'share_domain'=>env('share_domain_url'),
  223. 'share_switch'=>0,//无充值用户分享关闭
  224. 'pdd_ad'=>$pdd_ad,
  225. 'special_pay_template'=>$this->isMiWan(), //米玩站点特殊充值页面
  226. 'crm'=>$crm,
  227. 'self_pa_ad_switch'=>$adTargetId && $pdd_ad ? 1 : 0,//自有平台广告开关
  228. 'banners'=>$banners,
  229. 'guidepersonalaccount'=>$this->guidePersonalAccount(),
  230. 'cpc_channel'=>$cpc_channel,
  231. 'month_order_info'=>$month_order_info
  232. ]);
  233. if ($this->uid == env('SPECIAL_USER_LOG', 2)) {
  234. myLog('special')->info('welcome --------------------------');
  235. myLog('special')->info(json_decode($options, 1));
  236. }
  237. //统计用户ua
  238. $ua = $request->server('HTTP_USER_AGENT');
  239. $this->recordUA($ua);
  240. return view('wap.index', compact('options', 'title'));
  241. }
  242. private function judgeChannelActivity($user_info)
  243. {
  244. //新渠道送书币活动
  245. $channel_activities_hash = [
  246. 500 => 'https://cdn-novel.iycdm.com/h5/five_hundred_coin.png',
  247. 1000 => 'https://cdn-novel.iycdm.com/h5/thoudends_coin.png'
  248. ];
  249. $channel_activities_flag = [
  250. 'shall_reward' => 0,
  251. 'amount' => '',
  252. 'image' => ''
  253. ];
  254. try {
  255. $channel_activities = ChannelActivitiesService::getValidActivity((int)$this->distribution_channel_id);
  256. if ($channel_activities) {
  257. if (time() - strtotime($user_info->created_at->format('Y-m-d H:i:s')) <= 5 * 60) { //对在5分钟之内新注册的用户进行打赏
  258. $reward_info = DB::table('fission')->where([
  259. ['type', '=', 2], ['uid', '=', $this->uid]
  260. ])->first();
  261. if (!$reward_info) { //未被打赏的新用户
  262. //$user_info = UserService::getById($this->uid);
  263. DB::beginTransaction();
  264. $user_info->balance = $user_info->balance + $channel_activities->amount;
  265. $user_info->reward_balance = $user_info->reward_balance + $channel_activities->amount;
  266. if ($user_info->save()) {
  267. $fission_data = [
  268. 'uid' => $this->uid,
  269. 'prize' => $channel_activities->amount,
  270. 'created_at' => date('Y-m-d H:i:s'),
  271. 'updated_at' => date('Y-m-d H:i:s'),
  272. 'type' => 2
  273. ];
  274. DB::table('fission')->insert($fission_data);
  275. DB::commit();
  276. $channel_activities_flag['shall_reward'] = 1;
  277. $channel_activities_flag['amount'] = $channel_activities->amount;
  278. $channel_activities_flag['image'] = $channel_activities_hash[$channel_activities->amount];
  279. $force_sub_info = DB::table('force_subscribe_users')->where([['uid', '=', $this->uid], ['is_subscribed', '=', 1]])->first();
  280. if ($force_sub_info) {
  281. $bookUrl = env('PROTOCOL') . '://site' . encodeDistributionChannelId($this->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/';
  282. $res['openid'] = $force_sub_info->openid;
  283. $res['appid'] = $force_sub_info->appid;
  284. $res['content'] = "亲爱的会员您好:\n恭喜您获得" . ($channel_activities->amount) . "书币奖励\n<a href='" . $bookUrl . "'>去书城看书</a>";
  285. $res['type'] = 'one_task';
  286. $res['send_time'] = date("Y-m-d H:i:s");
  287. $res['task_id'] = md5('channel_activity_push');
  288. $send_data = array(
  289. 'send_time' => date("Y-m-d H:i:s"),
  290. 'data' => $res
  291. );
  292. dispatch((new SendTexts($send_data))->onConnection('rabbitmq')->delay(0)->onQueue('send_texts_list'));
  293. }
  294. } else {
  295. DB::rollBack();
  296. }
  297. }
  298. }
  299. }
  300. } catch (\Exception $e) {
  301. \Log::error('channel activities error:channel_id:' . ($this->distribution_channel_id) . 'uid:' . ($this->uid) . ':' . ($e->getMessage()));
  302. }
  303. return $channel_activities_flag;
  304. }
  305. private function outstandingYearOrder(){
  306. $outstanding_year_order = false;
  307. if(in_array($this->distribution_channel_id,explode(',',env('CAN_NOT_OUTSTANDING_YEAR_ORDER_SITE')))){
  308. return $outstanding_year_order;
  309. }
  310. //if( in_array($this->distribution_channel_id,explode(',',env('OUTSTANDING_YEAR_ORDER_SITE'))) ){
  311. //if($this->uid%2 == 0){
  312. //$userDivisionProperty = UserDivisionPropertyService::getUserProperty($this->uid);
  313. $userDivisionProperty = UserDivisionCpcPropertyService::getUserProperty($this->uid);
  314. $userDivisionProperty && $userDivisionProperty == 'high' && $outstanding_year_order = true;
  315. //}
  316. //}
  317. return $outstanding_year_order;
  318. }
  319. private function luckyUserForeverFree()
  320. {
  321. $lucky_user = 0;
  322. $lucky_user_img = '';
  323. if (!in_array($this->distribution_channel_id, [2, 14, 211])) return compact('lucky_user', 'lucky_user_img');
  324. try {
  325. $lucky_user = Redis::SISMEMBER('luckyYearOrderUser', $this->uid);
  326. } catch (\Exception $e) {
  327. }
  328. $lucky_user && $luckuser_img = 'https://cdn-novel.iycdm.com//h5/lucky.jpg';
  329. return compact('lucky_user', 'lucky_user_img');
  330. }
  331. private function latest_read_rec_books($channel, $sex)
  332. {
  333. $latest_read_rec_books = [];
  334. if ($channel->is_yq_move)//云栖迁移过来的站点
  335. {
  336. //用户性别
  337. if ($sex == 1)//男
  338. {
  339. $bids = [1896, 1969, 2115, 2526, 2610];
  340. } else {
  341. $bids = [1148, 1460, 1572, 1634, 2434, 2436];
  342. if (in_array($this->distribution_channel_id, [4042, 4043, 4044])) {
  343. $bids = [2323, 1347, 2168, 1550, 1295, 1574];
  344. }
  345. }
  346. $latest_read_rec_books = collectionTransform(new BookTransformer(), BookConfigService::getBooksByIds($bids));
  347. }
  348. return $latest_read_rec_books;
  349. }
  350. /**
  351. * 获取123底部强管banner
  352. */
  353. private function getSpecialBottomSubBanner()
  354. {
  355. $week = date('N');
  356. return 'https://cdn-novel.iycdm.com/h5/bottom_sub_banner/' . $week . '.jpg';
  357. }
  358. /**
  359. * 裂变
  360. * @return int
  361. */
  362. private function fission()
  363. {
  364. $fission_send_order_id = env('FISSION_SEND_ORDER_ID');
  365. if ($fission_send_order_id && $this->send_order_id && in_array($this->send_order_id, explode(',', $fission_send_order_id))) {
  366. $is_exist = DB::table('fission')->where('uid', $this->uid)->select('uid')->first();
  367. if (!$is_exist) {
  368. DB::table('fission')->insert([
  369. 'uid' => $this->uid,
  370. 'prize' => 200,
  371. 'created_at' => date('Y-m-d H:i:s'),
  372. 'updated_at' => date('Y-m-d H:i:s')
  373. ]);
  374. UserService::addBalance($this->uid, 200, 0, 200);
  375. return 1;
  376. }
  377. }
  378. return 0;
  379. }
  380. /**
  381. * 获取活动配置信息
  382. */
  383. private function activityOptions()
  384. {
  385. $h5_scheme = env('H5_SCHEME', 'https');
  386. $url = '';
  387. $is_show_activity = 0;
  388. $activity_title = '';
  389. $bottom_show_type = 1;
  390. $activity_img = '';
  391. $user = $this->userInfo($this->uid);
  392. /*$no_participate_activity = env('no_participate_activity', '');
  393. if ($no_participate_activity && in_array($this->distribution_channel_id, explode(',', $no_participate_activity))) {
  394. return compact('url', 'is_show_activity', 'activity_title', 'bottom_show_type', 'activity_img', 'user');
  395. }*/
  396. //自定义活动
  397. $show_custom_activity_channel = env('SHOW_CUSTOM_ACTIVITY_CHANNEL', '');
  398. if ($show_custom_activity_channel) {
  399. $custom_activity_page = ActivityService::getActiveCustomActivity($this->distribution_channel_id);
  400. if ($custom_activity_page) {
  401. if ($show_custom_activity_channel == 'all'
  402. || in_array($this->distribution_channel_id, explode(',', $show_custom_activity_channel))
  403. ) {
  404. $url = $h5_scheme . '://' . _domain() . $custom_activity_page->activity_page . '&fromtype=reader';;
  405. $is_show_activity = 1;
  406. $activity_title = '优惠活动';
  407. $bottom_show_type = 1;
  408. $activity_img = 'https://cdn-novel.iycdm.com/h5/2018-08-24-banner.png';
  409. }
  410. }
  411. }
  412. //自定义新用户活动
  413. $show_custom_new_user_activity_channel = env('SHOW_CUSTOM_NEW_USER_ACTIVITY_CHANNEL', '');
  414. if($show_custom_new_user_activity_channel && in_array($this->distribution_channel_id, explode(',', $show_custom_new_user_activity_channel ))){
  415. $custom_activity_page = ActivityService::getActiveCustomActivityByType($this->distribution_channel_id,'CUSTOM_NEW_USER');
  416. if($custom_activity_page){
  417. $charge_count = Order::where('uid',$this->uid)->where('status','PAID')->count();
  418. if($charge_count ==0 ){
  419. $url = $h5_scheme . '://' . _domain() . $custom_activity_page->activity_page;
  420. $is_show_activity = 1;
  421. $activity_title = '优惠活动';
  422. $bottom_show_type = 1;
  423. $activity_img = 'https://cdn-novel.iycdm.com/h5/2019-04-04-banner.jpg';
  424. }
  425. }
  426. }
  427. $activity_setting = ActivityService::getActivitySetting();
  428. if ($activity_setting) {
  429. $activity_id = isset($activity_setting['activity_id']) ? $activity_setting['activity_id'] : 0;
  430. $activity_info = Activity::find($activity_id);
  431. if ($activity_info &&
  432. time() > strtotime($activity_info->start_time) &&
  433. time() < strtotime($activity_info->end_time) &&
  434. $user &&
  435. isset($user->created_at) &&
  436. (time() - strtotime($user->created_at)) >= 86400 * 2
  437. ) {
  438. $activity_img = isset($activity_setting['wap_bottom_img']) ? $activity_setting['wap_bottom_img'] : '';
  439. /*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])){
  440. $activity_pool = [
  441. 'https://cdn-novel.iycdm.com/h5/activity-2019-06-05/reader-banner.jpg',
  442. 'https://cdn-novel.iycdm.com/h5/activity-2019-06-05/reader-banner2.jpg',
  443. 'https://cdn-novel.iycdm.com/h5/activity-2019-06-05/reader-banner3.jpg'
  444. ];
  445. $activity_img = collect($activity_pool)->random();
  446. }*/
  447. $url = $h5_scheme . '://' . _domain() . $activity_info->activity_page . '&fromtype=reader';
  448. $activity_title = isset($activity_setting['activity_title']) ? $activity_setting['activity_title'] : '';
  449. $status = ActivitySwitchService::isShowInPage($activity_id, $this->distribution_channel_id);
  450. if ($status) {
  451. $is_show_activity = 1;
  452. $bottom_show_type = 2;
  453. if($activity_setting['activity_id'] == env('OTHER_ACTIVITY_ID',0)){
  454. if(!in_array($this->distribution_channel_id, explode(',', env('OTHER_ACTIVITY_CHANNEL', '1')))){
  455. $is_show_activity = 0;
  456. }
  457. }
  458. }
  459. }
  460. }
  461. $year_activity_id = env('YEAR_ACTIVITY_ID');
  462. if ($year_activity_id) {
  463. $activity_info = Activity::find($year_activity_id);
  464. if ($activity_info &&
  465. time() > strtotime($activity_info->start_time) &&
  466. time() < strtotime($activity_info->end_time) &&
  467. $user &&
  468. isset($user->created_at) &&
  469. (time() - strtotime($user->created_at)) >= 86400 * 2
  470. ) {
  471. $sites = env('YEAR_ACTIVITY_CHANNEL', '');
  472. if ($sites && in_array($this->distribution_channel_id, explode(',', $sites))) {
  473. $is_show_activity = 1;
  474. $bottom_show_type = 2;
  475. /*$old_discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->whereIn('activity_id', [643, 827,1104])->count();
  476. if ($old_discount_coupon) {
  477. $activity_img = 'https://cdn-novel.iycdm.com/h5/activity-2019-05-10/reader-80.jpg';
  478. } else {
  479. $activity_img = 'https://cdn-novel.iycdm.com/h5/activity-2019-05-10/reader-50.jpg';
  480. }*/
  481. //$activity_img = sprintf('https://cdn-novel.iycdm.com/h5/activity-2019-07-10/reader-banner%s.jpg',random_int(1,3));
  482. $activity_img = 'https://cdn-novel.iycdm.com/h5/activity-2019-07-25/reader-banner.png';
  483. $url = $h5_scheme . '://' . _domain() . $activity_info->activity_page . '&fromtype=reader';
  484. }
  485. }
  486. }
  487. return compact('url', 'is_show_activity', 'activity_title', 'bottom_show_type', 'activity_img', 'user');
  488. }
  489. /**
  490. * 获取site标题
  491. */
  492. private function getSiteTitle(Request $request)
  493. {
  494. $title = "追书云";
  495. $get_force_subscribe_name = false;
  496. $subscribe = $request->cookie('force_subscribe_name');
  497. $appid = $request->get('appid');
  498. //用户进来携带的公众号信息
  499. if($appid){
  500. $force_subscribe_official = DB::table('official_accounts')->where('appid',$appid)->select('nickname')->first();
  501. if ($force_subscribe_official) {
  502. $title = $force_subscribe_official->nickname;
  503. if($title) return $title;
  504. }
  505. }
  506. if ($subscribe) return $subscribe;
  507. //强关公众号名称
  508. $force_subscribe = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
  509. $this->force_subscribe_info = $force_subscribe;
  510. if ($force_subscribe) {
  511. $force_subscribe_official = DB::table('official_accounts')->where('appid',$force_subscribe->appid)->select('nickname')->first();
  512. if ($force_subscribe_official) {
  513. $title = $force_subscribe_official->nickname;
  514. $get_force_subscribe_name = true;
  515. Cookie::queue('force_subscribe_name', $title, 12 * 3600);
  516. }
  517. }
  518. //可用公众号名称
  519. if (!$get_force_subscribe_name) {
  520. $res = OfficialAccountService::canUseOfficialAccountByChannelId(['distribution_channel_id' => $this->distribution_channel_id]);
  521. if ($res && isset($res->nickname) && !empty($res->nickname)) {
  522. $title = $res->nickname;
  523. Cookie::queue('force_subscribe_name', $title, 12 * 3600);
  524. }
  525. }
  526. return $title;
  527. }
  528. private function appad(){
  529. if($this->force_subscribe_info){
  530. $force_subscribe_info = $this->force_subscribe_info;
  531. }else{
  532. $force_subscribe_info = $this->force_subscribe_info = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
  533. //\Log::info(':'.($this->uid).'force_subs1:'.json_encode($force_subscribe_info));
  534. }
  535. if(!$force_subscribe_info){
  536. return false;
  537. }
  538. $force_sub_user_by_openid = ForceSubscribeUserIService::getForceSubscribeByUidOpenid($this->uid);
  539. if($force_sub_user_by_openid){
  540. $force_subscribe_info = $force_sub_user_by_openid;
  541. //\Log::info('force_subs:'.json_encode($force_subscribe_info));
  542. }
  543. //\Log::info('force_subscribe_:'.json_encode($force_subscribe_info));
  544. //\Log::info('distribution_channel_id:'.$this->distribution_channel_id);
  545. if($force_subscribe_info->subscribe_time &&
  546. (time()-strtotime($force_subscribe_info->subscribe_time) >=3*86400)
  547. && !OrderService::isPaidUserByOpenid($force_subscribe_info->openid) &&
  548. //!AdvertiseUserQueueService::getUserAdvertise($this->uid) &&
  549. in_array($this->distribution_channel_id,explode(',',env('SHARE_OPEN_SITE')))
  550. ){
  551. return true;
  552. }
  553. return false;
  554. }
  555. //CPC广告的优化逻辑
  556. private function cpcAd($openid){
  557. if (in_array($this->uid, explode(',', env('TEST_CPC_UID')))) {
  558. return true;
  559. }
  560. //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])){
  561. $cpc_status = Redis::hget('channel:setting:'.$this->distribution_channel_id,'cpc_status');
  562. if(is_null($cpc_status) || $cpc_status == 1){
  563. $cookie_ad_status = Cookie::get('cpc_ad_status');
  564. if($cookie_ad_status) return $cookie_ad_status == 'show';
  565. $property = UserDivisionCpcPropertyService::userLevel($openid);
  566. /*if(UserService::isCpcUser($this->uid)){
  567. Cookie::queue('cpc_ad_status', 'show');
  568. return true;
  569. }*/
  570. if($property && $property->property == 'none'){
  571. Cookie::queue('cpc_ad_status', 'show');
  572. return true;
  573. }
  574. }
  575. Cookie::queue('cpc_ad_status', 'unshow');
  576. return false;
  577. }
  578. private function pddAd(){
  579. if(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])){
  580. return [
  581. 'banner'=>'https://cdn-novel.iycdm.com/h5/20190531/banner.jpg',
  582. 'url'=>'https://m.ycsd.cn/reader/9F69C5F384552E71/663249E009CA5AC0?u=13002705&isLogin=1'
  583. ];
  584. }
  585. return '';
  586. }
  587. private function isMiWan(){
  588. $miwan_channel_ids = redisEnv('MIWAN_CHANNEL_ID');
  589. if(!$miwan_channel_ids) return false;
  590. return in_array($this->distribution_channel_id,explode(',',$miwan_channel_ids));
  591. }
  592. /**
  593. * 获取客服图片
  594. */
  595. private function getCustomerServiceImg()
  596. {
  597. $setting = CustomMsgService::customerImgUrlByChannelId($this->distribution_channel_id);
  598. if ($setting && $setting->customer_img_url) {
  599. $customer_service = $setting->customer_img_url;
  600. } else {
  601. $customer_service = env('KE_FU_QRCODE','https://cdn-novel.iycdm.com/static/img/kefu20190319.jpg');
  602. //$customer_service = 'https://cdn-novel.iycdm.com/static/img/kefu20190330.jpg';
  603. }
  604. return $customer_service;
  605. }
  606. /**
  607. * 推广链接跳转到用户上一阅读的章节
  608. */
  609. private function formWechatMsgJump(Request $request)
  610. {
  611. $path = $request->path();
  612. if ($path != 'reader') {
  613. return null;
  614. }
  615. $source = $request->input('source');
  616. if (!$source || $source != 'wechatmsg') {
  617. return null;
  618. }
  619. $bid = 0;
  620. $bid_str = $request->input('bid');
  621. $cid = $request->input('cid');
  622. try {
  623. $bid_arr = Hashids::decode($bid_str);
  624. if (isset($bid_arr[0])) {
  625. $bid = $bid_arr[0];
  626. }
  627. } catch (\Exception $e) {
  628. }
  629. if (!$bid) return null;
  630. $record_info = '';
  631. try {
  632. $record_info = ReadRecordService::getRecordByUidBid($this->uid, $bid);
  633. } catch (\Exception $e) {
  634. }
  635. if (!$record_info) return null;
  636. $record_info_arr = explode('_', $record_info);
  637. $param = $request->except(['_url', 'source', 'cid']);
  638. $param['stats'] = 1;
  639. if (isset($record_info_arr[0])) {
  640. $param['cid'] = $record_info_arr[0];
  641. if ($cid && $cid != $record_info_arr[0]) {
  642. $h5_scheme = env('H5_SCHEME', 'https');
  643. $param_str = http_build_query($param);
  644. $url = $h5_scheme . '://' . _domain() . '/reader?' . $param_str;
  645. return $url;
  646. }
  647. }
  648. return null;
  649. }
  650. //用户是否在广告样本中
  651. private function isUserInAdSample()
  652. {
  653. $res = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'AD_V2');
  654. if ($res) {
  655. return true;
  656. } else {
  657. return false;
  658. }
  659. }
  660. /**
  661. * 三天回本活动
  662. * @param Request $request
  663. * @return
  664. */
  665. public function activity(Request $request)
  666. {
  667. $send_time = Redis::hget('add_news_recovery_push_activity' . $this->uid, 'time');
  668. $send_time = time() - 100;
  669. if ($send_time) {
  670. if (time() - $send_time < 86400) {
  671. $activity_id = 1;
  672. $activity_info = ActivityService::getById($activity_id);
  673. if ($activity_info && $activity_info->product_id) {
  674. $from = $request->input('fromtype', 'main');
  675. Redis::sadd('push:activity:distribution_channel_id:' . $this->distribution_channel_id . 'from:' . $from . ':date:' . date('Y-m-d'), $this->uid);
  676. Redis::hincrby('customer:push:click:activity:distribution_channel_id:' . $this->distribution_channel_id . 'from:' . $from, date('Y-m-d'), 1);
  677. $param = [
  678. 'uid' => $this->uid,
  679. 'distribution_channel_id' => $this->distribution_channel_id,
  680. 'product_id' => $activity_info->product_id,
  681. 'activity_id' => $activity_id,
  682. 'fromtype' => $from,
  683. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . encodeDistributionChannelId($this->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/person'
  684. ];
  685. Redis::hdel('add_news_recovery_push_activity' . $this->uid, 'time');
  686. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  687. return view('pay.order.activity', ['url' => $url, 'code' => 0]);
  688. }
  689. }
  690. }
  691. return redirect('/continue');
  692. //return view('pay.order.activity', ['code' => 1, 'url' => '']);
  693. }
  694. /**
  695. * 商户活动
  696. * @param Request $request
  697. * @return view
  698. */
  699. public function channelActivity(Request $request)
  700. {
  701. $token = $request->input('token');
  702. //return view('pay.order.saleactivity', ['url' => $token, 'code' => 0]);
  703. $activity_info = ActivityService::getByToken($token);
  704. if ($activity_info && $activity_info->product_id) {
  705. $from = $request->input('fromtype', 'main');
  706. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  707. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  708. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  709. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  710. Redis::sadd($uv_key, $this->uid);
  711. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  712. $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_info->id)->count();
  713. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time) && empty($order)) {
  714. // $from = $request->input('from', 'main');
  715. // $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  716. // $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  717. // $uv_key = sprintf($uv_key_format,$activity_info->id,$this->distribution_channel_id,date('Y-m-d'));
  718. // $pv_key = sprintf($pv_key_format,$activity_info->id,$this->distribution_channel_id);
  719. // Redis::sadd($uv_key,$this->uid);
  720. // Redis::hincrby($pv_key,date('Y-m-d'),1);
  721. $param = [
  722. 'uid' => $this->uid,
  723. 'distribution_channel_id' => $this->distribution_channel_id,
  724. 'product_id' => $activity_info->product_id,
  725. 'activity_id' => $activity_info->id,
  726. 'fromtype' => $from,
  727. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  728. ];
  729. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  730. return view('pay.order.saleactivity', ['url' => $url, 'code' => 0]);
  731. }
  732. }
  733. return view('pay.order.saleactivity', ['url' => '###', 'code' => 0]);
  734. }
  735. public function springActivityV1(Request $request)
  736. {
  737. $token = $request->input('token');
  738. $activity_info = ActivityService::getByToken($token);
  739. if ($activity_info) {
  740. $from = $request->input('fromtype', 'main');
  741. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  742. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  743. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  744. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  745. Redis::sadd($uv_key, $this->uid);
  746. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  747. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  748. if ($request->input('redirect_url')) {
  749. $redirect_url = $request->input('redirect_url');
  750. $redirect_url = urldecode($redirect_url);
  751. }
  752. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  753. $param_fifty = [
  754. 'uid' => $this->uid,
  755. 'distribution_channel_id' => $this->distribution_channel_id,
  756. 'product_id' => env('SPRING_ACTIVITY_PRODUCT_FIFTY', 2),
  757. 'activity_id' => $activity_info->id,
  758. 'fromtype' => $from,
  759. 'pay_redirect_url' => $redirect_url
  760. ];
  761. $param_hundred = [
  762. 'uid' => $this->uid,
  763. 'distribution_channel_id' => $this->distribution_channel_id,
  764. 'product_id' => env('SPRING_ACTIVITY_PRODUCT_HUNDRED', 3),
  765. 'activity_id' => $activity_info->id,
  766. 'fromtype' => $from,
  767. 'pay_redirect_url' => $redirect_url
  768. ];
  769. $url_fifty = env('CREATE_PAY_URL') . '?' . http_build_query($param_fifty);
  770. $url_hundred = env('CREATE_PAY_URL') . '?' . http_build_query($param_hundred);
  771. return view('pay.order.springactivity', ['url' => ['fifty' => $url_fifty, 'hundred' => $url_hundred], 'code' => 0]);
  772. } else if (time() <= strtotime($activity_info->start_time)) {
  773. return view('pay.order.springactivity', ['url' => [], 'code' => 1]);
  774. } else {
  775. return view('pay.order.springactivity', ['url' => [], 'code' => 2]);
  776. }
  777. }
  778. return view('pay.order.springactivity', ['url' => [], 'code' => 3]);
  779. }
  780. public function springActivity(Request $request)
  781. {
  782. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  783. $token = $request->input('token');
  784. $activity_info = ActivityService::getByToken($token);
  785. if (!$activity_info) {
  786. $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  787. return redirect()->to($default_url);
  788. }
  789. $from = $request->input('fromtype', 'main');
  790. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  791. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  792. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  793. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  794. Redis::sadd($uv_key, $this->uid);
  795. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  796. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  797. if ($request->input('redirect_url')) {
  798. $redirect_url = $request->input('redirect_url');
  799. $redirect_url = urldecode($redirect_url);
  800. }
  801. //未开始
  802. if (time() < strtotime($activity_info->start_time)) {
  803. return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -1]);
  804. }
  805. //结束
  806. if (time() > strtotime($activity_info->end_time)) {
  807. return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2]);
  808. }
  809. $product_ids = [4063, 4064];
  810. $url = [];
  811. foreach ($product_ids as $product_id) {
  812. $param = [
  813. 'uid' => $this->uid,
  814. 'distribution_channel_id' => $this->distribution_channel_id,
  815. 'product_id' => $product_id,
  816. 'activity_id' => $activity_info->id,
  817. 'fromtype' => $from,
  818. 'pay_redirect_url' => $redirect_url,
  819. 'limit' => 100,
  820. ];
  821. $url[] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  822. }
  823. return view('pay.order.springactivity2019', ['url' => $url, 'code' => 0]);
  824. }
  825. /**
  826. *
  827. */
  828. public function womenActivity(Request $request)
  829. {
  830. $token = $request->input('token');
  831. $activity_info = ActivityService::getByToken($token);
  832. if ($activity_info) {
  833. $from = $request->input('fromtype', 'main');
  834. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  835. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  836. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  837. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  838. Redis::sadd($uv_key, $this->uid);
  839. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  840. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  841. if ($request->input('redirect_url')) {
  842. $redirect_url = $request->input('redirect_url');
  843. $redirect_url = urldecode($redirect_url);
  844. }
  845. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  846. $param = [
  847. 'uid' => $this->uid,
  848. 'distribution_channel_id' => $this->distribution_channel_id,
  849. 'product_id' => $activity_info->product_id,
  850. 'activity_id' => $activity_info->id,
  851. 'fromtype' => $from,
  852. 'pay_redirect_url' => $redirect_url
  853. ];
  854. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  855. return view('pay.order.womenactivity', ['url' => $url, 'code' => 0]);
  856. } else if (time() <= strtotime($activity_info->start_time)) {
  857. return view('pay.order.womenactivity', ['url' => [], 'code' => 1]);
  858. } else {
  859. return view('pay.order.womenactivity', ['url' => [], 'code' => 2]);
  860. }
  861. }
  862. return view('pay.order.womenactivity', ['url' => [], 'code' => 3]);
  863. }
  864. public function newUserActivity(Request $request)
  865. {
  866. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  867. $from = $request->input('fromtype', 'main');
  868. $send_time = $request->input('send_time');
  869. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  870. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  871. $activity_id = env('NEW_USER_ACTIVITY_ID', 5);
  872. $activity_info = ActivityService::getById($activity_id);
  873. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  874. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  875. Redis::sadd($uv_key, $this->uid);
  876. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  877. if (!$send_time) {
  878. 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)]);
  879. }
  880. $end_time_str = date('Y-m-d', $send_time + 86400);
  881. $end_time = strtotime(date('Y-m-d', $send_time + 86400) . ' 23:59:59');
  882. if ($send_time > $end_time) {
  883. return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  884. }
  885. if (time() > $end_time) {
  886. return view('pay.order.newUserActivity', ['url' => '###', 'code' => -2, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  887. }
  888. $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
  889. if ($order) {
  890. 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)]);
  891. //return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  892. }
  893. $param = [
  894. 'uid' => $this->uid,
  895. 'distribution_channel_id' => $this->distribution_channel_id,
  896. 'product_id' => $activity_info->product_id,
  897. 'activity_id' => $activity_info->id,
  898. 'fromtype' => $from,
  899. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  900. ];
  901. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  902. return view('pay.order.newUserActivity', ['url' => $url, 'code' => 0, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  903. }
  904. public function channelActivityNine(Request $request)
  905. {
  906. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  907. $token = $request->input('token');
  908. $activity_info = ActivityService::getByToken($token);
  909. if ($activity_info && $activity_info->product_id) {
  910. $from = $request->input('fromtype', 'main');
  911. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  912. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  913. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  914. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  915. Redis::sadd($uv_key, $this->uid);
  916. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  917. //渠道不符合
  918. if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
  919. 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)]);
  920. }
  921. //活动未开始
  922. if (time() < strtotime($activity_info->start_time)) {
  923. return view('pay.order.longactivitynine', ['url' => '###', 'code' => -3, 'start_time' => '', 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
  924. }
  925. //活动结束
  926. if (time() > strtotime($activity_info->end_time)) {
  927. 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)]);
  928. }
  929. $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_info->id)->count();
  930. //参加过了
  931. if ($order) {
  932. 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)]);
  933. }
  934. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time) && empty($order)) {
  935. $not_allow_paid_user_channel_id = env('NOT_ALLOW_PAID_USER_CHANNEL_ID', 0);
  936. //不允许支付过的用户参见9.9的活动
  937. if ($not_allow_paid_user_channel_id &&
  938. in_array($this->distribution_channel_id, explode(',', $not_allow_paid_user_channel_id)) &&
  939. Order::where('uid', $this->uid)->where('status', 'PAID')->first()
  940. ) {
  941. return view('pay.order.longactivitynine', ['url' => '', 'code' => -4, 'start_time' => '', 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
  942. }
  943. $param = [
  944. 'uid' => $this->uid,
  945. 'distribution_channel_id' => $this->distribution_channel_id,
  946. 'product_id' => $activity_info->product_id,
  947. 'activity_id' => $activity_info->id,
  948. 'fromtype' => $from,
  949. 'limit' => 1,
  950. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  951. ];
  952. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  953. 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)]);
  954. }
  955. }
  956. 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)]);
  957. }
  958. public function channelActivitySixtyEight(Request $request)
  959. {
  960. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  961. $token = $request->input('token');
  962. $img = 'https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn68.jpg';
  963. $activity_info = ActivityService::getByToken($token);
  964. if ($activity_info && $activity_info->product_id) {
  965. $from = $request->input('fromtype', 'main');
  966. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  967. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  968. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  969. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  970. Redis::sadd($uv_key, $this->uid);
  971. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  972. //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
  973. //渠道不符合
  974. if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
  975. 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)]);
  976. }
  977. //活动未开始
  978. if (time() < strtotime($activity_info->start_time)) {
  979. 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)]);
  980. }
  981. //活动结束
  982. if (time() > strtotime($activity_info->end_time)) {
  983. 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)]);
  984. }
  985. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  986. $param = [
  987. 'uid' => $this->uid,
  988. 'distribution_channel_id' => $this->distribution_channel_id,
  989. 'product_id' => $activity_info->product_id,
  990. 'activity_id' => $activity_info->id,
  991. 'fromtype' => $from,
  992. 'limit' => 100,
  993. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  994. ];
  995. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  996. 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)]);
  997. }
  998. }
  999. 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)]);
  1000. }
  1001. public function channelActivityFortyEight(Request $request)
  1002. {
  1003. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1004. $token = $request->input('token');
  1005. $activity_info = ActivityService::getByToken($token);
  1006. $img = 'https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn48.jpg';
  1007. if ($activity_info && $activity_info->product_id) {
  1008. $from = $request->input('fromtype', 'main');
  1009. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1010. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1011. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1012. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1013. Redis::sadd($uv_key, $this->uid);
  1014. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1015. //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
  1016. //渠道不符合
  1017. if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
  1018. 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)]);
  1019. }
  1020. //活动未开始
  1021. if (time() < strtotime($activity_info->start_time)) {
  1022. 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)]);
  1023. }
  1024. //活动结束
  1025. if (time() > strtotime($activity_info->end_time)) {
  1026. 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)]);
  1027. }
  1028. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1029. $param = [
  1030. 'uid' => $this->uid,
  1031. 'distribution_channel_id' => $this->distribution_channel_id,
  1032. 'product_id' => $activity_info->product_id,
  1033. 'activity_id' => $activity_info->id,
  1034. 'fromtype' => $from,
  1035. 'limit' => 100,
  1036. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1037. ];
  1038. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1039. 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)]);
  1040. }
  1041. }
  1042. 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)]);
  1043. }
  1044. public function channelNewUserActivity(Request $request)
  1045. {
  1046. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1047. $token = $request->get('token');
  1048. $activity_info = ActivityService::getByToken($token);
  1049. $from = $request->get('fromtype', 'main');
  1050. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1051. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1052. if ($activity_info && $activity_info->product_id){
  1053. $activity_id = $activity_info->id;
  1054. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1055. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1056. Redis::sadd($uv_key, $this->uid);
  1057. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1058. //活动未开始
  1059. if (time() < strtotime($activity_info->start_time)) {
  1060. 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)]);
  1061. }
  1062. //活动结束
  1063. if (time() > strtotime($activity_info->end_time)) {
  1064. 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)]);
  1065. }
  1066. $charge_count = Order::where('uid',$this->uid)->where('status','PAID')->count();
  1067. if($charge_count >0){
  1068. //不是新用户
  1069. 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)]);
  1070. }
  1071. $param = [
  1072. 'uid' => $this->uid,
  1073. 'distribution_channel_id' => $this->distribution_channel_id,
  1074. 'product_id' => $activity_info->product_id,
  1075. 'activity_id' => $activity_info->id,
  1076. 'fromtype' => $from,
  1077. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1078. ];
  1079. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1080. 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)]);
  1081. }
  1082. 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)]);
  1083. }
  1084. /**
  1085. * 清明活动
  1086. */
  1087. public function qingMingActivity(Request $request)
  1088. {
  1089. $token = $request->input('token');
  1090. $activity_info = ActivityService::getByToken($token);
  1091. if ($activity_info) {
  1092. $from = $request->input('fromtype', 'main');
  1093. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1094. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1095. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1096. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1097. Redis::sadd($uv_key, $this->uid);
  1098. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1099. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1100. if ($request->input('redirect_url')) {
  1101. $redirect_url = $request->input('redirect_url');
  1102. $redirect_url = urldecode($redirect_url);
  1103. }
  1104. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1105. $param = [
  1106. 'uid' => $this->uid,
  1107. 'distribution_channel_id' => $this->distribution_channel_id,
  1108. 'product_id' => $activity_info->product_id,
  1109. 'activity_id' => $activity_info->id,
  1110. 'fromtype' => $from,
  1111. 'pay_redirect_url' => $redirect_url
  1112. ];
  1113. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1114. return view('pay.order.qingmingactivity', ['url' => $url, 'code' => 0]);
  1115. } else if (time() <= strtotime($activity_info->start_time)) {
  1116. return view('pay.order.qingmingactivity', ['url' => [], 'code' => 1]);
  1117. } else {
  1118. return view('pay.order.qingmingactivity', ['url' => [], 'code' => 2]);
  1119. }
  1120. }
  1121. return view('pay.order.qingmingactivity', ['url' => [], 'code' => 3]);
  1122. }
  1123. public function readDayActivity(Request $request)
  1124. {
  1125. $token = $request->input('token');
  1126. $activity_info = ActivityService::getByToken($token);
  1127. if ($activity_info) {
  1128. $from = $request->input('fromtype', 'main');
  1129. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1130. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1131. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1132. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1133. Redis::sadd($uv_key, $this->uid);
  1134. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1135. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $this->distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1136. if ($request->input('redirect_url')) {
  1137. $redirect_url = $request->input('redirect_url');
  1138. $redirect_url = urldecode($redirect_url);
  1139. }
  1140. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1141. $param = [
  1142. 'uid' => $this->uid,
  1143. 'distribution_channel_id' => $this->distribution_channel_id,
  1144. 'product_id' => $activity_info->product_id,
  1145. 'activity_id' => $activity_info->id,
  1146. 'fromtype' => $from,
  1147. 'pay_redirect_url' => $redirect_url,
  1148. 'limit' => 100,
  1149. ];
  1150. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1151. return view('pay.order.laborDay', ['url' => $url, 'code' => 0]);
  1152. } else if (time() <= strtotime($activity_info->start_time)) {
  1153. return view('pay.order.laborDay', ['url' => [], 'code' => 1]);
  1154. } else {
  1155. return view('pay.order.laborDay', ['url' => [], 'code' => 2]);
  1156. }
  1157. }
  1158. return view('pay.order.laborDay', ['url' => [], 'code' => 3]);
  1159. }
  1160. public function commonActivity(Request $request)
  1161. {
  1162. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1163. $token = $request->input('token');
  1164. $activity_info = ActivityService::getByToken($token);
  1165. if ($activity_info && isset($activity_info->setting) && empty(!$activity_info->setting)) {
  1166. $imgs = json_decode($activity_info->setting, 1);
  1167. $from = $request->input('fromtype', 'main');
  1168. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1169. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1170. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1171. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1172. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1173. if ($request->input('redirect_url')) {
  1174. $redirect_url = $request->input('redirect_url');
  1175. $redirect_url = urldecode($redirect_url);
  1176. }
  1177. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1178. Redis::sadd($uv_key, $this->uid);
  1179. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1180. $param = [
  1181. 'uid' => $this->uid,
  1182. 'distribution_channel_id' => $this->distribution_channel_id,
  1183. 'product_id' => $activity_info->product_id,
  1184. 'activity_id' => $activity_info->id,
  1185. 'fromtype' => $from,
  1186. 'pay_redirect_url' => $redirect_url,
  1187. 'limit' => 100,
  1188. ];
  1189. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1190. return view('pay.order.common', ['url' => $url, 'code' => 0, 'img' => $imgs]);
  1191. } else if (time() <= strtotime($activity_info->start_time)) {
  1192. return view('pay.order.common', ['url' => [], 'code' => 1, 'img' => $imgs]);
  1193. } else {
  1194. return view('pay.order.common', ['url' => [], 'code' => 2, 'img' => $imgs]);
  1195. }
  1196. }
  1197. $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1198. return redirect()->to($default_url);
  1199. }
  1200. public function yearActivity(Request $request)
  1201. {
  1202. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1203. $from = $request->input('fromtype', 'main');
  1204. $sites = env('YEAR_ACTIVITY_CHANNEL', '');
  1205. $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1206. if (empty($sites)) {
  1207. return redirect()->to($not_access_url);
  1208. }
  1209. $site_arr = explode(',', $sites);
  1210. if (!in_array($this->distribution_channel_id, $site_arr)) {
  1211. return redirect()->to($not_access_url);
  1212. }
  1213. $year_activity_id = env('YEAR_ACTIVITY_ID');
  1214. if (!$year_activity_id) {
  1215. return redirect()->to($not_access_url);
  1216. }
  1217. $activity_info = Activity::find($year_activity_id);
  1218. if (!$activity_info) {
  1219. return redirect()->to($not_access_url);
  1220. }
  1221. $activity_id = $year_activity_id;
  1222. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1223. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1224. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1225. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1226. Redis::sadd($uv_key, $this->uid);
  1227. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1228. $start = $activity_info->start_time;
  1229. $end = $activity_info->end_time;
  1230. if (empty($start) || empty($end)) {
  1231. return redirect()->to($not_access_url);
  1232. }
  1233. $male_site = env('YEAR_MALE_SITE');
  1234. if ($male_site && in_array($this->distribution_channel_id, explode(',', $male_site))) {
  1235. $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('YEAR_MALE_BID'))));
  1236. } else {
  1237. $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('YEAR_FEMALE_BID'))));
  1238. }
  1239. $is_get = 0;
  1240. $discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->where('activity_id', $activity_id)->count();
  1241. //$old_discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->where('activity_id', $old_year_activity_id)->count();
  1242. $old_discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->whereIn('activity_id', [643, 827, 1104, 1294])->count();
  1243. if ($discount_coupon) {
  1244. $is_get = 1;
  1245. }
  1246. if ($old_discount_coupon) {
  1247. //51活动领取过 优惠80
  1248. $discount = 80;
  1249. $product_id = $activity_info->product_id;
  1250. } else {
  1251. //51活动领未取过 优惠50
  1252. $discount = 50;
  1253. $product_id = 1450;
  1254. }
  1255. if (time() < strtotime($start)) {
  1256. //未开始
  1257. return view('pay.order.yearactivityV3', ['url' => '', 'is_get' => 1, 'coupons_url' => '', 'code' => 1, 'books' => $books, 'activity_id' => $activity_id, 'discount' => $discount]);
  1258. }
  1259. if (time() > strtotime($end)) {
  1260. //结束
  1261. return view('pay.order.yearactivityV3', ['url' => '', 'is_get' => 1, 'coupons_url' => '', 'code' => 2, 'books' => $books, 'activity_id' => $activity_id, 'discount' => $discount]);
  1262. }
  1263. $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
  1264. //参加过了
  1265. if ($order) {
  1266. //return view('pay.order.yearactivityV2', ['url' => '', 'is_get' => 1, 'coupons_url' => '', 'code' => 3, 'books' => $books, 'activity_id' => $activity_id, 'discount' => $discount]);
  1267. }
  1268. $param = [
  1269. 'uid' => $this->uid,
  1270. 'distribution_channel_id' => $this->distribution_channel_id,
  1271. 'product_id' => $product_id,
  1272. 'activity_id' => $activity_id,
  1273. 'fromtype' => $from,
  1274. 'limit' => 10,
  1275. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1276. ];
  1277. $this->getCoupons($activity_id);
  1278. $coupons_url = $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1279. $param['product_id'] = 5;
  1280. $primary_url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1281. 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]);
  1282. }
  1283. private function getCoupons($activity_id)
  1284. {
  1285. if (!DB::table('discount_coupons')->where('uid', $this->uid)->where('activity_id', $activity_id)->count()) {
  1286. DB::table('discount_coupons')->insert([
  1287. 'uid' => $this->uid,
  1288. 'activity_id' => $activity_id,
  1289. 'created_at' => date('Y-m-d H:i:s'),
  1290. 'updated_at' => date('Y-m-d H:i:s')
  1291. ]);
  1292. }
  1293. }
  1294. public function summerActivity(Request $request)
  1295. {
  1296. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1297. $from = $request->input('fromtype', 'main');
  1298. $sites = env('YEAR_ACTIVITY_CHANNEL', '');
  1299. $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1300. if (empty($sites)) {
  1301. return redirect()->to($not_access_url);
  1302. }
  1303. if ($sites != 'all') {
  1304. $site_arr = explode(',', $sites);
  1305. if (!in_array($this->distribution_channel_id, $site_arr)) {
  1306. return redirect()->to($not_access_url);
  1307. }
  1308. }
  1309. $activity_id = 350;
  1310. $activity_info = Activity::find($activity_id);
  1311. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1312. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1313. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1314. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1315. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1316. if ($request->input('redirect_url')) {
  1317. $redirect_url = $request->input('redirect_url');
  1318. $redirect_url = urldecode($redirect_url);
  1319. }
  1320. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1321. Redis::sadd($uv_key, $this->uid);
  1322. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1323. $url_array = [];
  1324. $product_id_array = [2158, 2159, 2160, 2161];
  1325. foreach ($product_id_array as $v) {
  1326. $param = [
  1327. 'uid' => $this->uid,
  1328. 'distribution_channel_id' => $this->distribution_channel_id,
  1329. 'product_id' => $v,
  1330. 'activity_id' => $activity_id,
  1331. 'fromtype' => $from,
  1332. 'pay_redirect_url' => $redirect_url,
  1333. 'limit' => 100,
  1334. ];
  1335. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1336. $url_array[] = $url;
  1337. }
  1338. return view('pay.order.summerActivity', ['url' => '', 'code' => 0, 'url_array' => $url_array]);
  1339. } else if (time() <= strtotime($activity_info->start_time)) {
  1340. return view('pay.order.summerActivity', ['url' => [], 'code' => 1]);
  1341. } else {
  1342. return view('pay.order.summerActivity', ['url' => [], 'code' => 2]);
  1343. }
  1344. }
  1345. public function newUserSale(Request $request)
  1346. {
  1347. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1348. $from = $request->input('fromtype', 'main');
  1349. $send_time = $request->input('send_time');
  1350. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1351. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1352. $activity_id = 402;
  1353. $activity_info = ActivityService::getById($activity_id);
  1354. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1355. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1356. Redis::sadd($uv_key, $this->uid);
  1357. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1358. // 2226,2227,2228,22229,2230
  1359. if (!$send_time) {
  1360. $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
  1361. 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)]);
  1362. }
  1363. $end_time_str = date('Y-m-d', $send_time + 3 * 86400);
  1364. $end_time = strtotime(date('Y-m-d', $send_time + 3 * 86400) . ' 23:59:59');
  1365. if ($send_time > $end_time) {
  1366. $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
  1367. return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => -1, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  1368. }
  1369. if (time() > $end_time) {
  1370. $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
  1371. return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => -2, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  1372. }
  1373. $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
  1374. if ($order) {
  1375. $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id);
  1376. return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  1377. }
  1378. $url_info = $this->getUrls($activity_info->setting, $from, $this->distribution_channel_id, $encode_distribution_channel_id, $activity_id, true);
  1379. return view('pay.order.newUserOtherActivity', ['url' => $url_info, 'code' => 0, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  1380. }
  1381. private function getUrls($activity_info_setting, $from, $channel_id, $encode_channel_id, $activity_id, $is_access = false)
  1382. {
  1383. $product = DB::table('products')
  1384. ->whereIn('id', explode(',', $activity_info_setting))
  1385. ->select('id', 'price', 'type', 'given')
  1386. ->get();
  1387. $url_info = [];
  1388. $url_info['year'] = ['url' => '###'];
  1389. $url_info['charge'] = [];
  1390. $param = [
  1391. 'uid' => $this->uid,
  1392. 'distribution_channel_id' => $this->distribution_channel_id,
  1393. 'product_id' => $channel_id,
  1394. 'limit' => 1,
  1395. 'fromtype' => $from,
  1396. 'activity_id' => $activity_id,
  1397. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1398. ];
  1399. if (!$product) {
  1400. return $url_info;
  1401. }
  1402. foreach ($product as $v) {
  1403. if(in_array($this->distribution_channel_id,[6917,6918,6939]) && $v->type == 'YEAR_ORDER'){
  1404. continue;
  1405. }
  1406. if ($is_access) {
  1407. $param['product_id'] = $v->id;
  1408. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1409. } else {
  1410. $url = '###';
  1411. }
  1412. if ($v->type == 'YEAR_ORDER') {
  1413. $url_info['year']['url'] = $url;
  1414. } else {
  1415. $temp = [];
  1416. $temp['url'] = $url;
  1417. $temp['price'] = (int)$v->price;
  1418. $temp['given'] = (int)($v->given / 100);
  1419. $temp['total'] = $v->price * 100 + $v->given;
  1420. if ($v->price == 30) {
  1421. $temp['old_given'] = '无折扣';
  1422. } elseif ($v->price == 50) {
  1423. $temp['old_given'] = '送40元';
  1424. } elseif ($v->price == 100) {
  1425. $temp['old_given'] = '送100元';
  1426. } elseif ($v->price == 200) {
  1427. $temp['old_given'] = '送200元';
  1428. } else {
  1429. $temp['old_given'] = '';
  1430. }
  1431. $url_info['charge'][] = $temp;
  1432. }
  1433. }
  1434. return $url_info;
  1435. }
  1436. public function nationalDayActivity(Request $request)
  1437. {
  1438. $token = $request->input('token', '');
  1439. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1440. $activity_info = ActivityService::getByToken($token);
  1441. if (!$activity_info) {
  1442. $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1443. return redirect()->to($not_access_url);
  1444. }
  1445. $from = $request->input('fromtype', 'main');
  1446. $activity_id = $activity_info->id;
  1447. $activty_ids = env('NATIONAL_DAY_ACTIVITY_IDS', '1,2,3');
  1448. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1449. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1450. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1451. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1452. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1453. if ($request->input('redirect_url')) {
  1454. $redirect_url = $request->input('redirect_url');
  1455. $redirect_url = urldecode($redirect_url);
  1456. }
  1457. $activity_status = -1;
  1458. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1459. $activity_status = 1;
  1460. }
  1461. if (time() < strtotime($activity_info->start_time)) {
  1462. //未开始
  1463. $activity_status = -1;
  1464. }
  1465. if (time() > strtotime($activity_info->end_time)) {
  1466. //结束
  1467. $activity_status = -2;
  1468. }
  1469. Redis::sadd($uv_key, $this->uid);
  1470. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1471. $user_charge_count = (int)(Order::where('uid', $this->uid)->where('status', 'PAID')->count());
  1472. if ($user_charge_count == 0) {
  1473. $is_first_charge = 1;
  1474. } else {
  1475. $is_first_charge = 0;
  1476. }
  1477. $url_array = [];
  1478. $product_id_array = explode(',', $activty_ids);
  1479. foreach ($product_id_array as $key => $v) {
  1480. if ($user_charge_count >= 1 && $key == 0) {
  1481. //continue;
  1482. }
  1483. $param = [
  1484. 'uid' => $this->uid,
  1485. 'distribution_channel_id' => $this->distribution_channel_id,
  1486. 'product_id' => $v,
  1487. 'activity_id' => $activity_id,
  1488. 'fromtype' => $from,
  1489. 'pay_redirect_url' => $redirect_url,
  1490. 'limit' => 100,
  1491. ];
  1492. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1493. $url_array[] = $url;
  1494. }
  1495. return view('pay.order.nationalDayActivity', ['url' => $url_array, 'is_first_charge' => $is_first_charge, 'code' => $activity_status]);
  1496. }
  1497. public function cYactivity(Request $request)
  1498. {
  1499. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1500. $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1501. $site_arr = explode(',', env('YEAR_ACTIVITY_CHANNEL', '2'));
  1502. if (!in_array($this->distribution_channel_id, $site_arr)) {
  1503. return redirect()->to($default_url);
  1504. }
  1505. $activity_info = ActivityService::getById(929);
  1506. if ($activity_info) {
  1507. $from = $request->input('fromtype', 'main');
  1508. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1509. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1510. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1511. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1512. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1513. if ($request->input('redirect_url')) {
  1514. $redirect_url = $request->input('redirect_url');
  1515. $redirect_url = urldecode($redirect_url);
  1516. }
  1517. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1518. Redis::sadd($uv_key, $this->uid);
  1519. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1520. $param = [
  1521. 'uid' => $this->uid,
  1522. 'distribution_channel_id' => $this->distribution_channel_id,
  1523. 'product_id' => $activity_info->product_id,
  1524. 'activity_id' => $activity_info->id,
  1525. 'fromtype' => $from,
  1526. 'pay_redirect_url' => $redirect_url,
  1527. 'limit' => 100,
  1528. ];
  1529. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1530. return view('pay.order.cyangActivity', ['url' => $url, 'code' => 0,]);
  1531. } else if (time() <= strtotime($activity_info->start_time)) {
  1532. return view('pay.order.cyangActivity', ['url' => [], 'code' => 1,]);
  1533. } else {
  1534. return view('pay.order.cyangActivity', ['url' => [], 'code' => 2,]);
  1535. }
  1536. }
  1537. return redirect()->to($default_url);
  1538. return view('pay.order.cyangActivity', []);
  1539. }
  1540. public function newUserForeverActivity(Request $request)
  1541. {
  1542. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1543. $from = $request->input('fromtype', 'main');
  1544. $send_time = $request->input('send_time');
  1545. $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1546. if ($this->distribution_channel_id != 123) {
  1547. return redirect()->to($default_url);
  1548. }
  1549. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1550. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1551. $activity_id = env('FOREVER_ACTIVITY_ID', 5);
  1552. $activity_info = ActivityService::getById($activity_id);
  1553. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1554. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1555. Redis::sadd($uv_key, $this->uid);
  1556. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1557. $books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
  1558. if (!$send_time) {
  1559. return view('pay.order.foreverActivity', ['url' => '###', 'code' => -3, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'books' => $books]);
  1560. }
  1561. $end_time = $send_time + 86400 * 3;
  1562. $time_diff = $end_time - time();
  1563. if ($time_diff <= 0) {
  1564. return view('pay.order.foreverActivity', ['url' => '###', 'code' => -2, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'books' => $books]);
  1565. }
  1566. /*$order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
  1567. if ($order) {
  1568. return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  1569. }*/
  1570. $books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
  1571. $day = floor($time_diff / 86400);
  1572. $hour = floor(($time_diff - $day * 86400) / 3600);
  1573. $minute = floor(($time_diff - $day * 86400 - $hour * 3600) / 60);
  1574. $second = $time_diff - $day * 86400 - $hour * 3600 - $minute * 60;
  1575. $param = [
  1576. 'uid' => $this->uid,
  1577. 'distribution_channel_id' => $this->distribution_channel_id,
  1578. 'product_id' => $activity_info->product_id,
  1579. 'activity_id' => $activity_info->id,
  1580. 'fromtype' => $from,
  1581. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1582. ];
  1583. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1584. return view('pay.order.foreverActivity', ['url' => $url, 'code' => 0, 'time' => compact('day', 'hour', 'minute', 'second'), 'books' => $books]);
  1585. }
  1586. public function tempC()
  1587. {
  1588. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1589. $param = [
  1590. 'uid' => $this->uid,
  1591. 'distribution_channel_id' => $this->distribution_channel_id,
  1592. 'product_id' => 1450,
  1593. 'activity_id' => 0,
  1594. 'fromtype' => 'tempC',
  1595. 'limit' => 10,
  1596. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1597. ];
  1598. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1599. return redirect()->to($url);
  1600. }
  1601. /**
  1602. * 68元包年活动
  1603. * @param Request $request
  1604. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\Swoft\Http\Message\Server\Response
  1605. */
  1606. public function otherYearActivity(Request $request)
  1607. {
  1608. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1609. $from = $request->input('fromtype', 'main');
  1610. $send_time = $request->input('send_time');
  1611. $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1612. if ($this->distribution_channel_id != 123) {
  1613. return redirect()->to($default_url);
  1614. }
  1615. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1616. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1617. $activity_id = env('68_YEAR_ACTIVITY_ID', 5);
  1618. $activity_info = ActivityService::getById($activity_id);
  1619. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1620. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1621. Redis::sadd($uv_key, $this->uid);
  1622. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1623. //$books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
  1624. $books = '';
  1625. $time_diff = 0;
  1626. if (!$send_time) {
  1627. return view('pay.order.otherYearActivity', ['url' => '###', 'code' => -3, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'time_diff' => $time_diff]);
  1628. }
  1629. $end_time = $send_time + 86400 * 3;
  1630. $time_diff = $end_time - time();
  1631. if ($time_diff <= 0) {
  1632. return view('pay.order.otherYearActivity', ['url' => '###', 'code' => -2, 'time' => ['day' => 0, 'hour' => 0, 'minute' => 0, 'second' => 0], 'time_diff' => $time_diff]);
  1633. }
  1634. /*$order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('activity_id', $activity_id)->count();
  1635. if ($order) {
  1636. return view('pay.order.newUserActivity', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', $send_time), 'end_time' => $end_time_str]);
  1637. }*/
  1638. //$books = $books = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', env('FOREVER_ACTIVITY_BID'))));
  1639. $day = floor($time_diff / 86400);
  1640. $hour = floor(($time_diff - $day * 86400) / 3600);
  1641. $minute = floor(($time_diff - $day * 86400 - $hour * 3600) / 60);
  1642. $second = $time_diff - $day * 86400 - $hour * 3600 - $minute * 60;
  1643. $param = [
  1644. 'uid' => $this->uid,
  1645. 'distribution_channel_id' => $this->distribution_channel_id,
  1646. 'product_id' => $activity_info->product_id,
  1647. 'activity_id' => $activity_info->id,
  1648. 'fromtype' => $from,
  1649. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1650. ];
  1651. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1652. return view('pay.order.otherYearActivity', ['url' => $url, 'code' => 0, 'time' => compact('day', 'hour', 'minute', 'second'), 'time_diff' => $time_diff]);
  1653. }
  1654. /**
  1655. * 双十一购物节统计
  1656. * @param Request $request
  1657. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\Swoft\Http\Message\Server\Response
  1658. */
  1659. public function shoppingDayActivity(Request $request)
  1660. {
  1661. $token = $request->input('token', '');
  1662. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1663. $activity_info = ActivityService::getByToken($token);
  1664. if (!$activity_info) {
  1665. $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1666. return redirect()->to($not_access_url);
  1667. }
  1668. $from = $request->input('fromtype', 'main');
  1669. $activity_id = $activity_info->id;
  1670. $activty_ids = env('SHOPPING_DAY_ACTIVITY_IDS', '1,2,3');
  1671. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1672. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1673. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1674. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1675. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1676. if ($request->input('redirect_url')) {
  1677. $redirect_url = $request->input('redirect_url');
  1678. $redirect_url = urldecode($redirect_url);
  1679. }
  1680. $activity_status = -1;
  1681. if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
  1682. $activity_status = 1;
  1683. }
  1684. if (time() < strtotime($activity_info->start_time)) {
  1685. //未开始
  1686. $activity_status = -1;
  1687. }
  1688. if (time() > strtotime($activity_info->end_time)) {
  1689. //结束
  1690. $activity_status = -2;
  1691. }
  1692. Redis::sadd($uv_key, $this->uid);
  1693. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1694. $user_charge_count = (int)(Order::where('uid', $this->uid)->where('status', 'PAID')->count());
  1695. if ($user_charge_count == 0) {
  1696. $is_first_charge = 1;
  1697. } else {
  1698. $is_first_charge = 0;
  1699. }
  1700. $url_array = [];
  1701. $time_diff = strtotime($activity_info->end_time) - time();
  1702. $day = 0;
  1703. $hour = 0;
  1704. $minute = 0;
  1705. $second = 0;
  1706. if ($time_diff > 0) {
  1707. $day = floor($time_diff / 86400);
  1708. $hour = floor(($time_diff - $day * 86400) / 3600);
  1709. $minute = floor(($time_diff - $day * 86400 - $hour * 3600) / 60);
  1710. $second = $time_diff - $day * 86400 - $hour * 3600 - $minute * 60;
  1711. }
  1712. $product_id_array = explode(',', $activty_ids);
  1713. $product_infos = DB::table('products')->whereIn('id', $product_id_array)->select('id', 'price', 'given')->get();
  1714. foreach ($product_infos as $key => $v) {
  1715. if ($user_charge_count >= 1 && $key == 0) {
  1716. continue;
  1717. }
  1718. $limit = 100;
  1719. if ($key == 0) {
  1720. $limit = 1;
  1721. }
  1722. $param = [
  1723. 'uid' => $this->uid,
  1724. 'distribution_channel_id' => $this->distribution_channel_id,
  1725. 'product_id' => $v->id,
  1726. 'activity_id' => $activity_id,
  1727. 'fromtype' => $from,
  1728. 'pay_redirect_url' => $redirect_url,
  1729. 'limit' => $limit,
  1730. ];
  1731. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1732. $url_array[] = ['url' => $url, 'price' => (int)$v->price, 'given' => $v->given / 100, 'get' => $v->price * 100 + $v->given];
  1733. }
  1734. return view('pay.order.shoppingDayActivity', [
  1735. 'url' => $url_array,
  1736. 'is_first_charge' => $is_first_charge,
  1737. 'code' => $activity_status,
  1738. 'time' => compact('day', 'hour', 'minute', 'second'),
  1739. 'user_charge_count' => $user_charge_count,
  1740. 'time_diff' => $time_diff
  1741. ]
  1742. );
  1743. }
  1744. public function thanksGivingDayActivity(Request $request)
  1745. {
  1746. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1747. $from = $request->input('fromtype', 'main');
  1748. $sites = env('YEAR_ACTIVITY_CHANNEL', '');
  1749. $not_access_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1750. if (empty($sites)) {
  1751. return redirect()->to($not_access_url);
  1752. }
  1753. $site_arr = explode(',', $sites);
  1754. if (!in_array($this->distribution_channel_id, $site_arr)) {
  1755. return redirect()->to($not_access_url);
  1756. }
  1757. $year_activity_id = 1367;
  1758. $activity_info = Activity::find($year_activity_id);
  1759. if (!$activity_info) {
  1760. return redirect()->to($not_access_url);
  1761. }
  1762. $activity_id = $year_activity_id;
  1763. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1764. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1765. $uv_key = sprintf($uv_key_format, $activity_id, $this->distribution_channel_id, date('Y-m-d'));
  1766. $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
  1767. Redis::sadd($uv_key, $this->uid);
  1768. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1769. $start = $activity_info->start_time;
  1770. $end = $activity_info->end_time;
  1771. if (empty($start) || empty($end)) {
  1772. return redirect()->to($not_access_url);
  1773. }
  1774. $url = ['slow' => 'javascript:void(0)', 'height' => 'javascript:void(0)'];
  1775. $order = Order::where('uid', $this->uid)->where('status', 'PAID')->select('id')->first();
  1776. $charge_count = 0;
  1777. if ($order) {
  1778. $charge_count = 1;
  1779. }
  1780. if (time() < strtotime($start)) {
  1781. //未开始
  1782. return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 1, 'charge_count' => $charge_count]);
  1783. }
  1784. if (time() > strtotime($end)) {
  1785. //结束
  1786. return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 2, 'charge_count' => $charge_count]);
  1787. }
  1788. //3483 3484
  1789. $param = [
  1790. 'uid' => $this->uid,
  1791. 'distribution_channel_id' => $this->distribution_channel_id,
  1792. 'product_id' => 3483,
  1793. 'activity_id' => $activity_id,
  1794. 'fromtype' => $from,
  1795. 'limit' => 1,
  1796. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1797. ];
  1798. $this->getCoupons($activity_id);
  1799. $url['slow'] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1800. $param['product_id'] = 3484;
  1801. $param['limit'] = 100;
  1802. $url['height'] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1803. return view('pay.order.thanksGivingDayActivity', ['url' => $url, 'code' => 0, 'charge_count' => $charge_count]);
  1804. }
  1805. public function greatColdActivity(Request $request)
  1806. {
  1807. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1808. $token = $request->input('token');
  1809. $activity_info = ActivityService::getByToken($token);
  1810. if (!$activity_info) {
  1811. $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1812. return redirect()->to($default_url);
  1813. }
  1814. $from = $request->input('fromtype', 'main');
  1815. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1816. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1817. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1818. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1819. Redis::sadd($uv_key, $this->uid);
  1820. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1821. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1822. if ($request->input('redirect_url')) {
  1823. $redirect_url = $request->input('redirect_url');
  1824. $redirect_url = urldecode($redirect_url);
  1825. }
  1826. $least_charge_amount = Order::select('id', 'price')
  1827. ->where('uid', $this->uid)
  1828. ->where('status', 'PAID')
  1829. ->where('created_at', '>=', strtotime($activity_info->start_time) - 60 * 86400)
  1830. ->max('price');
  1831. $type = 'litter';
  1832. $product_ids = [3962, 3963];
  1833. $img = [
  1834. 'litter' => [
  1835. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/8-active.png',
  1836. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/8.png',
  1837. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23-active.png',
  1838. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23.png',
  1839. ],
  1840. 'big' => [
  1841. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23-active.png',
  1842. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23.png',
  1843. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/58-active.png',
  1844. 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/58.png',
  1845. ],
  1846. ];
  1847. if ($least_charge_amount && $least_charge_amount >= 30) {
  1848. $type = 'big';
  1849. $product_ids = [3960, 3961];
  1850. }
  1851. //未开始
  1852. if (time() < strtotime($activity_info->start_time)) {
  1853. return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -1, 'type' => $type, 'img' => $img]);
  1854. }
  1855. //结束
  1856. if (time() > strtotime($activity_info->end_time)) {
  1857. return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2, 'type' => $type, 'img' => $img]);
  1858. }
  1859. $url = [];
  1860. foreach ($product_ids as $product_id) {
  1861. $param = [
  1862. 'uid' => $this->uid,
  1863. 'distribution_channel_id' => $this->distribution_channel_id,
  1864. 'product_id' => $product_id,
  1865. 'activity_id' => $activity_info->id,
  1866. 'fromtype' => $from,
  1867. 'pay_redirect_url' => $redirect_url,
  1868. 'limit' => 100,
  1869. ];
  1870. $url[] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1871. }
  1872. return view('pay.order.greatColdActivity', ['url' => $url, 'code' => 0, 'type' => $type, 'img' => $img]);
  1873. }
  1874. public function channelYearActivity(Request $request)
  1875. {
  1876. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1877. $id = 2628;
  1878. $activity_info = ActivityService::getById($id);
  1879. if ($activity_info && $activity_info->product_id) {
  1880. $from = $request->input('fromtype', 'main');
  1881. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1882. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1883. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1884. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1885. Redis::sadd($uv_key, $this->uid);
  1886. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1887. $param = [
  1888. 'uid' => $this->uid,
  1889. 'distribution_channel_id' => $this->distribution_channel_id,
  1890. 'product_id' => $activity_info->product_id,
  1891. 'activity_id' => $activity_info->id,
  1892. 'fromtype' => $from,
  1893. 'limit' => 30,
  1894. 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
  1895. ];
  1896. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1897. return view('pay.order.channelYearActivity', ['url' => $url]);
  1898. }
  1899. $url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1900. return redirect()->to($url);
  1901. }
  1902. //春分活动
  1903. public function vernalEquinoxActivity(Request $request)
  1904. {
  1905. $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
  1906. $token = $request->input('token');
  1907. $activity_info = ActivityService::getByToken($token);
  1908. if (!$activity_info) {
  1909. $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
  1910. return redirect()->to($default_url);
  1911. }
  1912. $from = $request->input('fromtype', 'main');
  1913. $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
  1914. $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
  1915. $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
  1916. $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
  1917. Redis::sadd($uv_key, $this->uid);
  1918. Redis::hincrby($pv_key, date('Y-m-d'), 1);
  1919. $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
  1920. if ($request->input('redirect_url')) {
  1921. $redirect_url = $request->input('redirect_url');
  1922. $redirect_url = urldecode($redirect_url);
  1923. }
  1924. $least_charge_amount = Order::select('id', 'price')
  1925. ->where('uid', $this->uid)
  1926. ->where('status', 'PAID')
  1927. ->where('created_at', '>=', strtotime($activity_info->start_time) - 60 * 86400)
  1928. ->max('price');
  1929. $type = 'litter';
  1930. if ($least_charge_amount && $least_charge_amount >= 30) {
  1931. $img = 'https://cdn-novel.iycdm.com/h5/activity-2019-03-20/bg50.jpg';
  1932. $product_ids = 4806;
  1933. }else{
  1934. $img = 'https://cdn-novel.iycdm.com/h5/activity-2019-03-20/bg23.jpg';
  1935. $product_ids = 4805;
  1936. }
  1937. //未开始
  1938. if (time() < strtotime($activity_info->start_time)) {
  1939. return view('pay.order.vernalEquinoxActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -1, 'type' => $type, 'img' => $img]);
  1940. }
  1941. //结束
  1942. if (time() > strtotime($activity_info->end_time)) {
  1943. return view('pay.order.vernalEquinoxActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2, 'type' => $type, 'img' => $img]);
  1944. }
  1945. $param = [
  1946. 'uid' => $this->uid,
  1947. 'distribution_channel_id' => $this->distribution_channel_id,
  1948. 'product_id' => $product_ids,
  1949. 'activity_id' => $activity_info->id,
  1950. 'fromtype' => $from,
  1951. 'pay_redirect_url' => $redirect_url,
  1952. 'limit' => 100,
  1953. ];
  1954. $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
  1955. return view('pay.order.vernalEquinoxActivity', ['url' => $url, 'code' => 0, 'type' => $type, 'img' => $img]);
  1956. }
  1957. private function userPproperty($openid){
  1958. $old = UserDivisionCpcPropertyService::userLevel($openid);
  1959. if(!$old) return ;
  1960. $this->property = $old->property;
  1961. if($old->type != 'NEW') return ;
  1962. $send_data = array(
  1963. 'type' => 'visit',
  1964. 'data' => ['openid'=>$openid,'uid'=>$this->uid]
  1965. );
  1966. try {
  1967. $send = new SendStatisticsList($send_data);
  1968. $job = ($send)->onConnection('rabbitmq')->delay(0)->onQueue('send_statistics_list');
  1969. dispatch($job);
  1970. } catch (\Exception $e) {
  1971. \Log::info($e);
  1972. }
  1973. }
  1974. private function guidePersonalAccount(){
  1975. //weidian
  1976. $other_crm_config = Redis::hmget('channel:setting:'.$this->distribution_channel_id,['crm_status','crm_link']);
  1977. $crm_config = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE','OUT_ACTIVE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  1978. $out_status = Redis::SISMEMBER('crm:out_channel_sites',$this->distribution_channel_id);
  1979. if(empty($other_crm_config[0]) && empty($other_crm_config[1]) && empty($crm_config[0]) && empty($crm_config[1]) && empty($out_status)){
  1980. return '';
  1981. }
  1982. //Log::info('guidePersonalAccount1111111111111111111111');
  1983. $get_info = UserBindHkWelfareService::isHasGet($this->uid);
  1984. if($get_info) return '';
  1985. //Log::info('guidePersonalAccount2222222222222222222222');
  1986. $charge = $this->is_paid;
  1987. if($this->distribution_channel_id == 6687){
  1988. $charge = true;
  1989. }
  1990. if(!$charge) return '';
  1991. //其他渠道自己导粉
  1992. if($other_crm_config[0] && $other_crm_config[1]){
  1993. if($charge)
  1994. return ['title'=>'点击领取200书币>>','link'=>$other_crm_config[1]];
  1995. return '';
  1996. }
  1997. //站外导粉
  1998. if($out_status){
  1999. if($crm_config[2]){
  2000. return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid.'&fee=500'];
  2001. }
  2002. return '';
  2003. }
  2004. //Log::info('guidePersonalAccount33333333333333333');
  2005. if(empty($crm_config[0]) || empty($crm_config[1])) return '';
  2006. //Log::info('guidePersonalAccount4444444444444444');
  2007. if(!in_array($this->distribution_channel_id,explode(',',$crm_config[0]))){
  2008. return '';
  2009. }
  2010. //Log::info('guidePersonalAccount555555555555555');
  2011. if($charge){
  2012. return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid.'&fee=500'];
  2013. }
  2014. return '';
  2015. }
  2016. private function setIsPaid(){
  2017. $charge = Order::where('uid',$this->uid)
  2018. ->where('status','PAID')
  2019. ->select('id')
  2020. ->first();
  2021. if($charge){
  2022. Cookie::queue('is_paid', 1);
  2023. $this->is_paid = true;
  2024. }else{
  2025. Cookie::queue('is_paid', 0);
  2026. $this->is_paid = false;
  2027. }
  2028. }
  2029. //统计ua
  2030. private function recordUA($ua)
  2031. {
  2032. $is_ua_open = RedisEnv('ua_open');
  2033. if($is_ua_open && $ua)//开启
  2034. {
  2035. //判断是否已经统计
  2036. $has_got = Redis::hget('book_read:'.$this->uid,'ua');
  2037. if(!$has_got)
  2038. {
  2039. try{
  2040. Redis::hset('book_read:'.$this->uid,'ua',1);
  2041. UserService::recordUA($ua,$this->uid);
  2042. }catch (\Exception $e) {
  2043. }
  2044. }
  2045. }
  2046. }
  2047. private function monthOrderInfo($openid){
  2048. $property = $this->property;
  2049. if (!$property) return '';
  2050. if (in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))
  2051. && in_array($property, ['none','low', 'medium'])
  2052. ) {
  2053. if(!UserMonthService::isSignMonth($openid)){
  2054. return [
  2055. 'price'=>'30元',
  2056. 'text' => '30元包月 全站万本精彩小说免费看',
  2057. 'link'=> generateMonthOrderUrl($this->uid)
  2058. //'link'=> '/rmonthpay'
  2059. ];
  2060. }
  2061. }
  2062. return '';
  2063. }
  2064. }