作者 lyh

gx

@@ -144,25 +144,24 @@ class KeywordLogic extends BaseLogic @@ -144,25 +144,24 @@ class KeywordLogic extends BaseLogic
144 if($num > 1000){ 144 if($num > 1000){
145 $this->fail('最大数量不能超过1000'); 145 $this->fail('最大数量不能超过1000');
146 } 146 }
147 - DB::connection('custom_mysql')->beginTransaction();  
148 - try {  
149 - foreach ($this->param['title'] as $k=>$v) {  
150 - $data = [];  
151 - if (empty($v)) {  
152 - continue;  
153 - }  
154 - $this->model = new Keyword();  
155 - $info = $this->model->read(['title' => $v]);  
156 - if ($info !== false) {  
157 - continue;  
158 - }  
159 - $param['project_id'] = $this->user['project_id'];  
160 - $param['created_at'] = date('Y-m-d H:i:s');  
161 - $param['updated_at'] = $param['created_at'];  
162 - $param['title'] = $v;  
163 - $id = $this->model->insertGetId($param);  
164 - $data[$k] = $id; 147 + foreach ($this->param['title'] as $k=>$v) {
  148 + $data = [];
  149 + if (empty($v)) {
  150 + continue;
165 } 151 }
  152 + $this->model = new Keyword();
  153 + $info = $this->model->read(['title' => $v]);
  154 + if ($info !== false) {
  155 + continue;
  156 + }
  157 + $param['project_id'] = $this->user['project_id'];
  158 + $param['created_at'] = date('Y-m-d H:i:s');
  159 + $param['updated_at'] = $param['created_at'];
  160 + $param['title'] = $v;
  161 + $id = $this->model->insertGetId($param);
  162 + $data[$k] = $id;
  163 + }
  164 + if(!empty($data)){
166 foreach ($data as $k=>$ids){ 165 foreach ($data as $k=>$ids){
167 $route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $ids, $this->user['project_id']); 166 $route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $ids, $this->user['project_id']);
168 if (empty($route)) { 167 if (empty($route)) {
@@ -170,11 +169,7 @@ class KeywordLogic extends BaseLogic @@ -170,11 +169,7 @@ class KeywordLogic extends BaseLogic
170 } 169 }
171 $this->model->edit(['route' => $route], ['id' => $ids]); 170 $this->model->edit(['route' => $route], ['id' => $ids]);
172 } 171 }
173 - DB::connection('custom_mysql')->commit();  
174 - }catch (\Exception $e){  
175 - DB::connection('custom_mysql')->rollBack();  
176 } 172 }
177 -  
178 return $this->success(); 173 return $this->success();
179 } 174 }
180 175