|
...
|
...
|
@@ -136,31 +136,30 @@ class KeywordLogic extends BaseLogic |
|
|
|
* @time :2023/8/28 14:03
|
|
|
|
*/
|
|
|
|
public function batchAdd(){
|
|
|
|
$num = count($this->param['title']);
|
|
|
|
if($num > 1000){
|
|
|
|
$this->fail('最大数量不能超过1000');
|
|
|
|
$route_array = Translate::tran($this->param['title'], 'en');
|
|
|
|
if (empty($route_array)) {
|
|
|
|
$this->fail('路由生成失败,请稍后重试!');
|
|
|
|
}
|
|
|
|
$data = [];
|
|
|
|
foreach ($this->param['title'] as $k=>$v) {
|
|
|
|
if (empty($v)) {
|
|
|
|
try {
|
|
|
|
foreach ($this->param['title'] as $k=>$v){
|
|
|
|
if(empty($v)){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->model = new Keyword();
|
|
|
|
$info = $this->model->read(['title' => $v]);
|
|
|
|
if ($info !== false) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$info = $this->model->read(['title'=>$v]);
|
|
|
|
if($info === false){
|
|
|
|
$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[] = ['id'=>$id,'route'=>$v];
|
|
|
|
$route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
|
|
|
|
// $this->curlDelRoute(['new_route'=>$route]);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sleep(5);
|
|
|
|
foreach ($data as $v){
|
|
|
|
$route = RouteMap::setRoute($v['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']);
|
|
|
|
$this->model->edit(['route' => $route], ['id' => $id]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
...
|
...
|
|