123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988 |
- <?php
- namespace app\index\controller;
- use app\admin\service\ShortUrlService;
- use app\common\controller\Frontend;
- use app\common\library\Ip;
- use app\common\service\VipCpService;
- use app\common\service\WaterBookService;
- use app\main\constants\MarkConstants;
- use app\main\service\ActivityService;
- use app\main\service\AdminService;
- use app\main\service\BookService;
- use app\main\service\FufenService;
- use app\main\service\UrlService;
- use app\main\service\UserService;
- use think\Config;
- use think\Cookie;
- class Index extends Frontend
- {
- protected $layout = '';
- protected $tpname = ['1' => '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}<br/>备案号:<a href='http://www.beian.miit.gov.cn'>{$domainArr[$this_domain]}</a>";
- }
- 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 '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no">';
- if ($this->urlType != 2) {
- echo "<a href='/'>访问首页</a><br><br>";
- }
- echo "<a href='/index/index/clear'>清除cookie</a><br><br>";
- echo '<pre>';
- var_dump(Cookie::get());
- }
- /**
- * 清除cookie
- */
- public function clear()
- {
- echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no">';
- foreach (Cookie::get() as $key => $value) {
- Cookie::delete($key);
- }
- if ($this->urlType != 2) {
- echo "<a href='/'>访问首页</a><br><br>";
- }
- echo "<a href='/index/index/dev'>访问dev</a><br><br>";
- 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));
- }
- }
- }
- }
|