作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

@@ -74,15 +74,15 @@ class ProjectFilePDF extends Command @@ -74,15 +74,15 @@ class ProjectFilePDF extends Command
74 public function dataPush(array $items) 74 public function dataPush(array $items)
75 { 75 {
76 foreach ($items as $item) { 76 foreach ($items as $item) {
77 - $project_id = $item->project_id;  
78 - $application_id = $item->wx_id;  
79 - $wx_user_id = $item->wx_user_id; 77 + $project_id = $item->project_id;
  78 + $user_id = $item->user_id;
  79 + $friend_id = $item->friend_id;
80 // todo 根据项目查询数据 80 // todo 根据项目查询数据
81 $project_data = []; 81 $project_data = [];
82 $html = $this->html($project_data); 82 $html = $this->html($project_data);
83 - $filename = hash('md5', $this->time . '-' . $project_id . '-' . $application_id); 83 + $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
84 $file_path = $this->savePDF($html, $filename); 84 $file_path = $this->savePDF($html, $filename);
85 - $this->DataFile->saveData(compact('project_id', 'application_id', 'file_path') + ['time' => $this->time]); 85 + $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]);
86 } 86 }
87 } 87 }
88 88
@@ -63,7 +63,7 @@ class HtmlLanguageCollect extends Command @@ -63,7 +63,7 @@ class HtmlLanguageCollect extends Command
63 //设置数据库 63 //设置数据库
64 $project = ProjectServer::useProject($project_id); 64 $project = ProjectServer::useProject($project_id);
65 if ($project) { 65 if ($project) {
66 - $collect_info = CollectTask::select(['id', 'domain', 'route'])->where('id', $collect_id)->where('status', CollectTask::STATUS_UN)->where('language', '!=', '')->first(); 66 + $collect_info = CollectTask::select(['id', 'domain', 'route', 'language'])->where('id', $collect_id)->where('status', CollectTask::STATUS_UN)->where('language', '!=', '')->first();
67 67
68 if (!$collect_info) { 68 if (!$collect_info) {
69 sleep(2); 69 sleep(2);
@@ -75,10 +75,18 @@ class HtmlLanguageCollect extends Command @@ -75,10 +75,18 @@ class HtmlLanguageCollect extends Command
75 $collect_info->status = CollectTask::STATUS_ING; 75 $collect_info->status = CollectTask::STATUS_ING;
76 $collect_info->save(); 76 $collect_info->save();
77 77
78 - $web_url_domain = $collect_info->domain;  
79 - $home_url = $collect_info->domain;  
80 - $url_web_config = 'https://' . $collect_info->domain . '/wp-content/cache/user_config.text';  
81 - $data_config = http_get($url_web_config, ['charset' => 'UTF-8']); 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);
82 if ($data_config) { 90 if ($data_config) {
83 $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); 91 $web_url_arr = parse_url($data_config['web_url_domain'] ?? '');
84 if (isset($web_url_arr['host'])) { 92 if (isset($web_url_arr['host'])) {
@@ -93,20 +101,11 @@ class HtmlLanguageCollect extends Command @@ -93,20 +101,11 @@ class HtmlLanguageCollect extends Command
93 101
94 //采集html页面,下载资源到本地并替换 102 //采集html页面,下载资源到本地并替换
95 try { 103 try {
96 - $opts = [  
97 - 'http' => [  
98 - 'header' => 'User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0'  
99 - ],  
100 - 'ssl' => [  
101 - 'verify_peer' => false,  
102 - 'verify_peer_name' => false,  
103 - ]  
104 - ];  
105 - $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route, false, stream_context_create($opts)); 104 + $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false);
106 $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); 105 $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url);
107 106
108 if ($source_list) { 107 if ($source_list) {
109 - $html = $this->upload_source($html, $source_list, $project_id, $opts); 108 + $html = $this->upload_source($html, $source_list, $project_id);
110 } 109 }
111 } catch (\Exception $e) { 110 } catch (\Exception $e) {
112 $collect_info->status = CollectTask::STATUS_FAIL; 111 $collect_info->status = CollectTask::STATUS_FAIL;
@@ -279,7 +278,7 @@ class HtmlLanguageCollect extends Command @@ -279,7 +278,7 @@ class HtmlLanguageCollect extends Command
279 } 278 }
280 279
281 //下载并替换资源 280 //下载并替换资源
282 - protected function upload_source($html, $source, $project_id, $opts) 281 + protected function upload_source($html, $source, $project_id)
283 { 282 {
284 foreach ($source as $vs) { 283 foreach ($source as $vs) {
285 284
@@ -297,7 +296,7 @@ class HtmlLanguageCollect extends Command @@ -297,7 +296,7 @@ class HtmlLanguageCollect extends Command
297 296
298 if (substr($new_source, -3, 3) == 'css') { 297 if (substr($new_source, -3, 3) == 'css') {
299 // 下载css文件中的资源 298 // 下载css文件中的资源
300 - $css_html = file_get_contents($vs['url_complete'], false, stream_context_create($opts)); 299 + $css_html = curl_c($vs['url_complete'], false);
301 preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); 300 preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source);
302 $css_source = $result_css_source[1] ?? []; 301 $css_source = $result_css_source[1] ?? [];
303 302
@@ -140,7 +140,7 @@ class ProjectUpdate extends Command @@ -140,7 +140,7 @@ class ProjectUpdate extends Command
140 'seo_keywords' => $item['seo_keywords'] ?? '', 140 'seo_keywords' => $item['seo_keywords'] ?? '',
141 'seo_description' => $item['seo_description'] ?? '', 141 'seo_description' => $item['seo_description'] ?? '',
142 ]); 142 ]);
143 - $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['name'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id); 143 + $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id);
144 $model->edit(['route' => $route], ['id' => $id]); 144 $model->edit(['route' => $route], ['id' => $id]);
145 } catch (\Exception $e) { 145 } catch (\Exception $e) {
146 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 146 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
@@ -273,7 +273,7 @@ class ProjectUpdate extends Command @@ -273,7 +273,7 @@ class ProjectUpdate extends Command
273 ]), 273 ]),
274 'status' => Product::STATUS_ON 274 'status' => Product::STATUS_ON
275 ]); 275 ]);
276 - $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['ttile'], RouteMap::SOURCE_PRODUCT, $id, $project_id); 276 + $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT, $id, $project_id);
277 $model->edit(['route' => $route], ['id' => $id]); 277 $model->edit(['route' => $route], ['id' => $id]);
278 } catch (\Exception $e) { 278 } catch (\Exception $e) {
279 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 279 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
@@ -328,7 +328,7 @@ class ProjectUpdate extends Command @@ -328,7 +328,7 @@ class ProjectUpdate extends Command
328 'image' => $item['images'][0] ?? '', 328 'image' => $item['images'][0] ?? '',
329 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE 329 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE
330 ]); 330 ]);
331 - $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['ttile'], $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id); 331 + $route = $this->set_map($this->get_url_route($item['url']), $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
332 $model->edit(['url' => $route], ['id' => $id]); 332 $model->edit(['url' => $route], ['id' => $id]);
333 } catch (\Exception $e) { 333 } catch (\Exception $e) {
334 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 334 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
@@ -377,7 +377,7 @@ class ProjectUpdate extends Command @@ -377,7 +377,7 @@ class ProjectUpdate extends Command
377 'html' => $item['content'] ?? '', 377 'html' => $item['content'] ?? '',
378 'status' => 1 378 'status' => 1
379 ]); 379 ]);
380 - $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); 380 + $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PAGE, $id, $project_id);
381 $model->edit(['url' => $route], ['id' => $id]); 381 $model->edit(['url' => $route], ['id' => $id]);
382 } catch (\Exception $e) { 382 } catch (\Exception $e) {
383 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 383 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
@@ -465,7 +465,7 @@ class ProjectUpdate extends Command @@ -465,7 +465,7 @@ class ProjectUpdate extends Command
465 'keywords' => $item['keywords'] ?? '', 465 'keywords' => $item['keywords'] ?? '',
466 'describe' => $item['description'] ?? '' 466 'describe' => $item['description'] ?? ''
467 ]); 467 ]);
468 - $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id); 468 + $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
469 $model->edit(['route' => $route], ['id' => $parent_id]); 469 $model->edit(['route' => $route], ['id' => $parent_id]);
470 } catch (\Exception $e) { 470 } catch (\Exception $e) {
471 echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL; 471 echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;
@@ -516,4 +516,28 @@ class ProjectUpdate extends Command @@ -516,4 +516,28 @@ class ProjectUpdate extends Command
516 516
517 return $str; 517 return $str;
518 } 518 }
  519 +
  520 + //路由入库
  521 + protected function set_map($route, $source, $source_id, $project_id)
  522 + {
  523 + if (empty($route)) {
  524 + return '';
  525 + }
  526 +
  527 + $route_map = new RouteMap();
  528 + $route_map->project_id = $project_id;
  529 + $route_map->source = $source;
  530 + $route_map->source_id = $source_id;
  531 + $route_map->route = $route;
  532 +
  533 + if ($source == RouteMap::SOURCE_NEWS) {
  534 + $route_map->path = RouteMap::SOURCE_NEWS;
  535 + } elseif ($source == RouteMap::SOURCE_BLOG) {
  536 + $route_map->path = RouteMap::SOURCE_BLOG;
  537 + }
  538 +
  539 + $route_map->save();
  540 +
  541 + return $route;
  542 + }
519 } 543 }
@@ -58,7 +58,8 @@ class WebsiteData extends Command @@ -58,7 +58,8 @@ class WebsiteData extends Command
58 public function post_data($data) 58 public function post_data($data)
59 { 59 {
60 $url = env('AICC_URL'); 60 $url = env('AICC_URL');
61 - return http_post("{$url}/api/save_file_data", json_encode(compact('data'))); 61 + $msg = http_post("{$url}/api/save_file_data", json_encode(compact('data')));
  62 + print_r($msg);
62 } 63 }
63 64
64 } 65 }
@@ -111,11 +111,12 @@ if (!function_exists('http_get')) { @@ -111,11 +111,12 @@ if (!function_exists('http_get')) {
111 if (!function_exists('curl_c')) { 111 if (!function_exists('curl_c')) {
112 /** 112 /**
113 * @param $url 113 * @param $url
  114 + * @param $is_array
114 * @return [] 115 * @return []
115 * @author Akun 116 * @author Akun
116 * @date 2023/11/22 11:33 117 * @date 2023/11/22 11:33
117 */ 118 */
118 - function curl_c($url){ 119 + function curl_c($url,$is_array=true){
119 $header = array( 120 $header = array(
120 'Expect:', 121 'Expect:',
121 'Content-Type: application/json; charset=utf-8' 122 'Content-Type: application/json; charset=utf-8'
@@ -130,11 +131,12 @@ if (!function_exists('curl_c')) { @@ -130,11 +131,12 @@ if (!function_exists('curl_c')) {
130 curl_setopt($ch, CURLOPT_TIMEOUT, 120); 131 curl_setopt($ch, CURLOPT_TIMEOUT, 120);
131 curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 132 curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
132 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 133 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  134 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
133 curl_setopt($ch, CURLOPT_SSLVERSION, 'all'); 135 curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
134 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 136 curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
135 $content = curl_exec($ch); 137 $content = curl_exec($ch);
136 curl_close($ch); 138 curl_close($ch);
137 - return json_decode($content, true); 139 + return $is_array ? json_decode($content, true) : $content;
138 } 140 }
139 } 141 }
140 142
@@ -116,7 +116,13 @@ class NavController extends BaseController @@ -116,7 +116,13 @@ class NavController extends BaseController
116 * @author zbj 116 * @author zbj
117 * @date 2023/11/21 117 * @date 2023/11/21
118 */ 118 */
119 - public function import(){  
120 - 119 + public function import(NavLogic $navLogic){
  120 + $this->request->validate([
  121 + 'id'=>'required',
  122 + ],[
  123 + 'id.required' => 'ID不能为空',
  124 + ]);
  125 + $navLogic->importNav();
  126 + $this->response('success');
121 } 127 }
122 } 128 }
@@ -92,10 +92,11 @@ class KeywordController extends BaseController @@ -92,10 +92,11 @@ class KeywordController extends BaseController
92 */ 92 */
93 public function batchAdd(KeywordLogic $logic){ 93 public function batchAdd(KeywordLogic $logic){
94 $this->request->validate([ 94 $this->request->validate([
95 - 'title'=>['required','array'] 95 + 'title'=>['required','array', 'max:1000']
96 ],[ 96 ],[
97 'title.required' => 'title不能为空', 97 'title.required' => 'title不能为空',
98 - 'title.array' => 'title为数组' 98 + 'title.array' => 'title为数组',
  99 + 'title.max' => '批量操作不能超过1000条数据'
99 ]); 100 ]);
100 $logic->batchAdd(); 101 $logic->batchAdd();
101 $this->response('success'); 102 $this->response('success');
@@ -119,4 +120,22 @@ class KeywordController extends BaseController @@ -119,4 +120,22 @@ class KeywordController extends BaseController
119 $this->response('success'); 120 $this->response('success');
120 } 121 }
121 122
  123 + /**
  124 + * 批量删除
  125 + * @param KeywordLogic $logic
  126 + * @author zbj
  127 + * @date 2023/11/22
  128 + */
  129 + public function batchDel(KeywordLogic $logic){
  130 + $this->request->validate([
  131 + 'title'=>['required','array', 'max:1000']
  132 + ],[
  133 + 'title.required' => 'title不能为空',
  134 + 'title.array' => 'title为数组',
  135 + 'title.max' => '批量操作不能超过1000条数据'
  136 + ]);
  137 + $logic->batchDel();
  138 + $this->response('success');
  139 + }
  140 +
122 } 141 }
@@ -31,19 +31,20 @@ class ProjectAssociationController extends BaseController @@ -31,19 +31,20 @@ class ProjectAssociationController extends BaseController
31 if (empty($project_id)) { 31 if (empty($project_id)) {
32 $this->fail('请选择项目!', Code::USER_PARAMS_ERROE); 32 $this->fail('请选择项目!', Code::USER_PARAMS_ERROE);
33 } 33 }
34 - $status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用  
35 - $wx_user_id = (int)request()->post('user_id', 0);  
36 - if (empty($wx_user_id) && $status) { 34 + $status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用
  35 +
  36 + $user_id = (int)request()->post('user_id', 0);
  37 + if (empty($user_id) && $status) {
37 $this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE); 38 $this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE);
38 } 39 }
39 - $wx_id = (int)request()->post('wx_id', 0);  
40 - if (empty($wx_id) && $status) {  
41 - $this->fail('请选择要绑定的AICC项目!', Code::USER_PARAMS_ERROE); 40 + $friend_id = (int)request()->post('friend_id', 0);
  41 + if (empty($friend_id) && $status) {
  42 + $this->fail('请选择要绑定的AICC用户列表!', Code::USER_PARAMS_ERROE);
42 } 43 }
43 - $wx_nickname = request()->post('nickname', '');  
44 - $wx_user_name = request()->post('user_name', '');  
45 - $wx_image = request()->post('image', '');  
46 - $data = compact('project_id', 'wx_id', 'wx_nickname', 'wx_user_id', 'wx_user_name', 'wx_image'); 44 + $nickname = request()->post('nickname', '');
  45 + $user_name = request()->post('user_name', '');
  46 + $image = request()->post('image', '');
  47 + $data = compact('project_id', 'user_id', 'friend_id', 'nickname', 'user_name', 'image');
47 $this->ProjectAssociationLogic->saveWeChatData($data); 48 $this->ProjectAssociationLogic->saveWeChatData($data);
48 $this->response('success'); 49 $this->response('success');
49 } 50 }
@@ -116,4 +116,82 @@ class NavLogic extends BaseLogic @@ -116,4 +116,82 @@ class NavLogic extends BaseLogic
116 } 116 }
117 return $this->success(); 117 return $this->success();
118 } 118 }
  119 +
  120 +
  121 +
  122 + /**
  123 + * 一键导入 对应分类
  124 + * @throws \App\Exceptions\AsideGlobalException
  125 + * @throws \App\Exceptions\BsideGlobalException
  126 + */
  127 + public function importNav(){
  128 + $nav = $this->getInfo($this->param['id']);
  129 + if(!in_array($nav['url'], array_keys(BNav::ableImportMap()))){
  130 + $this->fail('该菜单不支持一键导入');
  131 + }
  132 +
  133 + $class = BNav::ableImportMap($nav['url']);
  134 + $category = new $class();
  135 + $fields = ['id', 'name', 'pid', 'alias'];
  136 + if($nav['url'] == 'products'){
  137 + $fields = ['id', 'title as name', 'pid', 'route as alias'];
  138 + }
  139 + $this->addByPid($category, $nav, $fields);
  140 + return $this->success();
  141 + }
  142 +
  143 + /**
  144 + * 一级一级的加
  145 + * @author zbj
  146 + * @date 2023/11/22
  147 + */
  148 + protected function addByPid($category, $nav, $fields, $pid = 0)
  149 + {
  150 + $nav_pid = $nav['id'];
  151 + if($pid){
  152 + $p_cate = $category->where('id', $pid)->select($fields)->first();
  153 + if($p_cate){
  154 + $nav_pid = $this->model->where('import_id', $nav['id'])->where('url', $p_cate['alias'])->value('id');
  155 + }
  156 + }
  157 + $list = $category->list(['pid' => $pid], 'id', $fields, 'asc');
  158 + $data = [];
  159 + $time = date('Y-m-d H:i:s');
  160 + foreach ($list as $item) {
  161 + if(in_array($item['alias'], array_keys(BNav::ableImportMap()))){
  162 + continue;
  163 + }
  164 + $exists_info = $this->model->where('import_id', $nav['id'])->where('url', $item['alias'])->first();
  165 + if($exists_info){
  166 + continue;
  167 + }
  168 + $data[] = [
  169 + 'pid' => $nav_pid,
  170 + 'name' => $item['name'],
  171 + 'url' => $item['alias'],
  172 + 'project_id' => $this->project['id'],
  173 + 'location' => $nav['location'],
  174 + 'group_id' => $nav['group_id'],
  175 + 'status' => BNav::STATUS_ACTIVE,
  176 + 'import_id' => $nav['id'],
  177 + 'created_at' => $time,
  178 + 'updated_at' => $time,
  179 + ];
  180 + }
  181 + //每500条更一次
  182 + $data_chunk = array_chunk($data,500);
  183 + foreach ($data_chunk as $chunk){
  184 + $this->model->insert($chunk);
  185 + }
  186 +
  187 + foreach ($list as $item) {
  188 + $this->addByPid($category, $nav, $fields, $item['id']);
  189 + }
  190 + }
  191 +
  192 +
  193 +
  194 +
  195 +
  196 +
119 } 197 }
@@ -6,6 +6,7 @@ use App\Exceptions\BsideGlobalException; @@ -6,6 +6,7 @@ use App\Exceptions\BsideGlobalException;
6 use App\Helper\Arr; 6 use App\Helper\Arr;
7 use App\Helper\Common; 7 use App\Helper\Common;
8 use App\Http\Logic\Bside\BaseLogic; 8 use App\Http\Logic\Bside\BaseLogic;
  9 +use App\Models\News\News;
9 use App\Models\Product\Keyword; 10 use App\Models\Product\Keyword;
10 use App\Models\Product\KeywordRelated; 11 use App\Models\Product\KeywordRelated;
11 use App\Models\Product\Product; 12 use App\Models\Product\Product;
@@ -38,6 +39,8 @@ class KeywordLogic extends BaseLogic @@ -38,6 +39,8 @@ class KeywordLogic extends BaseLogic
38 { 39 {
39 $info = $this->model->read($this->param); 40 $info = $this->model->read($this->param);
40 $info['url'] = $this->user['domain'] . $info['route']; 41 $info['url'] = $this->user['domain'] . $info['route'];
  42 + $info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
  43 +
41 return $this->success($info); 44 return $this->success($info);
42 } 45 }
43 46
@@ -209,4 +212,29 @@ class KeywordLogic extends BaseLogic @@ -209,4 +212,29 @@ class KeywordLogic extends BaseLogic
209 Common::del_user_cache('product_keyword',$project_id); 212 Common::del_user_cache('product_keyword',$project_id);
210 return ','.implode(',',$return).','; 213 return ','.implode(',',$return).',';
211 } 214 }
  215 +
  216 + /**
  217 + * 批量删除
  218 + * @return array
  219 + * @throws BsideGlobalException
  220 + * @throws \App\Exceptions\AsideGlobalException
  221 + * @author zbj
  222 + * @date 2023/11/22
  223 + */
  224 + public function batchDel(){
  225 + try {
  226 + foreach ($this->param['title'] as $v){
  227 + $info = $this->model->read(['title'=>$v]);
  228 + if($info){
  229 + $this->delRoute($info['id']);
  230 + $this->model->del(['id'=>$info['id']]);
  231 + }
  232 + }
  233 + //清除缓存
  234 + Common::del_user_cache('product_keyword',$this->user['project_id']);
  235 + }catch (\Exception $e){
  236 + $this->fail('error');
  237 + }
  238 + return $this->success();
  239 + }
212 } 240 }
@@ -10,14 +10,19 @@ class DataFile extends Base @@ -10,14 +10,19 @@ class DataFile extends Base
10 10
11 public function saveData(array $data): bool 11 public function saveData(array $data): bool
12 { 12 {
  13 + # v6项目ID
13 $project_id = (int)$data['project_id'] ?? 0; 14 $project_id = (int)$data['project_id'] ?? 0;
14 $isRes = self::query()->where('project_id', $project_id)->where('created_at', 'like', $data['time'] . '%')->first(); 15 $isRes = self::query()->where('project_id', $project_id)->where('created_at', 'like', $data['time'] . '%')->first();
15 if (!$isRes) { 16 if (!$isRes) {
16 $isRes = new self(); 17 $isRes = new self();
17 $isRes->project_id = $project_id; 18 $isRes->project_id = $project_id;
18 } 19 }
19 - $isRes->file_path = $data['file_path'];  
20 - $isRes->application_id = $data['application_id']; 20 + # AICC用户ID
  21 + $isRes->user_id = $data['user_id'];
  22 + # 第三方朋友ID
  23 + $isRes->friend_id = $data['friend_id'];
  24 + # 生成文件路径
  25 + $isRes->file_path = $data['file_path'];
21 return $isRes->save(); 26 return $isRes->save();
22 } 27 }
23 28
@@ -35,6 +35,21 @@ class BNav extends Base @@ -35,6 +35,21 @@ class BNav extends Base
35 const STATUS_DISABLED = 0; 35 const STATUS_DISABLED = 0;
36 36
37 37
  38 + /**
  39 + * @author zbj
  40 + * @date 2023/11/22
  41 + */
  42 + public static function ableImportMap($url=''){
  43 + $map = [
  44 + 'products' => '\\App\\Models\\Product\\Category',
  45 + 'news' => '\\App\\Models\\News\\NewsCategory',
  46 + 'blog' => '\\App\\Models\\Blog\\BlogCategory',
  47 + ];
  48 + if ($url){
  49 + return $map[$url] ?:"";
  50 + }
  51 + return $map;
  52 + }
38 53
39 54
40 /** 55 /**
@@ -85,7 +100,7 @@ class BNav extends Base @@ -85,7 +100,7 @@ class BNav extends Base
85 */ 100 */
86 public function getAbleImportAttribute($value) 101 public function getAbleImportAttribute($value)
87 { 102 {
88 - if(in_array($this->url, ['products','news','blogs'])){ 103 + if(in_array($this->url, array_keys(self::ableImportMap()))){
89 return 1; 104 return 1;
90 } 105 }
91 return 0; 106 return 0;
@@ -67,7 +67,7 @@ class Keyword extends Base @@ -67,7 +67,7 @@ class Keyword extends Base
67 if(!empty($value)){ 67 if(!empty($value)){
68 $value = Arr::setToArr($value); 68 $value = Arr::setToArr($value);
69 } 69 }
70 - return $value; 70 + return $value ?: [];
71 } 71 }
72 72
73 /** 73 /**
@@ -80,6 +80,6 @@ class Keyword extends Base @@ -80,6 +80,6 @@ class Keyword extends Base
80 if(!empty($value)){ 80 if(!empty($value)){
81 $value = Arr::setToArr($value); 81 $value = Arr::setToArr($value);
82 } 82 }
83 - return $value; 83 + return $value ?: [];
84 } 84 }
85 } 85 }
@@ -16,17 +16,23 @@ class ProjectAssociation extends Model @@ -16,17 +16,23 @@ class ProjectAssociation extends Model
16 */ 16 */
17 public function saveData(array $data): bool 17 public function saveData(array $data): bool
18 { 18 {
  19 + # V6项目ID
19 $project_id = (int)$data['project_id'] ?? 0; 20 $project_id = (int)$data['project_id'] ?? 0;
20 $isRes = self::query()->where('project_id', $project_id)->first(); 21 $isRes = self::query()->where('project_id', $project_id)->first();
21 if (!$isRes) { 22 if (!$isRes) {
22 $isRes = new self(); 23 $isRes = new self();
23 $isRes->project_id = $project_id; 24 $isRes->project_id = $project_id;
24 } 25 }
25 - $isRes->wx_id = $data['wx_id'];  
26 - $isRes->wx_nickname = $data['wx_nickname'];  
27 - $isRes->wx_user_id = $data['wx_user_id'];  
28 - $isRes->wx_user_name = $data['wx_user_name'];  
29 - $isRes->wx_image = $data['wx_image']; 26 + # AICC朋友ID
  27 + $isRes->friend_id = $data['friend_id'] ?? 0;
  28 + # AICC朋友昵称
  29 + $isRes->nickname = $data['nickname'] ?? 0;
  30 + # AICC用户ID
  31 + $isRes->user_id = $data['user_id'] ?? 0;
  32 + # AICC用户姓名
  33 + $isRes->user_name = $data['user_name'] ?? '';
  34 + # AICC朋友头像
  35 + $isRes->image = $data['image'] ?? '';
30 return $isRes->save(); 36 return $isRes->save();
31 } 37 }
32 38
@@ -50,8 +56,9 @@ class ProjectAssociation extends Model @@ -50,8 +56,9 @@ class ProjectAssociation extends Model
50 $status = 1; # 1 - 正常, 0 - 禁用 56 $status = 1; # 1 - 正常, 0 - 禁用
51 $lists = self::query()->where('status', $status) 57 $lists = self::query()->where('status', $status)
52 ->whereNotNull('project_id') 58 ->whereNotNull('project_id')
53 - ->whereNotNull('wx_user_id')  
54 - ->paginate($perPage, ['project_id', 'wx_id', 'wx_user_id'], 'page', $page); 59 + ->whereNotNull('friend_id')
  60 + ->whereNotNull('user_id')
  61 + ->paginate($perPage, ['project_id', 'friend_id', 'user_id'], 'page', $page);
55 $items = $lists->Items(); 62 $items = $lists->Items();
56 $totalPage = $lists->lastPage(); 63 $totalPage = $lists->lastPage();
57 $total = $lists->total(); 64 $total = $lists->total();
@@ -219,6 +219,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -219,6 +219,7 @@ Route::middleware(['bloginauth'])->group(function () {
219 Route::get('keyword/info', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'info'])->name('product_keyword_info'); 219 Route::get('keyword/info', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'info'])->name('product_keyword_info');
220 Route::post('keyword/save', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'save'])->name('product_keyword_save'); 220 Route::post('keyword/save', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'save'])->name('product_keyword_save');
221 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); 221 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
  222 + Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
222 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); 223 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
223 224
224 //产品参数 225 //产品参数
@@ -365,6 +366,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -365,6 +366,7 @@ Route::middleware(['bloginauth'])->group(function () {
365 Route::delete('/delete', [\App\Http\Controllers\Bside\Nav\NavController::class, 'delete'])->name('nav_delete'); 366 Route::delete('/delete', [\App\Http\Controllers\Bside\Nav\NavController::class, 'delete'])->name('nav_delete');
366 Route::get('/default-urls', [\App\Http\Controllers\Bside\Nav\NavController::class, 'urls'])->name('nav_default-urls'); 367 Route::get('/default-urls', [\App\Http\Controllers\Bside\Nav\NavController::class, 'urls'])->name('nav_default-urls');
367 Route::post('/sort', [\App\Http\Controllers\Bside\Nav\NavController::class, 'sort'])->name('nav_sort'); 368 Route::post('/sort', [\App\Http\Controllers\Bside\Nav\NavController::class, 'sort'])->name('nav_sort');
  369 + Route::post('/import', [\App\Http\Controllers\Bside\Nav\NavController::class, 'import'])->name('nav_import');
368 }); 370 });
369 371
370 //排名数据 372 //排名数据