作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !27
@@ -69,7 +69,7 @@ class ProjectImport extends Command @@ -69,7 +69,7 @@ class ProjectImport extends Command
69 $task->status = ImportTask::STATUS_COM;//导入完成 69 $task->status = ImportTask::STATUS_COM;//导入完成
70 $task->save(); 70 $task->save();
71 71
72 - $this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, '文件编码格式错误,仅支持UTF-8和GBK编码格式'); 72 + $this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, 0, '文件编码格式错误,仅支持UTF-8和GBK编码格式');
73 return true; 73 return true;
74 } elseif ($file_code_type === 'GBK') { 74 } elseif ($file_code_type === 'GBK') {
75 $is_gbk = 1; 75 $is_gbk = 1;
@@ -89,13 +89,14 @@ class ProjectImport extends Command @@ -89,13 +89,14 @@ class ProjectImport extends Command
89 $task->status = ImportTask::STATUS_COM;//导入完成 89 $task->status = ImportTask::STATUS_COM;//导入完成
90 $task->save(); 90 $task->save();
91 91
92 - $this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, '读取文件数据失败'); 92 + $this->send_mail($task->user_id, $task->created_at, $task->type, 0, 0, 0, '读取文件数据失败');
93 return true; 93 return true;
94 } 94 }
95 95
96 $total_count = 0; //总条数 96 $total_count = 0; //总条数
97 $success_count = 0; //成功导入条数 97 $success_count = 0; //成功导入条数
98 $repeat_count = 0; //过滤已存在条数 98 $repeat_count = 0; //过滤已存在条数
  99 + $fail_count = 0;
99 if (count($line_of_text) > 1) { 100 if (count($line_of_text) > 1) {
100 101
101 //设置数据库 102 //设置数据库
@@ -132,6 +133,7 @@ class ProjectImport extends Command @@ -132,6 +133,7 @@ class ProjectImport extends Command
132 } 133 }
133 } 134 }
134 } catch (\Exception $e) { 135 } catch (\Exception $e) {
  136 + $fail_count += 1;
135 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', title: ' . $v[0] . ', import fail, error: ' . $e->getMessage() . PHP_EOL; 137 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', title: ' . $v[0] . ', import fail, error: ' . $e->getMessage() . PHP_EOL;
136 } 138 }
137 } 139 }
@@ -146,7 +148,7 @@ class ProjectImport extends Command @@ -146,7 +148,7 @@ class ProjectImport extends Command
146 $task->success_count += $success_count; 148 $task->success_count += $success_count;
147 $task->save(); 149 $task->save();
148 150
149 - $this->send_mail($task->user_id, $task->created_at, $task->type, $success_count, $repeat_count, ''); 151 + $this->send_mail($task->user_id, $task->created_at, $task->type, $success_count, $fail_count, $repeat_count, '');
150 152
151 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import end, total count: ' . $total_count . ', success count: ' . $success_count . PHP_EOL; 153 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import end, total count: ' . $total_count . ', success count: ' . $success_count . PHP_EOL;
152 154
@@ -190,7 +192,7 @@ class ProjectImport extends Command @@ -190,7 +192,7 @@ class ProjectImport extends Command
190 } 192 }
191 193
192 //发送站内通知 194 //发送站内通知
193 - protected function send_mail($user_list, $time, $type, $success_count, $repeat_count, $reason) 195 + protected function send_mail($user_list, $time, $type, $success_count, $repeat_count, $fail_count, $reason)
194 { 196 {
195 if ($type == ImportTask::TYPE_NEWS) { 197 if ($type == ImportTask::TYPE_NEWS) {
196 $type_content = '新闻'; 198 $type_content = '新闻';
@@ -202,6 +204,7 @@ class ProjectImport extends Command @@ -202,6 +204,7 @@ class ProjectImport extends Command
202 $title = '导入结果通知'; 204 $title = '导入结果通知';
203 $content = '您于 ' . $time . ' 添加的 ' . $type_content . ' 导入任务已执行完成, 成功导入数据:' . $success_count . ' 条'; 205 $content = '您于 ' . $time . ' 添加的 ' . $type_content . ' 导入任务已执行完成, 成功导入数据:' . $success_count . ' 条';
204 $repeat_count && $content .= ',过滤已存在数据:' . $repeat_count . ' 条'; 206 $repeat_count && $content .= ',过滤已存在数据:' . $repeat_count . ' 条';
  207 + $fail_count && $content .= ',导入失败:' . $fail_count . ' 条';
205 $reason && $content .= ',原因:' . $reason; 208 $reason && $content .= ',原因:' . $reason;
206 209
207 $mail_model = new Mail(); 210 $mail_model = new Mail();
@@ -295,7 +295,7 @@ class BlogLogic extends BaseLogic @@ -295,7 +295,7 @@ class BlogLogic extends BaseLogic
295 ] 295 ]
296 ); 296 );
297 //更新路由 297 //更新路由
298 - $route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_BLOG, $id, $project_id); 298 + $route = RouteMap::setRoute((isset($data[1]) && $data[1]) ? $data[1] : $data[0], RouteMap::SOURCE_BLOG, $id, $project_id);
299 $this->edit(['url' => $route], ['id' => $id]); 299 $this->edit(['url' => $route], ['id' => $id]);
300 300
301 return true; 301 return true;
@@ -331,7 +331,7 @@ class NewsLogic extends BaseLogic @@ -331,7 +331,7 @@ class NewsLogic extends BaseLogic
331 ] 331 ]
332 ); 332 );
333 //更新路由 333 //更新路由
334 - $route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_NEWS, $id, $project_id); 334 + $route = RouteMap::setRoute((isset($data[1]) && $data[1]) ? $data[1] : $data[0], RouteMap::SOURCE_NEWS, $id, $project_id);
335 $this->edit(['url' => $route], ['id' => $id]); 335 $this->edit(['url' => $route], ['id' => $id]);
336 336
337 return true; 337 return true;
@@ -549,7 +549,7 @@ class ProductLogic extends BaseLogic @@ -549,7 +549,7 @@ class ProductLogic extends BaseLogic
549 ] 549 ]
550 ); 550 );
551 //更新路由 551 //更新路由
552 - $route = RouteMap::setRoute($data[1] ?: $data[0], RouteMap::SOURCE_PRODUCT, $id, $project_id); 552 + $route = RouteMap::setRoute((isset($data[1]) && $data[1]) ? $data[1] : $data[0], RouteMap::SOURCE_PRODUCT, $id, $project_id);
553 $this->edit(['route' => $route], ['id' => $id]); 553 $this->edit(['route' => $route], ['id' => $id]);
554 554
555 return true; 555 return true;