'lunbo', '2' => 'cainixihuan', '3' => 'remenshuangwen', '4' => 'nav', '5' => 'searchbox', '6' => 'blcoknav', '7' => 'changxiao','8'=>'recently'];
//1=轮播,2=横4,3=竖4,4=标题导航,5=搜索,6=块导航,7=榜单
protected $ranklivetime = 600; //榜单生存时间秒
protected $hotsearch_extime = 86400; //热门搜索书籍默认保存1天
protected $wxNoNeedLogin = ['dev', 'clear'];
public function _initialize()
{
parent::_initialize();
}
public function index()
{
$is_show_tabbar = 0;
$showBookShelf = 0;
if($this->user->isLogin()){
// 是否已经加入到书架 TRUE | FALSE
$showBookShelf = BookService::instance()->showBookShelfFun();
$is_show_tabbar = model("ChannelSpecialManage")->isWhite("show_tabbar", $this->user->channel_id);
$this->assign('channel_id', $this->user->channel_id);
}
$this->assign('showBookShelf', $showBookShelf);
$this->assign('is_show_tabbar', $is_show_tabbar);
$this->assign('tab_choice', 'bookcity');
// 联盟推广页 && 充值页 不读取用户信息
if ($this->urlType == 1 || $this->urlType == 2) {
$domain_coms = [
'温江区雨见源日用百货店' => [
'yjreadc.cn',
'yjreada.cn',
'yjreadd.cn',
'yjreadb.cn',
],
'莱可广告设计工作室' => [
'laiked.cn',
'laikeb.cn',
'laikef.cn',
'laikec.cn',
],
'内蒙古林信科技发展有限公司' => [
'lxtee.com',
'lxten.com',
'lxted.com',
'lxtee.cn',
'lxten.cn',
'lxtes.cn',
'linxine.cn',
'linjs.com',
'lintd.com',
'linpd.com',
'linxind.cn',
],
'天津每日趣阅网络技术有限公司' => [
'hzinc.cn',
'hzdue.cn'
],
'北京快乐农夫科技有限公司' => [
'klfuny.cn',
'karea.cn'
]
];
$domainArr = [
'lxtee.com' => '蒙ICP备18004074号-1',
'lxten.com' => '蒙ICP备18004074号-1',
'lxted.com' => '蒙ICP备18004074号-1',
'lxtee.cn' => '蒙ICP备18004074号-1',
'lxten.cn' => '蒙ICP备18004074号-1',
'lxtes.cn' => '蒙ICP备18004074号-1',
'linxine.cn' => '蒙ICP备18004074号-3',
'linjs.com' => '蒙ICP备18004074号-7',
'lintd.com' => '蒙ICP备18004074号-8',
'linpd.com' => '蒙ICP备18004074号-9',
'linxind.cn' => '蒙ICP备18004074号-6',
'laiked.cn' => '蜀ICP备18024149号-22',
'laikeb.cn' => '蜀ICP备18024149号-23',
'laikef.cn' => '蜀ICP备18024149号-24',
'laikec.cn' => '蜀ICP备18024149号-21',
'yjreadc.cn' => '蜀ICP备18034038号-10',
'yjreada.cn' => '蜀ICP备18034038号-11',
'yjreadd.cn' => '蜀ICP备18034038号-12',
'yjreadb.cn' => '蜀ICP备18034038号-9',
'hzinc.cn' => '津ICP备18006783号-2',
'hzdue.cn' => '津ICP备18006783号-3',
'klfuny.cn' => '京ICP备17030462号-36',
'karea.cn' => '京ICP备17030462号-32'
];
$host = get_host_no_port();
$domain_put = '';
$title = '';
if(!empty($host)){
$arr = explode('.',$host);
$this_domain = $arr[sizeof($arr)-2].'.'.$arr[sizeof($arr)-1];
if(array_key_exists($this_domain,$domainArr)){
$com_name = '内蒙古林信科技发展有限公司';
foreach($domain_coms as $key => $dom){
if(array_search($this_domain,$dom) !== false){
$com_name = $key;
break;
}
}
$domain_put .= "本站隶属于{$com_name}
备案号:{$domainArr[$this_domain]}";
}
if (in_array($this_domain, ['karea.cn'])) {
$title = '快乐农夫';
}
}
//dump($domain);die;
$this->assign('domain_put',$domain_put);
$this->assign('title',$title);
return $this->fetch();
}
if ($this->user->sex && $this->user->sex == 2) {
$type = 'girl';
} else {
$type = 'boy';
}
$pagesex = $this->request->get('type') ? $this->request->get('type') : $type;
$adminconfig = $this->adminconfig;
if (!isset($adminconfig['index_title'])) {
$adminconfig['index_title'] = '首页';
}
// $sql = "select r.*,a.name as aname,a.copywriting from resource as r INNER JOIN activity as a ON r.activity_id = a.id WHERE a.status = '1' AND r.status = '1' AND FIND_IN_SET({$tag},r.pop_range) AND a.starttime<" . time() . " AND a.endtime>" . time() . " ORDER BY a.createtime desc,r.weigh desc limit 1";
// $res = model('resource')->query($sql);
// if ($res) {
// $this->assign('activity', $res['0']);
// }
if ($adminconfig['page_sex'] == 1) {
$pagesex = 'boy';
} elseif ($adminconfig['page_sex'] == 2) {
$pagesex = 'girl';
}
Cookie::set('sex', $pagesex);
if ($pagesex == 'girl') {
$sexid = 2;
} else {
$sexid = 1;
}
$rencently[] = [];
if (Cookie::has('user_id')) {
$res = model('UserRecentlyRead')->getRecentlyRead(0, 10, null, true);
$rencently = $res['totalNum'] == 0 ? [] : $res['data'];
$this->view->assign('login', 1);//登录
}else {
$cookread = Cookie::has('read')?Cookie::get('read'):[];
$rencently = array_reverse($cookread);
$res['totalNum'] = count($rencently);
foreach ($rencently as &$value){
$bookinfo = model('Book')->BookInfo($value['book_id']);
$value['book_name'] = $bookinfo['name'];
}
$this->view->assign('login',0);//未登录
}
$this->assign('rencently', $rencently);
$this->view->assign('adminconfig', $adminconfig);
$pagedata = $this->page_block_resource($pagesex);
$ranklist = $this->ranklist($pagesex);
$this->assign('sexid', $sexid);
$this->view->assign('type', $pagesex);
$this->view->assign('pagedata', $pagedata);
$this->view->assign('ranklist', $ranklist);
//$this->view->assign('sex', model('User')->getUserSex($this->user->sex, $adminconfig, false, $pagesex));
$this->view->assign('sex', $this->user->sex ? $this->user->sex : '1');
$this->view->assign('avatar', $this->user->avatar ?: cdnurl('/assets/img/frontend/icon/nav_icon_4.png'));
$this->view->assign('isVip', $this->user->vip_endtime > time());
return $this->view->fetch();
}
public function classify_list()
{
return $this->view->fetch();
}
public function scan_code()
{
return $this->view->fetch();
}
/*
* 资源数据列表
*/
public function page_block_resource($type)
{
$showWaterBook = WaterBookService::instance()->showBook($this->user->channel_id, $this->user->id, Ip::ip());
if ($type == 'boy') {
if ($showWaterBook) {
$pageId = 3;
} else {
$pageId = 1;
}
} else {
if ($showWaterBook) {
$pageId = 4;
} else {
$pageId = 2;
}
}
$redisKey = 'P:' . $pageId;
if ($value = $this->redis->get($redisKey)) {
$result = json_decode($value, true);
return $result;
} else {
$boydata = [];
$girldata = [];
$boyCleanData = [];
$girlCleanData = [];
$block = collection(model('ManageBlock')
->order('page_id asc,weigh desc')->select())->toArray();
foreach ($block as $value) {
$where = [
'manage_block_resource.type' => 1,
'book.state' => 1
];
if (in_array($value['page_id'], [3, 4])) {
$where['book.classify_white_list'] = 1;
}
$books = collection(
model('ManageBlockResource')
->join('book', 'book.id= manage_block_resource.book_id')
->join('book_category bc', 'bc.id = book.book_category_id', 'LEFT')
->whereIn('block_id', $value['id'])
->field('bc.name as bc_name,book.book_category_id,book.name,book.author,book.is_finish, book.description,book.last_chapter_name,book.last_chapter_id,book.read_num,book.tags,manage_block_resource.*')
->where($where)
->order('weigh desc')
->limit(6)
->select()
)->toArray();
$special = collection(
model('ManageBlockResource')
->join('special_page', 'special_page.id=manage_block_resource.special_id')
->field('manage_block_resource.*,special_page.title as name')
->where('manage_block_resource.type=3')
->where('block_id', $value['id'])
->order('weigh desc')
->limit(6)
->select()
)->toArray();
if ($books) {
foreach ($books as $k => $v) {
$books[$k]['vip_pay'] = BookService::instance()->showCpVipSubScript($v['book_id']);
}
}
$list = array_merge($books, $special);
usort($list, function ($v1, $v2) {
return $v1['weigh'] < $v2['weigh'];
});
$value['block_resource'] = array_slice($list, 0, 6);
foreach ($value['block_resource'] as &$v2) {
$v2['read_nums'] = empty($v2['read_num']) ? 0 : friend_date($v2['read_num']);
$v2['tags'] = empty($v2['tags']) ? [] : explode(',', $v2['tags']);
}
if ($value['page_id'] == 1) {
$boydata[] = $value;
}
if ($value['page_id'] == 2) {
$girldata[] = $value;
}
if ($value['page_id'] == 3) {
$boyCleanData[] = $value;
}
if ($value['page_id'] == 4) {
$girlCleanData[] = $value;
}
}
if (!empty($boydata)) {
$this->redis->setex('P:1', 900, json_encode($boydata, JSON_UNESCAPED_UNICODE));
}
if (!empty($girldata)) {
$this->redis->setex('P:2', 900, json_encode($girldata, JSON_UNESCAPED_UNICODE));
}
if (!empty($boyCleanData)) {
$this->redis->setex('P:3', 900, json_encode($boyCleanData, JSON_UNESCAPED_UNICODE));
}
if (!empty($girlCleanData)) {
$this->redis->setex('P:4', 900, json_encode($girlCleanData, JSON_UNESCAPED_UNICODE));
}
switch ($pageId){
case 1:
return $boydata;
case 2:
return $girldata;
case 3:
return $boyCleanData;
case 4:
return $girlCleanData;
default:
return [];
}
}
}
/*
* 榜单列表 rank1男频 rank2女频 rank0不区分男女 按照idx排序
*/
public function ranklist($type)
{
$channel_id = AdminService::instance()->getAdminExtendModel()->getChannelId($this->user->channel_id);
$showWaterBook = WaterBookService::instance()->showBook($channel_id, $this->user->id, Ip::ip());
$where=[];
if($showWaterBook){
$where['book.classify_white_list']=1;
$key0 = 'RANK:0:W';
$key1 = 'RANK:1:W';
$key2 = 'RANK:2:W';
}else{
$key0 = 'RANK:0';
$key1 = 'RANK:1';
$key2 = 'RANK:2';
}
$boydata = [];
$girldata = [];
if ($this->redis->exists($key1) && $this->redis->exists($key2) && $this->redis->exists($key0)) {
$boydata = json_decode($this->redis->get($key1), true);
$girldata = json_decode($this->redis->get($key2), true);
$idxdata = json_decode($this->redis->get($key0), true);
} else {
$boydata['click'] = collection(
model('Book')->join('book_category bc','bc.id = book.book_category_id','LEFT')
->where(['book.state' => 1, 'book.sex' => 1])
->where($where)
->field('book.*,bc.name as bc_name')
->order('book.read_num desc')
->limit(3)
->select()
)->toArray();
foreach ($boydata['click'] as &$value) {
$value['vip_pay'] = BookService::instance()->showCpVipSubScript($value['id']);
$value['read_nums'] = friend_date($value['read_num']);
$value['author'] = $value['bc_name'];
}
$boydata['idx'] = collection(
model('Book')->join('book_category bc','bc.id = book.book_category_id','LEFT')
->where(['book.state' => 1, 'book.sex' => 1])
->where($where)
->field('book.*,bc.name as bc_name')
->order('book.idx desc')
->limit(3)
->select()
)->toArray();
foreach ($boydata['idx'] as &$value) {
$value['vip_pay'] = BookService::instance()->showCpVipSubScript($value['id']);
$value['read_nums'] = friend_date($value['read_num']);
$value['author'] = $value['bc_name'];
}
$girldata['click'] = collection(
model('Book')->join('book_category bc','bc.id = book.book_category_id','LEFT')
->where(['book.state' => 1, 'book.sex' => 2])
->where($where)
->field('book.*,bc.name as bc_name')
->order('book.read_num desc')
->limit(3)
->select()
)->toArray();
foreach ($girldata['click'] as &$value) {
$value['vip_pay'] = BookService::instance()->showCpVipSubScript($value['id']);
$value['read_nums'] = friend_date($value['read_num']);
$value['author'] = $value['bc_name'];
}
$girldata['idx'] = collection(
model('Book')->join('book_category bc','bc.id = book.book_category_id','LEFT')
->where(['book.state' => 1, 'book.sex' => 2])
->where($where)
->field('book.*,bc.name as bc_name')
->order('book.idx desc')
->limit(3)
->select()
)->toArray();
foreach ($girldata['idx'] as &$value) {
$value['vip_pay'] = BookService::instance()->showCpVipSubScript($value['id']);
$value['read_nums'] = friend_date($value['read_num']);
$value['author'] = $value['bc_name'];
}
$idxdata['idx'] = collection(
model('Book')->join('book_category bc','bc.id = book.book_category_id','LEFT')
->where(['book.state' => 1])
->where($where)
->field('book.*,bc.name as bc_name')
->order('book.idx desc')
->limit(3)
->select()
)->toArray();
foreach ($idxdata['idx'] as &$value) {
$value['vip_pay'] = BookService::instance()->showCpVipSubScript($value['id']);
$value['read_nums'] = friend_date($value['read_num']);
$value['author'] = $value['bc_name'];
}
if (!empty($boydata)) {
$this->redis->setex($key1, $this->ranklivetime, json_encode($boydata, JSON_UNESCAPED_UNICODE));
}
if (!empty($girldata)) {
$this->redis->setex($key2, $this->ranklivetime, json_encode($girldata, JSON_UNESCAPED_UNICODE));
}
if (!empty($idxdata)) {
$this->redis->setex($key0, $this->ranklivetime, json_encode($idxdata, JSON_UNESCAPED_UNICODE));
}
}
if ($type == 1) {
return $boydata;
} elseif ($type == 2) {
return $girldata;
} elseif ($type == 'boy') {
return $boydata;
} elseif ($type == 'girl') {
return $girldata;
} else {
return $idxdata;
}
}
/*
* 主编推荐列表
*/
public function recommendList($book_id)
{
if($book_id){
$bookInfo = model("book")->BookInfo($book_id);
}else{
return false;
}
$where = [];
$where['state'] = '1';
$where['book_category_id'] = $bookInfo['book_category_id'];
//最近阅读
$recentList = model('UserRecentlyRead')->getRecentlyRead(0);
$recentIds[] = $bookInfo['id'];
if ($recentList['totalNum'] > 0) {
foreach ($recentList['data'] as $v) {
$recentIds[] = $v['book_id'];
}
}
if ($recentIds) {
$where['id'] = ['not in', $recentIds];
}
$pagedata[0]['name'] = "主编推荐";
$pagedata[0]['page_id'] = 1;
$pagedata[0]['second_name'] = "主编推荐";
$pagedata[0]['block_resource'] = collection(model("Book")
->where($where)
->order('rand()')
->limit(4)
->select())->toArray();
if($pagedata[0]['block_resource']){
foreach ($pagedata[0]['block_resource'] as &$v){
$v['book_id'] = $v['id'];
}
}
return $pagedata;
}
public function recommendAjax(){
$book_id = $this->request->get("book_id");
if($book_id){
$pagedata = $this->recommendList($book_id);
}else{
return false;
}
return json($pagedata);
}
/**
* 搜索页
* @param int $sex 频道标示
*/
public function search()
{
$userId = $this->user->id;
$books = model('User')->getLike($userId);
$categoryArr = model("BookCategory")->getCategoryList();
foreach ($books as $k=>$v){
$books[$k]['author'] = $categoryArr[$v['book_category_id']];
}
if($this->request->isAjax()){
return json_encode($books);
}else{
$sex = input('sex');
$this->assign('sex', $sex);
$pagedata['name'] = '精彩推荐';
$pagedata['block_resource'] = $books;
$this->view->assign('value', $pagedata);
return $this->view->fetch();
}
}
/**
* 搜索接口
* @param string $keyword 关键词
* @param int $page 页码
* @return json
*/
public function searchapi()
{
$keyword = input('keyword');
$page = input('page', 1);
if (!empty($keyword)) {
$where = array();
//清水
$userObj = UserService::instance()->getUserInfo();
$channel_id = AdminService::instance()->getAdminExtendModel()->getChannelId($userObj->channel_id);
$is_water = WaterBookService::instance()->showBook($channel_id, $userObj->id, Ip::ip());
if ($is_water) {
$where['b.classify_white_list'] = 1;
}
$where['b.state'] = 1;
$where['b.name'] = array('like', '%' . $keyword . '%');
$total = model('book')
->alias('b')
->join('book_category bc','bc.id=b.book_category_id and bc.status=\'normal\'')
->where($where)
->count();
$books = model('book')
->alias('b')
->join('book_category bc','bc.id=b.book_category_id and bc.status=\'normal\'')
->where($where)
->page($page, 10)
->field('b.*,bc.name as author')
->select();
} else {
$total = 0;
$books = array();
}
$result = array(
'priMap' => array(
'total' => $total,
'searchList' => $books,
),
'index' => $page,
'ptype' => 'searchResult',
'keyword' => $keyword,
);
return json($result);
}
/**
* 查看cookie
*/
public function dev()
{
echo '';
if ($this->urlType != 2) {
echo "访问首页
";
}
echo "清除cookie
";
echo '
'; var_dump(Cookie::get()); } /** * 清除cookie */ public function clear() { echo ''; foreach (Cookie::get() as $key => $value) { Cookie::delete($key); } if ($this->urlType != 2) { echo "访问首页
"; } echo "访问dev
"; echo "cookie已清除!"; } /** * 推广链接 * @param $id */ public function referral($id) { $id = intval($id); $referralinfo = model('referral')->getone($id, false);//获取推广信息 if (isset($referralinfo['source_url']) && $referralinfo['source_url']) { //确认channel_id $channel_id = $referralinfo['admin_id']; $group_id = model("AuthGroupAccess")->getGroupId($referralinfo['admin_id']); if($group_id == 4){//判断分组 $extends = model("AdminExtend")->getInfo($referralinfo['admin_id']); if($extends['distribute']==0){ $channel_id = $extends['create_by']; } } $shor_id = $referralinfo['short_id'] ?? null; if($shor_id && $referralinfo['type'] == 1){ $url = getCurrentDomain($channel_id,$referralinfo['source_url'],['short_id'=>$shor_id]); }else{ $url = getCurrentDomain($channel_id,$referralinfo['source_url']); } //打点信息 $ext = $this->request->get('ext', ''); if (!empty($ext)) { $url .= '&ext='.$ext; } $this->redirect($url); } else { $this->redirect($this->request->domain()); } } public function activity($id,$rid = null) { $id = intval($id); $rid = intval($rid); $channel_id = UserService::instance()->getUserInfo()->channel_id; $adminConfig = AdminService::instance()->getAdminConfigModel()->getAdminInfoAll($channel_id); if (empty($id)) { $rid = $_GET['rid']??''; $aid = intval($_GET['aid']??''); if($aid){ $id = $aid; } if (empty($rid)) { $this->error('不存在此活动,正在跳转书城首页', '/index/index/index'); } } else { if(!$rid){ list($resource, $isRange) = ActivityService::instance()->getActivityResource($id); if (empty($resource)) { $this->error('不存在此活动,正在跳转书城首页', '/index/index/index'); } $rid = $resource['id']; } } if(!empty($id)){ $params['aid'] = $id; } $params['id'] = $rid; if (!empty($isRange)) { $params['isRange'] = 1; } $params['appid'] = $adminConfig['appid']; if (UserService::instance()->isLogin()) { $params['user_id'] = UserService::instance()->getUserInfo()->id; } elseif (Cookie::has('visitor')) { $params['visitor'] = Cookie::get('visitor'); } //打点信息 $ext = $this->request->get('ext', ''); if (!empty($ext)) { $params['ext'] = $ext; } if ($this->request->get('float_id')) { $params['float_id'] = $this->request->get('float_id'); } //有菜单支付域名时,跳转菜单支付域名 if ($_SERVER['HTTP_HOST'] != $adminConfig['wxpay_pay_host'] || (isset($adminConfig['menuwxpay_host']) && $_SERVER['HTTP_HOST'] != $adminConfig['menuwxpay_host'])) { $user_id = UserService::instance()->getUserInfo()->id; $channel_id = UserService::instance()->getUserChannelId()->data; $payHost = FufenService::instance()->getPayUrl($user_id, $channel_id)->data; $url = $payHost . '/index/recharge/activity?' . http_build_query($params); $this->redirect($url); // $menuophost = $adminConfig['menuophost'] ?? null; // $menuwxpay_host = $adminConfig['menuwxpay_host'] ?? null; // if($menuophost && $menuwxpay_host && $menuophost == getCurrentOphost()){ // $this->redirect(Config::get('site.scheme') . '://' . $adminConfig['menuwxpay_host'] . '/index/recharge/activity?' . http_build_query($params)); // }else{ // $this->redirect(Config::get('site.scheme') . '://' . $adminConfig['wxpay_pay_host'] . '/index/recharge/activity?' . http_build_query($params)); // } } } public function report() { return $this->view->fetch(); } /** * vip分流链接入口 * @param $id */ public function vipreferral($id) { $id = intval($id); if (empty($id)) { $this->redirect($this->request->domain()); } //是否禁用 if (!model("Referral")->checkVipReferralValid($id)) { $this->redirect($this->request->domain()); } $referralId = model("ReferralSlave")->getReferralId($id); if (!empty($referralId)) { $referralinfo = model('referral')->getone($referralId, false);//获取推广信息 if (isset($referralinfo['source_url']) && $referralinfo['source_url']) { //确认channel_id $channel_id = $referralinfo['admin_id']; $group_id = model("AuthGroupAccess")->getGroupId($referralinfo['admin_id']); if($group_id == 4){//判断分组 $extends = model("AdminExtend")->getInfo($referralinfo['admin_id']); if($extends['distribute']==0){ $channel_id = $extends['create_by']; } } $shor_id = $referralinfo['short_id'] ?? null; if($shor_id && $referralinfo['type'] == 1){ $url = getCurrentDomain($channel_id,$referralinfo['source_url'],['short_id'=>$shor_id]); }else{ $url = getCurrentDomain($channel_id,$referralinfo['source_url']); } //打点信息 $ext = $this->request->get('ext', ''); if (!empty($ext)) { $url .= '&ext='.$ext; } $this->redirect($url); } else { $this->redirect($this->request->domain()); } } $this->redirect($this->request->domain()); } /** * 书单 * @param $id */ public function booklist($id) { $id = intval($id); if (empty($id)) { $this->error('书单不存在'); die; } $result = model('BookList')->getInfo($id); if (empty($result)) { $this->error('书单不存在'); die; } $result['content'] = json_decode($result['content'], true); $this->view->assign('result', $result); return $this->view->fetch(); } /** * 渠道自定义书单 * @param $id */ public function booklistch($id) { $id = intval($id); if (empty($id)) { $this->error('书单不存在'); die; } $adminconfig = $this->adminconfig; $result = model('BookListCh')->getInfo($id); if (empty($result)) { $this->error('书单不存在'); die; } if (!in_array($adminconfig['admin_id'], json_decode($result['admin_ids']), true)) { $this->error('书单不存在'); die; } $ext = [ 'mark' => MarkConstants::MARK_BOOKLIST_MSG, 'push_id' => $id, 'push_idx' => 0, 'push_time' => time(), 'admin_id' => $adminconfig['admin_id'], ]; $result['content'] = json_decode($result['content'], true); $this->view->assign('result', $result); $this->view->assign('ext', $ext); return $this->view->fetch(); } /** * 客服消息 短链 * @param $id */ public function custom($id) { $id = intval($id); if (empty($id)) { $this->error('链接地址不存在'); die; } else { $shortUrlService = new ShortUrlService(); $url = $shortUrlService->getShortUrl($id); if (empty($url)) { $this->error('链接地址不存在'); die; } if (strpos($url, '{$ophost}')) { if (preg_match("/wx\w+/i", $url, $matches)) { $appId = $matches[0]; $channelData = AdminService::instance()->getAdminConfigModel()->getAdminInfoByAppId($appId); //得到此渠道的配置信息 adminInfoAll $admin_id = $channelData['admin_id']; //占位符转换 $url = UrlService::instance()->replaceReferralHost($admin_id, $url, false)->data; } } $this->redirect($url); } $this->error('链接地址不存在'); } public function questionnaire() { $endDate = '2020-08-15'; if (time() >= strtotime("{$endDate} + 1 days")) { $this->redirect($this->request->domain()); } $adminId = $this->adminconfig['admin_id']; $userid = UserService::instance()->getUserInfo()->id; $this->view->assign('admin_id', $adminId); $this->view->assign('adminconfig', $this->adminconfig); $this->view->assign('userid', $userid); $this->view->assign('endDate', $endDate); return $this->view->fetch(); } /** * 专题 * @param $id * @return string * @throws \think\Exception */ public function specialpage($id) { $id = intval($id); if (empty($id)) { $this->error('链接地址不存在'); die; } $result = model('SpecialPage')->getInfo($id); if (empty($result)) { $this->error('专题页不存在'); die; } $isForbidden = false; if ($result['status'] == "hidden") { $isForbidden = true; } if (isset($_GET['view']) && $_GET['view'] == 'preview') { $isForbidden = false; } $toUrl = '/'; $this->view->assign('result', $result); $this->view->assign('isForbidden', $isForbidden); $this->view->assign('toUrl', $toUrl); return $this->view->fetch(); } /** * 专属链接跳转中转 * @param $id */ public function rechargeurl($id) { $id = intval($id); if (empty($id)) { $this->error('链接不存在'); die; } $res = model("SpecialRechargeUrl")->checkUrl($id); if ($res['code'] == 201 || $res['code'] == 202) { $this->error('链接不存在'); die; } $params['id'] = $id; $params['isRange'] = $res['code'] == 203 ? 1 : 0; $channel_id = UserService::instance()->getUserInfo()->channel_id; $adminConfig = AdminService::instance()->getAdminConfigModel()->getAdminInfoAll($channel_id); $params['appid'] = $adminConfig['appid']; if (UserService::instance()->isLogin()) { $params['user_id'] = UserService::instance()->getUserInfo()->id; } elseif (Cookie::has('visitor')) { $params['visitor'] = Cookie::get('visitor'); } //打点信息 $ext = $this->request->get('ext', ''); if (!empty($ext)) { $params['ext'] = $ext; } //有菜单支付域名时,跳转菜单支付域名 if ($_SERVER['HTTP_HOST'] != $adminConfig['wxpay_pay_host'] || (isset($adminConfig['menuwxpay_host']) && $_SERVER['HTTP_HOST'] != $adminConfig['menuwxpay_host'])) { $menuophost = $adminConfig['menuophost'] ?? null; $menuwxpay_host = $adminConfig['menuwxpay_host'] ?? null; if($menuophost && $menuwxpay_host && $menuophost == getCurrentOphost()){ $this->redirect(Config::get('site.scheme') . '://' . $adminConfig['menuwxpay_host'] . '/index/recharge/special?' . http_build_query($params)); }else{ $this->redirect(Config::get('site.scheme') . '://' . $adminConfig['wxpay_pay_host'] . '/index/recharge/special?' . http_build_query($params)); } } } }