model = model('ReferralLibrary'); $this->guideModel = model('Guide'); $this->vipAdminBindModel = model('VipAdminBind'); $this->entryhostModel = model('Entryhost'); $this->bookAgentId = 0; $this->bookChannelId = 0; } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法 * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ /** * 查看 */ public function index() { $state = $this->request->param('state') ?? '1'; //设置过滤方法 $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('pkey_name')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $map = [ 'referral_library.admin_id' => $this->auth->id, 'referral.state' => $state, ]; $total = $this->model ->join('referral', 'referral_library.referral_id = referral.id') ->join('book', 'referral.book_id = book.id', 'left') ->where($where) ->where($map) ->count(); $list = $this->model ->join('referral', 'referral_library.referral_id = referral.id') ->join('book', 'referral.book_id = book.id', 'left') ->where($where) ->where($map) ->field('referral_library.*, referral.name as referral_name, referral.book_id, book.name as book_name, referral.chapter_idx, referral.chapter_id, referral.guide_chapter_idx, referral.state as state, referral.type, referral.chapter_name, referral.cost, referral.state') ->order($sort, $order) ->limit($offset, $limit) ->select(); foreach ($list as $k=>$v){ //获取当前书籍的默认关注章节 if(empty($v['guide_chapter_idx']) && !empty($v['book_id'])){ $default_chapter_idx = 0; $list[$k]['guide_chapter_idx'] = $default_chapter_idx; } //查询所有的关联的referral $childReferrals = model("referral")->join('referral_slave', 'referral.id = referral_slave.referral_id')->where('referral_slave.library_id', 'eq', $v['id'])->field('referral.*')->select(); $dayuvAll = $dayutAll = $daymtAll= $dayjtAll = $dayqtAll = $daydtAll = $guide_follow_numAll = $net_follow_numAll = $uvnumAll = $follownumAll = $moneyAll = 0; $childReferralChannelId = 0; $migrateCollectList = []; $migrate = VisitLimitService::instance()->checkMigratedV2(); if ($migrate) { $referralIds = array_column($childReferrals, 'id'); $migrateCollectList = \app\main\service\ReferralService::instance()->getReferralCollectFromApi($referralIds)->data; } if (!empty($childReferrals)) { foreach ($childReferrals as $childReferral) { $childReferralChannelId = empty($childReferralChannelId) ? $childReferral['admin_id'] : $childReferralChannelId; if ($migrate) { if (array_key_exists($childReferral['id'], $migrateCollectList)) { $dayuvAll += $migrateCollectList[$childReferral['id']]['dayuv']; $dayutAll += $migrateCollectList[$childReferral['id']]['dayut']; $daymtAll += $migrateCollectList[$childReferral['id']]['daymt']; $dayjtAll += $migrateCollectList[$childReferral['id']]['dayjt']; $dayqtAll += $migrateCollectList[$childReferral['id']]['dayqt']; $net_follow_numAll += $migrateCollectList[$childReferral['id']]['net_follow_num']; $uvnumAll += $migrateCollectList[$childReferral['id']]['uv']; $follownumAll += $migrateCollectList[$childReferral['id']]['follow']; $moneyAll += $migrateCollectList[$childReferral['id']]['money']; } } else { $dayMTkey = "M-T:".$childReferral['id'].":".date("d"); //今日充值金额key if (Redis::instance()->get(CacheConstants::getReadOfReferralIdKey($childReferral['id']))) { $dayuvAll += (int)Redis::instance()->get(CacheConstants::getReadOfReferralIdKey($childReferral['id'])); } if (Redis::instance()->get(CacheConstants::getSubscribeOfReferralIdKey($childReferral['id']))) { $dayutAll += (int)Redis::instance()->get(CacheConstants::getSubscribeOfReferralIdKey($childReferral['id'])); } if (Redis::instance()->get($dayMTkey)) { $daymtAll += (int)Redis::instance()->get($dayMTkey)? round(Redis::instance()->get($dayMTkey) / 100, 2) :0; } if (Redis::instance()->get(CacheConstants::getSubscribeOfPureReferralIdKey($childReferral['id']))) { $dayjtAll += (int)Redis::instance()->get(CacheConstants::getSubscribeOfPureReferralIdKey($childReferral['id'])); } if (Redis::instance()->get(CacheConstants::getUnsubscribeOfReferralIdKey($childReferral['id']))) { $dayqtAll += (int)Redis::instance()->get(CacheConstants::getUnsubscribeOfReferralIdKey($childReferral['id'])); //今日取消关注人数 } $net_follow_numAll += (int)$childReferral['net_follow_num']; $uvnumAll += (int)$childReferral['uv']; $follownumAll += (int)$childReferral['follow']; $moneyAll += $childReferral['money']; } } } $list[$k]['dayuv'] = $dayuvAll; $list[$k]['dayut'] = $dayutAll; //今日关注人数 $list[$k]['daymt'] = StringHelper::moneyFormat($daymtAll); //今日充值金额 $list[$k]['dayjt'] = $dayjtAll; //今日净关注人数 $list[$k]['dayqt'] = $dayqtAll; //今日取消关注人数 $list[$k]['net_follow_num'] = $net_follow_numAll; $list[$k]['uv'] = $uvnumAll; $list[$k]['follow'] = $follownumAll; $list[$k]['money'] = StringHelper::moneyFormat($moneyAll); if(!empty($v['book_id'])){ $isLimited = model('BookLimit')->backendHasLimit($this->bookAgentId,$this->bookChannelId,$v['book_id']); if($isLimited){ $list[$k]['limited'] = 1; }else{ $list[$k]['limited'] = 0; } }else{ $list[$k]['limited'] = 0; } if ($childReferralChannelId) { //地址替换 防止切换域名后无法访问 $list[$k]['short_url'] = getCurrentDomain($childReferralChannelId).'v/'.$v['id']; } $list[$k]['referral_library'] = [ 'id' => $list[$k]['id'], 'createtime' => $list[$k]['createtime'], ]; $list[$k]['referral'] = [ 'name' => $list[$k]['referral_name'], 'book_id' => $list[$k]['book_id'], ]; $list[$k]['book'] = [ 'name' => $list[$k]['book_name'], ]; } $result = array("total" => $total, "rows" => $list); return json($result); } $this->assign('state', $state); $this->assignconfig('state', $state); return $this->view->fetch(); } /** * 选择渠道商 */ public function selectchannel() { $hasQdsIds = $this->request->request('not_in_qds'); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('pkey_name')) { return $this->selectpage(); } $map = []; $map['vip_admin_bind.flag'] = ['EQ', '1']; $map['vip_admin_bind.admin_id_master'] = ['EQ', $this->auth->id]; $filter = $this->request->get("filter", ''); $filter = json_decode($filter, true); if ($hasQdsIds) { $map['vip_admin_bind.admin_id_slave'] = ['not in', explode(',', $hasQdsIds)]; } if (!empty($filter)) { foreach ($filter as $k => $v) { switch ($k) { case 'wx_nickname': $map['JSON_EXTRACT(admin_config.json, "$.authorizer_info.nick_name")'] = ['like', '%' . $v . '%']; break; case 'qds_username': $map["admin.username"] = ['like', "%$v%"]; break; case 'qds_nickname': $map["admin.nickname"] = ['like', "%$v%"]; break; default: break; } } } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $total = model('VipAdminBind') ->field('vip_admin_bind.*') ->join('admin_config', 'vip_admin_bind.admin_id_slave = admin_config.admin_id') ->join('admin', 'vip_admin_bind.admin_id_slave = admin.id', 'left') ->where($map) ->order($sort, $order) ->count(); $list = model('VipAdminBind') ->join('admin_config', 'vip_admin_bind.admin_id_slave = admin_config.admin_id') ->join('admin', 'vip_admin_bind.admin_id_slave = admin.id', 'left') ->field("admin_config.json, vip_admin_bind.admin_id_slave as qds_id") ->where($map) ->order($sort, $order) ->limit($offset, $limit) ->select(); $operatorList = []; if (!empty($list)) { foreach ($list as $item) { $qdsIds[] = $item->qds_id; } $operatorList = $this->getOperatorInfoByQdsIds($qdsIds); } foreach ($list as $item) { $adminJson = json_decode($item->json, true); $item->wx_nickname = $adminJson['authorizer_info']['nick_name']; unset($item->json); if (!empty($operatorList[$item->qds_id])) { $item->qds_nickname = $operatorList[$item->qds_id]['qds_nickname']; $item->qds_username = $operatorList[$item->qds_id]['qds_username']; $item->qds_id = $operatorList[$item->qds_id]['qds_id']; } } $result = array("total" => $total, "rows" => $list); return json($result); } $this->assignconfig('not_in_qds', $hasQdsIds); return $this->view->fetch(); } private function getFetchObj($where, $order) { $fetchObj = model('VipAdminBind')->join(['admin' => 'qds'], 'qds.id = vip_admin_bind.admin_id_slave') ->join('admin_config', 'qds.id = admin_config.admin_id') ->join(['auth_group_access' => 'aga_qds'], 'aga_qds.uid = qds.id and aga_qds.group_id=3') ->where(['vip_admin_bind.admin_id_master' => $this->auth->id]) ->where($where) ->order('vip_admin_bind.id', $order); return $fetchObj; } /** * @param $qdsIds * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ private function getOperatorInfoByQdsIds($qdsIds) { if (empty($qdsIds)) { return []; } $operatorList = model('VipAdminBind')->join(['admin' => 'operator'], 'operator.id = vip_admin_bind.admin_id_slave') ->where(['vip_admin_bind.admin_id_slave' => ['in', $qdsIds]]) ->field(['vip_admin_bind.admin_id_slave', 'operator.nickname as qds_nickname', 'operator.username as qds_username', 'operator.id' => 'qds_id']) ->select(); $result = []; foreach ($operatorList as $operator) { $result[$operator->admin_id_slave] = [ 'qds_nickname' => $operator->qds_nickname, 'qds_id' => $operator->qds_id, 'qds_username' => $operator->qds_username, ]; } return $result; } /** * 选择 */ public function doChoose($ids = "", $qdsIds = "") { if (empty($qdsIds) || empty($ids)) { Log::info('缺少参数'); return json_encode(['code' => 200]); } $qdsIds = trim($qdsIds, ','); $qdsIds = explode(',', $qdsIds); //过滤一下不是该VIP下账号的 $rows = model('VipAdminBind')->where('admin_id_master', 'eq', $this->auth->id)->where('admin_id_slave', 'in', $qdsIds)->where('flag', 'eq', 1)->select(); if (!empty($rows)) { $library = $this->model->join('referral', 'referral_library.referral_id = referral.id')->where('referral_library.referral_id', 'eq', $ids)->field("referral_library.id as libId, referral_library.short_url as vip_short_url,referral.*")->find(); if ($library) { foreach ($rows as $row) { $re = model("ReferralSlave")->join("referral", 'referral_slave.referral_id = referral.id')->where('referral_slave.library_id', 'eq', $library->libId)->where('referral.admin_id', 'eq', $row->admin_id_slave)->find(); if (!empty($re)) continue; $channelId = $row->admin_id_slave; //去生成推广链接 $params = [ 'push' => $library->push, 'manage_title_id' => $library->manage_title_id, 'manage_cover_id' => $library->manage_cover_id, 'manage_template_id' => $library-> manage_template_id, 'manage_preview_id' => $library->manage_preview_id, 'book_id' => $library->book_id, 'chapter_id' => $library->chapter_id, 'chapter_name' => $library->chapter_name, 'chapter_idx' => $library->chapter_idx, 'guide_chapter_idx' => $library->guide_chapter_idx, 'admin_id' => $channelId, 'name' => $library->name, //'cost' => $library->cost, 'wx_type' => $library->wx_type, 'type' => $library->type, 'guide_idx' => $library->guide_idx, 'guide_sex' => $library->guide_sex, 'guide_title' => $library->guide_title, 'guide_image' => $library->guide_image, 'share_image' => $library->share_image, 'share_title' => $library->share_title, 'createtime' => time(), ]; $insertId = model("Referral")->allowField(true)->insertGetId($params); if($insertId === false){ $this->error($this->model->getError()); } $source_url = ''; $source_url .= '/index/book/chapter?book_id=' . $params['book_id'] . '&sid=' . $params['chapter_id'] . '&referral_id=' . $insertId; $updateData['source_url'] =getCurrentDomain($channelId,$source_url); $updateData['jmp_url'] = getCurrentDomain($channelId,'/t/'.$insertId); //绑定域名短链ID及重置生成短链接的源地址,代理商使用渠道的短链域名池 $short = model('ShortRelation')->getRandShort($channelId); if($short){ $updateData['short_id'] = $short->id; $short_source_url = replaceShortDomain($updateData['jmp_url'], $short->id); $updateData['jmp_url'] = $short_source_url; }else{ $short_source_url = $updateData['source_url']; } $shoturl = new ShortUrl(); //生成腾讯短链 $updateData['short_url_qq'] = $shoturl->tencent($channelId, $short_source_url); //生成sina短链 $updateData['short_url_weibo'] = $shoturl->sina($short_source_url); model("Referral")->save($updateData, ['id' => $insertId]); //绑定 model("ReferralSlave")->allowField(true)->insertGetId(['library_id' => $library->libId, 'channel_id' => $channelId,'referral_id' => $insertId, 'createtime' => time()]); //删除Redis缓存 $redis = Redis::instance(); $redis->del('RI:N:'.$insertId); //增加分流链接的key $redisKey = BookConstants::VIP_REFERRAL_KEY.$library->libId; $redis->sadd($redisKey,$insertId); $redis->sRem($redisKey,0); } //如果短链没生成 则取第一个的域名 if (empty($library->vip_short_url)) { $channelId = reset($qdsIds); $source_url = '/v/'.$library->libId; $updateData = []; $updateData['short_url'] = getCurrentDomain($channelId,$source_url); $this->model->save($updateData, ['id' => $library->libId]); } } else { Log::error('library 空的'); } } return json_encode(['code' => 200]); } /** * 查看分流链接 * @param string $ids */ public function viewdata($ids ='') { if (empty($ids)) { $this->error('缺少参数'); } $library = $this->model->get($ids); //设置过滤方法 $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('pkey_name')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $map = [ 'referral_library.admin_id' => $this->auth->id, 'referral_slave.library_id' => $ids ]; $total = model("ReferralSlave") ->join('referral_library', 'referral_library.id = referral_slave.library_id') ->join('referral', 'referral.id = referral_slave.referral_id') ->where($where) ->where($map) ->count(); $list = model("ReferralSlave") ->join('referral_library', 'referral_library.id = referral_slave.library_id') ->join('referral', 'referral.id = referral_slave.referral_id') ->join('book', 'book.id = referral.book_id') ->where($where) ->where($map) ->field('referral.*, book.name as book_name') ->order($sort, $order) ->limit($offset, $limit) ->select(); if (!empty($list)) { $channelids = array_column($list, 'admin_id'); $channelInfos = model("AdminConfig")->alias('ac')->join('admin a', 'ac.admin_id = a.id')->field('ac.admin_id, a.username, a.nickname, ac.json')->where("ac.admin_id", 'in', implode(',', $channelids))->select(); $channelInfos = ArrayHelper::index($channelInfos, 'admin_id'); foreach ($list as $k=>$v){ $ophost_url = $this->getChannelOphost($v['admin_id']); //获取当前书籍的默认关注章节 $list[$k]['url_referral'] = $ophost_url.'/t/'.$v['id']; $list[$k]['skin_url'] = ReferralService::instance()->getSkinUrl($v['id'], $v['source_url']); $dayMTkey = "M-T:".$v['id'].":".date("d"); //今日充值金额key $list[$k]['dayuv'] = (int)Redis::instance()->get(CacheConstants::getReadOfReferralIdKey($v['id'])); $list[$k]['dayut'] = (int)Redis::instance()->get(CacheConstants::getSubscribeOfReferralIdKey($v['id'])); //今日关注人数 $list[$k]['daymt'] = (int)Redis::instance()->get($dayMTkey)? round(Redis::instance()->get($dayMTkey) / 100, 2) :0; //今日充值金额 $list[$k]['dayjt'] = (int)Redis::instance()->get(CacheConstants::getSubscribeOfPureReferralIdKey($v['id'])); //今日净关注人数 $list[$k]['dayqt'] = (int)Redis::instance()->get(CacheConstants::getUnsubscribeOfReferralIdKey($v['id'])); //今日取消关注人数 $list[$k]['daydt'] = (int)Redis::instance()->get(CacheConstants::getSubscribeOfDimReferralIdKey($v['id'])); //今日导粉号模糊关注人数 $list[$k]['guide_follow_num'] = (int)$list[$k]['guide_follow_num']; $list[$k]['net_follow_num'] = (int)$list[$k]['net_follow_num']; $dayMTNkey = "M-T-N:".$v['id'].":".date("d"); //今日充值笔数key $list[$k]['order_nums'] = (int)$list[$k]['orders_num']; $list[$k]['day_order_nums'] = (int)Redis::instance()->get($dayMTNkey); if(!empty($v['book_id'])){ $isLimited = model('BookLimit')->backendHasLimit($this->bookAgentId,$this->bookChannelId,$v['book_id']); if($isLimited){ $list[$k]['limited'] = 1; }else{ $list[$k]['limited'] = 0; } }else{ $list[$k]['limited'] = 0; } if (isset($channelInfos[$v['admin_id']])) { $list[$k]['username'] = $channelInfos[$v['admin_id']]['username']; $list[$k]['nickname'] = $channelInfos[$v['admin_id']]['nickname']; $list[$k]['gzhname'] = $channelInfos[$v['admin_id']]['json']['authorizer_info']['nick_name']; } $list[$k]['short_url'] = replaceShortDomain($list[$k]['url_referral'], $v['short_id']); } } $result = array("total" => $total, "rows" => $list); return json($result); } $this->assignconfig('id', $ids); $this->assignconfig('referral_id', $library->referral_id); return $this->view->fetch(); } /** * 删除 */ public function del($ids = "") { if ($ids) { $adminIds = $this->getDataLimitAdminIds(); if (is_array($adminIds)) { $count = $this->model->where($this->dataLimitField, 'in', $adminIds); } $list = model("ReferralSlave")->join('referral_library', 'referral_library.id = referral_slave.library_id')->where('referral_library.admin_id', 'eq', $this->auth->id)->where('referral_slave.referral_id', 'in', $ids)->field("referral_slave.*")->select(); $count = 0; foreach ($list as $k => $v) { $count += model("ReferralSlave")->where('id', 'eq', $v['id'])->delete(); $redis = Redis::instance(); //增加分流链接的key $redisKey = BookConstants::VIP_REFERRAL_KEY.$v['library_id']; $redis->sRem($redisKey,$v['referral_id']); } if ($count) { $this->success(); } else { $this->error(__('No rows were deleted')); } } $this->error(__('Parameter %s can not be empty', 'ids')); } public function viewdataexport($ids = null) { if (!in_array($this->group, [7, 8])) { $this->error('当前用户不是vip也不是vip运营'); } if (empty($ids)) { $this->error('请选择导出的分流链接'); } ini_set('memory_limit', '256M'); //内存限制 $columns = [ '公众号名称', '渠道商名称', '渠道商账号', '推广链接', '链接ID', '书籍ID', '入口页面(书名、关注章节)', '名称(渠道名称)', '创建时间' ]; $redis = Redis::instance(); header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename="代理商推广链接统计数据-' . date('YmdHis', time()) . '.csv"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); $fp = fopen('php://output', 'a');//打开output流 mb_convert_variables('GBK', 'UTF-8', $columns); fputcsv($fp, $columns);//将数据格式化为CSV格式并写入到output流中 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $channelIds = $this->vipAdminBindModel->getChannelIds($this->auth->id); if (empty($channelIds)) { fclose($fp); exit(); } //获取所有子链接 $total = model("ReferralSlave")->where('library_id', 'eq', $ids)->count(); if ($total == 0) { fclose($fp); exit(); } $limit = 3000; $pages = ceil($total / $limit); for ($i = 1; $i <= $pages; $i++) { $offset = ($i - 1) * $limit; $list = model("ReferralSlave") ->join('referral', 'referral_slave.referral_id = referral.id')->join('admin', 'admin.id = referral.admin_id')->join('admin_config', 'admin.id = admin_config.admin_id') ->join('book', 'referral.book_id = book.id', 'left') ->join('ophost', 'admin_config.ophost_id = ophost.id', 'left') ->field([ 'referral.*', 'book.name' => 'book_name', 'admin.username', 'admin.nickname', 'admin_config.json' => 'wx_json', 'admin_config.entryhost_id', 'admin_config.appid', 'ophost.host', ]) ->where('library_id', 'eq', $ids) ->order('referral_slave.id', 'desc') ->limit($offset, $limit) ->select(); foreach ($list as $k => $v) { $channelId = $v['admin_id']; //获取当前书籍的默认关注章节 if (empty($v['guide_chapter_idx']) && !empty($v['book_id'])) { $list[$k]['guide_chapter_idx'] = $this->guideModel->getGuideChapter($v['admin_id'], $v['book_id'], 0, $channelId); } if (!empty($v['entryhost_id'])) { $host = $this->entryhostModel->getInfo($channelId); $urlReferral = Config::get('site.scheme') . '://' . $host['host']; } else { $urlReferral = Config::get('site.scheme') . '://' . $v['appid'] . '.' . $v['host']; } $list[$k]['url_referral'] = $urlReferral . '/t/' . $v['id']; if (!empty($v['book_id'])) { $isLimited = model('BookLimit')->backendHasLimit(0, $v['admin_id'], $v['book_id']); if ($isLimited) { $list[$k]['limited'] = 1; } } $list[$k]['short_url'] = replaceShortDomain($list[$k]['url_referral'], $v['short_id']); if (isset($v['wx_json'])) { $adminJson = json_decode($v['wx_json'], true); if (isset($adminJson['authorizer_info']['nick_name'])) { $list[$k]['wx_nickname'] = $adminJson['authorizer_info']['nick_name']; } else { $list[$k]['wx_nickname'] = ''; } } else { $list[$k]['wx_nickname'] = ''; } $entry_page = ''; if (isset($v['type'])) { if ($v['type'] == 1) { if (isset($v['book_name']) && isset($v['chapter_name'])) { $entry_page .= $v['book_name']; $entry_page .= '--' . $v['chapter_name']; if (isset($list[$k]['guide_chapter_idx']) && !empty($list[$k]['guide_chapter_idx'])) { $entry_page .= '--关注章节:' . $list[$k]['guide_chapter_idx']; } else { $entry_page .= '--关注章节:默认'; } } else { $entry_page = '未知'; } } elseif ($v['type'] == 3) { $entry_page .= '落地页推广'; if (isset($v['book_name']) && isset($v['chapter_name'])) { $entry_page .= '--' . $v['book_name']; $entry_page .= '--' . $v['chapter_name']; } if (isset($list[$k]['guide_chapter_idx']) && !empty($list[$k]['guide_chapter_idx'])) { $entry_page .= '--关注章节:' . $list[$k]['guide_chapter_idx']; } else { $entry_page .= '--关注章节:默认'; } } else { $entry_page .= '书城首页推广'; } } else { $entry_page = '未知'; } //获取每列数据,转换处理成需要导出的数据 $rowData = [ $v['wx_nickname'] ?? '', $v['nickname'] ?? '', $v['username'] ?? '', $v['url_referral'] ?? '', $v['id'] ?? 0, empty($v['book_id']) ? 0 : "\t".$v['book_id']."\t", $entry_page ?? 0, $v['name'] ?? '', empty($v['createtime']) ? '无': date('Y-m-d H:i:s', $v['createtime']) ]; //需要格式转换,否则会乱码 mb_convert_variables('GBK', 'UTF-8', $rowData); fputcsv($fp, $rowData); } fclose($fp); exit(); } } private function getChannelOphost($channel_id){ $adminConfig = model('adminConfig')->getAdminInfoAll($channel_id); $url_referral = Config::get('site.scheme').'://'.$adminConfig['appid'].'.'.$adminConfig['ophost_host']; return $url_referral; } }