正在显示
1 个修改的文件
包含
24 行增加
和
2 行删除
| @@ -84,10 +84,11 @@ class GeoQuestionLogic extends BaseLogic | @@ -84,10 +84,11 @@ class GeoQuestionLogic extends BaseLogic | ||
| 84 | */ | 84 | */ |
| 85 | public function saveGeoQuestion(){ | 85 | public function saveGeoQuestion(){ |
| 86 | //处理数据 | 86 | //处理数据 |
| 87 | - $this->param['question'] = json_encode($this->param['question'] ?? [],true); | 87 | + $count = count($this->param['question']); |
| 88 | + $question = $this->param['question']; | ||
| 88 | $this->param['url'] = json_encode($this->param['url'] ?? [],true); | 89 | $this->param['url'] = json_encode($this->param['url'] ?? [],true); |
| 89 | $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); | 90 | $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); |
| 90 | - //执行时间设置为今天 | 91 | + if($count <= 20){ |
| 91 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 92 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 92 | $id = $this->param['id']; | 93 | $id = $this->param['id']; |
| 93 | $this->model->edit($this->param,['id'=>$id]); | 94 | $this->model->edit($this->param,['id'=>$id]); |
| @@ -96,6 +97,27 @@ class GeoQuestionLogic extends BaseLogic | @@ -96,6 +97,27 @@ class GeoQuestionLogic extends BaseLogic | ||
| 96 | $id = $this->model->addReturnId($this->param); | 97 | $id = $this->model->addReturnId($this->param); |
| 97 | } | 98 | } |
| 98 | return $this->success(['id'=>$id]); | 99 | return $this->success(['id'=>$id]); |
| 100 | + }else{ | ||
| 101 | + $chunks = array_chunk($question, 20); | ||
| 102 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 103 | + foreach ($chunks as $index => $chunk) { | ||
| 104 | + $this->param['question'] = json_encode($chunk ?? [],true); | ||
| 105 | + if($index == 0){ | ||
| 106 | + $id = $this->param['id']; | ||
| 107 | + $this->model->edit($this->param,['id'=>$id]); | ||
| 108 | + }else{ | ||
| 109 | + $id = $this->model->addReturnId($this->param); | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + }else{ | ||
| 113 | + $this->param['next_time'] = date('Y-m-d'); | ||
| 114 | + foreach ($chunks as $chunk) { | ||
| 115 | + $this->param['question'] = json_encode($chunk ?? [],true); | ||
| 116 | + $id = $this->model->addReturnId($this->param); | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + return $this->success(['id'=>$id]); | ||
| 120 | + } | ||
| 99 | } | 121 | } |
| 100 | 122 | ||
| 101 | /** | 123 | /** |
-
请 注册 或 登录 后发表评论