session()->get('manage_auth'); $distribution_channel_id = $request->input('distribution_channel_id'); $distribution_channel_name = $request->input('distribution_channel_name'); $official_account_name = $request->input('official_account_name'); if (!empty($manageId)) { $manageModel = ManageService::getById($manageId); if ($manageModel) { $role = $manageModel->role; $channels = ($role == 'admin') ? [] : ChannelService::getByDistributionManagesId($manageId); if ($distribution_channel_id) { $channels = [$distribution_channel_id]; } \Log::info('getBusinessChannelData_official_account_name:'.$official_account_name.' $distribution_channel_name:'.$distribution_channel_name); $result = OfficialAccountService::getBusinessChannelData($channels, $distribution_channel_name, $official_account_name,false); } } return response()->pagination(new BusinessChannelDataTransformer(), $result); } /** * 导出商务各自的渠道信息 * @param Request $request */ function exportBusinessChannelData(Request $request) { $result = []; $distribution_channel_id = $request->input('distribution_channel_id'); $distribution_channel_name = $request->input('distribution_channel_name'); $official_account_name = $request->input('official_account_name'); $manageId = $request->session()->get('manage_auth'); if (!empty($manageId)) { $manageModel = ManageService::getById($manageId); if ($manageModel) { $role = $manageModel->role; $channels = ($role == 'admin') ? [] : ChannelService::getByDistributionManagesId($manageId); if ($distribution_channel_id) { $channels = [$distribution_channel_id]; } \Log::info('getBusinessChannelData_official_account_name:'.$official_account_name.' $distribution_channel_name:'.$distribution_channel_name); $result = OfficialAccountService::getBusinessChannelData($channels, $distribution_channel_name, $official_account_name,false); } header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:attachment;filename=" . "明细" . date("YmdHis") . ".csv"); echo iconv("UTF-8", "GBK", "\"渠道ID\",\"渠道名称\",\"服务号名称\",\"日关注粉丝阈值\",\"总关注粉丝阈值\",\"当日实时关注粉丝数\",\"当日实时累计总粉丝数\"\r\n"); foreach ($result as $item) { echo("\"" . mb_convert_encoding($item->distribution_channel_id, "GBK", "UTF-8") . "\","); echo("\"" . mb_convert_encoding($item->distribution_channel_name, "GBK", "UTF-8") . "\","); echo("\"" . mb_convert_encoding($item->service_name, "GBK", "UTF-8") . "\","); echo("\"" . mb_convert_encoding($item->subscribe_day_maximum, "GBK", "UTF-8") . "\","); echo("\"" . mb_convert_encoding($item->subscribe_top_num, "GBK", "UTF-8") . "\","); echo("\"" . mb_convert_encoding($item->day_fans_num, "GBK", "UTF-8") . "\","); echo("\"" . $item->day_total_fans_num . "\"\r\n"); } exit(); } } }