正在显示
1 个修改的文件
包含
9 行增加
和
13 行删除
| @@ -84,25 +84,21 @@ class GeoQuestionLogic extends BaseLogic | @@ -84,25 +84,21 @@ class GeoQuestionLogic extends BaseLogic | ||
| 84 | */ | 84 | */ |
| 85 | public function saveGeoQuestion(){ | 85 | public function saveGeoQuestion(){ |
| 86 | //处理数据 | 86 | //处理数据 |
| 87 | + $max_num = 200;//最大数量 | ||
| 87 | $count = count($this->param['question']); | 88 | $count = count($this->param['question']); |
| 89 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 90 | + //编辑 | ||
| 91 | + $sum = $this->model->where('project_id',$this->param['project_id'])->where('id','!=',$this->param['id'])->sum('question_num') ?? 0; | ||
| 92 | + }else{ | ||
| 93 | + //新增 | ||
| 88 | $sum = $this->model->where('project_id',$this->param['project_id'])->sum('question_num') ?? 0; | 94 | $sum = $this->model->where('project_id',$this->param['project_id'])->sum('question_num') ?? 0; |
| 89 | - if($sum >= 200 || $count >= 200){ | 95 | + } |
| 96 | + if(($count + $sum) > $max_num){ | ||
| 90 | $this->fail('当前问题数量大于最大数量200个问题,不允许保存'); | 97 | $this->fail('当前问题数量大于最大数量200个问题,不允许保存'); |
| 91 | } | 98 | } |
| 92 | $question = $this->param['question']; | 99 | $question = $this->param['question']; |
| 93 | $this->param['url'] = json_encode($this->param['url'] ?? [],true); | 100 | $this->param['url'] = json_encode($this->param['url'] ?? [],true); |
| 94 | $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); | 101 | $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true); |
| 95 | - if($count <= 20){ | ||
| 96 | - $this->param['question_num'] = $count; | ||
| 97 | - if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 98 | - $id = $this->param['id']; | ||
| 99 | - $this->model->edit($this->param,['id'=>$id]); | ||
| 100 | - }else{ | ||
| 101 | - $this->param['next_time'] = date('Y-m-d'); | ||
| 102 | - $id = $this->model->addReturnId($this->param); | ||
| 103 | - } | ||
| 104 | - return $this->success(['id'=>$id]); | ||
| 105 | - }else{ | ||
| 106 | $chunks = array_chunk($question, 20); | 102 | $chunks = array_chunk($question, 20); |
| 107 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 103 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 108 | foreach ($chunks as $index => $chunk) { | 104 | foreach ($chunks as $index => $chunk) { |
| @@ -125,7 +121,7 @@ class GeoQuestionLogic extends BaseLogic | @@ -125,7 +121,7 @@ class GeoQuestionLogic extends BaseLogic | ||
| 125 | } | 121 | } |
| 126 | } | 122 | } |
| 127 | return $this->success(['id'=>$id]); | 123 | return $this->success(['id'=>$id]); |
| 128 | - } | 124 | + |
| 129 | } | 125 | } |
| 130 | 126 | ||
| 131 | /** | 127 | /** |
-
请 注册 或 登录 后发表评论