|
...
|
...
|
@@ -144,30 +144,37 @@ class KeywordLogic extends BaseLogic |
|
|
|
if($num > 1000){
|
|
|
|
$this->fail('最大数量不能超过1000');
|
|
|
|
}
|
|
|
|
foreach ($this->param['title'] as $k=>$v) {
|
|
|
|
$data = [];
|
|
|
|
if (empty($v)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->model = new Keyword();
|
|
|
|
$info = $this->model->read(['title' => $v]);
|
|
|
|
if ($info !== false) {
|
|
|
|
continue;
|
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
|
|
try {
|
|
|
|
foreach ($this->param['title'] as $k=>$v) {
|
|
|
|
$data = [];
|
|
|
|
if (empty($v)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->model = new Keyword();
|
|
|
|
$info = $this->model->read(['title' => $v]);
|
|
|
|
if ($info !== false) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
$param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$param['updated_at'] = $param['created_at'];
|
|
|
|
$param['title'] = $v;
|
|
|
|
$id = $this->model->insertGetId($param);
|
|
|
|
$data[$k] = $id;
|
|
|
|
}
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
$param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$param['updated_at'] = $param['created_at'];
|
|
|
|
$param['title'] = $v;
|
|
|
|
$id = $this->model->insertGetId($param);
|
|
|
|
$data[$k] = $id;
|
|
|
|
}
|
|
|
|
foreach ($data as $k=>$ids){
|
|
|
|
$route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $ids, $this->user['project_id']);
|
|
|
|
if (empty($route)) {
|
|
|
|
continue;
|
|
|
|
foreach ($data as $k=>$ids){
|
|
|
|
$route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $ids, $this->user['project_id']);
|
|
|
|
if (empty($route)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->model->edit(['route' => $route], ['id' => $ids]);
|
|
|
|
}
|
|
|
|
$this->model->edit(['route' => $route], ['id' => $ids]);
|
|
|
|
DB::connection('custom_mysql')->commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::connection('custom_mysql')->rollBack();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|