Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into develop
正在显示
9 个修改的文件
包含
269 行增加
和
45 行删除
| @@ -79,7 +79,13 @@ class ProjectImport extends Command | @@ -79,7 +79,13 @@ class ProjectImport extends Command | ||
| 79 | //读取csv文件 | 79 | //读取csv文件 |
| 80 | $line_of_text = []; | 80 | $line_of_text = []; |
| 81 | try { | 81 | try { |
| 82 | - $file_handle = fopen($task->file_url, 'r'); | 82 | + $opts = [ |
| 83 | + 'http' => [ | ||
| 84 | + 'method' => 'GET', | ||
| 85 | + 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246' | ||
| 86 | + ] | ||
| 87 | + ]; | ||
| 88 | + $file_handle = fopen($task->file_url, 'r', null, stream_context_create($opts)); | ||
| 83 | while (!feof($file_handle)) { | 89 | while (!feof($file_handle)) { |
| 84 | $line_of_text[] = fgetcsv($file_handle, 0, ','); | 90 | $line_of_text[] = fgetcsv($file_handle, 0, ','); |
| 85 | } | 91 | } |
| @@ -183,7 +189,7 @@ class ProjectImport extends Command | @@ -183,7 +189,7 @@ class ProjectImport extends Command | ||
| 183 | protected function get_code_type($file) | 189 | protected function get_code_type($file) |
| 184 | { | 190 | { |
| 185 | $list = array('GBK', 'UTF-8'); | 191 | $list = array('GBK', 'UTF-8'); |
| 186 | - $str = curl_c($file,false); | 192 | + $str = curl_c($file, false); |
| 187 | foreach ($list as $item) { | 193 | foreach ($list as $item) { |
| 188 | $tmp = mb_convert_encoding($str, $item, $item); | 194 | $tmp = mb_convert_encoding($str, $item, $item); |
| 189 | if (md5($tmp) == md5($str)) { | 195 | if (md5($tmp) == md5($str)) { |
| @@ -11,7 +11,6 @@ use App\Services\ProjectServer; | @@ -11,7 +11,6 @@ use App\Services\ProjectServer; | ||
| 11 | use Illuminate\Console\Command; | 11 | use Illuminate\Console\Command; |
| 12 | use Illuminate\Support\Facades\Cache; | 12 | use Illuminate\Support\Facades\Cache; |
| 13 | use Illuminate\Support\Facades\DB; | 13 | use Illuminate\Support\Facades\DB; |
| 14 | -use Illuminate\Support\Facades\Log; | ||
| 15 | use Illuminate\Support\Facades\Redis; | 14 | use Illuminate\Support\Facades\Redis; |
| 16 | 15 | ||
| 17 | /** | 16 | /** |
| @@ -41,7 +40,7 @@ class HtmlCollect extends Command | @@ -41,7 +40,7 @@ class HtmlCollect extends Command | ||
| 41 | public function handle() | 40 | public function handle() |
| 42 | { | 41 | { |
| 43 | while (true) { | 42 | while (true) { |
| 44 | - $this->start_collect(); | 43 | + $this->start_collect(); |
| 45 | } | 44 | } |
| 46 | } | 45 | } |
| 47 | 46 | ||
| @@ -268,6 +267,14 @@ class HtmlCollect extends Command | @@ -268,6 +267,14 @@ class HtmlCollect extends Command | ||
| 268 | $check_vc_b && $source[] = $check_vc_b; | 267 | $check_vc_b && $source[] = $check_vc_b; |
| 269 | } | 268 | } |
| 270 | 269 | ||
| 270 | + //a标签下载资源 | ||
| 271 | + preg_match_all('/<a\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_a); | ||
| 272 | + $down = $result_a[2] ?? []; | ||
| 273 | + foreach ($down as $vd) { | ||
| 274 | + $check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url); | ||
| 275 | + $check_vd && $source[] = $check_vd; | ||
| 276 | + } | ||
| 277 | + | ||
| 271 | return $source; | 278 | return $source; |
| 272 | } | 279 | } |
| 273 | 280 | ||
| @@ -286,7 +293,7 @@ class HtmlCollect extends Command | @@ -286,7 +293,7 @@ class HtmlCollect extends Command | ||
| 286 | (empty($host) || $host == $web_url_domain || $host == $home_url) | 293 | (empty($host) || $host == $web_url_domain || $host == $home_url) |
| 287 | && $path | 294 | && $path |
| 288 | && (strpos($path, '.') !== false) | 295 | && (strpos($path, '.') !== false) |
| 289 | - && (end($path_arr) != 'html') | 296 | + && (!in_array(end($path_arr), ['html', 'php', 'com', 'xml'])) |
| 290 | ) { | 297 | ) { |
| 291 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); | 298 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); |
| 292 | if (!$source) { | 299 | if (!$source) { |
| @@ -350,7 +357,7 @@ class HtmlCollect extends Command | @@ -350,7 +357,7 @@ class HtmlCollect extends Command | ||
| 350 | continue; | 357 | continue; |
| 351 | } | 358 | } |
| 352 | $path_arr = explode('.', $vcs); | 359 | $path_arr = explode('.', $vcs); |
| 353 | - if (end($path_arr) == 'html') { | 360 | + if (in_array(end($path_arr), ['html', 'php', 'com', 'xml'])) { |
| 354 | continue; | 361 | continue; |
| 355 | } | 362 | } |
| 356 | 363 |
| @@ -9,6 +9,7 @@ use App\Models\RouteMap\RouteMap; | @@ -9,6 +9,7 @@ use App\Models\RouteMap\RouteMap; | ||
| 9 | use App\Services\CosService; | 9 | use App\Services\CosService; |
| 10 | use App\Services\ProjectServer; | 10 | use App\Services\ProjectServer; |
| 11 | use Illuminate\Console\Command; | 11 | use Illuminate\Console\Command; |
| 12 | +use Illuminate\Support\Facades\Cache; | ||
| 12 | use Illuminate\Support\Facades\DB; | 13 | use Illuminate\Support\Facades\DB; |
| 13 | use Illuminate\Support\Facades\Redis; | 14 | use Illuminate\Support\Facades\Redis; |
| 14 | 15 | ||
| @@ -75,29 +76,8 @@ class HtmlLanguageCollect extends Command | @@ -75,29 +76,8 @@ class HtmlLanguageCollect extends Command | ||
| 75 | $collect_info->status = CollectTask::STATUS_ING; | 76 | $collect_info->status = CollectTask::STATUS_ING; |
| 76 | $collect_info->save(); | 77 | $collect_info->save(); |
| 77 | 78 | ||
| 78 | - //获取英文站域名 | ||
| 79 | - $domain = $collect_info->domain; | ||
| 80 | - if (strpos($domain, '/') !== false) { | ||
| 81 | - $domain = substr($domain, 0, strpos($domain, '/')); | ||
| 82 | - } else { | ||
| 83 | - $domain = str_replace($collect_info->language, 'www', $domain); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - $web_url_domain = $domain; | ||
| 87 | - $home_url = $domain; | ||
| 88 | - $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text'; | ||
| 89 | - $data_config = curl_c($url_web_config); | ||
| 90 | - if ($data_config) { | ||
| 91 | - $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 92 | - if (isset($web_url_arr['host'])) { | ||
| 93 | - $web_url_domain = $web_url_arr['host']; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 97 | - if (isset($home_url_arr['host'])) { | ||
| 98 | - $home_url = $home_url_arr['host']; | ||
| 99 | - } | ||
| 100 | - } | 79 | + //获取站点正式和测试域名 |
| 80 | + $old_info = $this->getOldDomain($project_id, $collect_info->domain); | ||
| 101 | 81 | ||
| 102 | //采集html页面,下载资源到本地并替换 | 82 | //采集html页面,下载资源到本地并替换 |
| 103 | try { | 83 | try { |
| @@ -110,7 +90,15 @@ class HtmlLanguageCollect extends Command | @@ -110,7 +90,15 @@ class HtmlLanguageCollect extends Command | ||
| 110 | return true; | 90 | return true; |
| 111 | } | 91 | } |
| 112 | 92 | ||
| 113 | - $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); | 93 | + //如果有base64图片,先替换掉,再进行资源匹配 |
| 94 | + $new_html = $html; | ||
| 95 | + preg_match_all("/data:([^;]*);base64,(.*)?\"/", $new_html, $result_img); | ||
| 96 | + $img_base64 = $result_img[2] ?? []; | ||
| 97 | + foreach ($img_base64 as $v64) { | ||
| 98 | + $new_html = str_replace($v64, '', $new_html); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + $source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']); | ||
| 114 | 102 | ||
| 115 | if ($source_list) { | 103 | if ($source_list) { |
| 116 | $html = $this->upload_source($html, $source_list, $project_id); | 104 | $html = $this->upload_source($html, $source_list, $project_id); |
| @@ -162,9 +150,6 @@ class HtmlLanguageCollect extends Command | @@ -162,9 +150,6 @@ class HtmlLanguageCollect extends Command | ||
| 162 | case 'blog': | 150 | case 'blog': |
| 163 | $source = RouteMap::SOURCE_BLOG; | 151 | $source = RouteMap::SOURCE_BLOG; |
| 164 | break; | 152 | break; |
| 165 | - case 'tag': | ||
| 166 | - $source = RouteMap::SOURCE_PRODUCT_KEYWORD; | ||
| 167 | - break; | ||
| 168 | default: | 153 | default: |
| 169 | $source = RouteMap::SOURCE_PRODUCT; | 154 | $source = RouteMap::SOURCE_PRODUCT; |
| 170 | break; | 155 | break; |
| @@ -197,6 +182,42 @@ class HtmlLanguageCollect extends Command | @@ -197,6 +182,42 @@ class HtmlLanguageCollect extends Command | ||
| 197 | return $task_id; | 182 | return $task_id; |
| 198 | } | 183 | } |
| 199 | 184 | ||
| 185 | + //获取站点老域名 | ||
| 186 | + protected function getOldDomain($project_id, $domain) | ||
| 187 | + { | ||
| 188 | + $key = 'project_collect_lan_domain_' . $project_id; | ||
| 189 | + | ||
| 190 | + $data = Cache::get($key); | ||
| 191 | + | ||
| 192 | + if (!$data) { | ||
| 193 | + $web_url_domain = $domain; | ||
| 194 | + $home_url = $domain; | ||
| 195 | + | ||
| 196 | + $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text'; | ||
| 197 | + $data_config = curl_c($url_web_config); | ||
| 198 | + if ($data_config) { | ||
| 199 | + $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 200 | + if (isset($web_url_arr['host'])) { | ||
| 201 | + $web_url_domain = $web_url_arr['host']; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 205 | + if (isset($home_url_arr['host'])) { | ||
| 206 | + $home_url = $home_url_arr['host']; | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + $data = [ | ||
| 211 | + 'web_url_domain' => $web_url_domain, | ||
| 212 | + 'home_url' => $home_url, | ||
| 213 | + ]; | ||
| 214 | + | ||
| 215 | + Cache::add($key, $data, 3600);//缓存1小时 | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + return $data; | ||
| 219 | + } | ||
| 220 | + | ||
| 200 | //正则匹配html资源 | 221 | //正则匹配html资源 |
| 201 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) | 222 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) |
| 202 | { | 223 | { |
| @@ -246,6 +267,13 @@ class HtmlLanguageCollect extends Command | @@ -246,6 +267,13 @@ class HtmlLanguageCollect extends Command | ||
| 246 | $check_vc_b && $source[] = $check_vc_b; | 267 | $check_vc_b && $source[] = $check_vc_b; |
| 247 | } | 268 | } |
| 248 | 269 | ||
| 270 | + //a标签下载资源 | ||
| 271 | + preg_match_all('/<a\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_a); | ||
| 272 | + $down = $result_a[2] ?? []; | ||
| 273 | + foreach ($down as $vd) { | ||
| 274 | + $check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url); | ||
| 275 | + $check_vd && $source[] = $check_vd; | ||
| 276 | + } | ||
| 249 | 277 | ||
| 250 | return $source; | 278 | return $source; |
| 251 | } | 279 | } |
| @@ -265,7 +293,7 @@ class HtmlLanguageCollect extends Command | @@ -265,7 +293,7 @@ class HtmlLanguageCollect extends Command | ||
| 265 | (empty($host) || $host == $web_url_domain || $host == $home_url) | 293 | (empty($host) || $host == $web_url_domain || $host == $home_url) |
| 266 | && $path | 294 | && $path |
| 267 | && (strpos($path, '.') !== false) | 295 | && (strpos($path, '.') !== false) |
| 268 | - && (end($path_arr) != 'html') | 296 | + && (!in_array(end($path_arr), ['html', 'php', 'com', 'xml'])) |
| 269 | ) { | 297 | ) { |
| 270 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); | 298 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); |
| 271 | if (!$source) { | 299 | if (!$source) { |
| @@ -329,7 +357,7 @@ class HtmlLanguageCollect extends Command | @@ -329,7 +357,7 @@ class HtmlLanguageCollect extends Command | ||
| 329 | continue; | 357 | continue; |
| 330 | } | 358 | } |
| 331 | $path_arr = explode('.', $vcs); | 359 | $path_arr = explode('.', $vcs); |
| 332 | - if(end($path_arr) == 'html'){ | 360 | + if(in_array(end($path_arr), ['html', 'php', 'com', 'xml'])){ |
| 333 | continue; | 361 | continue; |
| 334 | } | 362 | } |
| 335 | 363 |
| @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Inquiry; | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Inquiry; | ||
| 5 | 5 | ||
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | use App\Http\Logic\Bside\Inquiry\InquiryLogic; | 7 | use App\Http\Logic\Bside\Inquiry\InquiryLogic; |
| 8 | +use App\Models\Inquiry\InquiryForm; | ||
| 8 | use App\Rules\Ids; | 9 | use App\Rules\Ids; |
| 9 | use App\Services\BatchExportService; | 10 | use App\Services\BatchExportService; |
| 10 | use Illuminate\Http\Request; | 11 | use Illuminate\Http\Request; |
| @@ -20,9 +21,24 @@ use Illuminate\Support\Facades\Storage; | @@ -20,9 +21,24 @@ use Illuminate\Support\Facades\Storage; | ||
| 20 | class InquiryController extends BaseController | 21 | class InquiryController extends BaseController |
| 21 | { | 22 | { |
| 22 | 23 | ||
| 24 | + public function form_list(){ | ||
| 25 | + $list = InquiryForm::where('is_default', 0)->get(); | ||
| 26 | + $data = $list->toArray(); | ||
| 27 | + foreach ($data as &$item){ | ||
| 28 | + $field_text = []; | ||
| 29 | + foreach ($item['field'] as $v){ | ||
| 30 | + $field_text[$v] = InquiryForm::fieldMap($v); | ||
| 31 | + } | ||
| 32 | + $item['field_text'] = $field_text; | ||
| 33 | + } | ||
| 34 | + return $this->success($data); | ||
| 35 | + } | ||
| 36 | + | ||
| 23 | public function index(InquiryLogic $logic) | 37 | public function index(InquiryLogic $logic) |
| 24 | { | 38 | { |
| 25 | - if(($this->param['type']??'') == 'other'){ | 39 | + if(!empty($this->param['form_id'])){ |
| 40 | + $data = $logic->getFormDataList(); | ||
| 41 | + }elseif(($this->param['type']??'') == 'other'){ | ||
| 26 | $data = $logic->getOtherList(); | 42 | $data = $logic->getOtherList(); |
| 27 | }else{ | 43 | }else{ |
| 28 | $data = $logic->getApiList(); | 44 | $data = $logic->getApiList(); |
| @@ -36,7 +52,10 @@ class InquiryController extends BaseController | @@ -36,7 +52,10 @@ class InquiryController extends BaseController | ||
| 36 | ],[ | 52 | ],[ |
| 37 | 'id.required' => 'ID不能为空' | 53 | 'id.required' => 'ID不能为空' |
| 38 | ]); | 54 | ]); |
| 39 | - if(($this->param['type']??'') == 'other'){ | 55 | + |
| 56 | + if(!empty($this->param['form_id'])){ | ||
| 57 | + $data = $logic->getFormDataInfo($this->param['id'], $this->param['form_id']); | ||
| 58 | + }elseif(($this->param['type']??'') == 'other'){ | ||
| 40 | $data = $logic->getOtherInfo($this->param['id']); | 59 | $data = $logic->getOtherInfo($this->param['id']); |
| 41 | }else{ | 60 | }else{ |
| 42 | $data = $logic->getInfo($this->param['id']); | 61 | $data = $logic->getInfo($this->param['id']); |
| @@ -52,7 +71,9 @@ class InquiryController extends BaseController | @@ -52,7 +71,9 @@ class InquiryController extends BaseController | ||
| 52 | ],[ | 71 | ],[ |
| 53 | 'ids.required' => 'ID不能为空' | 72 | 'ids.required' => 'ID不能为空' |
| 54 | ]); | 73 | ]); |
| 55 | - if(($this->param['type']??'') == 'other'){ | 74 | + if(!empty($this->param['form_id'])){ |
| 75 | + $logic->deleteFormData($this->param['ids'], ['form_id' => $this->param['form_id']]); | ||
| 76 | + }elseif(($this->param['type']??'') == 'other'){ | ||
| 56 | $logic->deleteOther($this->param['ids']); | 77 | $logic->deleteOther($this->param['ids']); |
| 57 | }else{ | 78 | }else{ |
| 58 | $logic->delete($this->param['ids']); | 79 | $logic->delete($this->param['ids']); |
| @@ -71,13 +92,24 @@ class InquiryController extends BaseController | @@ -71,13 +92,24 @@ class InquiryController extends BaseController | ||
| 71 | */ | 92 | */ |
| 72 | public function export(InquiryLogic $logic) | 93 | public function export(InquiryLogic $logic) |
| 73 | { | 94 | { |
| 74 | - if(($this->param['type']??'') == 'other'){ | 95 | + if(!empty($this->param['form_id'])){ |
| 96 | + $data = $logic->getFormDataList(true); | ||
| 97 | + $field = InquiryForm::getField($this->param['form_id']); | ||
| 98 | + $map = [ | ||
| 99 | + 'submit_time' => '询盘发送时间', | ||
| 100 | + ]; | ||
| 101 | + foreach ($field as $v) { | ||
| 102 | + $map[$v] = InquiryForm::fieldMap($v); | ||
| 103 | + } | ||
| 104 | + $map['ip_address'] = '访问国家/地区(IP)'; | ||
| 105 | + $map['refer'] = '发送页面'; | ||
| 106 | + }elseif(($this->param['type']??'') == 'other'){ | ||
| 75 | $data = $logic->getOtherList(true); | 107 | $data = $logic->getOtherList(true); |
| 76 | $map = [ | 108 | $map = [ |
| 77 | 'submit_time' => '询盘发送时间', | 109 | 'submit_time' => '询盘发送时间', |
| 78 | 'email' => '邮箱', | 110 | 'email' => '邮箱', |
| 79 | 'ip_address' => '访问国家/地区(IP)', | 111 | 'ip_address' => '访问国家/地区(IP)', |
| 80 | - 'referer' => '发送页面', | 112 | + 'refer' => '发送页面', |
| 81 | ]; | 113 | ]; |
| 82 | }else{ | 114 | }else{ |
| 83 | $data = $logic->getApiList(true); | 115 | $data = $logic->getApiList(true); |
| @@ -95,6 +127,10 @@ class InquiryController extends BaseController | @@ -95,6 +127,10 @@ class InquiryController extends BaseController | ||
| 95 | $data = $data['list'] ?? []; | 127 | $data = $data['list'] ?? []; |
| 96 | foreach ($data as &$item){ | 128 | foreach ($data as &$item){ |
| 97 | $item['ip_address'] = "{$item['country']}({$item['ip']})"; | 129 | $item['ip_address'] = "{$item['country']}({$item['ip']})"; |
| 130 | + | ||
| 131 | + if(!empty($this->param['form_id'])){ | ||
| 132 | + $item = array_merge($item, $item['data']); | ||
| 133 | + } | ||
| 98 | } | 134 | } |
| 99 | 135 | ||
| 100 | //生成文件,发送到客户端 | 136 | //生成文件,发送到客户端 |
| @@ -8,8 +8,9 @@ use App\Helper\Translate; | @@ -8,8 +8,9 @@ use App\Helper\Translate; | ||
| 8 | use App\Http\Logic\Aside\Project\ProjectLogic; | 8 | use App\Http\Logic\Aside\Project\ProjectLogic; |
| 9 | use App\Http\Logic\Bside\BaseLogic; | 9 | use App\Http\Logic\Bside\BaseLogic; |
| 10 | use App\Models\Domain\DomainInfo; | 10 | use App\Models\Domain\DomainInfo; |
| 11 | +use App\Models\Inquiry\InquiryForm; | ||
| 12 | +use App\Models\Inquiry\InquiryFormData; | ||
| 11 | use App\Models\Inquiry\InquiryOther; | 13 | use App\Models\Inquiry\InquiryOther; |
| 12 | -use App\Services\ProjectServer; | ||
| 13 | use Illuminate\Support\Facades\DB; | 14 | use Illuminate\Support\Facades\DB; |
| 14 | 15 | ||
| 15 | /** | 16 | /** |
| @@ -68,7 +69,6 @@ class InquiryLogic extends BaseLogic | @@ -68,7 +69,6 @@ class InquiryLogic extends BaseLogic | ||
| 68 | if($search){ | 69 | if($search){ |
| 69 | $map['email'] = ['like','%'.$search.'%']; | 70 | $map['email'] = ['like','%'.$search.'%']; |
| 70 | } | 71 | } |
| 71 | - ProjectServer::useProject($this->user['project_id']); | ||
| 72 | 72 | ||
| 73 | $data = (new InquiryOther())->lists($map,$page,$page_size,'id', | 73 | $data = (new InquiryOther())->lists($map,$page,$page_size,'id', |
| 74 | ['id', 'email', 'ip', 'country', 'domain', DB::raw('referer as refer'), DB::raw('status as read_status'), 'submit_time'] | 74 | ['id', 'email', 'ip', 'country', 'domain', DB::raw('referer as refer'), DB::raw('status as read_status'), 'submit_time'] |
| @@ -77,6 +77,27 @@ class InquiryLogic extends BaseLogic | @@ -77,6 +77,27 @@ class InquiryLogic extends BaseLogic | ||
| 77 | return $this->success($data); | 77 | return $this->success($data); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | + public function getFormDataList($export = false){ | ||
| 81 | + $page_size = $export ? 1000 : 20; | ||
| 82 | + $search = $this->request['search'] ?: ''; | ||
| 83 | + $page = $this->request['page'] ?: 1; | ||
| 84 | + $form_id = $this->request['form_id'] ?? ''; | ||
| 85 | + $field = InquiryForm::getField($form_id); | ||
| 86 | + $map = [ | ||
| 87 | + 'form_id' => $form_id | ||
| 88 | + ]; | ||
| 89 | + if($search){ | ||
| 90 | + foreach ($field as $v){ | ||
| 91 | + $map['data->' . $v] = $search; | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + $fields = ['id', 'data', 'ip', 'country', 'domain', DB::raw('referer as refer'), DB::raw('status as read_status'), DB::raw('submit_at as submit_time')]; | ||
| 95 | + $lists = InquiryFormData::select($fields)->orderBy('id')->paginate($page_size, ['*'], 'page', $page); | ||
| 96 | + $data = $lists->toArray(); | ||
| 97 | + | ||
| 98 | + return $this->success($data); | ||
| 99 | + } | ||
| 100 | + | ||
| 80 | public function getInfo($id) | 101 | public function getInfo($id) |
| 81 | { | 102 | { |
| 82 | $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']); | 103 | $project = (new ProjectLogic())->getProjectInfo($this->user['project_id']); |
| @@ -93,10 +114,22 @@ class InquiryLogic extends BaseLogic | @@ -93,10 +114,22 @@ class InquiryLogic extends BaseLogic | ||
| 93 | return $this->success(['trans_message' => $trans_message]); | 114 | return $this->success(['trans_message' => $trans_message]); |
| 94 | } | 115 | } |
| 95 | 116 | ||
| 117 | + public function getFormDataInfo($id, $form_id){ | ||
| 118 | + //修改状态为已读 | ||
| 119 | + if($this->request['read_status']){ | ||
| 120 | + (new InquiryFormData())->edit(['status' => 1], ['id' => $id, 'form_id' => $form_id]); | ||
| 121 | + } | ||
| 122 | + //翻译 | ||
| 123 | + $trans_message = ''; | ||
| 124 | + if($this->request['message']){ | ||
| 125 | + $trans_message = Translate::tran($this->request['message'], 'zh'); | ||
| 126 | + } | ||
| 127 | + return $this->success(['trans_message' => $trans_message]); | ||
| 128 | + } | ||
| 129 | + | ||
| 96 | public function getOtherInfo($id){ | 130 | public function getOtherInfo($id){ |
| 97 | //修改状态为已读 | 131 | //修改状态为已读 |
| 98 | if($this->request['read_status']){ | 132 | if($this->request['read_status']){ |
| 99 | - ProjectServer::useProject($this->user['project_id']); | ||
| 100 | (new InquiryOther())->edit(['status' => 1], ['id' => $id]); | 133 | (new InquiryOther())->edit(['status' => 1], ['id' => $id]); |
| 101 | } | 134 | } |
| 102 | return $this->success(['trans_message' => '']); | 135 | return $this->success(['trans_message' => '']); |
| @@ -120,11 +153,21 @@ class InquiryLogic extends BaseLogic | @@ -120,11 +153,21 @@ class InquiryLogic extends BaseLogic | ||
| 120 | if(!$ids){ | 153 | if(!$ids){ |
| 121 | $this->fail('ID不能为空'); | 154 | $this->fail('ID不能为空'); |
| 122 | } | 155 | } |
| 123 | - ProjectServer::useProject($this->user['project_id']); | ||
| 124 | (new InquiryOther())->del(['id'=>['in',$ids]]); | 156 | (new InquiryOther())->del(['id'=>['in',$ids]]); |
| 125 | return $this->success(); | 157 | return $this->success(); |
| 126 | } | 158 | } |
| 127 | 159 | ||
| 160 | + public function deleteFormData($ids, $map = []) | ||
| 161 | + { | ||
| 162 | + $ids = array_filter(Arr::splitFilterToArray($ids), 'intval'); | ||
| 163 | + if(!$ids){ | ||
| 164 | + $this->fail('ID不能为空'); | ||
| 165 | + } | ||
| 166 | + $map['id'] = ['in',$ids]; | ||
| 167 | + (new InquiryFormData())->del($map); | ||
| 168 | + return $this->success(); | ||
| 169 | + } | ||
| 170 | + | ||
| 128 | 171 | ||
| 129 | 172 | ||
| 130 | } | 173 | } |
app/Models/Inquiry/InquiryForm.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Inquiry; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | +use Illuminate\Support\Facades\Cache; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Class InquiryForm | ||
| 11 | + * @package App\Models\Inquiry | ||
| 12 | + * @author zbj | ||
| 13 | + * @date 2023/12/5 | ||
| 14 | + */ | ||
| 15 | +class InquiryForm extends Base | ||
| 16 | +{ | ||
| 17 | + use SoftDeletes; | ||
| 18 | + | ||
| 19 | + //设置关联表名 | ||
| 20 | + /** | ||
| 21 | + * @var mixed | ||
| 22 | + */ | ||
| 23 | + protected $connection = "custom_mysql"; | ||
| 24 | + protected $table = 'gl_inquiry_form'; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 预设字段名称 | ||
| 29 | + * @author zbj | ||
| 30 | + * @date 2023/12/5 | ||
| 31 | + */ | ||
| 32 | + public static function fieldMap($field = ''){ | ||
| 33 | + $map = [ | ||
| 34 | + 'name' => '姓名', | ||
| 35 | + 'email' => '邮箱', | ||
| 36 | + 'phone' => '电话', | ||
| 37 | + 'mobile' => '电话', | ||
| 38 | + 'message' => '询盘内容', | ||
| 39 | + 'company' => '公司名称' | ||
| 40 | + ]; | ||
| 41 | + if($field){ | ||
| 42 | + return $map[$field] ?? $field; | ||
| 43 | + } | ||
| 44 | + return $map; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + public function getFieldAttribute($value) | ||
| 49 | + { | ||
| 50 | + return json_decode($value, true); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * @author zbj | ||
| 55 | + * @date 2023/12/5 | ||
| 56 | + */ | ||
| 57 | + public static function getField($form_id){ | ||
| 58 | + $cache_key = 'inquiry_form_field_' . $form_id; | ||
| 59 | + $field = Cache::get($cache_key); | ||
| 60 | + if(!$field){ | ||
| 61 | + $field = self::where('id', $form_id)->value('field'); | ||
| 62 | + $field && Cache::set($cache_key, $field, 3600); | ||
| 63 | + } | ||
| 64 | + return $field; | ||
| 65 | + } | ||
| 66 | +} |
app/Models/Inquiry/InquiryFormData.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Inquiry; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Class InquiryFormData | ||
| 10 | + * @package App\Models\Inquiry | ||
| 11 | + * @author zbj | ||
| 12 | + * @date 2023/12/4 | ||
| 13 | + */ | ||
| 14 | +class InquiryFormData extends Base | ||
| 15 | +{ | ||
| 16 | + use SoftDeletes; | ||
| 17 | + | ||
| 18 | + //设置关联表名 | ||
| 19 | + /** | ||
| 20 | + * @var mixed | ||
| 21 | + */ | ||
| 22 | + protected $connection = "custom_mysql"; | ||
| 23 | + protected $table = 'gl_inquiry_form_data'; | ||
| 24 | + | ||
| 25 | + public function getDataAttribute($value) | ||
| 26 | + { | ||
| 27 | + return json_decode($value, true); | ||
| 28 | + } | ||
| 29 | +} |
| @@ -83,9 +83,17 @@ class RouteMap extends Base | @@ -83,9 +83,17 @@ class RouteMap extends Base | ||
| 83 | if(in_array($route, $fixed)){ | 83 | if(in_array($route, $fixed)){ |
| 84 | return true; | 84 | return true; |
| 85 | } | 85 | } |
| 86 | + $path = ''; | ||
| 87 | + if($source == self::SOURCE_NEWS){ | ||
| 88 | + $path = self::SOURCE_NEWS; | ||
| 89 | + }elseif ($source == self::SOURCE_BLOG){ | ||
| 90 | + $path = self::SOURCE_BLOG.'s'; | ||
| 91 | + } | ||
| 92 | + | ||
| 86 | $where = [ | 93 | $where = [ |
| 87 | 'project_id' => $project_id, | 94 | 'project_id' => $project_id, |
| 88 | 'route' => $route, | 95 | 'route' => $route, |
| 96 | + 'path' => $path, | ||
| 89 | ]; | 97 | ]; |
| 90 | $route = self::where($where)->first(); | 98 | $route = self::where($where)->first(); |
| 91 | if($route){ | 99 | if($route){ |
| @@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 271 | //精准询盘 | 271 | //精准询盘 |
| 272 | Route::prefix('inquiry')->group(function () { | 272 | Route::prefix('inquiry')->group(function () { |
| 273 | Route::get('/', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'index'])->name('inquiry'); | 273 | Route::get('/', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'index'])->name('inquiry'); |
| 274 | + Route::get('/form_list', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'form_list'])->name('inquiry_form_list'); | ||
| 274 | Route::get('/info', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'info'])->name('inquiry_info'); | 275 | Route::get('/info', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'info'])->name('inquiry_info'); |
| 275 | Route::any('/delete', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'delete'])->name('inquiry_delete'); | 276 | Route::any('/delete', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'delete'])->name('inquiry_delete'); |
| 276 | Route::any('/export', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'export'])->name('inquiry_export'); | 277 | Route::any('/export', [\App\Http\Controllers\Bside\Inquiry\InquiryController::class, 'export'])->name('inquiry_export'); |
| @@ -424,7 +425,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -424,7 +425,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 424 | }); | 425 | }); |
| 425 | 426 | ||
| 426 | //自定义模板 | 427 | //自定义模板 |
| 427 | - Route::prefix('custom')->group(function () { | 428 | + Route::prefix('custom_module')->group(function () { |
| 428 | Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); | 429 | Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); |
| 429 | Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save'); | 430 | Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save'); |
| 430 | Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); | 431 | Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); |
-
请 注册 或 登录 后发表评论