正在显示
1 个修改的文件
包含
7 行增加
和
3 行删除
| @@ -140,6 +140,8 @@ class KeywordLogic extends BaseLogic | @@ -140,6 +140,8 @@ class KeywordLogic extends BaseLogic | ||
| 140 | if($num > 1000){ | 140 | if($num > 1000){ |
| 141 | $this->fail('最大数量不能超过1000'); | 141 | $this->fail('最大数量不能超过1000'); |
| 142 | } | 142 | } |
| 143 | + $data = []; | ||
| 144 | + DB::connection('custom_mysql')->beginTransaction(); | ||
| 143 | foreach ($this->param['title'] as $k=>$v) { | 145 | foreach ($this->param['title'] as $k=>$v) { |
| 144 | if (empty($v)) { | 146 | if (empty($v)) { |
| 145 | continue; | 147 | continue; |
| @@ -153,15 +155,17 @@ class KeywordLogic extends BaseLogic | @@ -153,15 +155,17 @@ class KeywordLogic extends BaseLogic | ||
| 153 | $param['created_at'] = date('Y-m-d H:i:s'); | 155 | $param['created_at'] = date('Y-m-d H:i:s'); |
| 154 | $param['updated_at'] = $param['created_at']; | 156 | $param['updated_at'] = $param['created_at']; |
| 155 | $param['title'] = $v; | 157 | $param['title'] = $v; |
| 156 | - DB::connection('custom_mysql')->beginTransaction(); | ||
| 157 | $id = $this->model->insertGetId($param); | 158 | $id = $this->model->insertGetId($param); |
| 158 | - $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 159 | + $data[] = ['id'=>$id,'route'=>$v]; |
| 160 | + } | ||
| 161 | + foreach ($data as $v){ | ||
| 162 | + $route = RouteMap::setRoute($v['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']); | ||
| 159 | if (empty($route)) { | 163 | if (empty($route)) { |
| 160 | DB::connection('custom_mysql')->rollBack(); | 164 | DB::connection('custom_mysql')->rollBack(); |
| 161 | } | 165 | } |
| 162 | $this->model->edit(['route' => $route], ['id' => $id]); | 166 | $this->model->edit(['route' => $route], ['id' => $id]); |
| 163 | - DB::connection('custom_mysql')->commit(); | ||
| 164 | } | 167 | } |
| 168 | + DB::connection('custom_mysql')->commit(); | ||
| 165 | return $this->success(); | 169 | return $this->success(); |
| 166 | } | 170 | } |
| 167 | 171 |
-
请 注册 或 登录 后发表评论