作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !3342
@@ -152,7 +152,11 @@ class ProjectController extends BaseController @@ -152,7 +152,11 @@ class ProjectController extends BaseController
152 if (isset($this->map['seo_plan']) && $this->map['seo_plan'] == 1) { 152 if (isset($this->map['seo_plan']) && $this->map['seo_plan'] == 1) {
153 $query = $query->orderBy('gl_project.cooperate_date', 'desc')->orderBy('gl_project.id', 'desc'); 153 $query = $query->orderBy('gl_project.cooperate_date', 'desc')->orderBy('gl_project.id', 'desc');
154 } else { 154 } else {
155 - $query = $query->orderBy('gl_project.uptime', 'desc')->orderBy('gl_project.id', 'desc'); 155 + if($this->map['type'] == 1){
  156 + $query = $query->orderBy('gl_project.id', 'desc');
  157 + }else{
  158 + $query = $query->orderBy('gl_project.uptime', 'desc')->orderBy('gl_project.id', 'desc');
  159 + }
156 } 160 }
157 return $query; 161 return $query;
158 } 162 }
@@ -412,7 +412,7 @@ class AsideTicketController extends BaseController @@ -412,7 +412,7 @@ class AsideTicketController extends BaseController
412 $this->request->validate([ 412 $this->request->validate([
413 'project_cate'=>'required' 413 'project_cate'=>'required'
414 ],[ 414 ],[
415 - 'project_cate.required' => 'ID不能为空' 415 + 'project_cate.required' => 'project_cate不能为空'
416 ]); 416 ]);
417 $ticket = new Tickets(); 417 $ticket = new Tickets();
418 $data = $ticket->getOrderTypeOptions($this->param['project_cate']); 418 $data = $ticket->getOrderTypeOptions($this->param['project_cate']);
@@ -84,48 +84,44 @@ class GeoQuestionLogic extends BaseLogic @@ -84,48 +84,44 @@ 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']);
88 - $sum = $this->model->where('project_id',$this->param['project_id'])->sum('question_num') ?? 0;  
89 - if($sum >= 200 || $count >= 200){ 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 + //新增
  94 + $sum = $this->model->where('project_id',$this->param['project_id'])->sum('question_num') ?? 0;
  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);  
107 - if(isset($this->param['id']) && !empty($this->param['id'])){  
108 - foreach ($chunks as $index => $chunk) {  
109 - $this->param['question_num'] = count($chunk);  
110 - $this->param['question'] = json_encode($chunk ?? [],true);  
111 - if($index == 0){  
112 - $id = $this->param['id'];  
113 - $this->model->edit($this->param,['id'=>$id]);  
114 - }else{  
115 - unset($this->param['id']);  
116 - $id = $this->model->addReturnId($this->param);  
117 - }  
118 - }  
119 - }else{  
120 - $this->param['next_time'] = date('Y-m-d');  
121 - foreach ($chunks as $chunk) {  
122 - $this->param['question_num'] = count($chunk);  
123 - $this->param['question'] = json_encode($chunk ?? [],true); 102 + $chunks = array_chunk($question, 20);
  103 + if(isset($this->param['id']) && !empty($this->param['id'])){
  104 + foreach ($chunks as $index => $chunk) {
  105 + $this->param['question_num'] = count($chunk);
  106 + $this->param['question'] = json_encode($chunk ?? [],true);
  107 + if($index == 0){
  108 + $id = $this->param['id'];
  109 + $this->model->edit($this->param,['id'=>$id]);
  110 + }else{
  111 + unset($this->param['id']);
124 $id = $this->model->addReturnId($this->param); 112 $id = $this->model->addReturnId($this->param);
125 } 113 }
126 } 114 }
127 - return $this->success(['id'=>$id]); 115 + }else{
  116 + $this->param['next_time'] = date('Y-m-d');
  117 + foreach ($chunks as $chunk) {
  118 + $this->param['question_num'] = count($chunk);
  119 + $this->param['question'] = json_encode($chunk ?? [],true);
  120 + $id = $this->model->addReturnId($this->param);
  121 + }
128 } 122 }
  123 + return $this->success(['id'=>$id]);
  124 +
129 } 125 }
130 126
131 /** 127 /**