合并分支 'zhl' 到 'master'
Zhl 查看合并请求 !654
正在显示
1 个修改的文件
包含
17 行增加
和
0 行删除
| @@ -20,6 +20,7 @@ use Illuminate\Foundation\Bus\Dispatchable; | @@ -20,6 +20,7 @@ use Illuminate\Foundation\Bus\Dispatchable; | ||
| 20 | use Illuminate\Queue\InteractsWithQueue; | 20 | use Illuminate\Queue\InteractsWithQueue; |
| 21 | use Illuminate\Queue\SerializesModels; | 21 | use Illuminate\Queue\SerializesModels; |
| 22 | use Illuminate\Support\Facades\DB; | 22 | use Illuminate\Support\Facades\DB; |
| 23 | +use Illuminate\Support\Facades\Log; | ||
| 23 | use Illuminate\Support\Facades\Schema; | 24 | use Illuminate\Support\Facades\Schema; |
| 24 | 25 | ||
| 25 | class CopyProjectJob implements ShouldQueue | 26 | class CopyProjectJob implements ShouldQueue |
| @@ -52,6 +53,7 @@ class CopyProjectJob implements ShouldQueue | @@ -52,6 +53,7 @@ class CopyProjectJob implements ShouldQueue | ||
| 52 | $projectModel = new Project(); | 53 | $projectModel = new Project(); |
| 53 | DB::beginTransaction(); | 54 | DB::beginTransaction(); |
| 54 | try { | 55 | try { |
| 56 | + $this->output('CopyProjectJob start, project_id: ' . $this->param['project_id']); | ||
| 55 | //复制初始项目 | 57 | //复制初始项目 |
| 56 | $data = $projectModel::where('id', $this->param['project_id'])->first(); | 58 | $data = $projectModel::where('id', $this->param['project_id'])->first(); |
| 57 | $data = $data->getAttributes(); | 59 | $data = $data->getAttributes(); |
| @@ -128,6 +130,7 @@ class CopyProjectJob implements ShouldQueue | @@ -128,6 +130,7 @@ class CopyProjectJob implements ShouldQueue | ||
| 128 | DB::commit(); | 130 | DB::commit(); |
| 129 | }catch (\Exception $e){ | 131 | }catch (\Exception $e){ |
| 130 | DB::rollBack(); | 132 | DB::rollBack(); |
| 133 | + $this->output('CopyProjectJob error, error message: ' . $e->getMessage()); | ||
| 131 | $this->fail('error'); | 134 | $this->fail('error'); |
| 132 | } | 135 | } |
| 133 | if($type != 0){ | 136 | if($type != 0){ |
| @@ -135,6 +138,7 @@ class CopyProjectJob implements ShouldQueue | @@ -135,6 +138,7 @@ class CopyProjectJob implements ShouldQueue | ||
| 135 | } | 138 | } |
| 136 | //修改项目状态 | 139 | //修改项目状态 |
| 137 | $projectModel->edit(['delete_status'=>0],['id'=>$project_id]); | 140 | $projectModel->edit(['delete_status'=>0],['id'=>$project_id]); |
| 141 | + $this->output('CopyProjectJob end, old project_id: ' . $this->param['project_id'] . ', new project_id: ' . $project_id); | ||
| 138 | return true; | 142 | return true; |
| 139 | } | 143 | } |
| 140 | 144 | ||
| @@ -184,4 +188,17 @@ class CopyProjectJob implements ShouldQueue | @@ -184,4 +188,17 @@ class CopyProjectJob implements ShouldQueue | ||
| 184 | } | 188 | } |
| 185 | return true; | 189 | return true; |
| 186 | } | 190 | } |
| 191 | + | ||
| 192 | + /** | ||
| 193 | + * @param $message | ||
| 194 | + * @return bool | ||
| 195 | + */ | ||
| 196 | + public function output($message) | ||
| 197 | + { | ||
| 198 | + $date = date('Y-m-d H:i:s'); | ||
| 199 | + $output = $date . ', ' . $message . PHP_EOL; | ||
| 200 | + echo $output; | ||
| 201 | + Log::info($output); | ||
| 202 | + return true; | ||
| 203 | + } | ||
| 187 | } | 204 | } |
-
请 注册 或 登录 后发表评论