作者 lyh

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

@@ -28,16 +28,16 @@ class ProjectFilePDF extends Command @@ -28,16 +28,16 @@ class ProjectFilePDF extends Command
28 */ 28 */
29 protected $description = '网站项目数据,生成PDF文件'; 29 protected $description = '网站项目数据,生成PDF文件';
30 30
31 - protected ProjectAssociation $AiccWechat; 31 + protected $ProjectAssociation;
32 32
33 - protected DataFile $DataFile; 33 + protected $DataFile;
34 34
35 protected $time; 35 protected $time;
36 36
37 - // 最大支持5个进程  
38 - public int $maxRunNumber = 50; 37 + protected $fileController;
39 38
40 - public FileController $fileController; 39 + // 最大支持5个进程
  40 + public $maxRunNumber = 50;
41 41
42 /** 42 /**
43 * Create a new command instance. 43 * Create a new command instance.
@@ -46,43 +46,48 @@ class ProjectFilePDF extends Command @@ -46,43 +46,48 @@ class ProjectFilePDF extends Command
46 */ 46 */
47 public function __construct() 47 public function __construct()
48 { 48 {
49 - $this->AiccWechat = new ProjectAssociation();  
50 - $this->DataFile = new DataFile();  
51 - $this->time = date("Y-m");  
52 - $this->fileController = new FileController(); 49 + $this->ProjectAssociation = new ProjectAssociation();
  50 + $this->DataFile = new DataFile();
  51 + $this->time = date("Y-m");
  52 + $this->fileController = new FileController();
53 parent::__construct(); 53 parent::__construct();
54 } 54 }
55 55
56 public function start(): int 56 public function start(): int
57 { 57 {
58 - $status = 1; # 1 - 正常, 0 - 禁用  
59 - $is_pdf = 0; # 0 - 未生成 1 - 已生成 2 - 其它问题  
60 - $lists = $this->DataFile::query()->where('status', $status)  
61 - ->where('project_id', '!=', 0)  
62 - ->where('friend_id', '!=', 0)  
63 - ->where('user_id', '!=', 0)  
64 - ->where('is_pdf', $is_pdf)->where('created_at', 'like', $this->time . '%')->first(); 58 + # 0 - 未生成
  59 + # 1 - 已生成
  60 + # 2 - 其它问题
  61 + $is_pdf = 0;
  62 + $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf)
  63 + ->where('project_id', '!=', 0)
  64 + ->where('friend_id', '!=', 0)
  65 + ->where('user_id', '!=', 0)
  66 + ->where('created_at', 'like', $this->time . '%')->first();
  67 +
65 if (is_null($lists)) { 68 if (is_null($lists)) {
66 $this->debug_echo('没有任务,等待中'); 69 $this->debug_echo('没有任务,等待中');
67 - sleep(60); 70 + sleep(30);
68 return 0; 71 return 0;
69 } 72 }
70 - $key = $this->signature . '-' . $lists->id;  
71 - $count = redis_get($key);  
72 - $item = $lists->getOriginal();  
73 - $project_id = $item->project_id;  
74 - $user_id = $item->user_id;  
75 - $friend_id = $item->friend_id; 73 + $key = $this->signature . '-' . $lists->id;
  74 + $count = redis_get($key);
  75 +
  76 + $project_id = $lists->project_id;
  77 + $user_id = $lists->user_id;
  78 + $friend_id = $lists->friend_id;
76 // todo 根据项目查询数据 79 // todo 根据项目查询数据
77 $project_data = []; 80 $project_data = [];
78 $html = $this->html($project_data); 81 $html = $this->html($project_data);
79 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id); 82 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
80 - $file_path = $this->savePDF($html, $filename); 83 +
  84 + $file_path = $this->savePDF($html, $filename);
81 if (empty($file_path)) { 85 if (empty($file_path)) {
82 $this->debug_echo('pdf生成失败!'); 86 $this->debug_echo('pdf生成失败!');
83 return 0; 87 return 0;
84 } 88 }
85 - $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]); 89 + $file_path = json_encode($file_path['data']);
  90 + $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]);
86 if (!$isRes) { 91 if (!$isRes) {
87 if ($count == 2) { 92 if ($count == 2) {
88 $lists->is_pdf = 2; 93 $lists->is_pdf = 2;
@@ -99,6 +104,66 @@ class ProjectFilePDF extends Command @@ -99,6 +104,66 @@ class ProjectFilePDF extends Command
99 return 0; 104 return 0;
100 } 105 }
101 106
  107 + /**
  108 + * Execute the console command.
  109 + *
  110 + * @return int
  111 + */
  112 +// public function handle()
  113 +// {
  114 +// # 0 - 未生成
  115 +// # 1 - 已生成
  116 +// # 2 - 其它问题
  117 +// $is_pdf = 0;
  118 +// $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf)
  119 +// ->where('project_id', '!=', 0)
  120 +// ->where('friend_id', '!=', 0)
  121 +// ->where('user_id', '!=', 0)
  122 +// ->where('created_at', 'like', $this->time . '%')->first();
  123 +//
  124 +// if (is_null($lists)) {
  125 +// $this->error('没有任务,等待中');
  126 +// sleep(60);
  127 +// return 0;
  128 +// }
  129 +// $key = $this->signature . '-' . $lists->id;
  130 +// $count = redis_get($key);
  131 +// $project_id = $lists->project_id;
  132 +// $user_id = $lists->user_id;
  133 +// $friend_id = $lists->friend_id;
  134 +// // todo 根据项目查询数据
  135 +// $project_data = [];
  136 +// $html = $this->html($project_data);
  137 +// $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
  138 +//
  139 +// $file_path = $this->savePDF($html, $filename);
  140 +// if (empty($file_path)) {
  141 +// $this->debug_echo('pdf生成失败!');
  142 +// return 0;
  143 +// }
  144 +// $file_path = $file_path['data'];
  145 +// $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]);
  146 +// if (!$isRes) {
  147 +// if ($count == 2) {
  148 +// $lists->status = 2;
  149 +// $lists->save();
  150 +// $this->error('项目文件数据保存失败! - 其他原因 - ' . $key);
  151 +// } else {
  152 +// redis_add($key, $count + 1);
  153 +// $this->error('项目文件数据保存失败! - ' . $key);
  154 +// }
  155 +// }
  156 +// $lists->status = 1;
  157 +// $lists->save();
  158 +// $this->info('项目文件数据保存成功!');
  159 +// return 0;
  160 +// }
  161 +
  162 + /**
  163 + * @param $html
  164 + * @param $filename
  165 + * @return array
  166 + */
102 public function savePDF($html, $filename) 167 public function savePDF($html, $filename)
103 { 168 {
104 169
@@ -127,15 +192,14 @@ class ProjectFilePDF extends Command @@ -127,15 +192,14 @@ class ProjectFilePDF extends Command
127 $dompdf->render(); 192 $dompdf->render();
128 193
129 // 获取PDF内容 194 // 获取PDF内容
130 - $pdfContent = $dompdf->output(); 195 + $pdfContent = $dompdf->output();
  196 + $this->fileController->path = '/V6/PDF';
131 197
132 // 将PDF内容保存到文件 198 // 将PDF内容保存到文件
133 @file_put_contents($savePath, $pdfContent); 199 @file_put_contents($savePath, $pdfContent);
134 -  
135 // 创建一个文件实例 200 // 创建一个文件实例
136 $file = new File($savePath); 201 $file = new File($savePath);
137 -  
138 - return $this->fileController->single($file); 202 + return $this->fileController->api_upload_single($file);
139 } 203 }
140 204
141 /** 205 /**
@@ -148,7 +212,7 @@ class ProjectFilePDF extends Command @@ -148,7 +212,7 @@ class ProjectFilePDF extends Command
148 $html = '<html>'; 212 $html = '<html>';
149 $html .= '<body style="font-family:arial">'; 213 $html .= '<body style="font-family:arial">';
150 $html .= '<h1>Hello, World!</h1>'; 214 $html .= '<h1>Hello, World!</h1>';
151 - $html .= '<p>中文内容</p>'; 215 + $html .= '<p>中文内容ffffff</p>';
152 $html .= '</body>'; 216 $html .= '</body>';
153 $html .= '</html>'; 217 $html .= '</html>';
154 return $html; 218 return $html;
@@ -244,7 +244,7 @@ class ProjectUpdate extends Command @@ -244,7 +244,7 @@ class ProjectUpdate extends Command
244 for ($i = 0; $i < count($item['category']); $i++) { 244 for ($i = 0; $i < count($item['category']); $i++) {
245 $return = $this->get_category_name_arr($item['category'], $pid); 245 $return = $this->get_category_name_arr($item['category'], $pid);
246 if ($return) { 246 if ($return) {
247 - $category_arr[] = $return['name']; 247 + $category_arr[] = $this->special2str($return['name']);
248 $pid = $return['id']; 248 $pid = $return['id'];
249 } 249 }
250 } 250 }
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Update;  
4 -  
5 -use App\Helper\Arr;  
6 -use App\Http\Logic\Bside\Product\CategoryLogic;  
7 -use App\Models\Blog\Blog;  
8 -use App\Models\Collect\CollectTask;  
9 -use App\Models\Com\UpdateLog;  
10 -use App\Models\News\News;  
11 -use App\Models\Product\Category;  
12 -use App\Models\Product\Keyword;  
13 -use App\Models\Product\Product;  
14 -use App\Models\RouteMap\RouteMap;  
15 -use App\Models\Template\BCustomTemplate;  
16 -use App\Models\WebSetting\WebSettingReceiving;  
17 -use App\Services\ProjectServer;  
18 -use Illuminate\Console\Command;  
19 -use Illuminate\Support\Facades\DB;  
20 -use Illuminate\Support\Facades\Redis;  
21 -  
22 -/**  
23 - * 4.0,5.0升级到6.0,内容同步  
24 - * Class ProjectImport  
25 - * @package App\Console\Commands  
26 - * @author Akun  
27 - * @date 2023/10/9 15:04  
28 - */  
29 -class Temp extends Command  
30 -{  
31 - /**  
32 - * The name and signature of the console command.  
33 - *  
34 - * @var string  
35 - */  
36 - protected $signature = 'project_update_temp';  
37 -  
38 - /**  
39 - * The console command description.  
40 - *  
41 - * @var string  
42 - */  
43 - protected $description = '执行项目升级任务';  
44 -  
45 -  
46 - public function handle()  
47 - {  
48 - $this->start_update();  
49 - }  
50 -  
51 - protected function start_update()  
52 - {  
53 -  
54 -// $data = UpdateLog::where('project_id','<=',530)->where('api_type','category')->get();  
55 - $data = UpdateLog::where('project_id', '=', 298)->where('api_type', 'category')->get();  
56 - foreach ($data as $task) {  
57 - $project_id = $task->project_id;  
58 - $api_type = $task->api_type;  
59 - $api_url_arr = explode('?', $task->api_url);  
60 - $api_url = $api_url_arr[0];  
61 -  
62 - echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', task_type: ' . $api_type . ', update start' . PHP_EOL;  
63 -  
64 - //设置数据库  
65 - $project = ProjectServer::useProject($project_id);  
66 - if ($project) {  
67 - //分类  
68 - $url = $api_url . '?' . http_build_query(['w' => 'category']);  
69 - $data = curl_c($url);  
70 - if (isset($data['code']) && $data['code'] == 200) {  
71 - $items = $data['data'] ?? [];  
72 - $this->category_insert($project_id, $items, 0);  
73 - } else {  
74 - continue;  
75 - }  
76 - }  
77 - //关闭数据库  
78 - DB::disconnect('custom_mysql');  
79 -  
80 - echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', task_type: ' . $api_type . ', update end ' . PHP_EOL;  
81 - }  
82 - }  
83 -  
84 - //获取地址路由  
85 - protected function get_url_route($url)  
86 - {  
87 - $arr = parse_url($url);  
88 - if (empty($arr['path'])) {  
89 - return '';  
90 - }  
91 - $path = $arr['path'];  
92 -  
93 - if (strpos($path, '.') !== false) {  
94 - $path = substr($path, 0, strpos($path, '.'));  
95 - }  
96 -  
97 - $path_arr = explode('/', $path);  
98 -  
99 - return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2];  
100 - }  
101 -  
102 - //多级分类入库  
103 - protected function category_insert($project_id, $items, $pid = 0)  
104 - {  
105 - $model = new Category();  
106 - foreach ($items as $item) {  
107 - if ($item['name'] ?? '') {  
108 - $parent = $model->read(['pid' => $pid, 'title' => $item['name']], 'id');  
109 - if (!$parent) {  
110 - try {  
111 - $item['name'] = $this->special2str($item['name']);  
112 - $parent_id = $model->addReturnId([  
113 - 'project_id' => $project_id,  
114 - 'title' => $item['name'],  
115 - 'pid' => $pid,  
116 - 'keywords' => $item['keywords'] ?? '',  
117 - 'describe' => $item['description'] ?? '',  
118 - 'route' => $this->get_url_route($item['url'])  
119 - ]);  
120 - $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);  
121 - } catch (\Exception $e) {  
122 - echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;  
123 - continue;  
124 - }  
125 - } else {  
126 - $parent_id = $parent['id'];  
127 - }  
128 -  
129 - if (!empty($item['children'])) {  
130 - $this->category_insert($project_id, $item['children'], $parent_id);  
131 - }  
132 - }  
133 - }  
134 - }  
135 -  
136 - //获取分类名称数组  
137 - protected function get_category_name_arr($category, $pid = 0)  
138 - {  
139 - foreach ($category as $k => $v) {  
140 - if ($v['parent'] == $pid) {  
141 - return $v;  
142 - }  
143 - }  
144 -  
145 - return [];  
146 - }  
147 -  
148 - //特殊字符转换  
149 - protected function special2str($str)  
150 - {  
151 - if (strpos($str, ';') === false) {  
152 - return $str;  
153 - }  
154 -  
155 - $list = [  
156 - '&lt;' => '<',  
157 - '&gt;' => '>',  
158 - '&amp;' => '&',  
159 - '&acute;' => '´',  
160 - '&quot;' => '“',  
161 - '&nbsp;' => ' '  
162 - ];  
163 -  
164 - foreach ($list as $k => $v) {  
165 - $str = str_replace($k, $v, $str);  
166 - }  
167 -  
168 - return $str;  
169 - }  
170 -  
171 - //路由入库  
172 - protected function set_map($route, $source, $source_id, $project_id)  
173 - {  
174 - if ($route) {  
175 - $route_map = RouteMap::where('project_id', $project_id)->where('source', $source)->where('source_id', $source_id)->first();  
176 - if (!$route_map) {  
177 - $route_map = new RouteMap();  
178 - $route_map->project_id = $project_id;  
179 - $route_map->source = $source;  
180 - $route_map->source_id = $source_id;  
181 - $route_map->route = $route;  
182 -  
183 - if ($source == RouteMap::SOURCE_NEWS) {  
184 - $route_map->path = RouteMap::SOURCE_NEWS;  
185 - } elseif ($source == RouteMap::SOURCE_BLOG) {  
186 - $route_map->path = RouteMap::SOURCE_BLOG;  
187 - }  
188 -  
189 - $route_map->save();  
190 - }  
191 - }  
192 - }  
193 -}  
@@ -69,7 +69,7 @@ class UpdateProgress extends Command @@ -69,7 +69,7 @@ class UpdateProgress extends Command
69 if(!empty($info)){ 69 if(!empty($info)){
70 $info = (array)$info; 70 $info = (array)$info;
71 //超时时间 71 //超时时间
72 - $time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60); 72 + $time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 30);
73 if($time > date("Y-m-d H:i:s")){ 73 if($time > date("Y-m-d H:i:s")){
74 DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]); 74 DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]);
75 //获取当前项目的用户 75 //获取当前项目的用户
@@ -24,12 +24,10 @@ class WebsiteData extends Command @@ -24,12 +24,10 @@ class WebsiteData extends Command
24 protected $description = '向AICC推送数据'; 24 protected $description = '向AICC推送数据';
25 25
26 // 最大支持5个进程 26 // 最大支持5个进程
27 - public int $maxRunNumber = 50; 27 + public $maxRunNumber = 50;
28 28
29 protected $time; 29 protected $time;
30 30
31 - protected $url;  
32 -  
33 /** 31 /**
34 * Create a new command instance. 32 * Create a new command instance.
35 * 33 *
@@ -38,10 +36,49 @@ class WebsiteData extends Command @@ -38,10 +36,49 @@ class WebsiteData extends Command
38 public function __construct() 36 public function __construct()
39 { 37 {
40 $this->time = date('Y-m'); 38 $this->time = date('Y-m');
41 - $this->url = env('AICC_URL');  
42 parent::__construct(); 39 parent::__construct();
43 } 40 }
44 41
  42 + /**
  43 + * Execute the console command.
  44 + *
  45 + * @return int
  46 + */
  47 +// public function handle()
  48 +// {
  49 +// # 0 - 未推送
  50 +// # 1 - 已推送
  51 +// # 2 - 其他问题
  52 +// $status = 0;
  53 +// $lists = DataFile::query()->where('status', $status)
  54 +// ->where('created_at', 'like', $this->time . '%')->first();
  55 +// if (is_null($lists)) {
  56 +// $this->error('没有任务,等待中');
  57 +// sleep(30);
  58 +// return 0;
  59 +// }
  60 +//
  61 +// $key = $this->signature . '-' . $lists->id;
  62 +// $count = redis_get($key);
  63 +// $data = $lists;
  64 +//
  65 +// $url = env('AICC_URL');
  66 +// $msg = http_post($url, json_encode(compact('data')));
  67 +// $status_code = $msg['status'];
  68 +// if ($status_code != 200) {
  69 +// if ($count == 2) {
  70 +// $lists->status = 2;
  71 +// $lists->save();
  72 +// $this->error('项目文件数据保存失败! - 其他原因 - ' . $key);
  73 +// } else {
  74 +// redis_add($key, $count + 1);
  75 +// $this->error('项目文件数据保存失败! - ' . $key);
  76 +// }
  77 +// }
  78 +// $lists->status = 1;
  79 +// $lists->save();
  80 +// return 0;
  81 +// }
45 82
46 public function start(): int 83 public function start(): int
47 { 84 {
@@ -53,26 +90,61 @@ class WebsiteData extends Command @@ -53,26 +90,61 @@ class WebsiteData extends Command
53 ->where('created_at', 'like', $this->time . '%')->first(); 90 ->where('created_at', 'like', $this->time . '%')->first();
54 if (is_null($lists)) { 91 if (is_null($lists)) {
55 $this->debug_echo('没有任务,等待中'); 92 $this->debug_echo('没有任务,等待中');
56 - sleep(60); 93 + sleep(30);
57 return 0; 94 return 0;
58 } 95 }
59 - $key = $this->signature . '-' . $lists->id;  
60 - $count = redis_get($key);  
61 - $isRes = http_post($this->url, json_encode(['data' => $lists->getOriginal()]));  
62 - if (!$isRes) { 96 +
  97 + $key = $this->signature . '-' . $lists->id;
  98 + $count = redis_get($key);
  99 + $data = $lists;
  100 + $url = env('AICC_URL');
  101 + $msg = http_post($url, json_encode(compact('data')));
  102 + $status_code = $msg['status'];
  103 + if ($status_code != 200) {
63 if ($count == 2) { 104 if ($count == 2) {
64 - $lists->is_pdf = 2; 105 + $lists->status = 2;
65 $lists->save(); 106 $lists->save();
66 - $this->debug_echo('项目文件数据推送失败! - 其他原因 - ' . $key); 107 + $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key);
67 } else { 108 } else {
68 redis_add($key, $count + 1); 109 redis_add($key, $count + 1);
69 - $this->debug_echo('项目文件数据推送失败! - ' . $key); 110 + $this->debug_echo('项目文件数据保存失败! - ' . $key);
70 } 111 }
71 } 112 }
72 $lists->status = 1; 113 $lists->status = 1;
73 $lists->save(); 114 $lists->save();
74 - $this->debug_echo('项目文件数据保存成功!'); 115 + $this->info('项目文件数据保存成功!');
75 return 0; 116 return 0;
76 } 117 }
77 118
  119 + /**
  120 + * Execute the console command.
  121 + *
  122 + * @return int
  123 + */
  124 +// public function handle()
  125 +// {
  126 +// $DataFile = new DataFile();
  127 +// $data = $DataFile->allData();
  128 +// # 详细数据
  129 +// $items = $data['items'];
  130 +// # 总分页
  131 +// $totalPage = $data['totalPage'];
  132 +// $this->post_data($items);
  133 +// if ($totalPage > 1) {
  134 +// for ($page = 2; $page <= $totalPage; $page++) {
  135 +// $da = $DataFile->allData($page);
  136 +// $this->post_data($da['items']);
  137 +// }
  138 +// }
  139 +// $this->info('项目文件数据推送完成!');
  140 +// return 0;
  141 +// }
  142 +
  143 + public function post_data($data)
  144 + {
  145 + $url = env('AICC_URL');
  146 + $msg = http_post($url, json_encode(compact('data')));
  147 + print_r($msg);
  148 + }
  149 +
78 } 150 }
@@ -107,8 +107,7 @@ class FileController @@ -107,8 +107,7 @@ class FileController
107 */ 107 */
108 public function single(&$files){ 108 public function single(&$files){
109 $hash = hash_file('md5', $files->getPathname()); 109 $hash = hash_file('md5', $files->getPathname());
110 -// $name = $files->getClientOriginalName();  
111 - $name = $files->getFilename(); 110 + $name = $files->getClientOriginalName();
112 //查看文件是否存在 111 //查看文件是否存在
113 $fileModel = new File(); 112 $fileModel = new File();
114 //查看图片是否已上传 113 //查看图片是否已上传
@@ -121,8 +120,7 @@ class FileController @@ -121,8 +120,7 @@ class FileController
121 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name)); 120 return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
122 } 121 }
123 $url = $this->config['root'].$this->path; 122 $url = $this->config['root'].$this->path;
124 -// $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();  
125 - $fileName = uniqid().rand(10000,99999).'.'.$files->getExtension(); 123 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
126 //同步数据到cos 124 //同步数据到cos
127 if($this->upload_location == 1){ 125 if($this->upload_location == 1){
128 $cosService = new CosService(); 126 $cosService = new CosService();
@@ -138,6 +136,53 @@ class FileController @@ -138,6 +136,53 @@ class FileController
138 } 136 }
139 137
140 /** 138 /**
  139 + * 接口上传单文件
  140 + * @param $files
  141 + * @return array
  142 + */
  143 + public function api_upload_single(&$files)
  144 + {
  145 + $hash = hash_file('md5', $files->getPathname());
  146 + $name = $files->getFilename();
  147 + //查看文件是否存在
  148 + $fileModel = new File();
  149 + //查看图片是否已上传
  150 + $param = ['hash' => $hash, 'refer' => $this->param['refer'] ?? 0];
  151 + if (isset($this->cache['project_id']) && !empty($this->cache['project_id'])) {
  152 + $param['project_id'] = $this->cache['project_id'];
  153 + }
  154 + $file_hash = $fileModel->read($param);
  155 + if ($file_hash !== false) {
  156 + return [
  157 + 'message' => '资源',
  158 + 'code' => Code::SUCCESS,
  159 + 'data' => $this->responseData($file_hash['path'], $name)
  160 + ];
  161 + }
  162 + $url = $this->config['root'] . $this->path;
  163 + $fileName = uniqid() . rand(10000, 99999) . '.' . $files->getExtension();
  164 + //同步数据到cos
  165 + if ($this->upload_location == 1) {
  166 + $cosService = new CosService();
  167 + $cosService->uploadFile($files, $this->path, $fileName);
  168 + } else {
  169 + $res = $files->move($url, $fileName);
  170 + if ($res === false) {
  171 + return [
  172 + 'message' => $files->getError(),
  173 + 'code' => Code::USER_ERROR
  174 + ];
  175 + }
  176 + }
  177 + $this->saveMysql($fileModel, $files->getSize(), $files->getExtension(), $fileName, $hash, $this->upload_location, $files->getMimeType(), $name);
  178 + return [
  179 + 'message' => '资源',
  180 + 'code' => Code::SUCCESS,
  181 + 'data' => $this->responseData($this->path . '/' . $fileName, $name)
  182 + ];
  183 + }
  184 +
  185 + /**
141 * @remark :保存数据库 186 * @remark :保存数据库
142 * @name :saveMysql 187 * @name :saveMysql
143 * @author :lyh 188 * @author :lyh
@@ -204,7 +249,7 @@ class FileController @@ -204,7 +249,7 @@ class FileController
204 $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name); 249 $this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
205 $data[] = $this->responseData($this->path.'/'.$fileName, $name); 250 $data[] = $this->responseData($this->path.'/'.$fileName, $name);
206 } 251 }
207 - $this->response('资源',Code::SUCCESS,$data); 252 + $this->response('资源',Code::SUCCESS,$data);
208 } 253 }
209 254
210 255
@@ -16,13 +16,13 @@ class DataFile extends Base @@ -16,13 +16,13 @@ class DataFile extends Base
16 if (!$isRes) { 16 if (!$isRes) {
17 $isRes = new self(); 17 $isRes = new self();
18 $isRes->project_id = $project_id; 18 $isRes->project_id = $project_id;
  19 + # AICC用户ID
  20 + $isRes->user_id = $data['user_id'];
  21 + # 第三方朋友ID
  22 + $isRes->friend_id = $data['friend_id'];
  23 + # 生成文件路径
  24 + $isRes->file_path = $data['file_path'];
19 } 25 }
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'];  
26 return $isRes->save(); 26 return $isRes->save();
27 } 27 }
28 28
@@ -109,6 +109,13 @@ class RouteMap extends Base @@ -109,6 +109,13 @@ class RouteMap extends Base
109 } 109 }
110 try { 110 try {
111 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); 111 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first();
  112 + //上线项目 不能修改链接了
  113 +// if($route_map){
  114 +// $project = ProjectLogic::instance()->getInfo($project_id);
  115 +// if($project['type'] !== Project::STATUS_ONE){
  116 +// return $route_map->route;
  117 +// }
  118 +// }
112 if(!$route_map){ 119 if(!$route_map){
113 $route_map = new self(); 120 $route_map = new self();
114 $route_map->source = $source; 121 $route_map->source = $source;
  1 +Options +FollowSymLinks -Indexes
  2 +RewriteEngine On
  3 +
  4 +RewriteCond %{HTTP:Authorization} .
  5 +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  6 +
  7 +RewriteCond %{REQUEST_FILENAME} !-d
  8 +RewriteCond %{REQUEST_FILENAME} !-f
  9 +RewriteRule ^ index.php [L]