作者 lyh

变更数据

@@ -84,18 +84,40 @@ class GeoQuestionLogic extends BaseLogic @@ -84,18 +84,40 @@ 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(isset($this->param['id']) && !empty($this->param['id'])){  
92 - $id = $this->param['id'];  
93 - $this->model->edit($this->param,['id'=>$id]); 91 + if($count <= 20){
  92 + if(isset($this->param['id']) && !empty($this->param['id'])){
  93 + $id = $this->param['id'];
  94 + $this->model->edit($this->param,['id'=>$id]);
  95 + }else{
  96 + $this->param['next_time'] = date('Y-m-d');
  97 + $id = $this->model->addReturnId($this->param);
  98 + }
  99 + return $this->success(['id'=>$id]);
94 }else{ 100 }else{
95 - $this->param['next_time'] = date('Y-m-d');  
96 - $id = $this->model->addReturnId($this->param); 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]);
97 } 120 }
98 - return $this->success(['id'=>$id]);  
99 } 121 }
100 122
101 /** 123 /**